Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
nanobeam.cc File Reference
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 43 of file nanobeam.cc.

References G4UImanager::ApplyCommand(), G4UImanager::GetUIpointer(), G4RunManager::Initialize(), G4UIsession::SessionStart(), G4MTRunManager::SetNumberOfThreads(), and G4RunManager::SetUserInitialization().

43  {
44 
45  // Choose the Random engine
46 
47  G4Random::setTheEngine(new CLHEP::RanecuEngine);
48 
49  // Construct the default run manager
50 
51 #ifdef G4MULTITHREADED
52  G4MTRunManager* runManager = new G4MTRunManager;
53 
54  // By default, only one thread for aberration coefficient calculation ("coef*" macros)
55  //
56  // For high statistics (no aberration coefficient calculation, "image*" & "grid*" macros),
57  // switch to more threads
58 
59  runManager->SetNumberOfThreads(1);
60  //runManager->SetNumberOfThreads(2);
61 
62 #else
63  G4RunManager* runManager = new G4RunManager;
64 #endif
65 
66 
67  //
68  // Set mandatory initialization classes
69 
71 
72  runManager->SetUserInitialization(detector);
73 
74  runManager->SetUserInitialization(new PhysicsList);
75 
76  // User action initialization
77 
78  runManager->SetUserInitialization(new ActionInitialization(detector));
79 
80  // Initialize G4 kernel
81 
82  runManager->Initialize();
83 
84  // Get the pointer to the User Interface manager
85 
86  G4UImanager* UImanager = G4UImanager::GetUIpointer();
87 
88  if (argc==1) // Define UI session for interactive mode.
89  {
90 #ifdef _WIN32
91  G4UIsession * session = new G4UIterminal();
92 #else
93  G4UIsession * session = new G4UIterminal(new G4UItcsh);
94 #endif
95  UImanager->ApplyCommand("/control/execute default.mac");
96  session->SessionStart();
97  delete session;
98  }
99  else // Batch mode
100  {
101  G4String command = "/control/execute ";
102  G4String fileName = argv[1];
103  UImanager->ApplyCommand(command+fileName);
104  }
105 
106  //
107 
108  delete runManager;
109 
110  return 0;
111 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
virtual G4UIsession * SessionStart()
Definition: G4UIsession.cc:38
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
virtual void Initialize()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419