Geant4  10.02.p03
OpNovice.cc File Reference
Include dependency graph for OpNovice.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file OpNovice.cc.

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  // Choose the Random engine
109  //
110  G4Random::setTheEngine(new CLHEP::RanecuEngine);
111 
112  // Construct the default run manager
113  //
114 #ifdef G4MULTITHREADED
115  G4MTRunManager * runManager = new G4MTRunManager;
116  if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
117 #else
118  G4RunManager * runManager = new G4RunManager;
119 #endif
120 
121  // Seed the random number generator manually
122  G4Random::setTheSeed(myseed);
123 
124  // Set mandatory initialization classes
125  //
126  // Detector construction
127  runManager-> SetUserInitialization(new OpNoviceDetectorConstruction());
128  // Physics list
129  runManager-> SetUserInitialization(new OpNovicePhysicsList());
130  // User action initialization
132 
133  // Initialize G4 kernel
134  //
135  runManager->Initialize();
136 
137 #ifdef G4VIS_USE
138  // Initialize visualization
139  //
140  G4VisManager* visManager = new G4VisExecutive;
141  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
142  // G4VisManager* visManager = new G4VisExecutive("Quiet");
143  visManager->Initialize();
144 #endif
145 
146  // Get the pointer to the User Interface manager
147  //
148  G4UImanager* UImanager = G4UImanager::GetUIpointer();
149 
150  if ( macro.size() ) {
151  // Batch mode
152  G4String command = "/control/execute ";
153  UImanager->ApplyCommand(command+macro);
154  }
155  else // Define UI session for interactive mode
156  {
157 #ifdef G4UI_USE
158  G4UIExecutive * ui = new G4UIExecutive(argc,argv,session);
159 #ifdef G4VIS_USE
160  UImanager->ApplyCommand("/control/execute vis.mac");
161 #else
162  UImanager->ApplyCommand("/control/execute OpNovice.in");
163 #endif
164  if (ui->IsGUI())
165  UImanager->ApplyCommand("/control/execute gui.mac");
166  ui->SessionStart();
167  delete ui;
168 #endif
169  }
170 
171  // Job termination
172  // Free the store: user actions, physics_list and detector_description are
173  // owned and deleted by the run manager, so they should not
174  // be deleted in the main() program !
175 
176 #ifdef G4VIS_USE
177  delete visManager;
178 #endif
179  delete runManager;
180 
181  return 0;
182 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4bool IsGUI() const
static G4UIterminal * session
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
void Initialize()
virtual void Initialize()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function: