Geant4  10.00.p01
gammaknife.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 // GEANT4 - GAMMAKNIFE example
28 // ----------------------------------------------------------------------------
29 // AUTHORS:
30 // G. Cuttone (a), J. Pipek (b) F.Romano* (a), M.G.Sabini (c)
31 //
32 // PAST AUTHORS:
33 // G.A.P. Cirrone (a), G.Russo (d), M.Russo (a)
34 //
35 // (a) Laboratori Nazionali del Sud - INFN, Catania, Italy
36 // (b) Faculty of Nuclear Sciences and Physical Engineering, Czech Technical University, Czech Republic
37 // (c) Dipartimento di Immagini, Ospedale Cannizzaro, Catania, Italy
38 // (d) Fondazione Istituto San Raffaele G.Giglio, Cefalù (Palermo), Italy
39 //
40 //
41 // *Corresponding author, email to francesco.romano@lns.infn.it
42 // ----------------------------------------------------------------------------
43 
44 #ifdef G4MULTITHREADED
45 #include "G4MTRunManager.hh"
46 #else
47 #include "G4RunManager.hh"
48 #endif
49 
50 #include "G4UImanager.hh"
51 #include "G4UIterminal.hh"
52 #include "G4UItcsh.hh"
53 
54 #ifdef G4VIS_USE
55  #include "G4VisExecutive.hh"
56 #endif
57 #ifdef G4UI_USE
58  #include "G4UIExecutive.hh"
59 #endif
60 
62 #include "GammaKnifePhysicsList.hh"
64 #include "GammaKnifeRunAction.hh"
66 
67 #include "Randomize.hh"
68 #include "G4RunManager.hh"
69 #include "G4UImessenger.hh"
70 #include "G4ScoringManager.hh"
71 #include "globals.hh"
72 #include "GammaKnifeController.hh"
73 #include "G4PhysListFactory.hh"
74 
75 #include <ctime>
76 
77 int main(int argc ,char ** argv)
78 {
79 
80  G4Random::setTheEngine(new CLHEP::RanecuEngine);
81  G4int seconds = time(NULL);
82  G4Random::setTheSeed(seconds);
83 
84 #ifdef G4MULTITHREADED
85  G4MTRunManager * runManager = new G4MTRunManager;
86 #else
87  G4RunManager * runManager = new G4RunManager;
88 #endif
89 
90  G4ScoringManager::GetScoringManager(); // This enables scoring
91 
92  // Initialize the geometry
94  runManager -> SetUserInitialization(detector);
95 
96  // Initialize the physics
97  G4PhysListFactory factory;
98  G4VModularPhysicsList* phys = 0;
99  G4String physName = "";
100 
101  // Physics List name defined via environment variable
102  char* path = getenv("PHYSLIST");
103  if (path) { physName = G4String(path); }
104 
105  if(physName != "" && factory.IsReferencePhysList(physName))
106  {
107  phys = factory.GetReferencePhysList(physName);
108  }
109 
110  if(!phys) { phys = new GammaKnifePhysicsList(); }
111 
112  runManager->SetUserInitialization(phys);
113 
114 
116  runManager->SetUserInitialization(actionInitialization);
117 
118  GammaKnifeController* controller = new GammaKnifeController( detector );
119  controller->ReadFile("MachineAngle.in"); // pre-load default
120 
121  // Initialize G4 kernel
122  //
123  runManager->Initialize();
124 
125 #ifdef G4VIS_USE
126  // Visualization manager
127  G4VisManager* visManager = new G4VisExecutive;
128  visManager -> Initialize();
129 #endif
130 
131  // Get the pointer to the User Interface manager
132  G4UImanager* UImanager = G4UImanager::GetUIpointer();
133 
134  if (argc!=1) {
135  // batch mode
136  G4String command = "/control/execute ";
137  G4String fileName = argv[1];
138  UImanager->ApplyCommand(command+fileName);
139  }
140  else {
141  // interactive mode : define UI session
142 #ifdef G4UI_USE
143  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
144 #ifdef G4VIS_USE
145  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
146 #else
147  UImanager->ApplyCommand("/control/execute batch.mac");
148 #endif
149  ui->SessionStart();
150  delete ui;
151 #endif
152  }
153 
154  // Job termination
155 #ifdef G4VIS_USE
156  delete visManager;
157 #endif
158 
159  delete runManager;
160  delete controller;
161 
162  return 0;
163 }
Definition of the GammaKnifeActionInitialization class.
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void ReadFile(std::string fileName)
void Initialize()
Definition: errprop.cc:96
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
G4bool IsReferencePhysList(const G4String &)
virtual void Initialize()
static G4ScoringManager * GetScoringManager()
int main(int argc, char **argv)
Definition: gammaknife.cc:77
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419