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 // Gorad (Geant4 Open-source Radiation Analys 26 // Gorad (Geant4 Open-source Radiation Analysis and Design) 27 // 27 // 28 // Author : Makoto Asai (SLAC National Accele 28 // Author : Makoto Asai (SLAC National Accelerator Laboratory) 29 // 29 // 30 // Development of Gorad is funded by NASA Joh 30 // Development of Gorad is funded by NASA Johnson Space Center (JSC) 31 // under the contract NNJ15HK11B. 31 // under the contract NNJ15HK11B. 32 // 32 // 33 // ******************************************* 33 // ******************************************************************** 34 // 34 // 35 // GRPhysicsList.cc 35 // GRPhysicsList.cc 36 // Gorad Physics List 36 // Gorad Physics List 37 // 37 // 38 // History 38 // History 39 // September 8th, 2020 : first implementatio 39 // September 8th, 2020 : first implementation 40 // 40 // 41 // ******************************************* 41 // ******************************************************************** 42 42 43 #include "GRPhysicsList.hh" 43 #include "GRPhysicsList.hh" 44 #include "GRPhysicsListMessenger.hh" 44 #include "GRPhysicsListMessenger.hh" 45 #include "G4SystemOfUnits.hh" 45 #include "G4SystemOfUnits.hh" 46 #include "G4PhysListFactory.hh" 46 #include "G4PhysListFactory.hh" 47 47 48 GRPhysicsList::GRPhysicsList() 48 GRPhysicsList::GRPhysicsList() 49 : PLName("FTFP_BERT"), physList(nullptr), 49 : PLName("FTFP_BERT"), physList(nullptr), 50 EM_opt("Op_0"), Had_opt("FTFP_BERT"), 50 EM_opt("Op_0"), Had_opt("FTFP_BERT"), 51 addHP(false), addRDM(false), addRMC(false), 51 addHP(false), addRDM(false), addRMC(false), addOptical(false), 52 stepLimit_opt(-1) 52 stepLimit_opt(-1) 53 { 53 { 54 factory = nullptr; 54 factory = nullptr; 55 messenger = new GRPhysicsListMessenger(this) 55 messenger = new GRPhysicsListMessenger(this); 56 56 57 globalCuts[0] = 0.7*mm; // e- 57 globalCuts[0] = 0.7*mm; // e- 58 globalCuts[1] = 0.7*mm; // e+ 58 globalCuts[1] = 0.7*mm; // e+ 59 globalCuts[2] = 0.7*mm; // gamma 59 globalCuts[2] = 0.7*mm; // gamma 60 globalCuts[3] = 0.7*mm; // proton 60 globalCuts[3] = 0.7*mm; // proton 61 } 61 } 62 62 63 GRPhysicsList::~GRPhysicsList() 63 GRPhysicsList::~GRPhysicsList() 64 { 64 { 65 delete factory; 65 delete factory; 66 if(physList) delete physList; 66 if(physList) delete physList; 67 delete messenger; 67 delete messenger; 68 } 68 } 69 69 70 void GRPhysicsList::ConstructParticle() 70 void GRPhysicsList::ConstructParticle() 71 { 71 { 72 if(!physList) GeneratePL(); 72 if(!physList) GeneratePL(); 73 physList->ConstructParticle(); 73 physList->ConstructParticle(); 74 } 74 } 75 75 76 void GRPhysicsList::ConstructProcess() 76 void GRPhysicsList::ConstructProcess() 77 { 77 { 78 if(!physList) GeneratePL(); 78 if(!physList) GeneratePL(); 79 physList->ConstructProcess(); 79 physList->ConstructProcess(); 80 } 80 } 81 81 82 #include "G4Region.hh" 82 #include "G4Region.hh" 83 #include "G4ProductionCuts.hh" 83 #include "G4ProductionCuts.hh" 84 84 85 void GRPhysicsList::SetCuts() 85 void GRPhysicsList::SetCuts() 86 { 86 { 87 if(!physList) GeneratePL(); 87 if(!physList) GeneratePL(); 88 physList->SetCutValue(globalCuts[2],"gamma") 88 physList->SetCutValue(globalCuts[2],"gamma"); // gamma should be defined first! 89 physList->SetCutValue(globalCuts[0],"e-"); 89 physList->SetCutValue(globalCuts[0],"e-"); 90 physList->SetCutValue(globalCuts[1],"e+"); 90 physList->SetCutValue(globalCuts[1],"e+"); 91 physList->SetCutValue(globalCuts[3],"proton" 91 physList->SetCutValue(globalCuts[3],"proton"); 92 } 92 } 93 93 94 void GRPhysicsList::SetGlobalCuts(G4double val 94 void GRPhysicsList::SetGlobalCuts(G4double val) 95 { 95 { 96 for(G4int i=0; i<4; i++) 96 for(G4int i=0; i<4; i++) 97 { SetGlobalCut(i,val); } 97 { SetGlobalCut(i,val); } 98 if(physList) SetCuts(); 98 if(physList) SetCuts(); 99 } 99 } 100 100 101 void GRPhysicsList::SetGlobalCut(G4int i, G4do 101 void GRPhysicsList::SetGlobalCut(G4int i, G4double val) 102 { 102 { 103 globalCuts[i] = val; 103 globalCuts[i] = val; 104 if(physList) SetCuts(); 104 if(physList) SetCuts(); 105 } 105 } 106 106 107 void GRPhysicsList::GeneratePLName() 107 void GRPhysicsList::GeneratePLName() 108 { 108 { 109 G4String plname = Had_opt; 109 G4String plname = Had_opt; 110 if(addHP && Had_opt != "Shielding") plname + 110 if(addHP && Had_opt != "Shielding") plname += "_HP"; 111 111 112 G4String EMopt = ""; 112 G4String EMopt = ""; 113 if(EM_opt=="Op_1") EMopt = "_EMV"; 113 if(EM_opt=="Op_1") EMopt = "_EMV"; 114 else if(EM_opt=="Op_3") EMopt = "_EMY"; 114 else if(EM_opt=="Op_3") EMopt = "_EMY"; 115 else if(EM_opt=="Op_4") EMopt = "_EMZ"; 115 else if(EM_opt=="Op_4") EMopt = "_EMZ"; 116 else if(EM_opt=="LIV") EMopt = "_LIV"; 116 else if(EM_opt=="LIV") EMopt = "_LIV"; 117 else if(EM_opt=="LIV_Pol") G4cout << "EM opt 117 else if(EM_opt=="LIV_Pol") G4cout << "EM option <LIV_Pol> is under development." << G4endl; 118 plname += EMopt; 118 plname += EMopt; 119 119 120 auto valid = factory->IsReferencePhysList(pl 120 auto valid = factory->IsReferencePhysList(plname); 121 if(valid) 121 if(valid) 122 { PLName = plname; } 122 { PLName = plname; } 123 else 123 else 124 { 124 { 125 G4ExceptionDescription ed; 125 G4ExceptionDescription ed; 126 ed << "Physics List <" << plname << "> is 126 ed << "Physics List <" << plname << "> is not a valid reference physics list."; 127 G4Exception("GRPhysicsList::GeneratePLName 127 G4Exception("GRPhysicsList::GeneratePLName()","GRPHYS0001", 128 FatalException,ed); 128 FatalException,ed); 129 } 129 } 130 } 130 } 131 131 132 #include "G4RadioactiveDecayPhysics.hh" 132 #include "G4RadioactiveDecayPhysics.hh" 133 #include "G4OpticalPhysics.hh" 133 #include "G4OpticalPhysics.hh" 134 #include "G4StepLimiterPhysics.hh" 134 #include "G4StepLimiterPhysics.hh" 135 #include "G4ParallelWorldPhysics.hh" 135 #include "G4ParallelWorldPhysics.hh" 136 #include "G4GenericBiasingPhysics.hh" 136 #include "G4GenericBiasingPhysics.hh" 137 #include "GRParallelWorldPhysics.hh" 137 #include "GRParallelWorldPhysics.hh" 138 #include "G4ProcessTable.hh" 138 #include "G4ProcessTable.hh" 139 #include "G4EmParameters.hh" 139 #include "G4EmParameters.hh" 140 #include "G4HadronicParameters.hh" 140 #include "G4HadronicParameters.hh" 141 141 142 void GRPhysicsList::GeneratePL() 142 void GRPhysicsList::GeneratePL() 143 { 143 { 144 if(physList) return; 144 if(physList) return; 145 145 146 factory = new G4PhysListFactory(); 146 factory = new G4PhysListFactory(); 147 GeneratePLName(); 147 GeneratePLName(); 148 physList = factory->GetReferencePhysList(PLN 148 physList = factory->GetReferencePhysList(PLName); 149 G4cout << "Creating " << PLName << " physics 149 G4cout << "Creating " << PLName << " physics list ################ " << applyGeomImpBias << G4endl; 150 150 151 if(addRDM && Had_opt != "Shielding") 151 if(addRDM && Had_opt != "Shielding") 152 { physList->RegisterPhysics(new G4Radioactiv 152 { physList->RegisterPhysics(new G4RadioactiveDecayPhysics()); 153 G4cout << "Adding G4RadioactiveDecayPhysic 153 G4cout << "Adding G4RadioactiveDecayPhysics ################ " << G4endl; } 154 154 155 if(addRMC) 155 if(addRMC) 156 { G4cout << "Reverse Monte Calro option is u 156 { G4cout << "Reverse Monte Calro option is under development." << G4endl; } 157 157 158 if(stepLimit_opt>=0) 158 if(stepLimit_opt>=0) 159 { physList->RegisterPhysics(new G4StepLimite 159 { physList->RegisterPhysics(new G4StepLimiterPhysics()); 160 G4cout << "Adding G4StepLimiterPhysics ### 160 G4cout << "Adding G4StepLimiterPhysics ################ " << G4endl; } 161 161 162 if(addOptical) // Optical processes should c 162 if(addOptical) // Optical processes should come last! 163 { physList->RegisterPhysics(new G4OpticalPhy 163 { physList->RegisterPhysics(new G4OpticalPhysics()); 164 G4cout << "Adding G4OpticalPhysics ####### 164 G4cout << "Adding G4OpticalPhysics ################ " << G4endl; } 165 165 166 if(applyGeomImpBias) // Geometry Importance 166 if(applyGeomImpBias) // Geometry Importance Biasing with parallel world 167 { 167 { 168 physList->RegisterPhysics(new GRParallelWo 168 physList->RegisterPhysics(new GRParallelWorldPhysics("GeomBias",false)); 169 G4cout << "Adding G4GenericBiasingPhysics 169 G4cout << "Adding G4GenericBiasingPhysics for GeomBias ################ " << G4endl; 170 } 170 } 171 171 172 G4int verbose = G4ProcessTable::GetProcessTa 172 G4int verbose = G4ProcessTable::GetProcessTable()->GetVerboseLevel(); 173 physList->SetVerboseLevel(verbose); 173 physList->SetVerboseLevel(verbose); 174 G4EmParameters::Instance()->SetVerbose(verbo 174 G4EmParameters::Instance()->SetVerbose(verbose); 175 G4HadronicParameters::Instance()->SetVerbose 175 G4HadronicParameters::Instance()->SetVerboseLevel(verbose); 176 } 176 } 177 177 178 #include "G4RegionStore.hh" 178 #include "G4RegionStore.hh" 179 179 180 G4Region* GRPhysicsList::FindRegion(const G4St 180 G4Region* GRPhysicsList::FindRegion(const G4String& reg) const 181 { 181 { 182 auto store = G4RegionStore::GetInstance(); 182 auto store = G4RegionStore::GetInstance(); 183 return store->GetRegion(reg); 183 return store->GetRegion(reg); 184 } 184 } 185 185 186 G4Region* GRPhysicsList::SetLocalCut(const G4S 186 G4Region* GRPhysicsList::SetLocalCut(const G4String& reg,G4int i,G4double val) 187 { 187 { 188 auto regPtr = FindRegion(reg); 188 auto regPtr = FindRegion(reg); 189 if(!regPtr) return regPtr; 189 if(!regPtr) return regPtr; 190 190 191 auto cuts = regPtr->GetProductionCuts(); 191 auto cuts = regPtr->GetProductionCuts(); 192 if(!cuts) 192 if(!cuts) 193 { 193 { 194 cuts = new G4ProductionCuts(); 194 cuts = new G4ProductionCuts(); 195 regPtr->SetProductionCuts(cuts); 195 regPtr->SetProductionCuts(cuts); 196 } 196 } 197 197 198 cuts->SetProductionCut(val,i); 198 cuts->SetProductionCut(val,i); 199 return regPtr; 199 return regPtr; 200 } 200 } 201 201 202 G4double GRPhysicsList::GetLocalCut(const G4St 202 G4double GRPhysicsList::GetLocalCut(const G4String& reg,G4int i) const 203 { 203 { 204 auto regPtr = FindRegion(reg); 204 auto regPtr = FindRegion(reg); 205 G4double val = -1.0; 205 G4double val = -1.0; 206 if(regPtr) 206 if(regPtr) 207 { 207 { 208 auto cuts = regPtr->GetProductionCuts(); 208 auto cuts = regPtr->GetProductionCuts(); 209 if(cuts) val = cuts->GetProductionCut(i); 209 if(cuts) val = cuts->GetProductionCut(i); 210 } 210 } 211 return val; 211 return val; 212 } 212 } 213 213 214 #include "G4UserLimits.hh" 214 #include "G4UserLimits.hh" 215 215 216 G4Region* GRPhysicsList::SetLocalStepLimit(con 216 G4Region* GRPhysicsList::SetLocalStepLimit(const G4String& reg,G4double val) 217 { 217 { 218 auto regPtr = FindRegion(reg); 218 auto regPtr = FindRegion(reg); 219 if(!regPtr) return regPtr; 219 if(!regPtr) return regPtr; 220 220 221 auto uLim = regPtr->GetUserLimits(); 221 auto uLim = regPtr->GetUserLimits(); 222 if(!uLim) 222 if(!uLim) 223 { 223 { 224 uLim = new G4UserLimits(val); 224 uLim = new G4UserLimits(val); 225 regPtr->SetUserLimits(uLim); 225 regPtr->SetUserLimits(uLim); 226 } 226 } 227 else 227 else 228 { uLim->SetMaxAllowedStep(val); } 228 { uLim->SetMaxAllowedStep(val); } 229 return regPtr; 229 return regPtr; 230 } 230 } 231 231 232 #include "G4Track.hh" 232 #include "G4Track.hh" 233 G4double GRPhysicsList::GetLocalStepLimit(cons 233 G4double GRPhysicsList::GetLocalStepLimit(const G4String& reg) const 234 { 234 { 235 static G4Track dummyTrack; 235 static G4Track dummyTrack; 236 auto regPtr = FindRegion(reg); 236 auto regPtr = FindRegion(reg); 237 G4double val = -1.0; 237 G4double val = -1.0; 238 if(regPtr) 238 if(regPtr) 239 { 239 { 240 auto uLim = regPtr->GetUserLimits(); 240 auto uLim = regPtr->GetUserLimits(); 241 if(uLim) val = uLim->GetMaxAllowedStep(dum 241 if(uLim) val = uLim->GetMaxAllowedStep(dummyTrack); 242 } 242 } 243 return val; 243 return val; 244 } 244 } 245 245 246 void GRPhysicsList::SetGlobalStepLimit(G4doubl 246 void GRPhysicsList::SetGlobalStepLimit(G4double val) 247 { SetLocalStepLimit("DefaultRegionForTheWorld" 247 { SetLocalStepLimit("DefaultRegionForTheWorld",val); } 248 248 249 G4double GRPhysicsList::GetGlobalStepLimit() c 249 G4double GRPhysicsList::GetGlobalStepLimit() const 250 { return GetLocalStepLimit("DefaultRegionForTh 250 { return GetLocalStepLimit("DefaultRegionForTheWorld"); } 251 251 252 252 253 253