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 /// \file field/field04/src/F04PhysicsList.cc 27 /// \file field/field04/src/F04PhysicsList.cc 28 /// \brief Implementation of the F04PhysicsLis 28 /// \brief Implementation of the F04PhysicsList class 29 // 29 // 30 30 31 #include "F04PhysicsList.hh" 31 #include "F04PhysicsList.hh" 32 << 33 #include "F04PhysicsListMessenger.hh" 32 #include "F04PhysicsListMessenger.hh" 34 33 35 #include "G4LossTableManager.hh" << 34 #include "G4StepLimiterPhysics.hh" 36 #include "G4OpticalPhysics.hh" 35 #include "G4OpticalPhysics.hh" 37 #include "G4ParticleTable.hh" << 36 38 #include "G4ParticleTypes.hh" << 37 #include "G4LossTableManager.hh" >> 38 39 #include "G4ProcessManager.hh" 39 #include "G4ProcessManager.hh" 40 #include "G4StepLimiterPhysics.hh" << 40 #include "G4ParticleTypes.hh" >> 41 #include "G4ParticleTable.hh" 41 42 42 #include "F04StepMax.hh" << 43 //#include "G4PhysListFactory.hh" 43 #include "FTFP_BERT.hh" 44 #include "FTFP_BERT.hh" 44 #include "QGSP_BERT.hh" 45 #include "QGSP_BERT.hh" 45 46 46 #include "G4DecayTable.hh" << 47 #include "G4DecayWithSpin.hh" << 48 #include "G4Electron.hh" << 49 #include "G4Gamma.hh" 47 #include "G4Gamma.hh" 50 #include "G4MuMinusCapturePrecompound.hh" << 48 #include "G4Electron.hh" 51 #include "G4MuonDecayChannelWithSpin.hh" << 52 #include "G4MuonMinusCapture.hh" << 53 #include "G4MuonRadiativeDecayChannelWithSpin. << 54 #include "G4PionDecayMakeSpin.hh" << 55 #include "G4Positron.hh" 49 #include "G4Positron.hh" >> 50 >> 51 #include "F04StepMax.hh" >> 52 56 #include "G4ProcessTable.hh" 53 #include "G4ProcessTable.hh" >> 54 >> 55 #include "G4PionDecayMakeSpin.hh" >> 56 #include "G4DecayWithSpin.hh" >> 57 >> 58 #include "G4DecayTable.hh" >> 59 #include "G4MuonDecayChannelWithSpin.hh" >> 60 #include "G4MuonRadiativeDecayChannelWithSpin.hh" >> 61 >> 62 #include "G4MuonMinusCapture.hh" >> 63 #include "G4MuMinusCapturePrecompound.hh" >> 64 57 #include "G4SystemOfUnits.hh" 65 #include "G4SystemOfUnits.hh" >> 66 #include "G4AutoDelete.hh" 58 67 59 G4ThreadLocal F04StepMax* F04PhysicsList::fSte << 68 G4ThreadLocal F04StepMax* F04PhysicsList::fStepMaxProcess = 0; 60 69 61 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 71 63 F04PhysicsList::F04PhysicsList(const G4String& << 72 F04PhysicsList::F04PhysicsList(G4String physName) : G4VModularPhysicsList() 64 { 73 { 65 G4LossTableManager::Instance(); << 74 G4LossTableManager::Instance(); >> 75 >> 76 defaultCutValue = 1.*mm; 66 77 67 defaultCutValue = 1. * mm; << 78 fMessenger = new F04PhysicsListMessenger(this); 68 79 69 fMessenger = new F04PhysicsListMessenger(thi << 80 SetVerboseLevel(1); 70 81 71 SetVerboseLevel(1); << 82 // G4PhysListFactory factory; >> 83 G4VModularPhysicsList* phys = NULL; >> 84 if (physName == "QGSP_BERT") { >> 85 phys = new QGSP_BERT; >> 86 } else { >> 87 phys = new FTFP_BERT; >> 88 } 72 89 73 // G4PhysListFactory factory; << 90 // if (factory.IsReferencePhysList(physName)) 74 G4VModularPhysicsList* phys = nullptr; << 91 // phys =factory.GetReferencePhysList(physName); 75 if (physName == "QGSP_BERT") { << 76 phys = new QGSP_BERT; << 77 } << 78 else { << 79 phys = new FTFP_BERT; << 80 } << 81 92 82 // if (factory.IsReferencePhysList(physNa << 93 // Physics List is defined via environment variable PHYSLIST 83 // phys =factory.GetReferencePhysList( << 94 // if (!phys) phys = factory.ReferencePhysList(); 84 95 85 // Physics List is defined via environment v << 96 if (!phys) G4Exception("F04PhysicsList::F04PhysicsList","InvalidSetup", 86 // if (!phys) phys = factory.ReferencePhy << 97 FatalException,"PhysicsList does not exist"); 87 98 88 if (!phys) << 99 for (G4int i = 0; ; ++i) { 89 G4Exception("F04PhysicsList::F04PhysicsLis << 100 G4VPhysicsConstructor* elem = 90 "PhysicsList does not exist"); << 101 const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i)); >> 102 if (elem == NULL) break; >> 103 G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl; >> 104 RegisterPhysics(elem); >> 105 } 91 106 92 for (G4int i = 0;; ++i) { << 107 RegisterPhysics(new G4StepLimiterPhysics()); 93 auto elem = const_cast<G4VPhysicsConstruct << 108 RegisterPhysics(new G4OpticalPhysics()); 94 if (elem == nullptr) break; << 95 G4cout << "RegisterPhysics: " << elem->Get << 96 RegisterPhysics(elem); << 97 } << 98 109 99 RegisterPhysics(new G4StepLimiterPhysics()); << 110 fMaxChargedStep = DBL_MAX; 100 RegisterPhysics(new G4OpticalPhysics()); << 101 } 111 } 102 112 103 //....oooOO0OOooo........oooOO0OOooo........oo 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 114 105 F04PhysicsList::~F04PhysicsList() 115 F04PhysicsList::~F04PhysicsList() 106 { 116 { 107 delete fMessenger; << 117 delete fMessenger; >> 118 >> 119 //delete fStepMaxProcess; 108 } 120 } 109 121 110 //....oooOO0OOooo........oooOO0OOooo........oo 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 123 112 void F04PhysicsList::ConstructParticle() 124 void F04PhysicsList::ConstructParticle() 113 { 125 { 114 G4VModularPhysicsList::ConstructParticle(); << 126 G4VModularPhysicsList::ConstructParticle(); 115 127 116 G4GenericIon::GenericIonDefinition(); << 128 G4GenericIon::GenericIonDefinition(); 117 129 118 auto muonPlusDecayTable = new G4DecayTable() << 130 G4DecayTable* muonPlusDecayTable = new G4DecayTable(); 119 muonPlusDecayTable->Insert(new G4MuonDecayCh << 131 muonPlusDecayTable -> Insert(new 120 muonPlusDecayTable->Insert(new G4MuonRadiati << 132 G4MuonDecayChannelWithSpin("mu+",0.986)); 121 G4MuonPlus::MuonPlusDefinition()->SetDecayTa << 133 muonPlusDecayTable -> Insert(new 122 << 134 G4MuonRadiativeDecayChannelWithSpin("mu+",0.014)); 123 auto muonMinusDecayTable = new G4DecayTable( << 135 G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(muonPlusDecayTable); 124 muonMinusDecayTable->Insert(new G4MuonDecayC << 136 125 muonMinusDecayTable->Insert(new G4MuonRadiat << 137 G4DecayTable* muonMinusDecayTable = new G4DecayTable(); 126 G4MuonMinus::MuonMinusDefinition()->SetDecay << 138 muonMinusDecayTable -> Insert(new >> 139 G4MuonDecayChannelWithSpin("mu-",0.986)); >> 140 muonMinusDecayTable -> Insert(new >> 141 G4MuonRadiativeDecayChannelWithSpin("mu-",0.014)); >> 142 G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(muonMinusDecayTable); 127 } 143 } 128 144 129 //....oooOO0OOooo........oooOO0OOooo........oo 145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 130 146 131 void F04PhysicsList::ConstructProcess() 147 void F04PhysicsList::ConstructProcess() 132 { 148 { 133 G4VModularPhysicsList::ConstructProcess(); << 149 G4VModularPhysicsList::ConstructProcess(); 134 150 135 fStepMaxProcess = new F04StepMax(); << 151 fStepMaxProcess = new F04StepMax(); 136 << 152 G4AutoDelete::Register(fStepMaxProcess); 137 auto decayWithSpin = new G4DecayWithSpin(); << 153 138 << 154 G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin(); 139 G4ProcessTable* processTable = G4ProcessTabl << 155 140 << 156 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable(); 141 G4VProcess* decay; << 157 142 decay = processTable->FindProcess("Decay", G << 158 G4VProcess* decay; 143 << 159 decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus()); 144 G4ProcessManager* pmanager; << 160 145 pmanager = G4MuonPlus::MuonPlus()->GetProces << 161 G4ProcessManager* pmanager; 146 << 162 pmanager = G4MuonPlus::MuonPlus()->GetProcessManager(); 147 if (pmanager) { << 163 148 if (decay) pmanager->RemoveProcess(decay); << 164 if (pmanager) { 149 pmanager->AddProcess(decayWithSpin); << 165 if (decay) pmanager->RemoveProcess(decay); 150 // set ordering for PostStepDoIt and AtRes << 166 pmanager->AddProcess(decayWithSpin); 151 pmanager->SetProcessOrdering(decayWithSpin << 167 // set ordering for PostStepDoIt and AtRestDoIt 152 pmanager->SetProcessOrdering(decayWithSpin << 168 pmanager ->SetProcessOrdering(decayWithSpin, idxPostStep); 153 } << 169 pmanager ->SetProcessOrdering(decayWithSpin, idxAtRest); >> 170 } 154 171 155 decay = processTable->FindProcess("Decay", G << 172 decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus()); 156 173 157 pmanager = G4MuonMinus::MuonMinus()->GetProc << 174 pmanager = G4MuonMinus::MuonMinus()->GetProcessManager(); 158 175 159 if (pmanager) { << 176 if (pmanager) { 160 if (decay) pmanager->RemoveProcess(decay); << 177 if (decay) pmanager->RemoveProcess(decay); 161 pmanager->AddProcess(decayWithSpin); << 178 pmanager->AddProcess(decayWithSpin); 162 // set ordering for PostStepDoIt and AtRes << 179 // set ordering for PostStepDoIt and AtRestDoIt 163 pmanager->SetProcessOrdering(decayWithSpin << 180 pmanager ->SetProcessOrdering(decayWithSpin, idxPostStep); 164 pmanager->SetProcessOrdering(decayWithSpin << 181 pmanager ->SetProcessOrdering(decayWithSpin, idxAtRest); 165 } << 182 } 166 183 167 G4VProcess* process = processTable->FindProc << 184 G4VProcess* process = processTable-> >> 185 FindProcess("muMinusCaptureAtRest",G4MuonMinus::MuonMinus()); 168 186 169 if (pmanager) { << 187 if (pmanager) { 170 if (process) pmanager->RemoveProcess(proce << 188 if (process) pmanager->RemoveProcess(process); 171 process = new G4MuonMinusCapture(new G4MuM << 189 process = new G4MuonMinusCapture(new G4MuMinusCapturePrecompound()); 172 pmanager->AddRestProcess(process); << 190 pmanager->AddRestProcess(process); 173 } << 191 } 174 192 175 auto poldecay = new G4PionDecayMakeSpin(); << 193 G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin(); 176 194 177 decay = processTable->FindProcess("Decay", G << 195 decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus()); 178 196 179 pmanager = G4PionPlus::PionPlus()->GetProces << 197 pmanager = G4PionPlus::PionPlus()->GetProcessManager(); 180 198 181 if (pmanager) { << 199 if (pmanager) { 182 if (decay) pmanager->RemoveProcess(decay); << 200 if (decay) pmanager->RemoveProcess(decay); 183 pmanager->AddProcess(poldecay); << 201 pmanager->AddProcess(poldecay); 184 // set ordering for PostStepDoIt and AtRes << 202 // set ordering for PostStepDoIt and AtRestDoIt 185 pmanager->SetProcessOrdering(poldecay, idx << 203 pmanager ->SetProcessOrdering(poldecay, idxPostStep); 186 pmanager->SetProcessOrdering(poldecay, idx << 204 pmanager ->SetProcessOrdering(poldecay, idxAtRest); 187 } << 205 } 188 206 189 decay = processTable->FindProcess("Decay", G << 207 decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus()); 190 208 191 pmanager = G4PionMinus::PionMinus()->GetProc << 209 pmanager = G4PionMinus::PionMinus()->GetProcessManager(); 192 210 193 if (pmanager) { << 211 if (pmanager) { 194 if (decay) pmanager->RemoveProcess(decay); << 212 if (decay) pmanager->RemoveProcess(decay); 195 pmanager->AddProcess(poldecay); << 213 pmanager->AddProcess(poldecay); 196 // set ordering for PostStepDoIt and AtRes << 214 // set ordering for PostStepDoIt and AtRestDoIt 197 pmanager->SetProcessOrdering(poldecay, idx << 215 pmanager ->SetProcessOrdering(poldecay, idxPostStep); 198 pmanager->SetProcessOrdering(poldecay, idx << 216 pmanager ->SetProcessOrdering(poldecay, idxAtRest); 199 } << 217 } 200 218 201 AddStepMax(); << 219 AddStepMax(); 202 } 220 } 203 221 204 /* 222 /* 205 //....oooOO0OOooo........oooOO0OOooo........oo 223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 206 224 207 void F04PhysicsList::RemoveFromPhysicsList(con 225 void F04PhysicsList::RemoveFromPhysicsList(const G4String& name) 208 { 226 { 209 G4bool success = false; 227 G4bool success = false; 210 for (G4PhysConstVector::iterator p = phys 228 for (G4PhysConstVector::iterator p = physicsVector->begin(); 211 p != phys 229 p != physicsVector->end(); ++p) { 212 G4VPhysicsConstructor* e = (*p); 230 G4VPhysicsConstructor* e = (*p); 213 if (e->GetPhysicsName() == name) { 231 if (e->GetPhysicsName() == name) { 214 physicsVector->erase(p); 232 physicsVector->erase(p); 215 success = true; 233 success = true; 216 break; 234 break; 217 } 235 } 218 } 236 } 219 if (!success) { 237 if (!success) { 220 std::ostringstream message; 238 std::ostringstream message; 221 message << "PhysicsList::RemoveFromPhys 239 message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found"; 222 G4Exception(message.str().c_str()); 240 G4Exception(message.str().c_str()); 223 } 241 } 224 } 242 } 225 243 226 //....oooOO0OOooo........oooOO0OOooo........oo 244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 227 245 228 void F04PhysicsList::ClearPhysics() 246 void F04PhysicsList::ClearPhysics() 229 { 247 { 230 for (G4PhysConstVector::iterator p = phys 248 for (G4PhysConstVector::iterator p = physicsVector->begin(); 231 p != phys 249 p != physicsVector->end(); ++p) { 232 delete (*p); 250 delete (*p); 233 } 251 } 234 physicsVector->clear(); 252 physicsVector->clear(); 235 } 253 } 236 */ 254 */ 237 255 238 //....oooOO0OOooo........oooOO0OOooo........oo 256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 239 257 240 void F04PhysicsList::SetStepMax(G4double step) 258 void F04PhysicsList::SetStepMax(G4double step) 241 { 259 { 242 fMaxChargedStep = step; << 260 fMaxChargedStep = step ; 243 fStepMaxProcess->SetStepMax(fMaxChargedStep) 261 fStepMaxProcess->SetStepMax(fMaxChargedStep); 244 } 262 } 245 263 246 //....oooOO0OOooo........oooOO0OOooo........oo 264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 247 265 248 F04StepMax* F04PhysicsList::GetStepMaxProcess( << 266 F04StepMax* F04PhysicsList::GetStepMaxProcess() 249 { 267 { 250 return fStepMaxProcess; 268 return fStepMaxProcess; 251 } 269 } 252 270 253 //....oooOO0OOooo........oooOO0OOooo........oo 271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 254 272 255 void F04PhysicsList::AddStepMax() 273 void F04PhysicsList::AddStepMax() 256 { 274 { 257 // Step limitation seen as a process 275 // Step limitation seen as a process 258 276 259 auto particleIterator = GetParticleIterator( << 277 auto particleIterator=GetParticleIterator(); 260 particleIterator->reset(); 278 particleIterator->reset(); 261 while ((*particleIterator)()) { << 279 while ((*particleIterator)()){ 262 G4ParticleDefinition* particle = particleI << 280 G4ParticleDefinition* particle = particleIterator->value(); 263 G4ProcessManager* pmanager = particle->Get << 281 G4ProcessManager* pmanager = particle->GetProcessManager(); 264 << 282 265 if (fStepMaxProcess->IsApplicable(*particl << 283 if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived()) 266 if (pmanager) pmanager->AddDiscreteProce << 284 { 267 } << 285 if (pmanager) pmanager ->AddDiscreteProcess(fStepMaxProcess); >> 286 } 268 } 287 } 269 } 288 } 270 289