Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** >> 22 // $Id: HadrontherapyPhysicsList.cc,v 1.0 >> 23 // ---------------------------------------------------------------------------- >> 24 // GEANT 4 - Hadrontherapy example >> 25 // ---------------------------------------------------------------------------- >> 26 // Code developed by: 25 // 27 // 26 // Hadrontherapy advanced example for Geant4 << 28 // G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a) 27 // See more at: https://twiki.cern.ch/twiki/bi << 29 // 28 // << 30 // (a) Laboratori Nazionali del Sud 29 // Using the builder concepts of Geant4 we ass << 31 // of the National Institute for Nuclear Physics, Catania, Italy 30 // Physics Lists that are particuilarly suited << 32 // (b) National Institute for Nuclear Physics Section of Genova, genova, Italy 31 // << 33 // 32 // 'HADRONTHERAPY_1' is more suited for proton << 34 // * cirrone@lns.infn.it 33 // 'HADRONTHERAPY_2' is suggested for better p << 35 // ---------------------------------------------------------------------------- 34 // << 35 // The Reference physics lists (already presen << 36 // be used as well. In this case the more suit << 37 // "QBBC", "QGSP_BIC", "Shielding", "QGSP_BERT << 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 "globals.hh" 50 #include "G4RunManager.hh" << 38 #include "G4ProcessManager.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 "HadrontherapyParticles.hh" 56 #include "G4PhysListFactory.hh" << 44 #include "HadrontherapyPhotonStandard.hh" 57 #include "G4VPhysicsConstructor.hh" << 45 #include "HadrontherapyPhotonEPDL.hh" 58 #include "G4HadronPhysicsQGSP_BIC_HP.hh" << 46 #include "HadrontherapyPhotonPenelope.hh" 59 #include "G4HadronPhysicsQGSP_BIC.hh" << 47 #include "HadrontherapyElectronStandard.hh" 60 #include "G4EmStandardPhysics_option4.hh" << 48 #include "HadrontherapyElectronEEDL.hh" 61 #include "G4EmStandardPhysics.hh" << 49 #include "HadrontherapyElectronPenelope.hh" 62 #include "G4EmExtraPhysics.hh" << 50 #include "HadrontherapyPositronStandard.hh" 63 #include "G4StoppingPhysics.hh" << 51 #include "HadrontherapyPositronPenelope.hh" 64 #include "G4DecayPhysics.hh" << 52 #include "HadrontherapyIonLowE.hh" 65 #include "G4HadronElasticPhysics.hh" << 53 #include "HadrontherapyIonStandard.hh" 66 #include "G4HadronElasticPhysicsHP.hh" << 54 #include "HadrontherapyProtonPrecompound.hh" 67 #include "G4RadioactiveDecayPhysics.hh" << 55 #include "HadrontherapyMuonStandard.hh" 68 #include "G4IonBinaryCascadePhysics.hh" << 56 #include "HadrontherapyDecay.hh" 69 #include "G4DecayPhysics.hh" << 70 #include "G4NeutronTrackingCut.hh" << 71 #include "G4LossTableManager.hh" << 72 #include "G4UnitsTable.hh" << 73 #include "G4ProcessManager.hh" << 74 #include "G4IonFluctuations.hh" << 75 #include "G4IonParametrisedLossModel.hh" << 76 #include "G4EmParameters.hh" << 77 #include "G4ParallelWorldPhysics.hh" << 78 #include "G4EmLivermorePhysics.hh" << 79 #include "G4AutoDelete.hh" << 80 #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 57 95 << 58 HadrontherapyPhysicsList::HadrontherapyPhysicsList(): G4VModularPhysicsList(), 96 ////////////////////////////////////////////// << 59 electronIsRegistered(false), 97 HadrontherapyPhysicsList::HadrontherapyPhysics << 60 positronIsRegistered(false), >> 61 photonIsRegistered(false), >> 62 ionIsRegistered(false), >> 63 protonPrecompoundIsRegistered(false), >> 64 muonIsRegistered(false), >> 65 decayIsRegistered(false) 98 { 66 { 99 G4LossTableManager::Instance(); << 67 // The threshold of production of secondaries is fixed to 10. mm 100 defaultCutValue = 1.*mm; << 68 // for all the particles, in all the experimental set-up 101 cutForGamma = defaultCutValue; << 69 defaultCutValue = 10. * mm; 102 cutForElectron = defaultCutValue; << 70 messenger = new HadrontherapyPhysicsListMessenger(this); 103 cutForPositron = defaultCutValue; << 71 SetVerboseLevel(1); 104 << 105 pMessenger = new HadrontherapyPhysicsListM << 106 SetVerboseLevel(1); << 107 decay_List = new G4DecayPhysics(); << 108 // Elecromagnetic physics << 109 // << 110 emPhysicsList = new G4EmStandardPhysics_op << 111 } 72 } 112 73 113 ////////////////////////////////////////////// << 114 HadrontherapyPhysicsList::~HadrontherapyPhysic 74 HadrontherapyPhysicsList::~HadrontherapyPhysicsList() >> 75 { >> 76 delete messenger; >> 77 } >> 78 >> 79 void HadrontherapyPhysicsList::AddPhysicsList(const G4String& name) 115 { 80 { 116 delete pMessenger; << 81 G4cout << "Adding PhysicsList component " << name << G4endl; 117 delete emPhysicsList; << 82 118 delete decay_List; << 83 // 119 //delete radioactiveDecay_List; << 84 // Electromagnetic physics. 120 hadronPhys.clear(); << 85 // 121 for(size_t i=0; i<hadronPhys.size(); i++) << 86 // The user can choose three alternative approaches: >> 87 // Standard, Low Energy based on the Livermore libraries and Low Energy Penelope >> 88 // >> 89 >> 90 // Register standard processes for photons >> 91 if (name == "photon-standard") 122 { 92 { 123 delete hadronPhys[i]; << 93 if (photonIsRegistered) >> 94 { >> 95 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 96 << " cannot be registered ---- photon List already existing" >> 97 << G4endl; >> 98 } >> 99 else >> 100 { >> 101 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 102 << " is registered" << G4endl; >> 103 RegisterPhysics( new HadrontherapyPhotonStandard(name) ); >> 104 photonIsRegistered = true; >> 105 } 124 } 106 } 125 } << 126 107 127 ////////////////////////////////////////////// << 108 // Register LowE-EPDL processes for photons 128 void HadrontherapyPhysicsList::ConstructPartic << 109 if (name == "photon-epdl") 129 { << 110 { 130 decay_List -> ConstructParticle(); << 111 if (photonIsRegistered) 131 << 112 { 132 } << 113 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 114 << " cannot be registered ---- photon List already existing" >> 115 << G4endl; >> 116 } >> 117 else >> 118 { >> 119 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 120 << " is registered" << G4endl; >> 121 RegisterPhysics( new HadrontherapyPhotonEPDL(name) ); >> 122 photonIsRegistered = true; >> 123 } >> 124 } 133 125 134 ////////////////////////////////////////////// << 126 // Register processes a' la Penelope for photons 135 void HadrontherapyPhysicsList::ConstructProces << 127 if (name == "photon-penelope") 136 { << 137 // Transportation << 138 // << 139 AddTransportation(); << 140 << 141 decay_List -> ConstructProcess(); << 142 emPhysicsList -> ConstructProcess(); << 143 << 144 << 145 //em_config.AddModels(); << 146 << 147 // Hadronic physics << 148 // << 149 for(size_t i=0; i < hadronPhys.size(); i++ << 150 { 128 { 151 hadronPhys[i] -> ConstructProcess(); << 129 if (photonIsRegistered) >> 130 { >> 131 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 132 << " cannot be registered ---- photon List already existing" >> 133 << G4endl; >> 134 } >> 135 else >> 136 { >> 137 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 138 << " is registered" << G4endl; >> 139 RegisterPhysics( new HadrontherapyPhotonPenelope(name) ); >> 140 photonIsRegistered = true; >> 141 } 152 } 142 } 153 << 154 // step limitation (as a full process) << 155 // << 156 AddStepMax(); << 157 << 158 //Parallel world sensitivity << 159 // << 160 G4ParallelWorldPhysics* pWorld = new G4Par << 161 pWorld->ConstructProcess(); << 162 << 163 return; << 164 } << 165 143 166 ////////////////////////////////////////////// << 144 // Register standard processes for electrons 167 void HadrontherapyPhysicsList::AddPhysicsList( << 145 if (name == "electron-standard") 168 { << 146 { 169 if (verboseLevel>1) { << 147 if (electronIsRegistered) 170 G4cout << "PhysicsList::AddPhysicsList << 148 { >> 149 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 150 << " cannot be registered ---- electron List already existing" >> 151 << G4endl; >> 152 } >> 153 else >> 154 { >> 155 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 156 << " is registered" << G4endl; >> 157 RegisterPhysics( new HadrontherapyElectronStandard(name) ); >> 158 electronIsRegistered = true; >> 159 } 171 } 160 } 172 if (name == emName) return; << 161 173 << 162 // Register LowE-EEDL processes for electrons 174 /////////////////////////////////// << 163 if (name == "electron-eedl") 175 // ELECTROMAGNETIC MODELS << 164 { 176 /////////////////////////////////// << 165 if (electronIsRegistered) 177 if (name == "standard_opt4") { << 166 { 178 emName = name; << 167 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 179 delete emPhysicsList; << 168 << " cannot be registered ---- electron List already existing" 180 hadronPhys.clear(); << 169 << G4endl; 181 emPhysicsList = new G4EmStandardPhysic << 170 } 182 G4RunManager::GetRunManager() -> Physi << 171 else 183 G4cout << "THE FOLLOWING ELECTROMAGNET << 172 { 184 << 173 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 185 ////////////////////////////////////// << 174 << " is registered" << G4endl; 186 // ELECTROMAGNETIC + HADRONIC MODELS << 175 RegisterPhysics( new HadrontherapyElectronEEDL(name) ); 187 ////////////////////////////////////// << 176 electronIsRegistered = true; 188 << 177 } 189 } else if (name == "HADRONTHERAPY_1") { << 178 } 190 << 179 191 AddPhysicsList("standard_opt4"); << 180 // Register processes a' la Penelope for electrons 192 hadronPhys.push_back( new G4DecayPhysi << 181 if (name == "electron-penelope") 193 hadronPhys.push_back( new G4Radioactiv << 182 { 194 hadronPhys.push_back( new G4IonBinaryC << 183 if (electronIsRegistered) 195 hadronPhys.push_back( new G4EmExtraPhy << 184 { 196 hadronPhys.push_back( new G4HadronElas << 185 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 197 hadronPhys.push_back( new G4StoppingPh << 186 << " cannot be registered ---- electron List already existing" 198 hadronPhys.push_back( new G4HadronPhys << 187 << G4endl; 199 hadronPhys.push_back( new G4NeutronTra << 188 } 200 << 189 else 201 G4cout << "HADRONTHERAPY_1 PHYSICS LIS << 190 { >> 191 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 192 << " is registered" << G4endl; >> 193 RegisterPhysics( new HadrontherapyElectronPenelope(name) ); >> 194 electronIsRegistered = true; >> 195 } 202 } 196 } 203 << 197 204 else if (name == "HADRONTHERAPY_2") { << 198 // Register standard processes for positrons 205 << 199 if (name == "positron-standard") 206 AddPhysicsList("standard_opt4"); << 200 { 207 hadronPhys.push_back( new G4DecayPhysi << 201 if (positronIsRegistered) 208 hadronPhys.push_back( new G4Radioactiv << 202 { 209 hadronPhys.push_back( new G4IonBinaryC << 203 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 210 hadronPhys.push_back( new G4EmExtraPhy << 204 << " cannot be registered ---- positron List already existing" 211 hadronPhys.push_back( new G4HadronElas << 205 << G4endl; 212 hadronPhys.push_back( new G4StoppingPh << 206 } 213 hadronPhys.push_back( new G4HadronPhys << 207 else 214 hadronPhys.push_back( new G4NeutronTra << 208 { 215 << 209 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 216 G4cout << "HADRONTHERAPY_2 PHYSICS LIS << 210 << " is registered" << G4endl; 217 << 211 RegisterPhysics( new HadrontherapyPositronStandard(name) ); 218 } << 212 positronIsRegistered = true; 219 << 213 } 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 } 214 } 226 << 215 // Register penelope processes for positrons 227 else if (name == "QGSP_BERT"){ << 216 if (name == "positron-penelope") 228 auto physicsList = new QGSP_BERT; << 217 { 229 G4RunManager::GetRunManager() -> SetUs << 218 if (positronIsRegistered) 230 G4RunManager::GetRunManager() -> Physi << 219 { 231 physicsList -> RegisterPhysics(new G4P << 220 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 221 << " cannot be registered ---- positron List already existing" << G4endl; >> 222 } >> 223 else >> 224 { >> 225 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 226 << " is registered" << G4endl; >> 227 RegisterPhysics( new HadrontherapyPositronPenelope(name) ); >> 228 positronIsRegistered = true; >> 229 } 232 } 230 } 233 << 231 234 else if (name == "QGSP_BIC_AllHP"){ << 232 // Register Low Energy ICRU processes for protons and ions 235 auto physicsList = new QGSP_BIC_AllHP; << 233 236 G4RunManager::GetRunManager() -> SetUs << 234 if (name == "ion-LowE") 237 G4RunManager::GetRunManager() -> Physi << 235 { 238 physicsList -> RegisterPhysics(new G4P << 236 if (ionIsRegistered) >> 237 { >> 238 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 239 << " cannot be registered ---- proton List already existing" >> 240 << G4endl; >> 241 } >> 242 else >> 243 { >> 244 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 245 << " is registered" << G4endl; >> 246 RegisterPhysics( new HadrontherapyIonLowE(name) ); >> 247 ionIsRegistered = true; >> 248 } 239 } 249 } 240 << 250 241 else if (name == "QGSP_BIC_HP"){ << 251 // Register Standard processes for protons and ions 242 auto physicsList = new QGSP_BIC_HP; << 252 243 G4RunManager::GetRunManager() -> SetUs << 253 if (name == "ion-standard") 244 G4RunManager::GetRunManager() -> Physi << 254 { 245 physicsList -> RegisterPhysics(new G4P << 255 if (ionIsRegistered) >> 256 { >> 257 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 258 << " cannot be registered ---- ion List already existing" >> 259 << G4endl; >> 260 } >> 261 else >> 262 { >> 263 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 264 << " is registered" << G4endl; >> 265 RegisterPhysics( new HadrontherapyIonStandard(name) ); >> 266 ionIsRegistered = true; >> 267 } 246 } 268 } 247 << 269 248 else if (name == "Shielding"){ << 270 // Register the Standard processes for muons 249 auto physicsList = new Shielding; << 271 if (name == "muon-standard") 250 G4RunManager::GetRunManager() -> SetUs << 272 { 251 G4RunManager::GetRunManager() -> Physi << 273 if (muonIsRegistered) 252 physicsList -> RegisterPhysics(new G4P << 274 { 253 } << 275 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name 254 << 276 << " cannot be registered ---- decay List already existing" 255 else if (name == "QBBC"){ << 277 << G4endl; 256 auto physicsList = new QBBC; << 278 } 257 G4RunManager::GetRunManager() -> SetUs << 279 else 258 G4RunManager::GetRunManager() -> Physi << 280 { 259 physicsList -> RegisterPhysics(new G4P << 281 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 282 << " is registered" << G4endl; >> 283 RegisterPhysics( new HadrontherapyMuonStandard(name) ); >> 284 muonIsRegistered = true; >> 285 } 260 } 286 } 261 << 287 262 else { << 288 // Register the decay process 263 G4cout << "PhysicsList::AddPhysicsList << 289 if (name == "decay") 264 << " is not defined" << 290 { 265 << G4endl; << 291 if (decayIsRegistered) >> 292 { >> 293 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 294 << " cannot be registered ---- decay List already existing" >> 295 << G4endl; >> 296 } >> 297 else >> 298 { >> 299 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 300 << " is registered" << G4endl; >> 301 RegisterPhysics( new HadrontherapyDecay(name) ); >> 302 decayIsRegistered = true; >> 303 } >> 304 } >> 305 // >> 306 // >> 307 // Register the hadronic physics for protons, neutrons, ions >> 308 // >> 309 // >> 310 if (name == "proton-precompound") >> 311 { >> 312 if (protonPrecompoundIsRegistered) >> 313 { >> 314 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 315 << " cannot be registered ---- decay List already existing" >> 316 << G4endl; >> 317 } >> 318 else >> 319 { >> 320 G4cout << "HadrontherapyPhysicsList::AddPhysicsList: " << name >> 321 << " is registered" << G4endl; >> 322 RegisterPhysics( new HadrontherapyProtonPrecompound(name) ); >> 323 protonPrecompoundIsRegistered = true; >> 324 } 266 } 325 } 267 << 326 >> 327 if (electronIsRegistered && positronIsRegistered && photonIsRegistered && >> 328 ionIsRegistered) >> 329 { >> 330 G4cout << >> 331 "Electromagnetic physics is registered for electron, positron, photons, protons" >> 332 << G4endl; >> 333 } >> 334 if (protonPrecompoundIsRegistered && muonIsRegistered && decayIsRegistered) >> 335 { >> 336 G4cout << " Hadronic physics is registered" << G4endl; >> 337 } 268 } 338 } 269 339 270 ////////////////////////////////////////////// << 340 void HadrontherapyPhysicsList::SetCuts() 271 void HadrontherapyPhysicsList::AddStepMax() << 341 { 272 { << 342 // Set the threshold of production equal to the defaultCutValue 273 // Step limitation seen as a process << 343 // in the experimental set-up 274 // This process must exist in all threads. << 344 G4VUserPhysicsList::SetCutsWithDefault(); 275 // << 276 HadrontherapyStepMax* stepMaxProcess = ne << 277 345 278 << 346 // Definition of a smaller threshold of production in the phantom region 279 auto particleIterator = GetParticleIterato << 347 // where high accuracy is required in the energy deposit calculation 280 particleIterator->reset(); << 348 281 while ((*particleIterator)()){ << 349 G4String regionName = "PhantomLog"; 282 G4ParticleDefinition* particle = parti << 350 G4Region* region = G4RegionStore::GetInstance()->GetRegion(regionName); 283 G4ProcessManager* pmanager = particle- << 351 G4ProductionCuts* cuts = new G4ProductionCuts ; 284 << 352 G4double regionCut = 0.001*mm; 285 if (stepMaxProcess->IsApplicable(*part << 353 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("gamma")); 286 { << 354 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("e-")); 287 pmanager ->AddDiscreteProcess(step << 355 cuts -> SetProductionCut(regionCut,G4ProductionCuts::GetIndex("e+")); 288 } << 356 region -> SetProductionCuts(cuts); 289 } << 357 >> 358 if (verboseLevel>0) DumpCutValuesTable(); 290 } 359 } >> 360 >> 361 291 362