Geant4  10.01.p01
iort_therapy.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // This is the *BASIC* version of IORT, a Geant4-based application
27 //
28 //
29 // ----------------------------------------------------------------------------
30 // GEANT 4 - IORT example
31 // ----------------------------------------------------------------------------
32 // Main Authors:
33 // G.Russo(a,b), C.Casarino*(c), G.C. Candiano(c), G.A.P. Cirrone(d), F.Romano(d)
34 //
35 // Contributor Authors:
36 // S.Guatelli(e)
37 //
38 // Past Authors:
39 // G.Arnetta(c), S.E.Mazzaglia(d)
40 //
41 // (a) Fondazione Istituto San Raffaele G.Giglio, Cefalù, Italy
42 //
43 // (b) IBFM-CNR , Segrate (Milano), Italy
44 //
45 // (c) LATO (Laboratorio di Tecnologie Oncologiche), Cefalù, Italy
46 //
47 // (d) Laboratori Nazionali del Sud of the INFN, Catania, Italy
48 //
49 // (e) University of Wallongong, Australia
50 //
51 //
52 // *Corresponding Author, email to carlo.casarino@polooncologicocefalu.it
53 // ----------------------------------------------------------------------------
54 
55 #include "G4RunManager.hh"
56 #include "G4UImanager.hh"
57 #include "G4PhysListFactory.hh"
58 #include "G4VModularPhysicsList.hh"
59 #include "IORTEventAction.hh"
60 #include "IORTPhysicsList.hh"
61 #include "IORTDetectorSD.hh"
63 #include "IORTRunAction.hh"
64 #include "IORTMatrix.hh"
65 #include "Randomize.hh"
66 #include "G4RunManager.hh"
67 #include "G4UImessenger.hh"
68 #include "globals.hh"
69 #include "IORTSteppingAction.hh"
70 #include "IORTAnalysisManager.hh"
72 #include "IORTGeometryMessenger.hh"
74 #include "G4ScoringManager.hh"
75 
76 
77 #ifdef G4VIS_USE
78 #include "G4VisExecutive.hh"
79 #endif
80 
81 #ifdef G4UI_USE
82 #include "G4UIExecutive.hh"
83 #endif
84 
85 #include <ctime>
87 
88 int main(int argc ,char ** argv)
89 {
90  // Set the Random engine
91  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
92 
93  //imported from eliot_geant4.9.3p01// to create a different seed
94  G4int seed = time(NULL);
95  CLHEP::HepRandom::setTheSeed(seed);
96  //imported from eliot_geant4.9.3p01
97 
98  G4RunManager* runManager = new G4RunManager;
99  // Geometry controller is responsible for instantiating the
100  // geometries. All geometry specific setup tasks are now in class
101  // IORTGeometryController.
102  IORTGeometryController *geometryController = new IORTGeometryController();
103 
104  // Connect the geometry controller to the G4 user interface
105  IORTGeometryMessenger *geometryMessenger = new IORTGeometryMessenger(geometryController);
106 
108  scoringManager->SetVerboseLevel(1);
109 
110 
111  // Initialize the default IORT geometry
112  geometryController->SetGeometry("default");
113 
114  // Initialize command based scoring
116 
117  // Initialize the physics
118  G4PhysListFactory factory;
119  G4VModularPhysicsList* phys = 0;
120  G4String physName = "";
121 
122  // Physics List name defined via environment variable
123  char* path = getenv("PHYSLIST");
124  if (path) { physName = G4String(path); }
125 
126  if(factory.IsReferencePhysList(physName))
127  {
128  phys = factory.GetReferencePhysList(physName);
129  }
130 
131  if(!phys) { phys = new IORTPhysicsList(); }
132 
133  runManager->SetUserInitialization(phys);
134 
135  // runManager -> SetUserInitialization(new IORTPhysicsList());
136 
137  // Initialize the primary particles
138  IORTPrimaryGeneratorAction *pPrimaryGenerator = new IORTPrimaryGeneratorAction();
139  runManager -> SetUserAction(pPrimaryGenerator);
140 
141  // Optional UserActions: run, event, stepping
142  IORTRunAction* pRunAction = new IORTRunAction();
143  runManager -> SetUserAction(pRunAction);
144 
145  IORTEventAction* pEventAction = new IORTEventAction();
146  runManager -> SetUserAction(pEventAction);
147 
148  IORTSteppingAction* steppingAction = new IORTSteppingAction(pRunAction);
149  runManager -> SetUserAction(steppingAction);
150 
151  // Interaction data: stopping powers
152  IORTInteractionParameters* pInteraction = new IORTInteractionParameters(true);
153 
154  // Initialize analysis
155 
156 #ifdef G4ANALYSIS_USE_ROOT
158  analysis -> book();
159 #endif
160 
161 #ifdef G4VIS_USE
162  // Visualization manager
163  G4VisManager* visManager = new G4VisExecutive;
164  visManager -> Initialize();
165 #endif
166 
167  G4UImanager* UImanager = G4UImanager::GetUIpointer();
168  if (argc!=1) // batch mode
169  {
170  G4String command = "/control/execute ";
171  G4String fileName = argv[1];
172  UImanager->ApplyCommand(command+fileName);
173  }
174  else
175  { // interactive mode : define UI session
176 
177 
178 #ifdef G4UI_USE
179  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
180 #ifdef G4VIS_USE
181  if(factory.IsReferencePhysList(physName))
182  {
183  UImanager->ApplyCommand("/control/execute defaultMacroWithReferencePhysicsList.mac");
184  }
185  else
186  {
187  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
188  }
189 
190 #endif
191  if (ui->IsGUI())
192  ui->SessionStart();
193  delete ui;
194 #endif
195  }
196 
197  // Job termination
198  // Store dose & fluence data to ASCII & ROOT files
199  if ( IORTMatrix * pMatrix = IORTMatrix::GetInstance() )
200  {
201  pMatrix -> TotalEnergyDeposit();
202  pMatrix -> StoreDoseFluenceAscii();
203 #ifdef G4ANALYSIS_USE_ROOT
204  pMatrix -> StoreDoseFluenceRoot();
205 #endif
206  }
207 
208 #ifdef G4ANALYSIS_USE_ROOT
209  if (analysis -> IsTheTFile()) analysis -> flush(); // Finalize & write the root file
210 #endif
211 
212 
213 #ifdef G4VIS_USE
214  delete visManager;
215 #endif
216 
217 
218  delete geometryMessenger;
219  delete geometryController;
220  delete pInteraction;
221  delete runManager;
222  return 0;
223 
224 }
225 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void Initialize()
Definition: errprop.cc:101
A class for connecting the simulation to an analysis package.
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
static IORTAnalysisManager * GetInstance()
Get the pointer to the analysis manager.
void SetGeometry(G4String)
Select a geometry by name.
int main(int argc, char **argv)
Definition: iort_therapy.cc:88
Controller for geometry selection.
static IORTMatrix * GetInstance()
Definition: IORTMatrix.cc:61
static G4ScoringManager * GetScoringManager()
G4bool IsGUI() const
void SetVerboseLevel(G4int vl)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432