Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file field/field04/src/F04PhysicsList.cc 28 /// \brief Implementation of the F04PhysicsList class 29 // 30 31 #include "F04PhysicsList.hh" 32 33 #include "F04PhysicsListMessenger.hh" 34 35 #include "G4LossTableManager.hh" 36 #include "G4OpticalPhysics.hh" 37 #include "G4ParticleTable.hh" 38 #include "G4ParticleTypes.hh" 39 #include "G4ProcessManager.hh" 40 #include "G4StepLimiterPhysics.hh" 41 42 #include "F04StepMax.hh" 43 #include "FTFP_BERT.hh" 44 #include "QGSP_BERT.hh" 45 46 #include "G4DecayTable.hh" 47 #include "G4DecayWithSpin.hh" 48 #include "G4Electron.hh" 49 #include "G4Gamma.hh" 50 #include "G4MuMinusCapturePrecompound.hh" 51 #include "G4MuonDecayChannelWithSpin.hh" 52 #include "G4MuonMinusCapture.hh" 53 #include "G4MuonRadiativeDecayChannelWithSpin.hh" 54 #include "G4PionDecayMakeSpin.hh" 55 #include "G4Positron.hh" 56 #include "G4ProcessTable.hh" 57 #include "G4SystemOfUnits.hh" 58 59 G4ThreadLocal F04StepMax* F04PhysicsList::fStepMaxProcess = nullptr; 60 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 63 F04PhysicsList::F04PhysicsList(const G4String& physName) : G4VModularPhysicsList() 64 { 65 G4LossTableManager::Instance(); 66 67 defaultCutValue = 1. * mm; 68 69 fMessenger = new F04PhysicsListMessenger(this); 70 71 SetVerboseLevel(1); 72 73 // G4PhysListFactory factory; 74 G4VModularPhysicsList* phys = nullptr; 75 if (physName == "QGSP_BERT") { 76 phys = new QGSP_BERT; 77 } 78 else { 79 phys = new FTFP_BERT; 80 } 81 82 // if (factory.IsReferencePhysList(physName)) 83 // phys =factory.GetReferencePhysList(physName); 84 85 // Physics List is defined via environment variable PHYSLIST 86 // if (!phys) phys = factory.ReferencePhysList(); 87 88 if (!phys) 89 G4Exception("F04PhysicsList::F04PhysicsList", "InvalidSetup", FatalException, 90 "PhysicsList does not exist"); 91 92 for (G4int i = 0;; ++i) { 93 auto elem = const_cast<G4VPhysicsConstructor*>(phys->GetPhysics(i)); 94 if (elem == nullptr) break; 95 G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl; 96 RegisterPhysics(elem); 97 } 98 99 RegisterPhysics(new G4StepLimiterPhysics()); 100 RegisterPhysics(new G4OpticalPhysics()); 101 } 102 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 104 105 F04PhysicsList::~F04PhysicsList() 106 { 107 delete fMessenger; 108 } 109 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 112 void F04PhysicsList::ConstructParticle() 113 { 114 G4VModularPhysicsList::ConstructParticle(); 115 116 G4GenericIon::GenericIonDefinition(); 117 118 auto muonPlusDecayTable = new G4DecayTable(); 119 muonPlusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu+", 0.986)); 120 muonPlusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu+", 0.014)); 121 G4MuonPlus::MuonPlusDefinition()->SetDecayTable(muonPlusDecayTable); 122 123 auto muonMinusDecayTable = new G4DecayTable(); 124 muonMinusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu-", 0.986)); 125 muonMinusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu-", 0.014)); 126 G4MuonMinus::MuonMinusDefinition()->SetDecayTable(muonMinusDecayTable); 127 } 128 129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 130 131 void F04PhysicsList::ConstructProcess() 132 { 133 G4VModularPhysicsList::ConstructProcess(); 134 135 fStepMaxProcess = new F04StepMax(); 136 137 auto decayWithSpin = new G4DecayWithSpin(); 138 139 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable(); 140 141 G4VProcess* decay; 142 decay = processTable->FindProcess("Decay", G4MuonPlus::MuonPlus()); 143 144 G4ProcessManager* pmanager; 145 pmanager = G4MuonPlus::MuonPlus()->GetProcessManager(); 146 147 if (pmanager) { 148 if (decay) pmanager->RemoveProcess(decay); 149 pmanager->AddProcess(decayWithSpin); 150 // set ordering for PostStepDoIt and AtRestDoIt 151 pmanager->SetProcessOrdering(decayWithSpin, idxPostStep); 152 pmanager->SetProcessOrdering(decayWithSpin, idxAtRest); 153 } 154 155 decay = processTable->FindProcess("Decay", G4MuonMinus::MuonMinus()); 156 157 pmanager = G4MuonMinus::MuonMinus()->GetProcessManager(); 158 159 if (pmanager) { 160 if (decay) pmanager->RemoveProcess(decay); 161 pmanager->AddProcess(decayWithSpin); 162 // set ordering for PostStepDoIt and AtRestDoIt 163 pmanager->SetProcessOrdering(decayWithSpin, idxPostStep); 164 pmanager->SetProcessOrdering(decayWithSpin, idxAtRest); 165 } 166 167 G4VProcess* process = processTable->FindProcess("muMinusCaptureAtRest", G4MuonMinus::MuonMinus()); 168 169 if (pmanager) { 170 if (process) pmanager->RemoveProcess(process); 171 process = new G4MuonMinusCapture(new G4MuMinusCapturePrecompound()); 172 pmanager->AddRestProcess(process); 173 } 174 175 auto poldecay = new G4PionDecayMakeSpin(); 176 177 decay = processTable->FindProcess("Decay", G4PionPlus::PionPlus()); 178 179 pmanager = G4PionPlus::PionPlus()->GetProcessManager(); 180 181 if (pmanager) { 182 if (decay) pmanager->RemoveProcess(decay); 183 pmanager->AddProcess(poldecay); 184 // set ordering for PostStepDoIt and AtRestDoIt 185 pmanager->SetProcessOrdering(poldecay, idxPostStep); 186 pmanager->SetProcessOrdering(poldecay, idxAtRest); 187 } 188 189 decay = processTable->FindProcess("Decay", G4PionMinus::PionMinus()); 190 191 pmanager = G4PionMinus::PionMinus()->GetProcessManager(); 192 193 if (pmanager) { 194 if (decay) pmanager->RemoveProcess(decay); 195 pmanager->AddProcess(poldecay); 196 // set ordering for PostStepDoIt and AtRestDoIt 197 pmanager->SetProcessOrdering(poldecay, idxPostStep); 198 pmanager->SetProcessOrdering(poldecay, idxAtRest); 199 } 200 201 AddStepMax(); 202 } 203 204 /* 205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 206 207 void F04PhysicsList::RemoveFromPhysicsList(const G4String& name) 208 { 209 G4bool success = false; 210 for (G4PhysConstVector::iterator p = physicsVector->begin(); 211 p != physicsVector->end(); ++p) { 212 G4VPhysicsConstructor* e = (*p); 213 if (e->GetPhysicsName() == name) { 214 physicsVector->erase(p); 215 success = true; 216 break; 217 } 218 } 219 if (!success) { 220 std::ostringstream message; 221 message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found"; 222 G4Exception(message.str().c_str()); 223 } 224 } 225 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 227 228 void F04PhysicsList::ClearPhysics() 229 { 230 for (G4PhysConstVector::iterator p = physicsVector->begin(); 231 p != physicsVector->end(); ++p) { 232 delete (*p); 233 } 234 physicsVector->clear(); 235 } 236 */ 237 238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 239 240 void F04PhysicsList::SetStepMax(G4double step) 241 { 242 fMaxChargedStep = step; 243 fStepMaxProcess->SetStepMax(fMaxChargedStep); 244 } 245 246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 247 248 F04StepMax* F04PhysicsList::GetStepMaxProcess() const 249 { 250 return fStepMaxProcess; 251 } 252 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 254 255 void F04PhysicsList::AddStepMax() 256 { 257 // Step limitation seen as a process 258 259 auto particleIterator = GetParticleIterator(); 260 particleIterator->reset(); 261 while ((*particleIterator)()) { 262 G4ParticleDefinition* particle = particleIterator->value(); 263 G4ProcessManager* pmanager = particle->GetProcessManager(); 264 265 if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived()) { 266 if (pmanager) pmanager->AddDiscreteProcess(fStepMaxProcess); 267 } 268 } 269 } 270