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 // Hadrontherapy advanced example for Geant4 26 // Hadrontherapy advanced example for Geant4 27 // See more at: https://twiki.cern.ch/twiki/bi 27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy 28 // 28 // 29 // Using the builder concepts of Geant4 we ass << 30 // Physics Lists that are particuilarly suited << 31 // 29 // 32 // 'HADRONTHERAPY_1' is more suited for proton << 30 // ****** SUGGESTED PHYSICS FOR ACCURATE SIMULATIONS ********* 33 // 'HADRONTHERAPY_2' is suggested for better p << 31 // ****** IN MEDICAL PHYSICS APPLICATIONS ********* 34 // 32 // 35 // The Reference physics lists (already presen << 33 // 'HADRONTHERAPY_1' and 'HADRONTHERAPY_2' are both suggested; 36 // be used as well. In this case the more suit << 34 // It can be activated inside any macro file using the command: 37 // "QBBC", "QGSP_BIC", "Shielding", "QGSP_BERT << 35 // /Physics/addPhysics HADRONTHERAPY_1 (HADRONTHERAPY_2) 38 // "QGSP_BIC_AllHP" and "QGSP_BIC_HP" << 39 // << 40 // NOTE: to activate the "_HP" physics you hav << 41 // variable pointing to the external dataset n << 42 // << 43 // All the lists can be activated inside any << 44 // /Physics/addPhysics << 45 // << 46 // Examples of usage are: << 47 // /Physics/addPhysics HADRONTHERAPY_1 or /Phy << 48 36 49 #include "G4SystemOfUnits.hh" 37 #include "G4SystemOfUnits.hh" 50 #include "G4RunManager.hh" 38 #include "G4RunManager.hh" 51 #include "G4Region.hh" 39 #include "G4Region.hh" 52 #include "G4RegionStore.hh" 40 #include "G4RegionStore.hh" 53 #include "HadrontherapyPhysicsList.hh" 41 #include "HadrontherapyPhysicsList.hh" 54 #include "HadrontherapyPhysicsListMessenger.hh 42 #include "HadrontherapyPhysicsListMessenger.hh" 55 #include "HadrontherapyStepMax.hh" 43 #include "HadrontherapyStepMax.hh" 56 #include "G4PhysListFactory.hh" 44 #include "G4PhysListFactory.hh" 57 #include "G4VPhysicsConstructor.hh" 45 #include "G4VPhysicsConstructor.hh" 58 #include "G4HadronPhysicsQGSP_BIC_HP.hh" 46 #include "G4HadronPhysicsQGSP_BIC_HP.hh" 59 #include "G4HadronPhysicsQGSP_BIC.hh" 47 #include "G4HadronPhysicsQGSP_BIC.hh" 60 #include "G4EmStandardPhysics_option4.hh" 48 #include "G4EmStandardPhysics_option4.hh" 61 #include "G4EmStandardPhysics.hh" 49 #include "G4EmStandardPhysics.hh" 62 #include "G4EmExtraPhysics.hh" 50 #include "G4EmExtraPhysics.hh" 63 #include "G4StoppingPhysics.hh" 51 #include "G4StoppingPhysics.hh" 64 #include "G4DecayPhysics.hh" 52 #include "G4DecayPhysics.hh" 65 #include "G4HadronElasticPhysics.hh" 53 #include "G4HadronElasticPhysics.hh" 66 #include "G4HadronElasticPhysicsHP.hh" 54 #include "G4HadronElasticPhysicsHP.hh" 67 #include "G4RadioactiveDecayPhysics.hh" 55 #include "G4RadioactiveDecayPhysics.hh" 68 #include "G4IonBinaryCascadePhysics.hh" 56 #include "G4IonBinaryCascadePhysics.hh" 69 #include "G4DecayPhysics.hh" 57 #include "G4DecayPhysics.hh" 70 #include "G4NeutronTrackingCut.hh" 58 #include "G4NeutronTrackingCut.hh" 71 #include "G4LossTableManager.hh" 59 #include "G4LossTableManager.hh" 72 #include "G4UnitsTable.hh" 60 #include "G4UnitsTable.hh" 73 #include "G4ProcessManager.hh" 61 #include "G4ProcessManager.hh" 74 #include "G4IonFluctuations.hh" 62 #include "G4IonFluctuations.hh" 75 #include "G4IonParametrisedLossModel.hh" 63 #include "G4IonParametrisedLossModel.hh" 76 #include "G4EmParameters.hh" << 64 #include "G4EmProcessOptions.hh" 77 #include "G4ParallelWorldPhysics.hh" 65 #include "G4ParallelWorldPhysics.hh" 78 #include "G4EmLivermorePhysics.hh" 66 #include "G4EmLivermorePhysics.hh" 79 #include "G4AutoDelete.hh" 67 #include "G4AutoDelete.hh" 80 #include "G4HadronPhysicsQGSP_BIC_AllHP.hh" 68 #include "G4HadronPhysicsQGSP_BIC_AllHP.hh" 81 #include "QGSP_BIC_HP.hh" << 82 #include "QGSP_BIC.hh" << 83 #include "G4HadronPhysicsQGSP_BERT.hh" << 84 #include "G4HadronPhysicsQGSP_BERT_HP.hh" << 85 #include "G4ParallelWorldPhysics.hh" << 86 // Physics List << 87 #include "QBBC.hh" << 88 #include "QGSP_BIC.hh" << 89 #include "Shielding.hh" << 90 #include "QGSP_BERT.hh" << 91 #include "QGSP_BIC_AllHP.hh" << 92 #include "QGSP_BIC_HP.hh" << 93 << 94 << 95 69 96 ////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////////// 97 HadrontherapyPhysicsList::HadrontherapyPhysics 71 HadrontherapyPhysicsList::HadrontherapyPhysicsList() : G4VModularPhysicsList() 98 { 72 { 99 G4LossTableManager::Instance(); 73 G4LossTableManager::Instance(); 100 defaultCutValue = 1.*mm; 74 defaultCutValue = 1.*mm; 101 cutForGamma = defaultCutValue; 75 cutForGamma = defaultCutValue; 102 cutForElectron = defaultCutValue; 76 cutForElectron = defaultCutValue; 103 cutForPositron = defaultCutValue; 77 cutForPositron = defaultCutValue; 104 78 105 pMessenger = new HadrontherapyPhysicsListM 79 pMessenger = new HadrontherapyPhysicsListMessenger(this); 106 SetVerboseLevel(1); 80 SetVerboseLevel(1); 107 decay_List = new G4DecayPhysics(); 81 decay_List = new G4DecayPhysics(); 108 // Elecromagnetic physics 82 // Elecromagnetic physics 109 // 83 // 110 emPhysicsList = new G4EmStandardPhysics_op 84 emPhysicsList = new G4EmStandardPhysics_option4(); >> 85 111 } 86 } 112 87 113 ////////////////////////////////////////////// 88 ///////////////////////////////////////////////////////////////////////////// 114 HadrontherapyPhysicsList::~HadrontherapyPhysic 89 HadrontherapyPhysicsList::~HadrontherapyPhysicsList() 115 { 90 { 116 delete pMessenger; 91 delete pMessenger; 117 delete emPhysicsList; 92 delete emPhysicsList; 118 delete decay_List; 93 delete decay_List; 119 //delete radioactiveDecay_List; 94 //delete radioactiveDecay_List; 120 hadronPhys.clear(); 95 hadronPhys.clear(); 121 for(size_t i=0; i<hadronPhys.size(); i++) 96 for(size_t i=0; i<hadronPhys.size(); i++) 122 { 97 { 123 delete hadronPhys[i]; 98 delete hadronPhys[i]; 124 } 99 } 125 } 100 } 126 101 127 ////////////////////////////////////////////// 102 ///////////////////////////////////////////////////////////////////////////// 128 void HadrontherapyPhysicsList::ConstructPartic 103 void HadrontherapyPhysicsList::ConstructParticle() 129 { 104 { 130 decay_List -> ConstructParticle(); 105 decay_List -> ConstructParticle(); 131 106 132 } 107 } 133 108 134 ////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////////// 135 void HadrontherapyPhysicsList::ConstructProces 110 void HadrontherapyPhysicsList::ConstructProcess() 136 { 111 { 137 // Transportation 112 // Transportation 138 // 113 // 139 AddTransportation(); 114 AddTransportation(); 140 115 141 decay_List -> ConstructProcess(); 116 decay_List -> ConstructProcess(); 142 emPhysicsList -> ConstructProcess(); 117 emPhysicsList -> ConstructProcess(); 143 118 144 119 145 //em_config.AddModels(); 120 //em_config.AddModels(); 146 121 147 // Hadronic physics 122 // Hadronic physics 148 // 123 // 149 for(size_t i=0; i < hadronPhys.size(); i++ 124 for(size_t i=0; i < hadronPhys.size(); i++) 150 { 125 { 151 hadronPhys[i] -> ConstructProcess(); 126 hadronPhys[i] -> ConstructProcess(); 152 } 127 } 153 128 154 // step limitation (as a full process) 129 // step limitation (as a full process) 155 // 130 // 156 AddStepMax(); 131 AddStepMax(); 157 132 158 //Parallel world sensitivity 133 //Parallel world sensitivity 159 // 134 // 160 G4ParallelWorldPhysics* pWorld = new G4Par 135 G4ParallelWorldPhysics* pWorld = new G4ParallelWorldPhysics("DetectorROGeometry"); 161 pWorld->ConstructProcess(); 136 pWorld->ConstructProcess(); 162 137 163 return; 138 return; 164 } 139 } 165 140 166 ////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////////// 167 void HadrontherapyPhysicsList::AddPhysicsList( 142 void HadrontherapyPhysicsList::AddPhysicsList(const G4String& name) 168 { 143 { 169 if (verboseLevel>1) { 144 if (verboseLevel>1) { 170 G4cout << "PhysicsList::AddPhysicsList 145 G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl; 171 } 146 } 172 if (name == emName) return; 147 if (name == emName) return; 173 148 174 /////////////////////////////////// 149 /////////////////////////////////// 175 // ELECTROMAGNETIC MODELS 150 // ELECTROMAGNETIC MODELS 176 /////////////////////////////////// 151 /////////////////////////////////// 177 if (name == "standard_opt4") { 152 if (name == "standard_opt4") { 178 emName = name; 153 emName = name; 179 delete emPhysicsList; 154 delete emPhysicsList; 180 hadronPhys.clear(); 155 hadronPhys.clear(); 181 emPhysicsList = new G4EmStandardPhysic 156 emPhysicsList = new G4EmStandardPhysics_option4(); 182 G4RunManager::GetRunManager() -> Physi 157 G4RunManager::GetRunManager() -> PhysicsHasBeenModified(); 183 G4cout << "THE FOLLOWING ELECTROMAGNET 158 G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option4" << G4endl; 184 159 185 ////////////////////////////////////// 160 //////////////////////////////////////// 186 // ELECTROMAGNETIC + HADRONIC MODELS 161 // ELECTROMAGNETIC + HADRONIC MODELS 187 ////////////////////////////////////// 162 //////////////////////////////////////// 188 163 189 } else if (name == "HADRONTHERAPY_1") { 164 } else if (name == "HADRONTHERAPY_1") { 190 165 191 AddPhysicsList("standard_opt4"); 166 AddPhysicsList("standard_opt4"); 192 hadronPhys.push_back( new G4DecayPhysi 167 hadronPhys.push_back( new G4DecayPhysics()); 193 hadronPhys.push_back( new G4Radioactiv 168 hadronPhys.push_back( new G4RadioactiveDecayPhysics()); 194 hadronPhys.push_back( new G4IonBinaryC 169 hadronPhys.push_back( new G4IonBinaryCascadePhysics()); 195 hadronPhys.push_back( new G4EmExtraPhy 170 hadronPhys.push_back( new G4EmExtraPhysics()); 196 hadronPhys.push_back( new G4HadronElas 171 hadronPhys.push_back( new G4HadronElasticPhysicsHP()); 197 hadronPhys.push_back( new G4StoppingPh 172 hadronPhys.push_back( new G4StoppingPhysics()); 198 hadronPhys.push_back( new G4HadronPhys 173 hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC_HP()); 199 hadronPhys.push_back( new G4NeutronTra 174 hadronPhys.push_back( new G4NeutronTrackingCut()); 200 175 201 G4cout << "HADRONTHERAPY_1 PHYSICS LIS 176 G4cout << "HADRONTHERAPY_1 PHYSICS LIST has been activated" << G4endl; 202 } 177 } 203 178 204 else if (name == "HADRONTHERAPY_2") { 179 else if (name == "HADRONTHERAPY_2") { 205 << 180 // HP models are switched off 206 AddPhysicsList("standard_opt4"); 181 AddPhysicsList("standard_opt4"); 207 hadronPhys.push_back( new G4DecayPhysi 182 hadronPhys.push_back( new G4DecayPhysics()); 208 hadronPhys.push_back( new G4Radioactiv 183 hadronPhys.push_back( new G4RadioactiveDecayPhysics()); 209 hadronPhys.push_back( new G4IonBinaryC 184 hadronPhys.push_back( new G4IonBinaryCascadePhysics()); 210 hadronPhys.push_back( new G4EmExtraPhy 185 hadronPhys.push_back( new G4EmExtraPhysics()); 211 hadronPhys.push_back( new G4HadronElas 186 hadronPhys.push_back( new G4HadronElasticPhysics()); 212 hadronPhys.push_back( new G4StoppingPh 187 hadronPhys.push_back( new G4StoppingPhysics()); 213 hadronPhys.push_back( new G4HadronPhys << 188 hadronPhys.push_back( new G4HadronPhysicsQGSP_BIC()); 214 hadronPhys.push_back( new G4NeutronTra 189 hadronPhys.push_back( new G4NeutronTrackingCut()); 215 190 216 G4cout << "HADRONTHERAPY_2 PHYSICS LIS << 191 G4cout << "HADRONTHERAPY_2 PHYSICS LIST has been activated" << G4endl; } 217 << 218 } << 219 << 220 else if (name == "QGSP_BIC"){ << 221 auto physicsList = new QGSP_BIC; << 222 G4RunManager::GetRunManager() -> SetUs << 223 G4RunManager::GetRunManager() -> Physi << 224 physicsList -> RegisterPhysics(new G4P << 225 } << 226 << 227 else if (name == "QGSP_BERT"){ << 228 auto physicsList = new QGSP_BERT; << 229 G4RunManager::GetRunManager() -> SetUs << 230 G4RunManager::GetRunManager() -> Physi << 231 physicsList -> RegisterPhysics(new G4P << 232 } << 233 << 234 else if (name == "QGSP_BIC_AllHP"){ << 235 auto physicsList = new QGSP_BIC_AllHP; << 236 G4RunManager::GetRunManager() -> SetUs << 237 G4RunManager::GetRunManager() -> Physi << 238 physicsList -> RegisterPhysics(new G4P << 239 } << 240 << 241 else if (name == "QGSP_BIC_HP"){ << 242 auto physicsList = new QGSP_BIC_HP; << 243 G4RunManager::GetRunManager() -> SetUs << 244 G4RunManager::GetRunManager() -> Physi << 245 physicsList -> RegisterPhysics(new G4P << 246 } << 247 << 248 else if (name == "Shielding"){ << 249 auto physicsList = new Shielding; << 250 G4RunManager::GetRunManager() -> SetUs << 251 G4RunManager::GetRunManager() -> Physi << 252 physicsList -> RegisterPhysics(new G4P << 253 } << 254 << 255 else if (name == "QBBC"){ << 256 auto physicsList = new QBBC; << 257 G4RunManager::GetRunManager() -> SetUs << 258 G4RunManager::GetRunManager() -> Physi << 259 physicsList -> RegisterPhysics(new G4P << 260 } << 261 << 262 else { 192 else { 263 G4cout << "PhysicsList::AddPhysicsList 193 G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" 264 << " is not defined" 194 << " is not defined" 265 << G4endl; 195 << G4endl; 266 } 196 } 267 197 268 } 198 } 269 199 270 ////////////////////////////////////////////// 200 ///////////////////////////////////////////////////////////////////////////// 271 void HadrontherapyPhysicsList::AddStepMax() 201 void HadrontherapyPhysicsList::AddStepMax() 272 { 202 { 273 // Step limitation seen as a process 203 // Step limitation seen as a process 274 // This process must exist in all threads. 204 // This process must exist in all threads. 275 // 205 // 276 HadrontherapyStepMax* stepMaxProcess = ne 206 HadrontherapyStepMax* stepMaxProcess = new HadrontherapyStepMax(); 277 << 207 G4AutoDelete::Register( stepMaxProcess ); 278 208 279 auto particleIterator = GetParticleIterato 209 auto particleIterator = GetParticleIterator(); 280 particleIterator->reset(); 210 particleIterator->reset(); 281 while ((*particleIterator)()){ 211 while ((*particleIterator)()){ 282 G4ParticleDefinition* particle = parti 212 G4ParticleDefinition* particle = particleIterator->value(); 283 G4ProcessManager* pmanager = particle- 213 G4ProcessManager* pmanager = particle->GetProcessManager(); 284 214 285 if (stepMaxProcess->IsApplicable(*part 215 if (stepMaxProcess->IsApplicable(*particle) && pmanager) 286 { 216 { 287 pmanager ->AddDiscreteProcess(step 217 pmanager ->AddDiscreteProcess(stepMaxProcess); 288 } 218 } 289 } 219 } 290 } 220 } 291 221