Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hadrontherapy.cc File Reference
Include dependency graph for hadrontherapy.cc:

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 102 of file hadrontherapy.cc.

103 {
104  // Set the Random engine
106 
107 // Only if an initial random seed is needed
108 //G4int seed =1414159599;// time(0);
109 //CLHEP::HepRandom::setTheSeed(seed);
110 // G4cout << "******************************************************************"<< seed << G4endl;
111 
112  //************************MT*********************
113 #ifdef G4MULTITHREADED
114 
115  G4MTRunManager* runManager = new G4MTRunManager;
116  //runManager->SetNumberOfThreads(2); // Is equal to 2 by default, it can be setted also with the macro command: /run/numberOfThread 2
117 #else
118  G4RunManager* runManager = new G4RunManager;
119 #endif
120 
121 
122  // Geometry controller is responsible for instantiating the
123  // geometries. All geometry specific setup tasks are now in class
124  // HadrontherapyGeometryController.
126 
127  // Connect the geometry controller to the G4 user interface
128  HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
129 
131  scoringManager->SetVerboseLevel(1);
132 
133 
134  // Initialize the default Hadrontherapy geometry
135  geometryController->SetGeometry("default");
136 
137  // Initialize command based scoring
139 
140  // Initialize the physics
141  G4PhysListFactory factory;
142  G4VModularPhysicsList* phys = 0;
143  G4String physName = "";
144 
145  // Physics List name defined via environment variable
146  char* path = getenv("PHYSLIST");
147  if (path) { physName = G4String(path); }
148 
149  if(physName != "" && factory.IsReferencePhysList(physName))
150  {
151  phys = factory.GetReferencePhysList(physName);
152  }
153  if (phys)
154  {
155  G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
156  phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
157  }
158  else
159  {
160  G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
161  phys = new HadrontherapyPhysicsList();
162  }
163 
164  runManager->SetUserInitialization(phys);
165 
166  //************************MT
168 
169 
170 
171  // Interaction data: stopping powers
173 
174  // Initialize analysis
176 
177 #ifdef G4ANALYSIS_USE_ROOT
178  analysis -> book();
179 #endif
180 
181  // Get the pointer to the visualization manager
182 #ifdef G4VIS_USE
183  G4VisManager* visManager = new G4VisExecutive;
184  visManager -> Initialize();
185 #endif
186 
187  // Get the pointer to the User Interface manager
188  G4UImanager* UImanager = G4UImanager::GetUIpointer();
189 
190  if (argc == 1) // Define UI session for interactive mode.
191  {
192 #ifdef G4UI_USE
193  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
194  G4cout << " UI session starts ..." << G4endl;
195  UImanager -> ApplyCommand("/control/execute macro/defaultMacro.mac");
196  ui -> SessionStart();
197  delete ui;
198 #endif
199  }
200  else // Batch mode
201  {
202  G4String command = "/control/execute ";
203  G4String fileName = argv[1];
204  UImanager -> ApplyCommand(command+fileName);
205  }
206 
207  // Job termination
208  // Store dose & fluence data to ASCII & ROOT files
210  {
211  pMatrix -> TotalEnergyDeposit();
212  pMatrix -> StoreDoseFluenceAscii();
213 #ifdef G4ANALYSIS_USE_ROOT
214 
215  pMatrix -> StoreDoseFluenceRoot();
216 #endif
217  }
218 
220  if(let -> doCalculation)
221  {
222  let -> LetOutput(); // Calculate let
223  let -> StoreLetAscii(); // Store it
224 #ifdef G4ANALYSIS_USE_ROOT
225 
226  let -> StoreLetRoot();
227 #endif
228  }
229 
230 
231 #ifdef G4ANALYSIS_USE_ROOT
232  if (analysis -> IsTheTFile()) analysis -> flush(); // Finalize & write the root file
233 #endif
234 
235 
236 #ifdef G4VIS_USE
237  delete visManager;
238 #endif
239 
240  delete geometryMessenger;
241  delete geometryController;
242  delete pInteraction;
243  delete runManager;
244  delete analysis;
245  return 0;
246 
247 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static HadrontherapyAnalysisManager * GetInstance()
void RegisterPhysics(G4VPhysicsConstructor *)
static HadrontherapyLet * GetInstance()
void Initialize()
Definition: errprop.cc:101
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
static HadrontherapyMatrix * GetInstance()
G4GLOB_DLL std::ostream G4cout
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
#define G4endl
Definition: G4ios.hh:61
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
static G4ScoringManager * GetScoringManager()
void SetVerboseLevel(G4int vl)

Here is the call graph for this function: