Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
OpNovice.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //
34 // Description: Test of Continuous Process G4Cerenkov
35 // and RestDiscrete Process G4Scintillation
36 // -- Generation Cerenkov Photons --
37 // -- Generation Scintillation Photons --
38 // -- Transport of optical Photons --
39 // Version: 5.0
40 // Created: 1996-04-30
41 // Author: Juliet Armstrong
42 // mail: gum@triumf.ca
43 //
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
46 #include "G4Types.hh"
47 
48 #ifdef G4MULTITHREADED
49 #include "G4MTRunManager.hh"
50 #else
51 #include "G4RunManager.hh"
52 #endif
53 
54 #include "G4UImanager.hh"
55 
56 #include "OpNovicePhysicsList.hh"
58 
60 
61 #include "G4VisExecutive.hh"
62 #include "G4UIExecutive.hh"
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 namespace {
66  void PrintUsage() {
67  G4cerr << " Usage: " << G4endl;
68  G4cerr << " OpNovice [-m macro ] [-u UIsession] [-t nThreads] [-r seed] "
69  << G4endl;
70  G4cerr << " note: -t option is available only for multi-threaded mode."
71  << G4endl;
72  }
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
77 int main(int argc,char** argv)
78 {
79  // Evaluate arguments
80  //
81  if ( argc > 9 ) {
82  PrintUsage();
83  return 1;
84  }
85 
86  G4String macro;
88 #ifdef G4MULTITHREADED
89  G4int nThreads = 0;
90 #endif
91 
92  G4long myseed = 345354;
93  for ( G4int i=1; i<argc; i=i+2 ) {
94  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
95  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
96  else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
97 #ifdef G4MULTITHREADED
98  else if ( G4String(argv[i]) == "-t" ) {
99  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
100  }
101 #endif
102  else {
103  PrintUsage();
104  return 1;
105  }
106  }
107 
108  // Instantiate G4UIExecutive if interactive mode
109  G4UIExecutive* ui = nullptr;
110  if ( macro.size() == 0 ) {
111  ui = new G4UIExecutive(argc, argv);
112  }
113 
114  // Choose the Random engine
115  //
116  G4Random::setTheEngine(new CLHEP::RanecuEngine);
117 
118  // Construct the default run manager
119  //
120 #ifdef G4MULTITHREADED
121  G4MTRunManager * runManager = new G4MTRunManager;
122  if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
123 #else
124  G4RunManager * runManager = new G4RunManager;
125 #endif
126 
127  // Seed the random number generator manually
128  G4Random::setTheSeed(myseed);
129 
130  // Set mandatory initialization classes
131  //
132  // Detector construction
133  runManager-> SetUserInitialization(new OpNoviceDetectorConstruction());
134  // Physics list
135  runManager-> SetUserInitialization(new OpNovicePhysicsList());
136  // User action initialization
138 
139  // Initialize G4 kernel
140  //
141  runManager->Initialize();
142 
143  // Initialize visualization
144  //
145  G4VisManager* visManager = new G4VisExecutive;
146  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
147  // G4VisManager* visManager = new G4VisExecutive("Quiet");
148  visManager->Initialize();
149 
150  // Get the pointer to the User Interface manager
151  //
152  G4UImanager* UImanager = G4UImanager::GetUIpointer();
153 
154  if ( macro.size() ) {
155  // Batch mode
156  G4String command = "/control/execute ";
157  UImanager->ApplyCommand(command+macro);
158  }
159  else // Define UI session for interactive mode
160  {
161  UImanager->ApplyCommand("/control/execute vis.mac");
162  if (ui->IsGUI())
163  UImanager->ApplyCommand("/control/execute gui.mac");
164  ui->SessionStart();
165  delete ui;
166  }
167 
168  // Job termination
169  // Free the store: user actions, physics_list and detector_description are
170  // owned and deleted by the run manager, so they should not
171  // be deleted in the main() program !
172 
173  delete visManager;
174  delete runManager;
175 
176  return 0;
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetNumberOfThreads(G4int n)
Definition of the OpNoviceDetectorConstruction class.
static G4UIterminal * session
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:449
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the OpNovicePhysicsList class.
Definition of the OpNoviceActionInitialization class.
long G4long
Definition: G4Types.hh:80
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cerr
int G4int
Definition: G4Types.hh:78
void Initialize()
G4bool IsGUI() const
virtual void Initialize()