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 // ------------------------------------------- 27 // ------------------------------------------------------------------- 28 // 28 // 29 // GEANT4 Class file 29 // GEANT4 Class file 30 // 30 // 31 // 31 // 32 // File name: G4VMscModel 32 // File name: G4VMscModel 33 // 33 // 34 // Author: Vladimir Ivanchenko 34 // Author: Vladimir Ivanchenko 35 // 35 // 36 // Creation date: 07.03.2008 36 // Creation date: 07.03.2008 37 // 37 // 38 // Modifications: 38 // Modifications: 39 // 39 // 40 // 40 // 41 // Class Description: 41 // Class Description: 42 // 42 // 43 // General interface to msc models 43 // General interface to msc models 44 44 45 // ------------------------------------------- 45 // ------------------------------------------------------------------- 46 // 46 // 47 47 48 #include "G4VMscModel.hh" 48 #include "G4VMscModel.hh" 49 #include "G4SystemOfUnits.hh" 49 #include "G4SystemOfUnits.hh" 50 #include "G4ParticleChangeForMSC.hh" 50 #include "G4ParticleChangeForMSC.hh" 51 #include "G4TransportationManager.hh" 51 #include "G4TransportationManager.hh" 52 #include "G4LossTableManager.hh" 52 #include "G4LossTableManager.hh" 53 #include "G4LossTableBuilder.hh" 53 #include "G4LossTableBuilder.hh" 54 #include "G4EmParameters.hh" 54 #include "G4EmParameters.hh" 55 55 56 //....oooOO0OOooo........oooOO0OOooo........oo 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 58 59 G4VMscModel::G4VMscModel(const G4String& nam): 59 G4VMscModel::G4VMscModel(const G4String& nam): 60 G4VEmModel(nam), 60 G4VEmModel(nam), 61 lambdalimit(1.*CLHEP::mm), 61 lambdalimit(1.*CLHEP::mm), 62 geomMin(1.e-6*CLHEP::mm), 62 geomMin(1.e-6*CLHEP::mm), 63 geomMax(1.e50*CLHEP::mm), 63 geomMax(1.e50*CLHEP::mm), 64 fDisplacement(0.,0.,0.), 64 fDisplacement(0.,0.,0.), 65 steppingAlgorithm(fUseSafety) 65 steppingAlgorithm(fUseSafety) 66 { 66 { 67 dedx = 2.0*CLHEP::MeV*CLHEP::cm2/CLHEP::g; 67 dedx = 2.0*CLHEP::MeV*CLHEP::cm2/CLHEP::g; 68 } 68 } 69 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 71 72 G4VMscModel::~G4VMscModel() = default; << 72 G4VMscModel::~G4VMscModel() >> 73 {} 73 74 74 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 75 76 76 G4ParticleChangeForMSC* 77 G4ParticleChangeForMSC* 77 G4VMscModel::GetParticleChangeForMSC(const G4P << 78 G4VMscModel::GetParticleChangeForMSC(const G4ParticleDefinition* p) 78 { 79 { 79 // recomputed for each new run 80 // recomputed for each new run 80 if(nullptr == safetyHelper) { 81 if(nullptr == safetyHelper) { 81 safetyHelper = G4TransportationManager::Ge 82 safetyHelper = G4TransportationManager::GetTransportationManager() 82 ->GetSafetyHelper(); 83 ->GetSafetyHelper(); 83 safetyHelper->InitialiseHelper(); 84 safetyHelper->InitialiseHelper(); 84 } 85 } 85 G4ParticleChangeForMSC* change = nullptr; 86 G4ParticleChangeForMSC* change = nullptr; 86 if (nullptr != pParticleChange) { 87 if (nullptr != pParticleChange) { 87 change = static_cast<G4ParticleChangeForMS 88 change = static_cast<G4ParticleChangeForMSC*>(pParticleChange); 88 } else { 89 } else { 89 change = new G4ParticleChangeForMSC(); 90 change = new G4ParticleChangeForMSC(); 90 } 91 } >> 92 if(IsMaster() && nullptr != p) { >> 93 >> 94 // table is always built for low mass particles >> 95 if(p->GetParticleName() != "GenericIon" && >> 96 (p->GetPDGMass() < CLHEP::GeV || ForceBuildTableFlag()) ) { >> 97 >> 98 G4EmParameters* param = G4EmParameters::Instance(); >> 99 G4LossTableBuilder* builder = >> 100 G4LossTableManager::Instance()->GetTableBuilder(); >> 101 G4double emin = std::max(LowEnergyLimit(), LowEnergyActivationLimit()); >> 102 G4double emax = std::min(HighEnergyLimit(), HighEnergyActivationLimit()); >> 103 emin = std::max(emin, param->MinKinEnergy()); >> 104 emax = std::min(emax, param->MaxKinEnergy()); >> 105 if(emin < emax) { >> 106 xSectionTable = builder->BuildTableForModel(xSectionTable, this, p, >> 107 emin, emax, true); >> 108 } >> 109 } >> 110 } 91 return change; 111 return change; 92 } 112 } 93 113 94 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 115 96 void G4VMscModel::InitialiseParameters(const G 116 void G4VMscModel::InitialiseParameters(const G4ParticleDefinition* part) 97 { 117 { 98 if(IsLocked()) { return; } 118 if(IsLocked()) { return; } 99 G4EmParameters* param = G4EmParameters::Inst 119 G4EmParameters* param = G4EmParameters::Instance(); 100 if(std::abs(part->GetPDGEncoding()) == 11) { 120 if(std::abs(part->GetPDGEncoding()) == 11) { 101 steppingAlgorithm = param->MscStepLimitTyp 121 steppingAlgorithm = param->MscStepLimitType(); 102 facrange = param->MscRangeFactor(); 122 facrange = param->MscRangeFactor(); 103 latDisplasment = param->LateralDisplacemen 123 latDisplasment = param->LateralDisplacement(); 104 } else { 124 } else { 105 steppingAlgorithm = param->MscMuHadStepLim 125 steppingAlgorithm = param->MscMuHadStepLimitType(); 106 facrange = param->MscMuHadRangeFactor(); 126 facrange = param->MscMuHadRangeFactor(); 107 latDisplasment = param->MuHadLateralDispla 127 latDisplasment = param->MuHadLateralDisplacement(); 108 } 128 } 109 skin = param->MscSkin(); 129 skin = param->MscSkin(); 110 facgeom = param->MscGeomFactor(); 130 facgeom = param->MscGeomFactor(); 111 facsafety = param->MscSafetyFactor(); 131 facsafety = param->MscSafetyFactor(); 112 lambdalimit = param->MscLambdaLimit(); 132 lambdalimit = param->MscLambdaLimit(); 113 } 133 } 114 134 115 //....oooOO0OOooo........oooOO0OOooo........oo 135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 136 117 void G4VMscModel::DumpParameters(std::ostream& 137 void G4VMscModel::DumpParameters(std::ostream& out) const 118 { 138 { 119 G4String alg = "UseSafety"; 139 G4String alg = "UseSafety"; 120 if (steppingAlgorithm == fUseDistanceToBound 140 if (steppingAlgorithm == fUseDistanceToBoundary) alg = "DistanceToBoundary"; 121 else if (steppingAlgorithm == fMinimal) alg 141 else if (steppingAlgorithm == fMinimal) alg = "Minimal"; 122 else if (steppingAlgorithm == fUseSafetyPlus 142 else if (steppingAlgorithm == fUseSafetyPlus) alg = "SafetyPlus"; 123 143 124 out << std::setw(18) << "StepLim=" << alg << 144 out << std::setw(18) << "StepLim=" << alg << " Rfact=" << facrange 125 << " Gfact=" << facgeom << " Sfact=" << 145 << " Gfact=" << facgeom << " Sfact=" << facsafety << " DispFlag:" << latDisplasment 126 << " Skin=" << skin << " Llim=" << lambd 146 << " Skin=" << skin << " Llim=" << lambdalimit/CLHEP::mm << " mm" << G4endl; 127 } 147 } 128 148 129 //....oooOO0OOooo........oooOO0OOooo........oo 149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 130 150 131 void G4VMscModel::SampleSecondaries(std::vecto 151 void G4VMscModel::SampleSecondaries(std::vector<G4DynamicParticle*>*, 132 const G4Ma 152 const G4MaterialCutsCouple*, 133 const G4Dy 153 const G4DynamicParticle*, 134 G4double, 154 G4double, G4double) 135 {} 155 {} 136 156 137 //....oooOO0OOooo........oooOO0OOooo........oo << 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 138 158 139 G4double G4VMscModel::GetDEDX(const G4Particle 159 G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy, 140 const G4Material 160 const G4MaterialCutsCouple* couple) 141 { 161 { 142 G4double x; 162 G4double x; 143 if (nullptr != ionisation) { 163 if (nullptr != ionisation) { 144 x = ionisation->GetDEDX(kinEnergy, couple) 164 x = ionisation->GetDEDX(kinEnergy, couple); 145 } else { 165 } else { 146 const G4double q = part->GetPDGCharge()*in 166 const G4double q = part->GetPDGCharge()*inveplus; 147 x = dedx*q*q; 167 x = dedx*q*q; 148 } 168 } 149 return x; 169 return x; 150 } << 170 } 151 171 152 //....oooOO0OOooo........oooOO0OOooo........oo << 172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 153 173 154 G4double G4VMscModel::GetDEDX(const G4Particle 174 G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy, 155 const G4Material 175 const G4MaterialCutsCouple* couple, G4double logKinEnergy) 156 { 176 { 157 G4double x; 177 G4double x; 158 if (nullptr != ionisation) { 178 if (nullptr != ionisation) { 159 x = ionisation->GetDEDX(kinEnergy, couple, 179 x = ionisation->GetDEDX(kinEnergy, couple, logKinEnergy); 160 } else { 180 } else { 161 const G4double q = part->GetPDGCharge()*in 181 const G4double q = part->GetPDGCharge()*inveplus; 162 x = dedx*q*q; 182 x = dedx*q*q; 163 } 183 } 164 return x; 184 return x; 165 } 185 } 166 186 167 //....oooOO0OOooo........oooOO0OOooo........oo 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 168 188 169 G4double G4VMscModel::GetRange(const G4Particl 189 G4double G4VMscModel::GetRange(const G4ParticleDefinition* part, G4double kinEnergy, 170 const G4Materia 190 const G4MaterialCutsCouple* couple) 171 { 191 { 172 // << ionisation << " " << part->GetPartic 192 // << ionisation << " " << part->GetParticleName() << G4endl; 173 localtkin = kinEnergy; 193 localtkin = kinEnergy; 174 if (nullptr != ionisation) { 194 if (nullptr != ionisation) { 175 localrange = ionisation->GetRange(kinEnerg 195 localrange = ionisation->GetRange(kinEnergy, couple); 176 } else { 196 } else { 177 const G4double q = part->GetPDGCharge()*in 197 const G4double q = part->GetPDGCharge()*inveplus; 178 localrange = kinEnergy/(dedx*q*q*couple->G 198 localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity()); 179 } 199 } 180 //G4cout << "R(mm)= " << localrange << " " 200 //G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl; 181 return localrange; 201 return localrange; 182 } << 202 } 183 203 184 //....oooOO0OOooo........oooOO0OOooo........oo << 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 185 205 186 G4double G4VMscModel::GetRange(const G4Particl 206 G4double G4VMscModel::GetRange(const G4ParticleDefinition* part,G4double kinEnergy, 187 const G4Materia 207 const G4MaterialCutsCouple* couple, G4double logKinEnergy) 188 { 208 { 189 //G4cout << "G4VMscModel::GetRange E(MeV)= " 209 //G4cout << "G4VMscModel::GetRange E(MeV)= " << kinEnergy << " " 190 // << ionisation << " " << part->GetPartic 210 // << ionisation << " " << part->GetParticleName() << G4endl; 191 localtkin = kinEnergy; 211 localtkin = kinEnergy; 192 if (nullptr != ionisation) { 212 if (nullptr != ionisation) { 193 localrange = ionisation->GetRange(kinEnerg 213 localrange = ionisation->GetRange(kinEnergy, couple, logKinEnergy); 194 } else { 214 } else { 195 const G4double q = part->GetPDGCharge()*in 215 const G4double q = part->GetPDGCharge()*inveplus; 196 localrange = kinEnergy/(dedx*q*q*couple->G 216 localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity()); 197 } 217 } 198 //G4cout << "R(mm)= " << localrange << " " 218 //G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl; 199 return localrange; 219 return localrange; 200 } << 220 } 201 221 202 //....oooOO0OOooo........oooOO0OOooo........oo 222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 203 223 204 G4double G4VMscModel::GetEnergy(const G4Partic 224 G4double G4VMscModel::GetEnergy(const G4ParticleDefinition* part, 205 G4double range 225 G4double range, const G4MaterialCutsCouple* couple) 206 { 226 { 207 G4double e; 227 G4double e; 208 //G4cout << "G4VMscModel::GetEnergy R(mm)= " 228 //G4cout << "G4VMscModel::GetEnergy R(mm)= " << range << " " << ionisation 209 // << " Rlocal(mm)= " << localrange << 229 // << " Rlocal(mm)= " << localrange << " Elocal(MeV)= " << localtkin << G4endl; 210 if(nullptr != ionisation) { e = ionisation-> 230 if(nullptr != ionisation) { e = ionisation->GetKineticEnergy(range, couple); } 211 else { 231 else { 212 e = localtkin; 232 e = localtkin; 213 if(localrange > range) { 233 if(localrange > range) { 214 G4double q = part->GetPDGCharge()*invepl 234 G4double q = part->GetPDGCharge()*inveplus; 215 e -= (localrange - range)*dedx*q*q*coupl 235 e -= (localrange - range)*dedx*q*q*couple->GetMaterial()->GetDensity(); 216 } 236 } 217 } 237 } 218 return e; 238 return e; 219 } 239 } 220 240 221 //....oooOO0OOooo........oooOO0OOooo........oo 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 222 242