Geant4 Cross Reference |
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 // D Chiappara, GAP Cirrone, G Petringa 27 // D Chiappara, GAP Cirrone, G Petringa 28 // 28 // 29 // ** RADIOBIO example ** 29 // ** RADIOBIO example ** 30 // make easy the calculation of the main radio 30 // make easy the calculation of the main radiobiology quantities used in 31 // charged particles radiation therapy: depth 31 // charged particles radiation therapy: depth dose, Fluence in depth, 32 // LET (Linear Energy Transfer) and RBE (Relat 32 // LET (Linear Energy Transfer) and RBE (Relative Bioology Effectiveness) 33 // 33 // 34 34 35 #include "G4PhysListFactory.hh" 35 #include "G4PhysListFactory.hh" 36 #include "G4RunManagerFactory.hh" 36 #include "G4RunManagerFactory.hh" 37 #include "G4ScoringManager.hh" 37 #include "G4ScoringManager.hh" 38 #include "G4Timer.hh" 38 #include "G4Timer.hh" 39 #include "G4UImanager.hh" 39 #include "G4UImanager.hh" 40 #include "G4UImessenger.hh" 40 #include "G4UImessenger.hh" 41 #include "G4VModularPhysicsList.hh" 41 #include "G4VModularPhysicsList.hh" 42 #include "Randomize.hh" 42 #include "Randomize.hh" 43 #include "globals.hh" 43 #include "globals.hh" 44 44 45 #include "ActionInitialization.hh" 45 #include "ActionInitialization.hh" 46 #include "DetectorConstruction.hh" 46 #include "DetectorConstruction.hh" 47 #include "Dose.hh" 47 #include "Dose.hh" 48 #include "LET.hh" 48 #include "LET.hh" 49 #include "Manager.hh" 49 #include "Manager.hh" 50 #include "PhysicsList.hh" 50 #include "PhysicsList.hh" 51 #include "PrimaryGeneratorAction.hh" 51 #include "PrimaryGeneratorAction.hh" 52 #include "RBE.hh" 52 #include "RBE.hh" 53 #include <time.h> 53 #include <time.h> 54 54 55 // #ifdef G4VIS_USE << 55 //#ifdef G4VIS_USE 56 #include "G4VisExecutive.hh" 56 #include "G4VisExecutive.hh" 57 // #endif << 57 //#endif 58 58 59 // #ifdef G4UI_USE << 59 //#ifdef G4UI_USE 60 #include "G4UIExecutive.hh" 60 #include "G4UIExecutive.hh" 61 // #endif << 61 //#endif 62 62 63 using namespace RadioBio; 63 using namespace RadioBio; 64 64 65 ////////////////////////////////////////////// 65 //////////////////////////////////////////////////////////////////////////////// 66 int main(int argc, char** argv) 66 int main(int argc, char** argv) 67 { 67 { 68 G4UIExecutive* ui = nullptr; 68 G4UIExecutive* ui = nullptr; 69 if (argc == 1) { 69 if (argc == 1) { 70 ui = new G4UIExecutive(argc, argv); 70 ui = new G4UIExecutive(argc, argv); 71 } 71 } 72 72 73 // Instantiate the G4Timer object, to monito 73 // Instantiate the G4Timer object, to monitor the CPU time spent for 74 // the entire execution 74 // the entire execution 75 G4Timer* theTimer = new G4Timer(); 75 G4Timer* theTimer = new G4Timer(); 76 // Start the benchmark 76 // Start the benchmark 77 theTimer->Start(); 77 theTimer->Start(); 78 78 79 // Set the Random engine 79 // Set the Random engine 80 // The following guarantees random generatio 80 // The following guarantees random generation also for different runs 81 // in multithread 81 // in multithread 82 CLHEP::RanluxEngine defaultEngine(1234567, 4 82 CLHEP::RanluxEngine defaultEngine(1234567, 4); 83 G4Random::setTheEngine(&defaultEngine); 83 G4Random::setTheEngine(&defaultEngine); 84 G4int seed = time(NULL); 84 G4int seed = time(NULL); 85 G4Random::setTheSeed(seed); 85 G4Random::setTheSeed(seed); 86 86 87 // Create the run manager. Uses by default s 87 // Create the run manager. Uses by default serial or parallel computation. 88 auto* runManager = G4RunManagerFactory::Crea 88 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); 89 89 90 // Create Scoring manager 90 // Create Scoring manager 91 G4ScoringManager* scoringManager = G4Scoring 91 G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager(); 92 scoringManager->SetVerboseLevel(1); 92 scoringManager->SetVerboseLevel(1); 93 93 94 // Creating PhysicsList 94 // Creating PhysicsList 95 G4VModularPhysicsList* phys = new PhysicsLis 95 G4VModularPhysicsList* phys = new PhysicsList(); 96 96 97 // Set mandatory initialization classes 97 // Set mandatory initialization classes 98 DetectorConstruction* det = new DetectorCons 98 DetectorConstruction* det = new DetectorConstruction(); 99 runManager->SetUserInitialization(det); 99 runManager->SetUserInitialization(det); 100 100 101 // Creation of Manager 101 // Creation of Manager 102 Manager* RBman = Manager::CreateInstance(); 102 Manager* RBman = Manager::CreateInstance(); 103 103 104 // Create and Register Radiobiological quant 104 // Create and Register Radiobiological quantities 105 Dose* dose = new Dose(); 105 Dose* dose = new Dose(); 106 RBman->Register(dose, "Dose"); 106 RBman->Register(dose, "Dose"); 107 107 108 LET* let = new LET(); 108 LET* let = new LET(); 109 RBman->Register(let, "LET"); 109 RBman->Register(let, "LET"); 110 110 111 RBE* rbe = new RBE(); 111 RBE* rbe = new RBE(); 112 RBman->Register(rbe, "RBE"); 112 RBman->Register(rbe, "RBE"); 113 113 114 // Initialisation of physics 114 // Initialisation of physics 115 runManager->SetUserInitialization(phys); 115 runManager->SetUserInitialization(phys); 116 116 117 // Initialisation of the Actions 117 // Initialisation of the Actions 118 runManager->SetUserInitialization(new Action 118 runManager->SetUserInitialization(new ActionInitialization(det)); 119 119 120 // Initialize command based scoring 120 // Initialize command based scoring 121 G4ScoringManager::GetScoringManager(); 121 G4ScoringManager::GetScoringManager(); 122 122 123 // Initialise the Visualisation 123 // Initialise the Visualisation 124 // #ifdef G4VIS_USE << 124 //#ifdef G4VIS_USE 125 G4VisManager* visManager = new G4VisExecutiv 125 G4VisManager* visManager = new G4VisExecutive; 126 visManager->Initialize(); 126 visManager->Initialize(); 127 // #endif << 127 //#endif 128 128 129 //** Get the pointer to the User Interface m 129 //** Get the pointer to the User Interface manager 130 G4UImanager* UImanager = G4UImanager::GetUIp 130 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 131 131 132 if (!ui) { 132 if (!ui) { 133 // batch mode 133 // batch mode 134 G4String command = "/control/execute "; 134 G4String command = "/control/execute "; 135 G4String fileName = argv[1]; 135 G4String fileName = argv[1]; 136 UImanager->ApplyCommand(command + fileName 136 UImanager->ApplyCommand(command + fileName); 137 } 137 } 138 138 139 else { 139 else { 140 // UImanager -> ApplyCommand("/control/exe 140 // UImanager -> ApplyCommand("/control/execute macro/MacroPablo.mac"); 141 UImanager->ApplyCommand("/control/execute 141 UImanager->ApplyCommand("/control/execute macro/visualize.mac"); 142 142 143 ui->SessionStart(); 143 ui->SessionStart(); 144 delete ui; 144 delete ui; 145 } 145 } 146 146 147 // Save data in RadioBioManager 147 // Save data in RadioBioManager 148 RBman->StoreAll(); 148 RBman->StoreAll(); 149 149 150 // Stop the benchmark here 150 // Stop the benchmark here 151 theTimer->Stop(); 151 theTimer->Stop(); 152 152 153 G4cout << "The simulation took: " << theTime 153 G4cout << "The simulation took: " << theTimer->GetRealElapsed() << " s to run (real time)" 154 << G4endl; 154 << G4endl; 155 155 156 delete theTimer; 156 delete theTimer; 157 delete runManager; 157 delete runManager; 158 } 158 } 159 159