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 // $Id: G4VEmProcess.cc,v 1.88 2010-08-17 17:36:59 vnivanch Exp $ >> 27 // GEANT4 tag $Name: not supported by cvs2svn $ >> 28 // 26 // ------------------------------------------- 29 // ------------------------------------------------------------------- 27 // 30 // 28 // GEANT4 Class file 31 // GEANT4 Class file 29 // 32 // 30 // 33 // 31 // File name: G4VEmProcess 34 // File name: G4VEmProcess 32 // 35 // 33 // Author: Vladimir Ivanchenko on base 36 // Author: Vladimir Ivanchenko on base of Laszlo Urban code 34 // 37 // 35 // Creation date: 01.10.2003 38 // Creation date: 01.10.2003 36 // 39 // 37 // Modifications: by V.Ivanchenko << 40 // Modifications: >> 41 // 30-06-04 make it to be pure discrete process (V.Ivanchenko) >> 42 // 30-09-08 optimise integral option (V.Ivanchenko) >> 43 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko) >> 44 // 11-03-05 Shift verbose level by 1, add applyCuts and killPrimary flags (VI) >> 45 // 14-03-05 Update logic PostStepDoIt (V.Ivanchenko) >> 46 // 08-04-05 Major optimisation of internal interfaces (V.Ivanchenko) >> 47 // 18-04-05 Use G4ParticleChangeForGamma (V.Ivanchenko) >> 48 // 25-07-05 Add protection: integral mode only for charged particles (VI) >> 49 // 04-09-05 default lambdaFactor 0.8 (V.Ivanchenko) >> 50 // 11-01-06 add A to parameters of ComputeCrossSectionPerAtom (VI) >> 51 // 12-09-06 add SetModel() (mma) >> 52 // 12-04-07 remove double call to Clear model manager (V.Ivanchenko) >> 53 // 27-10-07 Virtual functions moved to source (V.Ivanchenko) >> 54 // 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko) >> 55 // 17-02-10 Added pointer currentParticle (VI) 38 // 56 // 39 // Class Description: based class for discrete << 57 // Class Description: 40 // 58 // 41 59 42 // ------------------------------------------- 60 // ------------------------------------------------------------------- 43 // 61 // 44 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 64 47 #include "G4VEmProcess.hh" 65 #include "G4VEmProcess.hh" 48 #include "G4PhysicalConstants.hh" << 49 #include "G4SystemOfUnits.hh" << 50 #include "G4ProcessManager.hh" 66 #include "G4ProcessManager.hh" 51 #include "G4LossTableManager.hh" 67 #include "G4LossTableManager.hh" 52 #include "G4LossTableBuilder.hh" 68 #include "G4LossTableBuilder.hh" 53 #include "G4Step.hh" 69 #include "G4Step.hh" 54 #include "G4ParticleDefinition.hh" 70 #include "G4ParticleDefinition.hh" 55 #include "G4VEmModel.hh" 71 #include "G4VEmModel.hh" 56 #include "G4DataVector.hh" 72 #include "G4DataVector.hh" 57 #include "G4PhysicsTable.hh" 73 #include "G4PhysicsTable.hh" 58 #include "G4EmDataHandler.hh" << 59 #include "G4PhysicsLogVector.hh" 74 #include "G4PhysicsLogVector.hh" 60 #include "G4VParticleChange.hh" 75 #include "G4VParticleChange.hh" 61 #include "G4ProductionCutsTable.hh" 76 #include "G4ProductionCutsTable.hh" 62 #include "G4Region.hh" 77 #include "G4Region.hh" 63 #include "G4Gamma.hh" 78 #include "G4Gamma.hh" 64 #include "G4Electron.hh" 79 #include "G4Electron.hh" 65 #include "G4Positron.hh" 80 #include "G4Positron.hh" 66 #include "G4PhysicsTableHelper.hh" 81 #include "G4PhysicsTableHelper.hh" 67 #include "G4EmBiasingManager.hh" 82 #include "G4EmBiasingManager.hh" 68 #include "G4EmParameters.hh" << 69 #include "G4EmProcessSubType.hh" << 70 #include "G4EmTableUtil.hh" << 71 #include "G4EmUtility.hh" << 72 #include "G4DNAModelSubType.hh" << 73 #include "G4GenericIon.hh" << 74 #include "G4Log.hh" << 75 #include <iostream> << 76 83 77 //....oooOO0OOooo........oooOO0OOooo........oo 84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 78 85 79 G4VEmProcess::G4VEmProcess(const G4String& nam 86 G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type): 80 G4VDiscreteProcess(name, type) << 87 G4VDiscreteProcess(name, type), >> 88 secondaryParticle(0), >> 89 buildLambdaTable(true), >> 90 theLambdaTable(0), >> 91 theDensityFactor(0), >> 92 theDensityIdx(0), >> 93 integral(false), >> 94 applyCuts(false), >> 95 startFromNull(false), >> 96 currentModel(0), >> 97 particle(0), >> 98 currentParticle(0), >> 99 currentCouple(0) 81 { 100 { 82 theParameters = G4EmParameters::Instance(); << 83 SetVerboseLevel(1); 101 SetVerboseLevel(1); 84 102 85 // Size of tables << 103 // Size of tables assuming spline 86 minKinEnergy = 0.1*CLHEP::keV; << 104 minKinEnergy = 0.1*keV; 87 maxKinEnergy = 100.0*CLHEP::TeV; << 105 maxKinEnergy = 10.0*TeV; >> 106 nLambdaBins = 77; 88 107 89 // default lambda factor 108 // default lambda factor 90 invLambdaFactor = 1.0/lambdaFactor; << 109 lambdaFactor = 0.8; >> 110 >> 111 // default limit on polar angle >> 112 polarAngleLimit = 0.0; >> 113 biasFactor = 1.0; 91 114 92 // particle types 115 // particle types 93 theGamma = G4Gamma::Gamma(); << 116 theGamma = G4Gamma::Gamma(); 94 theElectron = G4Electron::Electron(); << 117 theElectron = G4Electron::Electron(); 95 thePositron = G4Positron::Positron(); << 118 thePositron = G4Positron::Positron(); 96 119 97 pParticleChange = &fParticleChange; 120 pParticleChange = &fParticleChange; 98 fParticleChange.SetSecondaryWeightByProcess( << 99 secParticles.reserve(5); 121 secParticles.reserve(5); 100 122 >> 123 preStepLambda = 0.0; >> 124 mfpKinEnergy = DBL_MAX; >> 125 101 modelManager = new G4EmModelManager(); 126 modelManager = new G4EmModelManager(); 102 lManager = G4LossTableManager::Instance(); << 127 biasManager = 0; 103 lManager->Register(this); << 128 biasFlag = false; 104 isTheMaster = lManager->IsMaster(); << 129 weightFlag = false; 105 G4LossTableBuilder* bld = lManager->GetTable << 130 (G4LossTableManager::Instance())->Register(this); 106 theDensityFactor = bld->GetDensityFactors(); << 107 theDensityIdx = bld->GetCoupleIndexes(); << 108 } 131 } 109 132 110 //....oooOO0OOooo........oooOO0OOooo........oo 133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 111 134 112 G4VEmProcess::~G4VEmProcess() 135 G4VEmProcess::~G4VEmProcess() 113 { 136 { 114 if(isTheMaster) { << 137 if(1 < verboseLevel) { 115 delete theData; << 138 G4cout << "G4VEmProcess destruct " << GetProcessName() 116 delete theEnergyOfCrossSectionMax; << 139 << " " << this << " " << theLambdaTable <<G4endl; >> 140 } >> 141 Clear(); >> 142 if(theLambdaTable) { >> 143 theLambdaTable->clearAndDestroy(); >> 144 delete theLambdaTable; 117 } 145 } 118 delete modelManager; 146 delete modelManager; 119 delete biasManager; 147 delete biasManager; 120 lManager->DeRegister(this); << 148 (G4LossTableManager::Instance())->DeRegister(this); 121 } 149 } 122 150 123 //....oooOO0OOooo........oooOO0OOooo........oo 151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 124 152 125 void G4VEmProcess::AddEmModel(G4int order, G4V << 153 void G4VEmProcess::Clear() 126 const G4Region* << 127 { 154 { 128 if(nullptr == ptr) { return; } << 155 currentCouple = 0; 129 G4VEmFluctuationModel* fm = nullptr; << 156 preStepLambda = 0.0; 130 modelManager->AddEmModel(order, ptr, fm, reg << 157 mfpKinEnergy = DBL_MAX; 131 ptr->SetParticleChange(pParticleChange); << 132 } 158 } 133 159 134 //....oooOO0OOooo........oooOO0OOooo........oo 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 135 161 136 void G4VEmProcess::SetEmModel(G4VEmModel* ptr, << 162 G4double G4VEmProcess::MinPrimaryEnergy(const G4ParticleDefinition*, >> 163 const G4Material*) 137 { 164 { 138 if(nullptr == ptr) { return; } << 165 return 0.0; 139 if(!emModels.empty()) { << 140 for(auto & em : emModels) { if(em == ptr) << 141 } << 142 emModels.push_back(ptr); << 143 } 166 } 144 167 145 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 146 169 147 void G4VEmProcess::PreparePhysicsTable(const G << 170 void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p, >> 171 const G4Region* region) 148 { 172 { 149 if(nullptr == particle) { SetParticle(&part) << 173 G4VEmFluctuationModel* fm = 0; >> 174 modelManager->AddEmModel(order, p, fm, region); >> 175 if(p) { p->SetParticleChange(pParticleChange); } >> 176 } 150 177 151 if(part.GetParticleType() == "nucleus" && << 178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 152 part.GetParticleSubType() == "generic") { << 153 179 154 G4String pname = part.GetParticleName(); << 180 void G4VEmProcess::SetModel(G4VEmModel* p, G4int index) 155 if(pname != "deuteron" && pname != "triton << 181 { 156 pname != "He3" && pname != "alpha" && p << 182 G4int n = emModels.size(); 157 pname != "helium" && pname != "hydrogen << 183 if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} } >> 184 emModels[index] = p; >> 185 } 158 186 159 particle = G4GenericIon::GenericIon(); << 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 160 isIon = true; << 161 } << 162 } << 163 if(particle != &part) { return; } << 164 188 165 lManager->PreparePhysicsTable(&part, this); << 189 G4VEmModel* G4VEmProcess::Model(G4int index) >> 190 { >> 191 G4VEmModel* p = 0; >> 192 if(index >= 0 && index < G4int(emModels.size())) { p = emModels[index]; } >> 193 return p; >> 194 } 166 195 167 // for new run << 196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 168 currentCouple = nullptr; << 169 preStepLambda = 0.0; << 170 fLambdaEnergy = 0.0; << 171 197 172 InitialiseProcess(particle); << 198 void G4VEmProcess::UpdateEmModel(const G4String& nam, >> 199 G4double emin, G4double emax) >> 200 { >> 201 modelManager->UpdateEmModel(nam, emin, emax); >> 202 } 173 203 174 G4LossTableBuilder* bld = lManager->GetTable << 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 175 const G4ProductionCutsTable* theCoupleTable= << 176 G4ProductionCutsTable::GetProductionCutsTa << 177 theCutsGamma = theCoupleTable->GetEnergyC << 178 theCutsElectron = theCoupleTable->GetEnergyC << 179 theCutsPositron = theCoupleTable->GetEnergyC << 180 << 181 // initialisation of the process << 182 if(!actMinKinEnergy) { minKinEnergy = thePar << 183 if(!actMaxKinEnergy) { maxKinEnergy = thePar << 184 << 185 applyCuts = theParameters->ApplyCuts() << 186 lambdaFactor = theParameters->LambdaFacto << 187 invLambdaFactor = 1.0/lambdaFactor; << 188 theParameters->DefineRegParamForEM(this); << 189 << 190 // integral option may be disabled << 191 if(!theParameters->Integral()) { fXSType = f << 192 << 193 // prepare tables << 194 if(isTheMaster) { << 195 if(nullptr == theData) { theData = new G4E << 196 205 197 if(buildLambdaTable) { << 206 G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) 198 theLambdaTable = theData->MakeTable(0); << 207 { >> 208 return modelManager->GetModel(idx, ver); >> 209 } >> 210 >> 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 212 >> 213 void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part) >> 214 { >> 215 if(!particle) { SetParticle(&part); } >> 216 if(1 < verboseLevel) { >> 217 G4cout << "G4VEmProcess::PreparePhysicsTable() for " >> 218 << GetProcessName() >> 219 << " and particle " << part.GetParticleName() >> 220 << " local particle " << particle->GetParticleName() >> 221 << G4endl; >> 222 } >> 223 >> 224 G4LossTableManager* man = G4LossTableManager::Instance(); >> 225 G4LossTableBuilder* bld = man->GetTableBuilder(); >> 226 >> 227 man->PreparePhysicsTable(&part, this); >> 228 >> 229 if(particle == &part) { >> 230 Clear(); >> 231 InitialiseProcess(particle); >> 232 >> 233 const G4ProductionCutsTable* theCoupleTable= >> 234 G4ProductionCutsTable::GetProductionCutsTable(); >> 235 size_t n = theCoupleTable->GetTableSize(); >> 236 >> 237 theEnergyOfCrossSectionMax.resize(n, 0.0); >> 238 theCrossSectionMax.resize(n, DBL_MAX); >> 239 >> 240 // initialisation of models >> 241 G4int nmod = modelManager->NumberOfModels(); >> 242 for(G4int i=0; i<nmod; ++i) { >> 243 G4VEmModel* mod = modelManager->GetModel(i); >> 244 mod->SetPolarAngleLimit(polarAngleLimit); >> 245 if(mod->HighEnergyLimit() > maxKinEnergy) { >> 246 mod->SetHighEnergyLimit(maxKinEnergy); >> 247 } >> 248 } >> 249 >> 250 if(man->AtomDeexcitation()) { modelManager->SetFluoFlag(true); } >> 251 theCuts = modelManager->Initialise(particle,secondaryParticle, >> 252 2.,verboseLevel); >> 253 theCutsGamma = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut); >> 254 theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut); >> 255 theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut); >> 256 >> 257 // prepare tables >> 258 if(buildLambdaTable){ >> 259 theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable); 199 bld->InitialiseBaseMaterials(theLambdaTa 260 bld->InitialiseBaseMaterials(theLambdaTable); 200 } 261 } 201 // high energy table << 262 // forced biasing 202 if(minKinEnergyPrim < maxKinEnergy) { << 263 if(biasManager) { 203 theLambdaTablePrim = theData->MakeTable( << 264 biasManager->Initialise(part,GetProcessName(),verboseLevel); 204 bld->InitialiseBaseMaterials(theLambdaTa << 265 biasFlag = false; 205 } << 266 } 206 } << 267 } 207 // models << 268 theDensityFactor = bld->GetDensityFactors(); 208 baseMat = bld->GetBaseMaterialFlag(); << 269 theDensityIdx = bld->GetCoupleIndexes(); 209 numberOfModels = modelManager->NumberOfModel << 210 currentModel = modelManager->GetModel(0); << 211 if(nullptr != lManager->AtomDeexcitation()) << 212 modelManager->SetFluoFlag(true); << 213 } << 214 // forced biasing << 215 if(nullptr != biasManager) { << 216 biasManager->Initialise(part, GetProcessNa << 217 biasFlag = false; << 218 } << 219 << 220 theCuts = << 221 G4EmTableUtil::PrepareEmProcess(this, part << 222 modelManag << 223 secID, tri << 224 verboseLev << 225 } 270 } 226 271 227 //....oooOO0OOooo........oooOO0OOooo........oo 272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 228 273 229 void G4VEmProcess::BuildPhysicsTable(const G4P 274 void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part) 230 { 275 { 231 if(nullptr == masterProc) { << 276 G4String partname = part.GetParticleName(); 232 if(isTheMaster) { masterProc = this; } << 277 if(1 < verboseLevel) { 233 else { masterProc = static_cast<const G4VE << 278 G4cout << "G4VEmProcess::BuildPhysicsTable() for " 234 } << 279 << GetProcessName() 235 G4int nModels = modelManager->NumberOfModels << 280 << " and particle " << partname 236 G4bool isLocked = theParameters->IsPrintLock << 281 << " buildLambdaTable= " << buildLambdaTable 237 G4bool toBuild = (buildLambdaTable || minKin << 282 << G4endl; 238 << 283 } 239 G4EmTableUtil::BuildEmProcess(this, masterPr << 284 240 nModels, verbo << 285 (G4LossTableManager::Instance())->BuildPhysicsTable(particle); 241 isLocked, toBu << 286 >> 287 if(buildLambdaTable) { >> 288 BuildLambdaTable(); >> 289 FindLambdaMax(); >> 290 } >> 291 >> 292 // reduce printout for nuclear stopping >> 293 G4bool gproc = true; >> 294 G4int st = GetProcessSubType(); >> 295 if((st == fCoulombScattering || st == fNuclearStopping) && >> 296 part.GetParticleType() == "nucleus" && >> 297 partname != "GenericIon" && partname != "alpha") { gproc = false; } >> 298 >> 299 if(gproc && 0 < verboseLevel) { PrintInfoDefinition(); } >> 300 >> 301 if(1 < verboseLevel) { >> 302 G4cout << "G4VEmProcess::BuildPhysicsTable() done for " >> 303 << GetProcessName() >> 304 << " and particle " << partname >> 305 << G4endl; >> 306 } 242 } 307 } 243 308 244 //....oooOO0OOooo........oooOO0OOooo........oo 309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 245 310 246 void G4VEmProcess::BuildLambdaTable() 311 void G4VEmProcess::BuildLambdaTable() 247 { 312 { 248 G4double scale = theParameters->MaxKinEnergy << 313 if(1 < verboseLevel) { 249 G4int nbin = << 314 G4cout << "G4EmProcess::BuildLambdaTable() for process " 250 theParameters->NumberOfBinsPerDecade()*G4l << 315 << GetProcessName() << " and particle " 251 if(actBinning) { nbin = std::max(nbin, nLamb << 316 << particle->GetParticleName() << " " << this 252 scale = nbin/G4Log(scale); << 317 << G4endl; 253 << 318 } 254 G4LossTableBuilder* bld = lManager->GetTable << 255 G4EmTableUtil::BuildLambdaTable(this, partic << 256 bld, theLamb << 257 minKinEnergy << 258 maxKinEnergy << 259 startFromNul << 260 } << 261 319 262 //....oooOO0OOooo........oooOO0OOooo........oo << 320 // Access to materials >> 321 const G4ProductionCutsTable* theCoupleTable= >> 322 G4ProductionCutsTable::GetProductionCutsTable(); >> 323 size_t numOfCouples = theCoupleTable->GetTableSize(); 263 324 264 void G4VEmProcess::StreamInfo(std::ostream& ou << 325 G4LossTableBuilder* bld = (G4LossTableManager::Instance())->GetTableBuilder(); 265 const G4ParticleDefinition& << 326 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag(); 266 { << 327 267 G4String indent = (rst ? " " : ""); << 328 G4PhysicsLogVector* aVector = 0; 268 out << std::setprecision(6); << 329 G4PhysicsLogVector* bVector = 0; 269 out << G4endl << indent << GetProcessName() << 330 270 if (!rst) { << 331 G4double scale = 0.0; 271 out << " for " << part.GetParticleName(); << 332 if(startFromNull) { scale = std::log(maxKinEnergy/minKinEnergy); } 272 } << 333 273 if(fXSType != fEmNoIntegral) { out << " XSt << 334 for(size_t i=0; i<numOfCouples; ++i) { 274 if(applyCuts) { out << " applyCuts:1 "; } << 335 275 G4int subtype = GetProcessSubType(); << 336 if (bld->GetFlag(i)) { 276 out << " SubType=" << subtype; << 337 277 if (subtype == fAnnihilation) { << 338 // create physics vector and fill it 278 G4int mod = theParameters->PositronAtRestM << 339 const G4MaterialCutsCouple* couple = 279 const G4String namp[2] = {"Simple", "Allis << 340 theCoupleTable->GetMaterialCutsCouple(i); 280 out << " AtRestModel:" << namp[mod]; << 341 delete (*theLambdaTable)[i]; 281 } << 342 282 if(biasFactor != 1.0) { out << " BiasingFac << 343 // if start from zero then change the scale 283 out << " BuildTable=" << buildLambdaTable << << 344 if(startFromNull) { 284 if(buildLambdaTable) { << 345 G4double emin = MinPrimaryEnergy(particle,couple->GetMaterial()); 285 if(particle == &part) { << 346 if(0.0 >= emin) { emin = eV; } 286 for(auto & v : *theLambdaTable) { << 347 else if(maxKinEnergy <= emin) { emin = 0.5*maxKinEnergy; } 287 if(nullptr != v) { << 348 G4int bin = 288 out << " Lambda table from "; << 349 G4int(nLambdaBins*std::log(maxKinEnergy/emin)/scale + 0.5); 289 G4double emin = v->Energy(0); << 350 if(bin < 3) { bin = 3; } 290 G4double emax = v->GetMaxEnergy(); << 351 aVector = new G4PhysicsLogVector(emin, maxKinEnergy, bin); 291 G4int nbin = G4int(v->GetVectorLengt << 352 292 if(emin > minKinEnergy) { out << "th << 353 // start not from zero 293 else { out << G4BestUnit(emin,"Energ << 354 } else if(!bVector) { 294 out << " to " << 355 aVector = 295 << G4BestUnit(emax,"Energy") << 356 new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nLambdaBins); 296 << ", " << G4lrint(nbin/std::log << 357 bVector = aVector; 297 << " bins/decade, spline: " << 358 } else { 298 << splineFlag << G4endl; << 359 aVector = new G4PhysicsLogVector(*bVector); 299 break; << 300 } << 301 } << 302 } else { << 303 out << " Used Lambda table of " << 304 << particle->GetParticleName() << G4endl << 305 } << 306 } << 307 if(minKinEnergyPrim < maxKinEnergy) { << 308 if(particle == &part) { << 309 for(auto & v : *theLambdaTablePrim) { << 310 if(nullptr != v) { << 311 out << " LambdaPrime table from << 312 << G4BestUnit(v->Energy(0),"Ener << 313 << " to " << 314 << G4BestUnit(v->GetMaxEnergy(), << 315 << " in " << v->GetVectorLength( << 316 << " bins " << G4endl; << 317 break; << 318 } << 319 } 360 } 320 } else { << 361 aVector->SetSpline(splineFlag); 321 out << " Used LambdaPrime table of << 362 modelManager->FillLambdaVector(aVector, couple, startFromNull); 322 << particle->GetParticleName() << 363 if(splineFlag) { aVector->FillSecondDerivatives(); } >> 364 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector); 323 } 365 } 324 } 366 } 325 StreamProcessInfo(out); << 326 modelManager->DumpModelList(out, verboseLeve << 327 367 328 if(verboseLevel > 2 && buildLambdaTable) { << 368 if(1 < verboseLevel) { 329 out << " LambdaTable address= " << th << 369 G4cout << "Lambda table is built for " 330 if(theLambdaTable && particle == &part) { << 370 << particle->GetParticleName() 331 out << (*theLambdaTable) << G4endl; << 371 << G4endl; 332 } << 333 } 372 } 334 } 373 } 335 374 336 //....oooOO0OOooo........oooOO0OOooo........oo 375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 337 376 338 void G4VEmProcess::StartTracking(G4Track* trac << 377 void G4VEmProcess::PrintInfoDefinition() 339 { 378 { 340 // reset parameters for the new track << 379 if(verboseLevel > 0) { 341 currentParticle = track->GetParticleDefiniti << 380 G4cout << G4endl << GetProcessName() << ": for " 342 theNumberOfInteractionLengthLeft = -1.0; << 381 << particle->GetParticleName(); 343 mfpKinEnergy = DBL_MAX; << 382 if(integral) { G4cout << ", integral: 1 "; } 344 preStepLambda = 0.0; << 383 if(applyCuts) { G4cout << ", applyCuts: 1 "; } 345 << 384 G4cout << " SubType= " << GetProcessSubType();; 346 if(isIon) { massRatio = proton_mass_c2/curre << 385 if(biasFactor != 1.0) { G4cout << " BiasingFactor= " << biasFactor; } 347 << 386 G4cout << G4endl; 348 // forced biasing only for primary particles << 387 if(buildLambdaTable) { 349 if(biasManager) { << 388 G4cout << " Lambda tables from " 350 if(0 == track->GetParentID()) { << 389 << G4BestUnit(minKinEnergy,"Energy") 351 // primary particle << 390 << " to " 352 biasFlag = true; << 391 << G4BestUnit(maxKinEnergy,"Energy") 353 biasManager->ResetForcedInteraction(); << 392 << " in " << nLambdaBins << " bins, spline: " >> 393 << (G4LossTableManager::Instance())->SplineFlag() >> 394 << G4endl; 354 } 395 } >> 396 PrintInfo(); >> 397 modelManager->DumpModelList(verboseLevel); >> 398 } >> 399 >> 400 if(verboseLevel > 2 && buildLambdaTable) { >> 401 G4cout << " LambdaTable address= " << theLambdaTable << G4endl; >> 402 if(theLambdaTable) { G4cout << (*theLambdaTable) << G4endl; } 355 } 403 } 356 } 404 } 357 405 358 //....oooOO0OOooo........oooOO0OOooo........oo 406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 359 407 360 G4double G4VEmProcess::PostStepGetPhysicalInte 408 G4double G4VEmProcess::PostStepGetPhysicalInteractionLength( 361 const G4Track& tr 409 const G4Track& track, 362 G4double previo 410 G4double previousStepSize, 363 G4ForceCondition* 411 G4ForceCondition* condition) 364 { 412 { >> 413 // condition is set to "Not Forced" 365 *condition = NotForced; 414 *condition = NotForced; 366 G4double x = DBL_MAX; 415 G4double x = DBL_MAX; 367 << 416 if(previousStepSize <= 0.0) { theNumberOfInteractionLengthLeft = -1.0; } 368 DefineMaterial(track.GetMaterialCutsCouple() << 417 InitialiseStep(track); 369 preStepKinEnergy = track.GetKineticEnergy(); << 418 if(!currentModel->IsActive(preStepKinEnergy)) { return x; } 370 const G4double scaledEnergy = preStepKinEner << 371 SelectModel(scaledEnergy, currentCoupleIndex << 372 /* << 373 G4cout << "PostStepGetPhysicalInteractionLen << 374 << " couple: " << currentCouple << G << 375 */ << 376 if(!currentModel->IsActive(scaledEnergy)) { << 377 theNumberOfInteractionLengthLeft = -1.0; << 378 currentInteractionLength = DBL_MAX; << 379 mfpKinEnergy = DBL_MAX; << 380 preStepLambda = 0.0; << 381 return x; << 382 } << 383 419 384 // forced biasing only for primary particles 420 // forced biasing only for primary particles 385 if(biasManager) { 421 if(biasManager) { 386 if(0 == track.GetParentID()) { 422 if(0 == track.GetParentID()) { 387 if(biasFlag && << 423 if(0 == track.GetCurrentStepNumber()) { 388 biasManager->ForcedInteractionRegion( << 424 biasFlag = true; 389 return biasManager->GetStepLimit((G4in << 425 biasManager->ResetForcedInteraction(); >> 426 } >> 427 if(biasFlag && biasManager->ForcedInteractionRegion(currentCoupleIndex)) { >> 428 return biasManager->GetStepLimit(currentCoupleIndex, previousStepSize); 390 } 429 } 391 } 430 } 392 } 431 } 393 432 394 // compute mean free path 433 // compute mean free path >> 434 if(preStepKinEnergy < mfpKinEnergy) { >> 435 if (integral) { ComputeIntegralLambda(preStepKinEnergy); } >> 436 else { preStepLambda = GetCurrentLambda(preStepKinEnergy); } >> 437 if(preStepLambda <= 0.0) { mfpKinEnergy = 0.0; } >> 438 } 395 439 396 ComputeIntegralLambda(preStepKinEnergy, trac << 440 // non-zero cross sect}ion 397 << 441 if(preStepLambda > 0.0) { 398 // zero cross section << 399 if(preStepLambda <= 0.0) { << 400 theNumberOfInteractionLengthLeft = -1.0; << 401 currentInteractionLength = DBL_MAX; << 402 << 403 } else { << 404 << 405 // non-zero cross section << 406 if (theNumberOfInteractionLengthLeft < 0.0 442 if (theNumberOfInteractionLengthLeft < 0.0) { 407 << 408 // beggining of tracking (or just after 443 // beggining of tracking (or just after DoIt of this process) 409 theNumberOfInteractionLengthLeft = -G4Lo << 444 ResetNumberOfInteractionLengthLeft(); 410 theInitialNumberOfInteractionLength = th << 445 } else if(currentInteractionLength < DBL_MAX) { 411 << 446 // subtract NumberOfInteractionLengthLeft 412 } else { << 447 SubtractNumberOfInteractionLengthLeft(previousStepSize); 413 << 448 if(theNumberOfInteractionLengthLeft < 0.) 414 theNumberOfInteractionLengthLeft -= << 449 theNumberOfInteractionLengthLeft = perMillion; 415 previousStepSize/currentInteractionLen << 416 theNumberOfInteractionLengthLeft = << 417 std::max(theNumberOfInteractionLengthL << 418 } 450 } 419 451 420 // new mean free path and step limit for t << 452 // get mean free path and step limit 421 currentInteractionLength = 1.0/preStepLamb 453 currentInteractionLength = 1.0/preStepLambda; 422 x = theNumberOfInteractionLengthLeft * cur 454 x = theNumberOfInteractionLengthLeft * currentInteractionLength; 423 } << 455 #ifdef G4VERBOSE 424 return x; << 456 if (verboseLevel>2){ 425 } << 457 G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength "; 426 << 458 G4cout << "[ " << GetProcessName() << "]" << G4endl; 427 //....oooOO0OOooo........oooOO0OOooo........oo << 459 G4cout << " for " << currentParticle->GetParticleName() >> 460 << " in Material " << currentMaterial->GetName() >> 461 << " Ekin(MeV)= " << preStepKinEnergy/MeV >> 462 <<G4endl; >> 463 G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]" >> 464 << "InteractionLength= " << x/cm <<"[cm] " <<G4endl; >> 465 } >> 466 #endif 428 467 429 void G4VEmProcess::ComputeIntegralLambda(G4dou << 468 // zero cross section case 430 { << 469 } else { 431 if (fXSType == fEmNoIntegral) { << 470 if(theNumberOfInteractionLengthLeft > DBL_MIN && 432 preStepLambda = GetCurrentLambda(e, LogEki << 471 currentInteractionLength < DBL_MAX) { 433 472 434 } else if (fXSType == fEmIncreasing) { << 473 // subtract NumberOfInteractionLengthLeft 435 if(e*invLambdaFactor < mfpKinEnergy) { << 474 SubtractNumberOfInteractionLengthLeft(previousStepSize); 436 preStepLambda = GetCurrentLambda(e, LogE << 475 if(theNumberOfInteractionLengthLeft < 0.) 437 mfpKinEnergy = (preStepLambda > 0.0) ? e << 476 theNumberOfInteractionLengthLeft = perMillion; 438 } << 439 << 440 } else if(fXSType == fEmDecreasing) { << 441 if(e < mfpKinEnergy) { << 442 const G4double e1 = e*lambdaFactor; << 443 preStepLambda = GetCurrentLambda(e1); << 444 mfpKinEnergy = e1; << 445 } << 446 << 447 } else if(fXSType == fEmOnePeak) { << 448 const G4double epeak = (*theEnergyOfCrossS << 449 if(e <= epeak) { << 450 if(e*invLambdaFactor < mfpKinEnergy) { << 451 preStepLambda = GetCurrentLambda(e, Lo << 452 mfpKinEnergy = (preStepLambda > 0.0) ? << 453 } << 454 } else if(e < mfpKinEnergy) { << 455 const G4double e1 = std::max(epeak, e*la << 456 preStepLambda = GetCurrentLambda(e1); << 457 mfpKinEnergy = e1; << 458 } 477 } 459 } else { << 478 currentInteractionLength = DBL_MAX; 460 preStepLambda = GetCurrentLambda(e, LogEki << 461 } 479 } >> 480 return x; 462 } 481 } 463 482 464 //....oooOO0OOooo........oooOO0OOooo........oo 483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 465 484 466 G4VParticleChange* G4VEmProcess::PostStepDoIt( 485 G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track, 467 << 486 const G4Step&) 468 { 487 { 469 // clear number of interaction lengths in an << 470 theNumberOfInteractionLengthLeft = -1.0; << 471 mfpKinEnergy = DBL_MAX; << 472 << 473 fParticleChange.InitializeForPostStep(track) 488 fParticleChange.InitializeForPostStep(track); 474 489 475 // Do not make anything if particle is stopp 490 // Do not make anything if particle is stopped, the annihilation then 476 // should be performed by the AtRestDoIt! 491 // should be performed by the AtRestDoIt! 477 if (track.GetTrackStatus() == fStopButAlive) 492 if (track.GetTrackStatus() == fStopButAlive) { return &fParticleChange; } 478 493 479 const G4double finalT = track.GetKineticEner << 494 G4double finalT = track.GetKineticEnergy(); 480 495 481 // forced process - should happen only once 496 // forced process - should happen only once per track 482 if(biasFlag) { 497 if(biasFlag) { 483 if(biasManager->ForcedInteractionRegion((G << 498 if(biasManager->ForcedInteractionRegion(currentCoupleIndex)) { 484 biasFlag = false; 499 biasFlag = false; 485 } 500 } 486 } 501 } 487 502 488 // check active and select model << 489 const G4double scaledEnergy = finalT*massRat << 490 SelectModel(scaledEnergy, currentCoupleIndex << 491 if(!currentModel->IsActive(scaledEnergy)) { << 492 << 493 // Integral approach 503 // Integral approach 494 if (fXSType != fEmNoIntegral) { << 504 if (integral) { 495 const G4double logFinalT = << 505 G4double lx = GetLambda(finalT, currentCouple); 496 track.GetDynamicParticle()->GetLogKineti << 506 if(preStepLambda<lx && 1 < verboseLevel) { 497 const G4double lx = std::max(GetCurrentLam << 507 G4cout << "WARING: for " << currentParticle->GetParticleName() 498 #ifdef G4VERBOSE << 508 << " and " << GetProcessName() 499 if(preStepLambda < lx && 1 < verboseLevel) << 509 << " E(MeV)= " << finalT/MeV 500 G4cout << "WARNING: for " << currentPart << 510 << " preLambda= " << preStepLambda << " < " 501 << " and " << GetProcessName() << << 511 << lx << " (postLambda) " 502 << " preLambda= " << preStepLambd << 512 << G4endl; 503 << " < " << lx << " (postLambda) << 504 } 513 } 505 #endif << 514 506 // if false interaction then use new cross << 515 if(preStepLambda*G4UniformRand() > lx) { 507 // if both values are zero - no interactio << 516 ClearNumberOfInteractionLengthLeft(); 508 if(preStepLambda*G4UniformRand() >= lx) { << 509 return &fParticleChange; 517 return &fParticleChange; 510 } 518 } 511 } 519 } 512 520 >> 521 SelectModel(finalT, currentCoupleIndex); >> 522 if(!currentModel->IsActive(finalT)) { return &fParticleChange; } >> 523 513 // define new weight for primary and seconda 524 // define new weight for primary and secondaries 514 G4double weight = fParticleChange.GetParentW << 525 if(weightFlag) { 515 if(weightFlag) { << 526 G4double weight = fParticleChange.GetParentWeight()/biasFactor; 516 weight /= biasFactor; << 527 fParticleChange.ProposeParentWeight(weight); 517 fParticleChange.ProposeWeight(weight); << 518 } 528 } 519 << 529 /* 520 #ifdef G4VERBOSE << 530 if(0 < verboseLevel) { 521 if(1 < verboseLevel) { << 522 G4cout << "G4VEmProcess::PostStepDoIt: Sam 531 G4cout << "G4VEmProcess::PostStepDoIt: Sample secondary; E= " 523 << finalT/MeV 532 << finalT/MeV 524 << " MeV; model= (" << currentModel 533 << " MeV; model= (" << currentModel->LowEnergyLimit() 525 << ", " << currentModel->HighEnerg 534 << ", " << currentModel->HighEnergyLimit() << ")" 526 << G4endl; 535 << G4endl; 527 } 536 } 528 #endif << 537 */ 529 538 530 // sample secondaries 539 // sample secondaries 531 secParticles.clear(); 540 secParticles.clear(); 532 currentModel->SampleSecondaries(&secParticle 541 currentModel->SampleSecondaries(&secParticles, 533 currentCoupl << 542 currentCouple, 534 track.GetDyn << 543 track.GetDynamicParticle(), 535 (*theCuts)[c << 544 (*theCuts)[currentCoupleIndex]); 536 << 537 G4int num0 = (G4int)secParticles.size(); << 538 << 539 // splitting or Russian roulette << 540 if(biasManager) { << 541 if(biasManager->SecondaryBiasingRegion((G4 << 542 G4double eloss = 0.0; << 543 weight *= biasManager->ApplySecondaryBia << 544 secParticles, track, currentModel, &fP << 545 (G4int)currentCoupleIndex, (*theCuts)[ << 546 step.GetPostStepPoint()->GetSafety()); << 547 if(eloss > 0.0) { << 548 eloss += fParticleChange.GetLocalEnerg << 549 fParticleChange.ProposeLocalEnergyDepo << 550 } << 551 } << 552 } << 553 545 554 // save secondaries 546 // save secondaries 555 G4int num = (G4int)secParticles.size(); << 547 G4int num = secParticles.size(); 556 if(num > 0) { 548 if(num > 0) { 557 549 558 fParticleChange.SetNumberOfSecondaries(num 550 fParticleChange.SetNumberOfSecondaries(num); 559 G4double edep = fParticleChange.GetLocalEn 551 G4double edep = fParticleChange.GetLocalEnergyDeposit(); 560 G4double time = track.GetGlobalTime(); << 561 << 562 G4int n1(0), n2(0); << 563 if(num0 > mainSecondaries) { << 564 currentModel->FillNumberOfSecondaries(n1 << 565 } << 566 552 567 for (G4int i=0; i<num; ++i) { 553 for (G4int i=0; i<num; ++i) { 568 G4DynamicParticle* dp = secParticles[i]; 554 G4DynamicParticle* dp = secParticles[i]; 569 if (nullptr != dp) { << 555 const G4ParticleDefinition* p = dp->GetParticleDefinition(); 570 const G4ParticleDefinition* p = dp->Ge << 556 G4double e = dp->GetKineticEnergy(); 571 G4double e = dp->GetKineticEnergy(); << 557 G4bool good = true; 572 G4bool good = true; << 558 if(applyCuts) { 573 if(applyCuts) { << 559 if (p == theGamma) { 574 if (p == theGamma) { << 560 if (e < (*theCutsGamma)[currentCoupleIndex]) good = false; 575 if (e < (*theCutsGamma)[currentCou << 561 576 << 562 } else if (p == theElectron) { 577 } else if (p == theElectron) { << 563 if (e < (*theCutsElectron)[currentCoupleIndex]) good = false; 578 if (e < (*theCutsElectron)[current << 564 579 << 565 } else if (p == thePositron) { 580 } else if (p == thePositron) { << 566 if (electron_mass_c2 < (*theCutsGamma)[currentCoupleIndex] && 581 if (electron_mass_c2 < (*theCutsGa << 567 e < (*theCutsPositron)[currentCoupleIndex]) { 582 e < (*theCutsPositron)[current << 568 good = false; 583 good = false; << 569 e += 2.0*electron_mass_c2; 584 e += 2.0*electron_mass_c2; << 570 } 585 } << 571 } 586 } << 572 if(!good) { 587 // added secondary if it is good << 573 delete dp; 588 } << 574 edep += e; 589 if (good) { << 575 } 590 G4Track* t = new G4Track(dp, time, t << 576 } 591 t->SetTouchableHandle(track.GetTouch << 577 if (good) { fParticleChange.AddSecondary(dp); } 592 if (biasManager) { << 578 } 593 t->SetWeight(weight * biasManager- << 594 } else { << 595 t->SetWeight(weight); << 596 } << 597 pParticleChange->AddSecondary(t); << 598 << 599 // define type of secondary << 600 if(i < mainSecondaries) { << 601 t->SetCreatorModelID(secID); << 602 if(GetProcessSubType() == fCompton << 603 t->SetCreatorModelID(_ComptonGam << 604 } << 605 } else if(i < mainSecondaries + n1) << 606 t->SetCreatorModelID(tripletID); << 607 } else if(i < mainSecondaries + n1 + << 608 t->SetCreatorModelID(_IonRecoil); << 609 } else { << 610 if(i < num0) { << 611 if(p == theGamma) { << 612 t->SetCreatorModelID(fluoID); << 613 } else { << 614 t->SetCreatorModelID(augerID); << 615 } << 616 } else { << 617 t->SetCreatorModelID(biasID); << 618 } << 619 } << 620 /* << 621 G4cout << "Secondary(post step) has << 622 << ", Ekin= " << t->GetKineti << 623 << GetProcessName() << " fluo << 624 << " augerID= " << augerID << << 625 */ << 626 } else { << 627 delete dp; << 628 edep += e; << 629 } << 630 } << 631 } << 632 fParticleChange.ProposeLocalEnergyDeposit( 579 fParticleChange.ProposeLocalEnergyDeposit(edep); 633 } 580 } 634 581 635 if(0.0 == fParticleChange.GetProposedKinetic 582 if(0.0 == fParticleChange.GetProposedKineticEnergy() && 636 fAlive == fParticleChange.GetTrackStatus( 583 fAlive == fParticleChange.GetTrackStatus()) { 637 if(particle->GetProcessManager()->GetAtRes 584 if(particle->GetProcessManager()->GetAtRestProcessVector()->size() > 0) 638 { fParticleChange.ProposeTrackStatus( 585 { fParticleChange.ProposeTrackStatus(fStopButAlive); } 639 else { fParticleChange.ProposeTrackStatus( 586 else { fParticleChange.ProposeTrackStatus(fStopAndKill); } 640 } 587 } 641 588 >> 589 ClearNumberOfInteractionLengthLeft(); 642 return &fParticleChange; 590 return &fParticleChange; 643 } 591 } 644 592 645 //....oooOO0OOooo........oooOO0OOooo........oo 593 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 646 594 647 G4bool G4VEmProcess::StorePhysicsTable(const G 595 G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part, 648 const G << 596 const G4String& directory, 649 G4bool << 597 G4bool ascii) 650 { 598 { 651 if(!isTheMaster || part != particle) { retur << 599 G4bool yes = true; 652 if(G4EmTableUtil::StoreTable(this, part, the << 600 653 directory, "Lambda", << 601 if ( theLambdaTable && part == particle) { 654 verboseLevel, a << 602 const G4String name = 655 G4EmTableUtil::StoreTable(this, part, the << 603 GetPhysicsTableFileName(part,directory,"Lambda",ascii); 656 directory, "LambdaPrim", << 604 yes = theLambdaTable->StorePhysicsTable(name,ascii); 657 verboseLevel, a << 605 658 return true; << 606 if ( yes ) { >> 607 G4cout << "Physics tables are stored for " << particle->GetParticleName() >> 608 << " and process " << GetProcessName() >> 609 << " in the directory <" << directory >> 610 << "> " << G4endl; >> 611 } else { >> 612 G4cout << "Fail to store Physics Tables for " >> 613 << particle->GetParticleName() >> 614 << " and process " << GetProcessName() >> 615 << " in the directory <" << directory >> 616 << "> " << G4endl; >> 617 } 659 } 618 } 660 return false; << 619 return yes; 661 } 620 } 662 621 663 //....oooOO0OOooo........oooOO0OOooo........oo 622 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 664 623 665 G4bool G4VEmProcess::RetrievePhysicsTable(cons 624 G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part, 666 cons << 625 const G4String& directory, 667 G4bo << 626 G4bool ascii) 668 { 627 { 669 if(!isTheMaster || part != particle) { retur << 628 if(1 < verboseLevel) { >> 629 G4cout << "G4VEmProcess::RetrievePhysicsTable() for " >> 630 << part->GetParticleName() << " and process " >> 631 << GetProcessName() << G4endl; >> 632 } 670 G4bool yes = true; 633 G4bool yes = true; 671 if(buildLambdaTable) { << 634 672 yes = G4EmTableUtil::RetrieveTable(this, p << 635 if(!buildLambdaTable || particle != part) return yes; 673 "Lambda << 636 674 ascii, << 637 const G4String particleName = part->GetParticleName(); 675 } << 638 G4String filename; 676 if(yes && minKinEnergyPrim < maxKinEnergy) { << 639 677 yes = G4EmTableUtil::RetrieveTable(this, p << 640 filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii); 678 "Lambda << 641 yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable, 679 ascii, << 642 filename,ascii); >> 643 if ( yes ) { >> 644 if (0 < verboseLevel) { >> 645 G4cout << "Lambda table for " << particleName >> 646 << " is Retrieved from <" >> 647 << filename << ">" >> 648 << G4endl; >> 649 } >> 650 if((G4LossTableManager::Instance())->SplineFlag()) { >> 651 size_t n = theLambdaTable->length(); >> 652 for(size_t i=0; i<n; ++i) { >> 653 if((* theLambdaTable)[i]) { >> 654 (* theLambdaTable)[i]->SetSpline(true); >> 655 } >> 656 } >> 657 } >> 658 } else { >> 659 if (1 < verboseLevel) { >> 660 G4cout << "Lambda table for " << particleName << " in file <" >> 661 << filename << "> is not exist" >> 662 << G4endl; >> 663 } 680 } 664 } >> 665 681 return yes; 666 return yes; 682 } 667 } 683 668 684 //....oooOO0OOooo........oooOO0OOooo........oo 669 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 685 670 686 G4double G4VEmProcess::GetCrossSection(G4doubl << 671 G4double 687 const G << 672 G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy, >> 673 const G4MaterialCutsCouple* couple) 688 { 674 { 689 CurrentSetup(couple, kinEnergy); << 675 // Cross section per atom is calculated 690 return GetCurrentLambda(kinEnergy, G4Log(kin << 676 DefineMaterial(couple); >> 677 G4double cross = 0.0; >> 678 if(theLambdaTable) { >> 679 cross = (*theDensityFactor)[currentCoupleIndex]* >> 680 (((*theLambdaTable)[basedCoupleIndex])->Value(kineticEnergy)); >> 681 } else { >> 682 SelectModel(kineticEnergy, currentCoupleIndex); >> 683 cross = currentModel->CrossSectionPerVolume(currentMaterial, >> 684 currentParticle,kineticEnergy); >> 685 } >> 686 >> 687 if(cross < 0.0) { cross = 0.0; } >> 688 return cross; 691 } 689 } 692 690 693 //....oooOO0OOooo........oooOO0OOooo........oo 691 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 694 692 695 G4double G4VEmProcess::GetMeanFreePath(const G 693 G4double G4VEmProcess::GetMeanFreePath(const G4Track& track, 696 G4doubl << 694 G4double, 697 G4Force << 695 G4ForceCondition* condition) 698 { 696 { 699 *condition = NotForced; 697 *condition = NotForced; 700 return G4VEmProcess::MeanFreePath(track); 698 return G4VEmProcess::MeanFreePath(track); 701 } 699 } 702 700 703 //....oooOO0OOooo........oooOO0OOooo........oo 701 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 704 702 705 G4double << 703 G4double G4VEmProcess::MeanFreePath(const G4Track& track) 706 G4VEmProcess::ComputeCrossSectionPerAtom(G4dou << 707 G4dou << 708 { 704 { 709 SelectModel(kinEnergy, currentCoupleIndex); << 705 DefineMaterial(track.GetMaterialCutsCouple()); 710 return (currentModel) ? << 706 preStepLambda = GetCurrentLambda(track.GetKineticEnergy()); 711 currentModel->ComputeCrossSectionPerAtom(c << 707 G4double x = DBL_MAX; 712 Z << 708 if(0.0 < preStepLambda) { x = 1.0/preStepLambda; } >> 709 return x; 713 } 710 } 714 711 715 //....oooOO0OOooo........oooOO0OOooo........oo 712 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 716 713 717 G4PhysicsVector* << 714 G4double 718 G4VEmProcess::LambdaPhysicsVector(const G4Mate << 715 G4VEmProcess::ComputeCrossSectionPerAtom(G4double kineticEnergy, >> 716 G4double Z, G4double A, G4double cut) 719 { 717 { 720 DefineMaterial(couple); << 718 SelectModel(kineticEnergy, currentCoupleIndex); 721 G4PhysicsVector* newv = new G4PhysicsLogVect << 719 G4double x = 0.0; 722 << 720 if(currentModel) { 723 return newv; << 721 x = currentModel->ComputeCrossSectionPerAtom(currentParticle,kineticEnergy, >> 722 Z,A,cut); >> 723 } >> 724 return x; 724 } 725 } 725 726 726 //....oooOO0OOooo........oooOO0OOooo........oo 727 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 727 728 728 const G4Element* G4VEmProcess::GetCurrentEleme << 729 void G4VEmProcess::FindLambdaMax() 729 { 730 { 730 return (nullptr != currentModel) ? << 731 if(1 < verboseLevel) { 731 currentModel->GetCurrentElement(currentMat << 732 G4cout << "### G4VEmProcess::FindLambdaMax: " >> 733 << particle->GetParticleName() >> 734 << " and process " << GetProcessName() << G4endl; >> 735 } >> 736 size_t n = theLambdaTable->length(); >> 737 G4PhysicsVector* pv; >> 738 G4double e, s, emax, smax; >> 739 >> 740 size_t i; >> 741 >> 742 // first loop on existing vectors >> 743 for (i=0; i<n; ++i) { >> 744 pv = (*theLambdaTable)[i]; >> 745 if(pv) { >> 746 size_t nb = pv->GetVectorLength(); >> 747 emax = DBL_MAX; >> 748 smax = 0.0; >> 749 if(nb > 0) { >> 750 for (size_t j=0; j<nb; ++j) { >> 751 e = pv->Energy(j); >> 752 s = (*pv)(j); >> 753 if(s > smax) { >> 754 smax = s; >> 755 emax = e; >> 756 } >> 757 } >> 758 } >> 759 theEnergyOfCrossSectionMax[i] = emax; >> 760 theCrossSectionMax[i] = smax; >> 761 if(1 < verboseLevel) { >> 762 G4cout << "For " << particle->GetParticleName() >> 763 << " Max CS at i= " << i << " emax(MeV)= " << emax/MeV >> 764 << " lambda= " << smax << G4endl; >> 765 } >> 766 } >> 767 } >> 768 // second loop using base materials >> 769 for (size_t i=0; i<n; ++i) { >> 770 pv = (*theLambdaTable)[i]; >> 771 if(!pv){ >> 772 G4int j = (*theDensityIdx)[i]; >> 773 theEnergyOfCrossSectionMax[i] = theEnergyOfCrossSectionMax[j]; >> 774 theCrossSectionMax[i] = (*theDensityFactor)[i]*theCrossSectionMax[j]; >> 775 } >> 776 } 732 } 777 } 733 778 734 //....oooOO0OOooo........oooOO0OOooo........oo 779 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 735 780 736 const G4Element* G4VEmProcess::GetTargetElemen << 781 G4PhysicsVector* >> 782 G4VEmProcess::LambdaPhysicsVector(const G4MaterialCutsCouple*) 737 { 783 { 738 return (nullptr != currentModel) ? << 784 G4PhysicsVector* v = 739 currentModel->GetCurrentElement(currentMat << 785 new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nLambdaBins); >> 786 v->SetSpline((G4LossTableManager::Instance())->SplineFlag()); >> 787 return v; 740 } 788 } 741 789 742 //....oooOO0OOooo........oooOO0OOooo........oo 790 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 743 791 744 const G4Isotope* G4VEmProcess::GetTargetIsotop << 792 const G4Element* G4VEmProcess::GetCurrentElement() const 745 { 793 { 746 return (nullptr != currentModel) ? << 794 const G4Element* elm = 0; 747 currentModel->GetCurrentIsotope(GetCurrent << 795 if(currentModel) {elm = currentModel->GetCurrentElement(); } >> 796 return elm; 748 } 797 } 749 798 750 //....oooOO0OOooo........oooOO0OOooo........oo 799 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 751 800 752 void G4VEmProcess::SetCrossSectionBiasingFacto 801 void G4VEmProcess::SetCrossSectionBiasingFactor(G4double f, G4bool flag) 753 { 802 { 754 if(f > 0.0) { 803 if(f > 0.0) { 755 biasFactor = f; 804 biasFactor = f; 756 weightFlag = flag; 805 weightFlag = flag; 757 if(1 < verboseLevel) { 806 if(1 < verboseLevel) { 758 G4cout << "### SetCrossSectionBiasingFac 807 G4cout << "### SetCrossSectionBiasingFactor: for " 759 << particle->GetParticleName() << 808 << particle->GetParticleName() 760 << " and process " << GetProcessN << 809 << " and process " << GetProcessName() 761 << " biasFactor= " << f << " weig << 810 << " biasFactor= " << f << " weightFlag= " << flag 762 << G4endl; << 811 << G4endl; 763 } 812 } 764 } 813 } 765 } 814 } 766 815 767 //....oooOO0OOooo........oooOO0OOooo........oo 816 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 768 817 769 void 818 void 770 G4VEmProcess::ActivateForcedInteraction(G4doub 819 G4VEmProcess::ActivateForcedInteraction(G4double length, const G4String& r, 771 G4bool << 820 G4bool flag) 772 { 821 { 773 if(nullptr == biasManager) { biasManager = n << 822 if(!biasManager) { biasManager = new G4EmBiasingManager(); } 774 if(1 < verboseLevel) { 823 if(1 < verboseLevel) { 775 G4cout << "### ActivateForcedInteraction: 824 G4cout << "### ActivateForcedInteraction: for " 776 << particle->GetParticleName() << 825 << particle->GetParticleName() 777 << " and process " << GetProcessNam << 826 << " and process " << GetProcessName() 778 << " length(mm)= " << length/mm << 827 << " length(mm)= " << length/mm 779 << " in G4Region <" << r << 828 << " in G4Region <" << r 780 << "> weightFlag= " << flag << 829 << "> weightFlag= " << flag 781 << G4endl; << 830 << G4endl; 782 } 831 } 783 weightFlag = flag; 832 weightFlag = flag; 784 biasManager->ActivateForcedInteraction(lengt 833 biasManager->ActivateForcedInteraction(length, r); 785 } << 786 << 787 //....oooOO0OOooo........oooOO0OOooo........oo << 788 << 789 void << 790 G4VEmProcess::ActivateSecondaryBiasing(const G << 791 G4double factor, << 792 G4double energyLimit) << 793 { << 794 if (0.0 <= factor) { << 795 << 796 // Range cut can be applied only for e- << 797 if(0.0 == factor && secondaryParticle != G << 798 { return; } << 799 << 800 if(!biasManager) { biasManager = new G4EmB << 801 biasManager->ActivateSecondaryBiasing(regi << 802 if(1 < verboseLevel) { << 803 G4cout << "### ActivateSecondaryBiasing: << 804 << " process " << GetProcessName() << 805 << " factor= " << factor << 806 << " in G4Region <" << region << 807 << "> energyLimit(MeV)= " << energyLimi << 808 << G4endl; << 809 } << 810 } << 811 } << 812 << 813 //....oooOO0OOooo........oooOO0OOooo........oo << 814 << 815 void G4VEmProcess::SetLambdaBinning(G4int n) << 816 { << 817 if(5 < n && n < 10000000) { << 818 nLambdaBins = n; << 819 actBinning = true; << 820 } else { << 821 G4double e = (G4double)n; << 822 PrintWarning("SetLambdaBinning", e); << 823 } << 824 } << 825 << 826 //....oooOO0OOooo........oooOO0OOooo........oo << 827 << 828 void G4VEmProcess::SetMinKinEnergy(G4double e) << 829 { << 830 if(1.e-3*eV < e && e < maxKinEnergy) { << 831 nLambdaBins = G4lrint(nLambdaBins*G4Log(ma << 832 /G4Log(maxKinEnergy/ << 833 minKinEnergy = e; << 834 actMinKinEnergy = true; << 835 } else { PrintWarning("SetMinKinEnergy", e); << 836 } << 837 << 838 //....oooOO0OOooo........oooOO0OOooo........oo << 839 << 840 void G4VEmProcess::SetMaxKinEnergy(G4double e) << 841 { << 842 if(minKinEnergy < e && e < 1.e+6*TeV) { << 843 nLambdaBins = G4lrint(nLambdaBins*G4Log(e/ << 844 /G4Log(maxKinEnergy/ << 845 maxKinEnergy = e; << 846 actMaxKinEnergy = true; << 847 } else { PrintWarning("SetMaxKinEnergy", e); << 848 } << 849 << 850 //....oooOO0OOooo........oooOO0OOooo........oo << 851 << 852 void G4VEmProcess::SetMinKinEnergyPrim(G4doubl << 853 { << 854 if(theParameters->MinKinEnergy() <= e && << 855 e <= theParameters->MaxKinEnergy()) { min << 856 else { PrintWarning("SetMinKinEnergyPrim", e << 857 } << 858 << 859 //....oooOO0OOooo........oooOO0OOooo........oo << 860 << 861 G4VEmProcess* G4VEmProcess::GetEmProcess(const << 862 { << 863 return (nam == GetProcessName()) ? this : nu << 864 } << 865 << 866 //....oooOO0OOooo........oooOO0OOooo........oo << 867 << 868 G4double G4VEmProcess::PolarAngleLimit() const << 869 { << 870 return theParameters->MscThetaLimit(); << 871 } << 872 << 873 //....oooOO0OOooo........oooOO0OOooo........oo << 874 << 875 void G4VEmProcess::PrintWarning(G4String tit, << 876 { << 877 G4String ss = "G4VEmProcess::" + tit; << 878 G4ExceptionDescription ed; << 879 ed << "Parameter is out of range: " << val << 880 << " it will have no effect!\n" << " Pro << 881 << GetProcessName() << " nbins= " << the << 882 << " Emin(keV)= " << theParameters->MinKi << 883 << " Emax(GeV)= " << theParameters->MaxKi << 884 G4Exception(ss, "em0044", JustWarning, ed); << 885 } << 886 << 887 //....oooOO0OOooo........oooOO0OOooo........oo << 888 << 889 void G4VEmProcess::ProcessDescription(std::ost << 890 { << 891 if(nullptr != particle) { << 892 StreamInfo(out, *particle, true); << 893 } << 894 } 834 } 895 835 896 //....oooOO0OOooo........oooOO0OOooo........oo 836 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 897 837