LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
field06.cc File Reference

Main program of the field/field06 example. More...

#include <unistd.h>
#include "F06PhysicsList.hh"
#include "F06DetectorConstruction.hh"
#include "F06ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the field/field06 example.

Definition in file field06.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 77 of file field06.cc.

References PrintUsage(), and session.

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 = 1234;
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 F06DetectorConstruction());
128  // Physics list
129  runManager->SetUserInitialization(new F06PhysicsList());
130  // User action initialization
131  runManager->SetUserInitialization(new F06ActionInitialization());
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
156  { // interactive mode : define UI session
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 field06.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 }
static G4UIterminal * session
void PrintUsage()