Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExUCN.cc File Reference

Main program of the exoticphysics/ucn example. More...

#include <unistd.h>
#include "ExUCNPhysicsList.hh"
#include "ExUCNDetectorConstruction.hh"
#include "ExUCNActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIcommand.hh"
#include "Randomize.hh"
Include dependency graph for ExUCN.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the exoticphysics/ucn example.

Definition in file ExUCN.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 78 of file ExUCN.cc.

79 {
80  // Evaluate arguments
81  //
82  if ( argc > 9 ) {
83  PrintUsage();
84  return 1;
85  }
86 
87  G4String macro;
89 #ifdef G4MULTITHREADED
90  G4int nThreads = 0;
91 #endif
92 
93  G4long myseed = 1234;
94  for ( G4int i=1; i<argc; i=i+2 ) {
95  if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
96  else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
97  else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
98 #ifdef G4MULTITHREADED
99  else if ( G4String(argv[i]) == "-t" ) {
100  nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
101  }
102 #endif
103  else {
104  PrintUsage();
105  return 1;
106  }
107  }
108 
109  // Choose the Random engine
110  //
111  G4Random::setTheEngine(new CLHEP::RanecuEngine);
112 
113  // Construct the default run manager
114  //
115 #ifdef G4MULTITHREADED
116  G4MTRunManager * runManager = new G4MTRunManager;
117  if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
118 #else
119  G4RunManager * runManager = new G4RunManager;
120 #endif
121 
122  // Seed the random number generator manually
123  G4Random::setTheSeed(myseed);
124 
125  // Set mandatory initialization classes
126  //
127  // Detector construction
129  // Physics list
130  runManager->SetUserInitialization(new ExUCNPhysicsList());
131  // User action initialization
133 
134  // Initialize G4 kernel
135  //
136  runManager->Initialize();
137 
138 #ifdef G4VIS_USE
139  // Initialize visualization
140  //
141  G4VisManager* visManager = new G4VisExecutive;
142  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
143  // G4VisManager* visManager = new G4VisExecutive("Quiet");
144  visManager->Initialize();
145 #endif
146 
147  // Get the pointer to the User Interface manager
148  //
149  G4UImanager* UImanager = G4UImanager::GetUIpointer();
150 
151  if ( macro.size() ) {
152  // batch mode
153  G4String command = "/control/execute ";
154  UImanager->ApplyCommand(command+macro);
155  }
156  else
157  { // interactive mode : define UI session
158 #ifdef G4UI_USE
159  G4UIExecutive* ui = new G4UIExecutive(argc, argv, session);
160 #ifdef G4VIS_USE
161  UImanager->ApplyCommand("/control/execute vis.mac");
162 #else
163  UImanager->ApplyCommand("/control/execute ExUCN.in");
164 #endif
165  if (ui->IsGUI())
166  UImanager->ApplyCommand("/control/execute gui.mac");
167  ui->SessionStart();
168  delete ui;
169 #endif
170  }
171 
172  // Job termination
173  // Free the store: user actions, physics_list and detector_description are
174  // owned and deleted by the run manager, so they should not
175  // be deleted in the main() program !
176 
177 #ifdef G4VIS_USE
178  delete visManager;
179 #endif
180  delete runManager;
181 
182  return 0;
183 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
Action initialization class.
long G4long
Definition: G4Types.hh:80
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
static G4UIterminal * session
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void Initialize()
virtual void Initialize()
G4bool IsGUI() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function: