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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/hadrontherapy/hadrontherapy.cc (Version 11.3.0) and /examples/advanced/hadrontherapy/hadrontherapy.cc (Version 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // ------------------------------------------- <<  26 //      ----------------------------------------------------------------------------
 27 //                         GEANT 4 - Hadronthe <<  27 //                              GEANT 4 - Hadrontherapy example
 28 // ------------------------------------------- <<  28 //      ----------------------------------------------------------------------------
 29 //                                                 29 //
 30 //                                     MAIN AU <<  30 //                                      MAIN AUTHORS
 31 //                                  ==========     31 //                                  ====================
 32 //         G.A.P. Cirrone(a)*, L. Pandola(a),  <<  32 //                             G.A.P. Cirrone(a)*, F.Romano(a)
 33 //              *Corresponding author, email t << 
 34 //                                                 33 //
                                                   >>  34 //                 *Corresponding author, email to pablo.cirrone@lns.infn.it
 35 //                                                 35 //
 36 //                 ==========>   PAST CONTRIBU <<  36 //                                          WEB
                                                   >>  37 //                                      ===========
                                                   >>  38 //                       http://www.lns.infn.it/link/Hadrontherapy
 37 //                                                 39 //
 38 //                    R.Calcagno(a), G.Daniels << 
 39 //                    S.Guatelli(c), A.Heikkin << 
 40 //                    A.Lechner(d), S.E.Mazzag << 
 41 //                    M.G.Pia(e), F.Romano(a), << 
 42 //                    M.Russo(a), A.Tramontana << 
 43 //                                                 40 //
 44 //              (a) Laboratori Nazionali del S <<  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
 45 //              (b) Helsinki Institute of Phys     50 //              (b) Helsinki Institute of Physics, Helsinki, Finland
 46 //              (c) University of Wallongong,      51 //              (c) University of Wallongong, Australia
 47 //              (d) CERN, Geneve, Switzwerland     52 //              (d) CERN, Geneve, Switzwerland
 48 //              (e) INFN Section of Genova, Ge     53 //              (e) INFN Section of Genova, Genova, Italy
 49 //              (f) Physics and Astronomy Depa     54 //              (f) Physics and Astronomy Department, Univ. of Catania, Catania, Italy
 50 //              (g) CNR-IBFM, Italy            << 
 51 //              (h) Institute of Applied Elect << 
 52 //                  Huazhong University of Sci << 
 53 //                                                 55 //
 54 //                                                 56 //
 55 //                                          WE << 
 56 //                                      ====== << 
 57 //       https://twiki.cern.ch/twiki/bin/view/ << 
 58 //                                             << 
 59 // -------------------------------------------     57 // ----------------------------------------------------------------------------
 60                                                    58 
 61 #include "G4RunManager.hh"                         59 #include "G4RunManager.hh"
 62 #include "G4UImanager.hh"                          60 #include "G4UImanager.hh"
 63 #include "G4PhysListFactory.hh"                    61 #include "G4PhysListFactory.hh"
 64 #include "G4VModularPhysicsList.hh"                62 #include "G4VModularPhysicsList.hh"
 65 #include "HadrontherapyEventAction.hh"             63 #include "HadrontherapyEventAction.hh"
 66 #include "HadrontherapyPhysicsList.hh"             64 #include "HadrontherapyPhysicsList.hh"
 67 #include "HadrontherapyDetectorSD.hh"              65 #include "HadrontherapyDetectorSD.hh"
 68 #include "HadrontherapyPrimaryGeneratorAction.     66 #include "HadrontherapyPrimaryGeneratorAction.hh"
 69 #include "HadrontherapyRunAction.hh"               67 #include "HadrontherapyRunAction.hh"
 70 #include "HadrontherapyMatrix.hh"                  68 #include "HadrontherapyMatrix.hh"
 71 #include "Randomize.hh"                            69 #include "Randomize.hh"
 72                                                    70 
 73 #include "G4UImessenger.hh"                        71 #include "G4UImessenger.hh"
 74 #include "globals.hh"                              72 #include "globals.hh"
 75 #include "HadrontherapySteppingAction.hh"          73 #include "HadrontherapySteppingAction.hh"
 76 #include "HadrontherapyGeometryController.hh"      74 #include "HadrontherapyGeometryController.hh"
 77 #include "HadrontherapyGeometryMessenger.hh"       75 #include "HadrontherapyGeometryMessenger.hh"
 78 #include "HadrontherapyInteractionParameters.h     76 #include "HadrontherapyInteractionParameters.hh"
 79 #include "HadrontherapyLet.hh"                     77 #include "HadrontherapyLet.hh"
 80                                                    78 
 81 #include "G4ScoringManager.hh"                     79 #include "G4ScoringManager.hh"
 82 #include "G4ParallelWorldPhysics.hh"               80 #include "G4ParallelWorldPhysics.hh"
 83 #include <time.h>                                  81 #include <time.h>
 84 #include "G4Timer.hh"                          <<  82 
 85 #include "G4RunManagerFactory.hh"              <<  83 //************************MT*********************
                                                   >>  84 #ifdef G4MULTITHREADED
                                                   >>  85 #include "G4MTRunManager.hh"
                                                   >>  86 #else
                                                   >>  87 #include "G4RunManager.hh"
                                                   >>  88 #endif
                                                   >>  89 
 86 #include "HadrontherapyActionInitialization.hh     90 #include "HadrontherapyActionInitialization.hh"
 87                                                    91 
                                                   >>  92 #ifdef G4VIS_USE
 88 #include "G4VisExecutive.hh"                       93 #include "G4VisExecutive.hh"
 89 #include "G4UIExecutive.hh"                    <<  94 #endif
 90                                                    95 
 91 #include "QBBC.hh"                             <<  96 #ifdef G4UI_USE
                                                   >>  97 #include "G4UIExecutive.hh"
                                                   >>  98 #endif
 92                                                    99 
 93 //////////////////////////////////////////////    100 //////////////////////////////////////////////////////////////////////////////////////////////
 94 int main(int argc ,char ** argv)                  101 int main(int argc ,char ** argv)
 95 {                                                 102 {
 96     // Detect interactive mode (if no argument << 
 97     //                                         << 
 98     G4UIExecutive* ui = nullptr;               << 
 99     if ( argc == 1 ) { ui = new G4UIExecutive( << 
100                                                << 
101     //Instantiate the G4Timer object, to monit << 
102     //the entire execution                     << 
103     G4Timer* theTimer = new G4Timer();         << 
104     //Start the benchmark                      << 
105     theTimer->Start();                         << 
106                                                   103     
107     // Set the Random engine                      104     // Set the Random engine
108     // The following guarantees random generat    105     // The following guarantees random generation also for different runs
109     // in multithread                             106     // in multithread
110     CLHEP::RanluxEngine defaultEngine( 1234567    107     CLHEP::RanluxEngine defaultEngine( 1234567, 4 );
111     G4Random::setTheEngine( &defaultEngine );     108     G4Random::setTheEngine( &defaultEngine );
112     G4int seed = (G4int) time( NULL );         << 109     G4int seed = time( NULL );
113     G4Random::setTheSeed( seed );                 110     G4Random::setTheSeed( seed );
114                                                   111     
115     // Construct the default run manager       << 112 #ifdef G4MULTITHREADED
116     //                                         << 113     
117     auto* runManager = G4RunManagerFactory::Cr << 114     G4MTRunManager* runManager = new G4MTRunManager;
118                                                << 115 #else
119     // Define the number of threads for the si << 116     G4RunManager* runManager = new G4RunManager;
120     G4int nThreads = 4;                        << 117 #endif
121     runManager->SetNumberOfThreads(nThreads);  << 118     
122                                                << 119     
123     // Geometry controller is responsible for  << 120     // Geometry controller is responsible for instantiating the
124     //                                         << 121     // geometries. All geometry specific setup tasks are now in class
                                                   >> 122     // HadrontherapyGeometryController.
125     HadrontherapyGeometryController *geometryC    123     HadrontherapyGeometryController *geometryController = new HadrontherapyGeometryController();
126                                                   124     
127     // Connect the geometry controller to the     125     // Connect the geometry controller to the G4 user interface
128     //                                         << 
129     HadrontherapyGeometryMessenger *geometryMe    126     HadrontherapyGeometryMessenger *geometryMessenger = new HadrontherapyGeometryMessenger(geometryController);
130                                                   127     
131     G4ScoringManager *scoringManager = G4Scori    128     G4ScoringManager *scoringManager = G4ScoringManager::GetScoringManager();
132     scoringManager->SetVerboseLevel(1);           129     scoringManager->SetVerboseLevel(1);
133                                                   130     
                                                   >> 131     
134     // Initialize the default Hadrontherapy ge    132     // Initialize the default Hadrontherapy geometry
135     geometryController->SetGeometry("default")    133     geometryController->SetGeometry("default");
136                                                   134     
                                                   >> 135     // Initialize command based scoring
                                                   >> 136     G4ScoringManager::GetScoringManager();
                                                   >> 137     
137     // Initialize the physics                     138     // Initialize the physics
138     G4PhysListFactory factory;                    139     G4PhysListFactory factory;
139     G4VModularPhysicsList* physicsList = 0;    << 140     G4VModularPhysicsList* phys = 0;
140     physicsList = new HadrontherapyPhysicsList << 141     G4String physName = "";
                                                   >> 142     
                                                   >> 143     // Physics List name defined via environment variable
                                                   >> 144     char* path = getenv("PHYSLIST");
                                                   >> 145     if (path) { physName = G4String(path); }
141                                                   146     
142     if (physicsList)                           << 147     if(physName != "" && factory.IsReferencePhysList(physName))
                                                   >> 148     {
                                                   >> 149         phys = factory.GetReferencePhysList(physName);
                                                   >> 150     }
                                                   >> 151     if (phys)
143     {                                             152     {
144         G4cout << "Going to register G4Paralle    153         G4cout << "Going to register G4ParallelWorldPhysics" << G4endl;
145         physicsList -> RegisterPhysics(new G4P << 154         phys->RegisterPhysics(new G4ParallelWorldPhysics("DetectorROGeometry"));
                                                   >> 155     }
                                                   >> 156     else
                                                   >> 157     {
                                                   >> 158         G4cout << "Using HadrontherapyPhysicsList()" << G4endl;
                                                   >> 159         phys = new HadrontherapyPhysicsList();
146     }                                             160     }
147                                                   161     
148     // Initialisations of physics              << 162     runManager->SetUserInitialization(phys);
149     runManager->SetUserInitialization(physicsL << 
150                                                   163     
151     // Initialisation of the Actions           << 164     //************************MT
152     runManager->SetUserInitialization(new Hadr    165     runManager->SetUserInitialization(new HadrontherapyActionInitialization);
153                                                   166     
154     // Initialize command based scoring        << 167     
155     G4ScoringManager::GetScoringManager();     << 
156                                                   168     
157     // Interaction data: stopping powers          169     // Interaction data: stopping powers
158     //                                         << 
159     HadrontherapyInteractionParameters* pInter    170     HadrontherapyInteractionParameters* pInteraction = new HadrontherapyInteractionParameters(true);
160                                                   171     
161     // Initialize analysis                        172     // Initialize analysis
162     //                                         << 173     HadrontherapyAnalysisManager* analysis = HadrontherapyAnalysisManager::GetInstance();
163     HadrontherapyAnalysis* analysis = Hadronth << 
164                                                   174     
165                                                << 175     
166     // Initialise the Visualisation            << 176     // Get the pointer to the visualization manager
167     //                                         << 177 #ifdef G4VIS_USE
168     auto visManager = new G4VisExecutive(argc, << 178     G4VisManager* visManager = new G4VisExecutive;
169     visManager -> Initialize();                   179     visManager -> Initialize();
                                                   >> 180 #endif
170                                                   181     
171     //** Get the pointer to the User Interface << 182     // Get the pointer to the User Interface manager
172     //                                         << 183     G4UImanager* UImanager = G4UImanager::GetUIpointer();
173     auto UImanager = G4UImanager::GetUIpointer << 
174                                                   184     
175     if ( !ui ) {                               << 185     if (argc == 1)   // Define UI session for interactive mode.
176         // batch mode                          << 186     {
177         G4String command = "/control/execute " << 187 #ifdef G4UI_USE
178         G4String fileName = argv[1];           << 188         G4UIExecutive* ui = new G4UIExecutive(argc, argv);
179         UImanager->ApplyCommand(command+fileNa << 189         G4cout << " UI session starts ..." << G4endl;
180     }                                          << 190         
181                                                << 
182     else {                                     << 
183         UImanager -> ApplyCommand("/control/ma << 
184         UImanager -> ApplyCommand("/control/ex    191         UImanager -> ApplyCommand("/control/execute macro/defaultMacro.mac");
                                                   >> 192         
                                                   >> 193         
185         ui -> SessionStart();                     194         ui -> SessionStart();
186         delete ui;                                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);
187     }                                             203     }
188     delete visManager;                         << 
189                                                << 
190     //Stop the benchmark here                  << 
191     theTimer->Stop();                          << 
192                                                << 
193     G4cout << "The simulation took: " << theTi << 
194     << G4endl;                                 << 
195                                                   204     
196     // Job termination                            205     // Job termination
197     // Free the store: user actions, physics_l << 206     if ( HadrontherapyMatrix * pMatrix = HadrontherapyMatrix::GetInstance() )
198     // owned and deleted by the run manager, s << 
199     // in the main() program !                 << 
200                                                << 
201                                                << 
202         if ( HadrontherapyMatrix * pMatrix = H << 
203     {                                             207     {
204         // pMatrix -> TotalEnergyDeposit();       208         // pMatrix -> TotalEnergyDeposit();
205         pMatrix -> StoreDoseFluenceAscii();       209         pMatrix -> StoreDoseFluenceAscii();
206                                                   210         
207     }                                             211     }
208                                                   212     
209     if (HadrontherapyLet *let = HadrontherapyL    213     if (HadrontherapyLet *let = HadrontherapyLet::GetInstance())
210         if(let -> doCalculation)                  214         if(let -> doCalculation)
211         {                                         215         {
212             let -> LetOutput();   // Calculate    216             let -> LetOutput();   // Calculate let
213             let -> StoreLetAscii(); // Store i    217             let -> StoreLetAscii(); // Store it
214         }                                         218         }
                                                   >> 219     
                                                   >> 220     
                                                   >> 221     
                                                   >> 222 #ifdef G4VIS_USE
                                                   >> 223     delete visManager;
                                                   >> 224 #endif
215                                                   225     
216     delete geometryMessenger;                     226     delete geometryMessenger;
217     delete geometryController;                    227     delete geometryController;
218     delete pInteraction;                          228     delete pInteraction;
219     delete runManager;                            229     delete runManager;
220     delete analysis;                              230     delete analysis;
221     return 0;                                     231     return 0;
222                                                   232     
223 }                                                 233 }
224                                                   234