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