Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
hadrontherapy.cc
이 파일의 문서화 페이지로 가기
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"
77 #include "HadrontherapyLet.hh"
78 
79 #include "G4ScoringManager.hh"
81 #include <time.h>
82 
83 //************************MT*********************
84 #ifdef G4MULTITHREADED
85 #include "G4MTRunManager.hh"
86 #else
87 #include "G4RunManager.hh"
88 #endif
89 
91 
92 #ifdef G4VIS_USE
93 #include "G4VisExecutive.hh"
94 #endif
95 
96 #ifdef G4UI_USE
97 #include "G4UIExecutive.hh"
98 #endif
99 
101 int main(int argc ,char ** argv)
102 {
103 
104  // Set the Random engine
105  // The following guarantees random generation also for different runs
106  // in multithread
107  CLHEP::RanluxEngine defaultEngine( 1234567, 4 );
108  G4Random::setTheEngine( &defaultEngine );
109  G4int seed = time( NULL );
110  G4Random::setTheSeed( seed );
111 
112 #ifdef G4MULTITHREADED
113 
114  G4MTRunManager* runManager = new G4MTRunManager;
115 #else
116  G4RunManager* runManager = new G4RunManager;
117 #endif
118 
119 
120  // Geometry controller is responsible for instantiating the
121  // geometries. All geometry specific setup tasks are now in class
122  // HadrontherapyGeometryController.
124 
125  // Connect the geometry controller to the G4 user interface
126  HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
127 
129  scoringManager->SetVerboseLevel(1);
130 
131 
132  // Initialize the default Hadrontherapy geometry
133  geometryController->SetGeometry("default");
134 
135  // Initialize command based scoring
137 
138  // Initialize the physics
139  G4PhysListFactory factory;
140  G4VModularPhysicsList* phys = 0;
141  G4String physName = "";
142 
143  // Physics List name defined via environment variable
144  char* path = getenv("PHYSLIST");
145  if (path) { physName = G4String(path); }
146 
147  if(physName != "" && factory.IsReferencePhysList(physName))
148  {
149  phys = factory.GetReferencePhysList(physName);
150  }
151  if (phys)
152  {
153  G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
154  phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
155  }
156  else
157  {
158  G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
159  phys = new HadrontherapyPhysicsList();
160  }
161 
162  runManager->SetUserInitialization(phys);
163 
164  //************************MT
166 
167 
168 
169  // Interaction data: stopping powers
171 
172  // Initialize analysis
174 
175 
176  // Get the pointer to the visualization manager
177 #ifdef G4VIS_USE
178  G4VisManager* visManager = new G4VisExecutive;
179  visManager -> Initialize();
180 #endif
181 
182  // Get the pointer to the User Interface manager
183  G4UImanager* UImanager = G4UImanager::GetUIpointer();
184 
185  if (argc == 1) // Define UI session for interactive mode.
186  {
187 #ifdef G4UI_USE
188  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
189  G4cout << " UI session starts ..." << G4endl;
190 
191  UImanager -> ApplyCommand("/control/execute macro/defaultMacro.mac");
192 
193 
194  ui -> SessionStart();
195  delete ui;
196 #endif
197  }
198  else // Batch mode
199  {
200  G4String command = "/control/execute ";
201  G4String fileName = argv[1];
202  UImanager -> ApplyCommand(command+fileName);
203  }
204 
205  // Job termination
207  {
208  // pMatrix -> TotalEnergyDeposit();
209  pMatrix -> StoreDoseFluenceAscii();
210 
211  }
212 
214  if(let -> doCalculation)
215  {
216  let -> LetOutput(); // Calculate let
217  let -> StoreLetAscii(); // Store it
218  }
219 
220 
221 
222 #ifdef G4VIS_USE
223  delete visManager;
224 #endif
225 
226  delete geometryMessenger;
227  delete geometryController;
228  delete pInteraction;
229  delete runManager;
230  delete analysis;
231  return 0;
232 
233 }
static HadrontherapyMatrix * GetInstance()
#define G4endl
Definition: G4ios.hh:61
void Initialize()
Definition: errprop.cc:101
void SetVerboseLevel(G4int vl)
G4bool IsReferencePhysList(const G4String &)
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
static HadrontherapyLet * GetInstance()
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
long seed
Definition: chem4.cc:68
void RegisterPhysics(G4VPhysicsConstructor *)
int main(int argc, char **argv)
Definition: genwindef.cc:359
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static G4ScoringManager * GetScoringManager()
static HadrontherapyAnalysisManager * GetInstance()