Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hadrontherapy.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 // ----------------------------------------------------------------------------
27 // GEANT 4 - Hadrontherapy example
28 // ----------------------------------------------------------------------------
29 //
30 // MAIN AUTHORS
31 // ====================
32 // G.A.P. Cirrone(a)*, F.Romano(a)
33 //
34 // *Corresponding author, email to pablo.cirrone@lns.infn.it
35 //
36 // WEB
37 // ===========
38 // http://www.lns.infn.it/link/Hadrontherapy
39 //
40 //
41 // ==========> PAST CONTRIBUTORS <==========
42 //
43 // R. Calcagno(a), G.Danielsen (b), F.Di Rosa(a),
44 // S.Guatelli(c), A.Heikkinen(b), P.Kaitaniemi(b),
45 // A.Lechner(d), S.E.Mazzaglia(a), M.G.Pia(e),
46 // G.Russo(a), M.Russo(a), A. Tramontana (a),
47 // A.Varisano(a)
48 //
49 // (a) Laboratori Nazionali del Sud of INFN, Catania, Italy
50 // (b) Helsinki Institute of Physics, Helsinki, Finland
51 // (c) University of Wallongong, Australia
52 // (d) CERN, Geneve, Switzwerland
53 // (e) INFN Section of Genova, Genova, Italy
54 // (f) Physics and Astronomy Department, Univ. of Catania, Catania, Italy
55 //
56 //
57 // ----------------------------------------------------------------------------
58 
59 #include "G4RunManager.hh"
60 #include "G4UImanager.hh"
61 #include "G4PhysListFactory.hh"
62 #include "G4VModularPhysicsList.hh"
68 #include "HadrontherapyMatrix.hh"
69 #include "Randomize.hh"
70 
71 #include "G4UImessenger.hh"
72 #include "globals.hh"
78 #include "HadrontherapyLet.hh"
79 
80 #include "G4ScoringManager.hh"
82 #include <time.h>
83 
84 //************************MT*********************
85 #ifdef G4MULTITHREADED
86 #include "G4MTRunManager.hh"
87 #else
88 #include "G4RunManager.hh"
89 #endif
90 
92 
93 #ifdef G4VIS_USE
94 #include "G4VisExecutive.hh"
95 #endif
96 
97 #ifdef G4UI_USE
98 #include "G4UIExecutive.hh"
99 #endif
100 
102 int main(int argc ,char ** argv)
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
int main(int argc, char **argv)
Definition: genwindef.cpp:30
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)