LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
hadrontherapy.cc File Reference
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "HadrontherapyEventAction.hh"
#include "HadrontherapyPhysicsList.hh"
#include "HadrontherapyDetectorSD.hh"
#include "HadrontherapyPrimaryGeneratorAction.hh"
#include "HadrontherapyRunAction.hh"
#include "HadrontherapyMatrix.hh"
#include "Randomize.hh"
#include "G4UImessenger.hh"
#include "globals.hh"
#include "HadrontherapySteppingAction.hh"
#include "HadrontherapyAnalysisManager.hh"
#include "HadrontherapyGeometryController.hh"
#include "HadrontherapyGeometryMessenger.hh"
#include "HadrontherapyInteractionParameters.hh"
#include "HadrontherapyLet.hh"
#include "G4ScoringManager.hh"
#include "G4ParallelWorldPhysics.hh"
#include <time.h>
#include "HadrontherapyActionInitialization.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 102 of file hadrontherapy.cc.

References Initialize().

103 {
104  // Set the Random engine
105  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
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.
125  HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController();
126 
127  // Connect the geometry controller to the G4 user interface
128  HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
129 
130  G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager();
131  scoringManager->SetVerboseLevel(1);
132 
133 
134  // Initialize the default Hadrontherapy geometry
135  geometryController->SetGeometry("default");
136 
137  // Initialize command based scoring
138  G4ScoringManager::GetScoringManager();
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
167  runManager->SetUserInitialization(new HadrontherapyActionInitialization);
168 
169 
170 
171  // Interaction data: stopping powers
172  HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters(true);
173 
174  // Initialize analysis
175  HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::GetInstance();
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
209  if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
210  {
211  pMatrix -> TotalEnergyDeposit();
212  pMatrix -> StoreDoseFluenceAscii();
213 #ifdef G4ANALYSIS_USE_ROOT
214 
215  pMatrix -> StoreDoseFluenceRoot();
216 #endif
217  }
218 
219  if (HadrontherapyLet *let = HadrontherapyLet::GetInstance())
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 }
void Initialize()
Definition: errprop.cc:101