| 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 | // Hadrontherapy.cc
|
|---|
| 27 | //
|
|---|
| 28 | // Main of the Hadrontherapy example;
|
|---|
| 29 | // Released with the Geant4 9.3 version (December 2009)
|
|---|
| 30 | //
|
|---|
| 31 | // Last modified: G.A.P.Cirrone
|
|---|
| 32 | //
|
|---|
| 33 | // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
|
|---|
| 34 | //
|
|---|
| 35 | // ----------------------------------------------------------------------------
|
|---|
| 36 | // GEANT 4 - Hadrontherapy example
|
|---|
| 37 | // ----------------------------------------------------------------------------
|
|---|
| 38 | // Code developed by:
|
|---|
| 39 | //
|
|---|
| 40 | // G.A.P. Cirrone(a)°, G.Cuttone(a), F.Di Rosa(a), E.Mazzaglia(a), F.Romano(a)
|
|---|
| 41 | //
|
|---|
| 42 | // Contributor authors:
|
|---|
| 43 | // P.Kaitaniemi(d), A.Heikkinen(d), Gillis Danielsen (d)
|
|---|
| 44 | //
|
|---|
| 45 | // Past authors:
|
|---|
| 46 | // M.G.Pia(b), S.Guatelli(c), G.Russo(a), M.Russo(a), A.Lechner(e)
|
|---|
| 47 | //
|
|---|
| 48 | // (a) Laboratori Nazionali del Sud
|
|---|
| 49 | // of the INFN, Catania, Italy
|
|---|
| 50 | //
|
|---|
| 51 | // (b) INFN Section of Genova, Italy
|
|---|
| 52 | //
|
|---|
| 53 | // (c) University of Wallongong, Australia
|
|---|
| 54 | //
|
|---|
| 55 | // (d) Helsinki Institute of Physics, Helsinki, Finland
|
|---|
| 56 | //
|
|---|
| 57 | // (e) CERN, (CH)
|
|---|
| 58 | //
|
|---|
| 59 | // *Corresponding author, email to cirrone@lns.infn.it
|
|---|
| 60 | // ----------------------------------------------------------------------------
|
|---|
| 61 |
|
|---|
| 62 | #include "G4RunManager.hh"
|
|---|
| 63 | #include "G4UImanager.hh"
|
|---|
| 64 | #include "G4UIterminal.hh"
|
|---|
| 65 | #include "G4UItcsh.hh"
|
|---|
| 66 | #include "HadrontherapyEventAction.hh"
|
|---|
| 67 | #include "HadrontherapyPhysicsList.hh"
|
|---|
| 68 | #include "HadrontherapyDetectorSD.hh"
|
|---|
| 69 | #include "HadrontherapyPrimaryGeneratorAction.hh"
|
|---|
| 70 | #include "HadrontherapyRunAction.hh"
|
|---|
| 71 | #include "HadrontherapyMatrix.hh"
|
|---|
| 72 | #include "Randomize.hh"
|
|---|
| 73 | #include "G4RunManager.hh"
|
|---|
| 74 | #include "G4UImanager.hh"
|
|---|
| 75 | #include "G4UImessenger.hh"
|
|---|
| 76 | #include "globals.hh"
|
|---|
| 77 | #include "HadrontherapySteppingAction.hh"
|
|---|
| 78 | #include "HadrontherapyAnalysisManager.hh"
|
|---|
| 79 | #include "HadrontherapyGeometryController.hh"
|
|---|
| 80 | #include "HadrontherapyGeometryMessenger.hh"
|
|---|
| 81 | #include "HadrontherapyInteractionParameters.hh"
|
|---|
| 82 | #include "G4ScoringManager.hh"
|
|---|
| 83 | #include "IAEAScoreWriter.hh"
|
|---|
| 84 |
|
|---|
| 85 | #if defined(G4UI_USE_TCSH)
|
|---|
| 86 | #include "G4UIterminal.hh"
|
|---|
| 87 | #include "G4UItcsh.hh"
|
|---|
| 88 | #endif
|
|---|
| 89 |
|
|---|
| 90 | #ifdef G4UI_USE_XM
|
|---|
| 91 | #include "G4UIXm.hh"
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 | #ifdef G4VIS_USE
|
|---|
| 95 | #include "G4VisExecutive.hh"
|
|---|
| 96 | #endif
|
|---|
| 97 |
|
|---|
| 98 | #ifdef G4UI_USE_QT
|
|---|
| 99 | #include "G4UIQt.hh"
|
|---|
| 100 | #include "G4Qt.hh"
|
|---|
| 101 | #endif
|
|---|
| 102 |
|
|---|
| 103 | //////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 104 | int main(int argc ,char ** argv)
|
|---|
| 105 | {
|
|---|
| 106 | // Set the Random engine
|
|---|
| 107 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
|
|---|
| 108 |
|
|---|
| 109 | G4RunManager* runManager = new G4RunManager;
|
|---|
| 110 |
|
|---|
| 111 | //Initialize possible analysis needs, needs to come early in order to pick up metadata
|
|---|
| 112 | #ifdef ANALYSIS_USE
|
|---|
| 113 | HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::getInstance();
|
|---|
| 114 | analysis -> book();
|
|---|
| 115 | #endif
|
|---|
| 116 | // Geometry controller is responsible for instantiating the
|
|---|
| 117 | // geometries. All geometry specific setup tasks are now in class
|
|---|
| 118 | // HadrontherapyGeometryController.
|
|---|
| 119 | HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController();
|
|---|
| 120 |
|
|---|
| 121 | // Connect the geometry controller to the G4 user interface
|
|---|
| 122 | HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
|
|---|
| 123 |
|
|---|
| 124 | G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager();
|
|---|
| 125 | scoringManager->SetVerboseLevel(1);
|
|---|
| 126 | scoringManager->SetScoreWriter(new IAEAScoreWriter());
|
|---|
| 127 |
|
|---|
| 128 | // Initialize the default Hadrontherapy geometry
|
|---|
| 129 | geometryController->SetGeometry("default");
|
|---|
| 130 |
|
|---|
| 131 | // Initialize command based scoring
|
|---|
| 132 | G4ScoringManager::GetScoringManager();
|
|---|
| 133 |
|
|---|
| 134 | // Initialize the physics
|
|---|
| 135 | runManager -> SetUserInitialization(new HadrontherapyPhysicsList());
|
|---|
| 136 |
|
|---|
| 137 | // Initialize the primary particles
|
|---|
| 138 | HadrontherapyPrimaryGeneratorAction *pPrimaryGenerator = new HadrontherapyPrimaryGeneratorAction();
|
|---|
| 139 | runManager -> SetUserAction(pPrimaryGenerator);
|
|---|
| 140 |
|
|---|
| 141 | // Optional UserActions: run, event, stepping
|
|---|
| 142 | HadrontherapyRunAction* pRunAction = new HadrontherapyRunAction();
|
|---|
| 143 | runManager -> SetUserAction(pRunAction);
|
|---|
| 144 |
|
|---|
| 145 | HadrontherapyEventAction* pEventAction = new HadrontherapyEventAction();
|
|---|
| 146 | runManager -> SetUserAction(pEventAction);
|
|---|
| 147 |
|
|---|
| 148 | HadrontherapySteppingAction* steppingAction = new HadrontherapySteppingAction(pRunAction);
|
|---|
| 149 | runManager -> SetUserAction(steppingAction);
|
|---|
| 150 |
|
|---|
| 151 | // Interaction data: stopping powers
|
|---|
| 152 | HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters();
|
|---|
| 153 |
|
|---|
| 154 | #ifdef G4VIS_USE
|
|---|
| 155 | // Visualization manager
|
|---|
| 156 | G4VisManager* visManager = new G4VisExecutive;
|
|---|
| 157 | visManager -> Initialize();
|
|---|
| 158 | #endif
|
|---|
| 159 |
|
|---|
| 160 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 161 |
|
|---|
| 162 | if (argc!=1) // batch mode
|
|---|
| 163 | {
|
|---|
| 164 | G4String command = "/control/execute ";
|
|---|
| 165 | G4String fileName = argv[1];
|
|---|
| 166 | UI->ApplyCommand(command+fileName);
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | else // interactive mode : define visualization UI terminal
|
|---|
| 170 | {
|
|---|
| 171 | G4UIsession* session = 0;
|
|---|
| 172 |
|
|---|
| 173 | // If the enviroment variable for the TCSH terminal is active, it is used and the
|
|---|
| 174 | // defaultMacro.mac file is executed
|
|---|
| 175 | #if defined(G4UI_USE_TCSH)
|
|---|
| 176 | session = new G4UIterminal(new G4UItcsh);
|
|---|
| 177 | UI->ApplyCommand("/control/execute defaultMacro.mac");
|
|---|
| 178 |
|
|---|
| 179 | // Alternatively (if G4UI_USE_TCSH is not defined) the program search for the
|
|---|
| 180 | // G$UI_USE_QT variable. It starts a graphical user interface based on the QT libraries
|
|---|
| 181 | // In the following case the GUI.mac file is also executed
|
|---|
| 182 | //
|
|---|
| 183 | #elif defined(G4UI_USE_QT)
|
|---|
| 184 | session = new G4UIQt(argc,argv);
|
|---|
| 185 | UI->ApplyCommand("/control/execute macro/GUI.mac");
|
|---|
| 186 |
|
|---|
| 187 | // As final option, the simpler user interface terminal is opened
|
|---|
| 188 | #else
|
|---|
| 189 | session = new G4UIterminal();
|
|---|
| 190 | UI->ApplyCommand("/control/execute defaultMacro.mac");
|
|---|
| 191 | #endif
|
|---|
| 192 | session->SessionStart();
|
|---|
| 193 | delete session;
|
|---|
| 194 | }
|
|---|
| 195 | HadrontherapyMatrix* matrix = HadrontherapyMatrix::getInstance();
|
|---|
| 196 | if (matrix) matrix -> TotalEnergyDeposit();
|
|---|
| 197 |
|
|---|
| 198 | #ifdef ANALYSIS_USE
|
|---|
| 199 | analysis -> finish();
|
|---|
| 200 | #endif
|
|---|
| 201 |
|
|---|
| 202 | // Job termination
|
|---|
| 203 | #ifdef G4VIS_USE
|
|---|
| 204 | delete visManager;
|
|---|
| 205 | #endif
|
|---|
| 206 |
|
|---|
| 207 | delete geometryMessenger;
|
|---|
| 208 | delete geometryController;
|
|---|
| 209 | delete pInteraction;
|
|---|
| 210 | delete runManager;
|
|---|
| 211 | return 0;
|
|---|
| 212 | }
|
|---|