Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
92 
93  //imported from eliot_geant4.9.3p01// to create a different seed
94  G4int seed = time(NULL);
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
156  analysis -> book();
157 
158 
159 #ifdef G4VIS_USE
160  // Visualization manager
161  G4VisManager* visManager = new G4VisExecutive;
162  visManager -> Initialize();
163 #endif
164 
165  G4UImanager* UImanager = G4UImanager::GetUIpointer();
166  if (argc!=1) // batch mode
167  {
168  G4String command = "/control/execute ";
169  G4String fileName = argv[1];
170  UImanager->ApplyCommand(command+fileName);
171  }
172  else
173  { // interactive mode : define UI session
174 
175 
176 #ifdef G4UI_USE
177  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
178 #ifdef G4VIS_USE
179  if(factory.IsReferencePhysList(physName))
180  {
181  UImanager->ApplyCommand("/control/execute defaultMacroWithReferencePhysicsList.mac");
182  }
183  else
184  {
185  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
186  }
187 
188 #endif
189  if (ui->IsGUI())
190  ui->SessionStart();
191  delete ui;
192 #endif
193  }
194 
195  // Job termination
196  // Store dose & fluence data to ASCII & ROOT files
197  if ( IORTMatrix * pMatrix = IORTMatrix::GetInstance() )
198  {
199  pMatrix -> TotalEnergyDeposit();
200  pMatrix -> StoreDoseFluenceAscii();
201  pMatrix -> StoreDoseFluenceRoot();
202  }
203 
204 
205  analysis -> flush(); // Finalize & write the root file
206 
207 #ifdef G4VIS_USE
208  delete visManager;
209 #endif
210 
211 
212  delete geometryMessenger;
213  delete geometryController;
214  delete pInteraction;
215  delete runManager;
216  return 0;
217 
218 }
219 
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void Initialize()
Definition: errprop.cc:101
int main(int argc, char **argv)
Definition: genwindef.cpp:30
int G4int
Definition: G4Types.hh:78
static void setTheSeed(long seed, int lux=3)
Definition: Random.cc:231
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
long seed
Definition: chem4.cc:68
static IORTAnalysisManager * GetInstance()
static void setTheEngine(HepRandomEngine *theNewEngine)
Definition: Random.cc:270
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:447