Geant4  10.02.p03
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

◆ main()

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);
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  //************************MT*********************
122  // G4RunManager* runManager = new G4RunManager;
123 
124  // Geometry controller is responsible for instantiating the
125  // geometries. All geometry specific setup tasks are now in class
126  // HadrontherapyGeometryController.
128 
129  // Connect the geometry controller to the G4 user interface
130  HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
131 
133  scoringManager->SetVerboseLevel(1);
134 
135 
136  // Initialize the default Hadrontherapy geometry
137  geometryController->SetGeometry("default");
138 
139  // Initialize command based scoring
141 
142  // Initialize the physics
143  G4PhysListFactory factory;
144  G4VModularPhysicsList* phys = 0;
145  G4String physName = "";
146 
147  // Physics List name defined via environment variable
148  char* path = getenv("PHYSLIST");
149  if (path) { physName = G4String(path); }
150 
151  if(physName != "" && factory.IsReferencePhysList(physName))
152  {
153  phys = factory.GetReferencePhysList(physName);
154  }
155  if (phys)
156  {
157  G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
158  phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
159  }
160  else
161  {
162  G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
163  phys = new HadrontherapyPhysicsList();
164  }
165 
166  runManager->SetUserInitialization(phys);
167 
168  //************************MT
170  //************************MT
171 
172 
173  //************************MT: DA SPOSTARE IN hADRONTHERAPYACTIONiNITIALIZATION.CC*********************
174  /*
175  // Initialize the primary particles
176  HadrontherapyPrimaryGeneratorAction *pPrimaryGenerator = new HadrontherapyPrimaryGeneratorAction();
177  runManager -> SetUserAction(pPrimaryGenerator);
178 
179  // Optional UserActions: run, event, stepping
180  HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction();
181  runManager -> SetUserAction(pRunAction);
182 
183  HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction();
184  runManager -> SetUserAction(pEventAction);
185 
186  HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction);
187  runManager -> SetUserAction(steppingAction);
188  */
189  // Interaction data: stopping powers
191 
192  // Initialize analysis
194 #ifdef G4ANALYSIS_USE_ROOT
195  analysis -> book();
196 #endif
197 
198  // Get the pointer to the visualization manager
199 #ifdef G4VIS_USE
200  G4VisManager* visManager = new G4VisExecutive;
201  visManager -> Initialize();
202 #endif
203 
204  // Get the pointer to the User Interface manager
205  G4UImanager* UImanager = G4UImanager::GetUIpointer();
206 
207  // If no macro file is passed as argument,
208  // the User Interface is called
209  if (argc==1)
210  {
211 #ifdef G4UI_USE
212  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
213 #ifdef G4VIS_USE
214 
215  if(factory.IsReferencePhysList(physName))
216  {
217  UImanager->ApplyCommand("/control/execute macro/defaultMacroWithReferencePhysicsList.mac");
218  }
219  else
220  {
221  UImanager->ApplyCommand("/control/execute macro/defaultMacro.mac");
222  }
223 
224 #endif
225  ui->SessionStart();
226  delete ui;
227 #endif
228  }
229  // Batch mode: the following commands are called when a macro file
230  // is passed as argument
231  else
232  {
233  G4String command = "/control/execute ";
234  G4String fileName = argv[1];
235  UImanager->ApplyCommand(command+fileName);
236  }
237 
238  // Job termination
239  // Store dose & fluence data to ASCII & ROOT files
241  {
242  pMatrix -> TotalEnergyDeposit();
243  pMatrix -> StoreDoseFluenceAscii();
244 #ifdef G4ANALYSIS_USE_ROOT
245 
246  pMatrix -> StoreDoseFluenceRoot();
247 #endif
248  }
249 
251  if(let -> doCalculation)
252  {
253  let -> LetOutput(); // Calculate let
254  let -> StoreLetAscii(); // Store it
255 #ifdef G4ANALYSIS_USE_ROOT
256 
257  let -> StoreLetRoot();
258 #endif
259  }
260 
261 
262 #ifdef G4ANALYSIS_USE_ROOT
263  if (analysis -> IsTheTFile()) analysis -> flush(); // Finalize & write the root file
264 #endif
265 
266 
267 #ifdef G4VIS_USE
268  delete visManager;
269 #endif
270 
271  delete geometryMessenger;
272  delete geometryController;
273  delete pInteraction;
274  delete runManager;
275  delete analysis;
276  return 0;
277 
278 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
static HadrontherapyAnalysisManager * GetInstance()
void RegisterPhysics(G4VPhysicsConstructor *)
static HadrontherapyLet * GetInstance()
void Initialize()
Definition: errprop.cc:101
int G4int
Definition: G4Types.hh:78
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:132
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
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:171
static G4ScoringManager * GetScoringManager()
void SetVerboseLevel(G4int vl)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:446
Here is the call graph for this function: