ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gammaknife.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file gammaknife.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 // 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 #include "G4Types.hh"
45 
46 #ifdef G4MULTITHREADED
47 #include "G4MTRunManager.hh"
48 #else
49 #include "G4RunManager.hh"
50 #endif
51 
52 #include "G4UImanager.hh"
53 #include "G4UIterminal.hh"
54 #include "G4UItcsh.hh"
55 
56 #include "G4VisExecutive.hh"
57 
58 #include "G4UIExecutive.hh"
59 
61 #include "GammaKnifePhysicsList.hh"
63 #include "GammaKnifeRunAction.hh"
65 
66 #include "Randomize.hh"
67 #include "G4RunManager.hh"
68 #include "G4UImessenger.hh"
69 #include "G4ScoringManager.hh"
70 #include "globals.hh"
71 #include "GammaKnifeController.hh"
72 #include "G4PhysListFactory.hh"
73 
74 #include <ctime>
75 
76 int main(int argc ,char ** argv)
77 {
78 
79  G4Random::setTheEngine(new CLHEP::RanecuEngine);
80  G4int seconds = time(NULL);
81  G4Random::setTheSeed(seconds);
82 
83 #ifdef G4MULTITHREADED
84  G4MTRunManager * runManager = new G4MTRunManager;
85 #else
86  G4RunManager * runManager = new G4RunManager;
87 #endif
88 
89  G4ScoringManager::GetScoringManager(); // This enables scoring
90 
91  // Initialize the geometry
93  runManager -> SetUserInitialization(detector);
94 
95  // Initialize the physics
96  G4PhysListFactory factory;
97  G4VModularPhysicsList* phys = 0;
98  G4String physName = "";
99 
100  // Physics List name defined via environment variable
101  char* path = std::getenv("PHYSLIST");
102  if (path) { physName = G4String(path); }
103 
104  if(physName != "" && factory.IsReferencePhysList(physName))
105  {
106  phys = factory.GetReferencePhysList(physName);
107  }
108 
109  if(!phys) { phys = new GammaKnifePhysicsList(); }
110 
111  runManager->SetUserInitialization(phys);
112 
113 
115  runManager->SetUserInitialization(actionInitialization);
116 
117  GammaKnifeController* controller = new GammaKnifeController( detector );
118  controller->ReadFile("MachineAngle.in"); // pre-load default
119 
120  // Initialize G4 kernel
121  //
122  runManager->Initialize();
123 
124  // Visualization manager
125  G4VisManager* visManager = new G4VisExecutive;
126  visManager -> Initialize();
127 
128  // Get the pointer to the User Interface manager
129  G4UImanager* UImanager = G4UImanager::GetUIpointer();
130 
131  if (argc!=1) {
132  // batch mode
133  G4String command = "/control/execute ";
134  G4String fileName = argv[1];
135  UImanager->ApplyCommand(command+fileName);
136  }
137  else {
138  // interactive mode : define UI session
139 
140  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
141 
142  UImanager->ApplyCommand("/control/execute defaultMacro.mac");
143 
144  UImanager->ApplyCommand("/control/execute batch.mac");
145 
146  ui->SessionStart();
147  delete ui;
148 
149  }
150 
151  delete visManager;
152 
153  delete runManager;
154  delete controller;
155 
156  return 0;
157 }