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( << 121 fParticleChange.SetSecondaryWeightByProcess(false); 99 secParticles.reserve(5); 122 secParticles.reserve(5); 100 123 >> 124 preStepLambda = 0.0; >> 125 mfpKinEnergy = DBL_MAX; >> 126 101 modelManager = new G4EmModelManager(); 127 modelManager = new G4EmModelManager(); 102 lManager = G4LossTableManager::Instance(); << 128 biasManager = 0; 103 lManager->Register(this); << 129 biasFlag = false; 104 isTheMaster = lManager->IsMaster(); << 130 weightFlag = false; 105 G4LossTableBuilder* bld = lManager->GetTable << 131 (G4LossTableManager::Instance())->Register(this); 106 theDensityFactor = bld->GetDensityFactors(); << 107 theDensityIdx = bld->GetCoupleIndexes(); << 108 } 132 } 109 133 110 //....oooOO0OOooo........oooOO0OOooo........oo 134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 111 135 112 G4VEmProcess::~G4VEmProcess() 136 G4VEmProcess::~G4VEmProcess() 113 { 137 { 114 if(isTheMaster) { << 138 if(1 < verboseLevel) { 115 delete theData; << 139 G4cout << "G4VEmProcess destruct " << GetProcessName() 116 delete theEnergyOfCrossSectionMax; << 140 << " " << this << " " << theLambdaTable <<G4endl; >> 141 } >> 142 Clear(); >> 143 if(theLambdaTable) { >> 144 theLambdaTable->clearAndDestroy(); >> 145 delete theLambdaTable; 117 } 146 } 118 delete modelManager; 147 delete modelManager; 119 delete biasManager; 148 delete biasManager; 120 lManager->DeRegister(this); << 149 (G4LossTableManager::Instance())->DeRegister(this); 121 } 150 } 122 151 123 //....oooOO0OOooo........oooOO0OOooo........oo 152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 124 153 125 void G4VEmProcess::AddEmModel(G4int order, G4V << 154 void G4VEmProcess::Clear() 126 const G4Region* << 127 { 155 { 128 if(nullptr == ptr) { return; } << 156 currentCouple = 0; 129 G4VEmFluctuationModel* fm = nullptr; << 157 preStepLambda = 0.0; 130 modelManager->AddEmModel(order, ptr, fm, reg << 158 mfpKinEnergy = DBL_MAX; 131 ptr->SetParticleChange(pParticleChange); << 132 } 159 } 133 160 134 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 135 162 136 void G4VEmProcess::SetEmModel(G4VEmModel* ptr, << 163 G4double G4VEmProcess::MinPrimaryEnergy(const G4ParticleDefinition*, >> 164 const G4Material*) 137 { 165 { 138 if(nullptr == ptr) { return; } << 166 return 0.0; 139 if(!emModels.empty()) { << 140 for(auto & em : emModels) { if(em == ptr) << 141 } << 142 emModels.push_back(ptr); << 143 } 167 } 144 168 145 //....oooOO0OOooo........oooOO0OOooo........oo 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 146 170 147 void G4VEmProcess::PreparePhysicsTable(const G << 171 void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p, >> 172 const G4Region* region) 148 { 173 { 149 if(nullptr == particle) { SetParticle(&part) << 174 G4VEmFluctuationModel* fm = 0; >> 175 modelManager->AddEmModel(order, p, fm, region); >> 176 if(p) { p->SetParticleChange(pParticleChange); } >> 177 } 150 178 151 if(part.GetParticleType() == "nucleus" && << 179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 152 part.GetParticleSubType() == "generic") { << 153 180 154 G4String pname = part.GetParticleName(); << 181 void G4VEmProcess::SetModel(G4VEmModel* p, G4int index) 155 if(pname != "deuteron" && pname != "triton << 182 { 156 pname != "He3" && pname != "alpha" && p << 183 G4int n = emModels.size(); 157 pname != "helium" && pname != "hydrogen << 184 if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} } >> 185 emModels[index] = p; >> 186 } 158 187 159 particle = G4GenericIon::GenericIon(); << 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 160 isIon = true; << 161 } << 162 } << 163 if(particle != &part) { return; } << 164 189 165 lManager->PreparePhysicsTable(&part, this); << 190 G4VEmModel* G4VEmProcess::Model(G4int index) >> 191 { >> 192 G4VEmModel* p = 0; >> 193 if(index >= 0 && index < G4int(emModels.size())) { p = emModels[index]; } >> 194 return p; >> 195 } 166 196 167 // for new run << 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 168 currentCouple = nullptr; << 169 preStepLambda = 0.0; << 170 fLambdaEnergy = 0.0; << 171 198 172 InitialiseProcess(particle); << 199 void G4VEmProcess::UpdateEmModel(const G4String& nam, >> 200 G4double emin, G4double emax) >> 201 { >> 202 modelManager->UpdateEmModel(nam, emin, emax); >> 203 } 173 204 174 G4LossTableBuilder* bld = lManager->GetTable << 205 //....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 206 197 if(buildLambdaTable) { << 207 G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) 198 theLambdaTable = theData->MakeTable(0); << 208 { >> 209 return modelManager->GetModel(idx, ver); >> 210 } >> 211 >> 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 213 >> 214 void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part) >> 215 { >> 216 if(!particle) { SetParticle(&part); } >> 217 if(1 < verboseLevel) { >> 218 G4cout << "G4VEmProcess::PreparePhysicsTable() for " >> 219 << GetProcessName() >> 220 << " and particle " << part.GetParticleName() >> 221 << " local particle " << particle->GetParticleName() >> 222 << G4endl; >> 223 } >> 224 >> 225 G4LossTableManager* man = G4LossTableManager::Instance(); >> 226 G4LossTableBuilder* bld = man->GetTableBuilder(); >> 227 >> 228 man->PreparePhysicsTable(&part, this); >> 229 >> 230 if(particle == &part) { >> 231 Clear(); >> 232 InitialiseProcess(particle); >> 233 >> 234 const G4ProductionCutsTable* theCoupleTable= >> 235 G4ProductionCutsTable::GetProductionCutsTable(); >> 236 size_t n = theCoupleTable->GetTableSize(); >> 237 >> 238 theEnergyOfCrossSectionMax.resize(n, 0.0); >> 239 theCrossSectionMax.resize(n, DBL_MAX); >> 240 >> 241 // initialisation of models >> 242 G4int nmod = modelManager->NumberOfModels(); >> 243 for(G4int i=0; i<nmod; ++i) { >> 244 G4VEmModel* mod = modelManager->GetModel(i); >> 245 mod->SetPolarAngleLimit(polarAngleLimit); >> 246 if(mod->HighEnergyLimit() > maxKinEnergy) { >> 247 mod->SetHighEnergyLimit(maxKinEnergy); >> 248 } >> 249 } >> 250 >> 251 if(man->AtomDeexcitation()) { modelManager->SetFluoFlag(true); } >> 252 theCuts = modelManager->Initialise(particle,secondaryParticle, >> 253 2.,verboseLevel); >> 254 theCutsGamma = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut); >> 255 theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut); >> 256 theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut); >> 257 >> 258 // prepare tables >> 259 if(buildLambdaTable){ >> 260 theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable); 199 bld->InitialiseBaseMaterials(theLambdaTa 261 bld->InitialiseBaseMaterials(theLambdaTable); 200 } 262 } 201 // high energy table << 263 // forced biasing 202 if(minKinEnergyPrim < maxKinEnergy) { << 264 if(biasManager) { 203 theLambdaTablePrim = theData->MakeTable( << 265 biasManager->Initialise(part,GetProcessName(),verboseLevel); 204 bld->InitialiseBaseMaterials(theLambdaTa << 266 biasFlag = false; 205 } << 267 } 206 } << 268 } 207 // models << 269 theDensityFactor = bld->GetDensityFactors(); 208 baseMat = bld->GetBaseMaterialFlag(); << 270 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 } 271 } 226 272 227 //....oooOO0OOooo........oooOO0OOooo........oo 273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 228 274 229 void G4VEmProcess::BuildPhysicsTable(const G4P 275 void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part) 230 { 276 { 231 if(nullptr == masterProc) { << 277 G4String partname = part.GetParticleName(); 232 if(isTheMaster) { masterProc = this; } << 278 if(1 < verboseLevel) { 233 else { masterProc = static_cast<const G4VE << 279 G4cout << "G4VEmProcess::BuildPhysicsTable() for " 234 } << 280 << GetProcessName() 235 G4int nModels = modelManager->NumberOfModels << 281 << " and particle " << partname 236 G4bool isLocked = theParameters->IsPrintLock << 282 << " buildLambdaTable= " << buildLambdaTable 237 G4bool toBuild = (buildLambdaTable || minKin << 283 << G4endl; 238 << 284 } 239 G4EmTableUtil::BuildEmProcess(this, masterPr << 285 240 nModels, verbo << 286 (G4LossTableManager::Instance())->BuildPhysicsTable(particle); 241 isLocked, toBu << 287 >> 288 if(buildLambdaTable) { >> 289 BuildLambdaTable(); >> 290 FindLambdaMax(); >> 291 } >> 292 >> 293 // reduce printout for nuclear stopping >> 294 G4bool gproc = true; >> 295 G4int st = GetProcessSubType(); >> 296 if((st == fCoulombScattering || st == fNuclearStopping) && >> 297 part.GetParticleType() == "nucleus" && >> 298 partname != "GenericIon" && partname != "alpha") { gproc = false; } >> 299 >> 300 if(gproc && 0 < verboseLevel) { PrintInfoDefinition(); } >> 301 >> 302 if(1 < verboseLevel) { >> 303 G4cout << "G4VEmProcess::BuildPhysicsTable() done for " >> 304 << GetProcessName() >> 305 << " and particle " << partname >> 306 << G4endl; >> 307 } 242 } 308 } 243 309 244 //....oooOO0OOooo........oooOO0OOooo........oo 310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 245 311 246 void G4VEmProcess::BuildLambdaTable() 312 void G4VEmProcess::BuildLambdaTable() 247 { 313 { 248 G4double scale = theParameters->MaxKinEnergy << 314 if(1 < verboseLevel) { 249 G4int nbin = << 315 G4cout << "G4EmProcess::BuildLambdaTable() for process " 250 theParameters->NumberOfBinsPerDecade()*G4l << 316 << GetProcessName() << " and particle " 251 if(actBinning) { nbin = std::max(nbin, nLamb << 317 << particle->GetParticleName() << " " << this 252 scale = nbin/G4Log(scale); << 318 << G4endl; 253 << 319 } 254 G4LossTableBuilder* bld = lManager->GetTable << 255 G4EmTableUtil::BuildLambdaTable(this, partic << 256 bld, theLamb << 257 minKinEnergy << 258 maxKinEnergy << 259 startFromNul << 260 } << 261 320 262 //....oooOO0OOooo........oooOO0OOooo........oo << 321 // Access to materials >> 322 const G4ProductionCutsTable* theCoupleTable= >> 323 G4ProductionCutsTable::GetProductionCutsTable(); >> 324 size_t numOfCouples = theCoupleTable->GetTableSize(); 263 325 264 void G4VEmProcess::StreamInfo(std::ostream& ou << 326 G4LossTableBuilder* bld = (G4LossTableManager::Instance())->GetTableBuilder(); 265 const G4ParticleDefinition& << 327 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag(); 266 { << 328 267 G4String indent = (rst ? " " : ""); << 329 G4PhysicsLogVector* aVector = 0; 268 out << std::setprecision(6); << 330 G4PhysicsLogVector* bVector = 0; 269 out << G4endl << indent << GetProcessName() << 331 270 if (!rst) { << 332 G4double scale = 0.0; 271 out << " for " << part.GetParticleName(); << 333 if(startFromNull) { scale = std::log(maxKinEnergy/minKinEnergy); } 272 } << 334 273 if(fXSType != fEmNoIntegral) { out << " XSt << 335 for(size_t i=0; i<numOfCouples; ++i) { 274 if(applyCuts) { out << " applyCuts:1 "; } << 336 275 G4int subtype = GetProcessSubType(); << 337 if (bld->GetFlag(i)) { 276 out << " SubType=" << subtype; << 338 277 if (subtype == fAnnihilation) { << 339 // create physics vector and fill it 278 G4int mod = theParameters->PositronAtRestM << 340 const G4MaterialCutsCouple* couple = 279 const G4String namp[2] = {"Simple", "Allis << 341 theCoupleTable->GetMaterialCutsCouple(i); 280 out << " AtRestModel:" << namp[mod]; << 342 delete (*theLambdaTable)[i]; 281 } << 343 282 if(biasFactor != 1.0) { out << " BiasingFac << 344 // if start from zero then change the scale 283 out << " BuildTable=" << buildLambdaTable << << 345 if(startFromNull) { 284 if(buildLambdaTable) { << 346 G4double emin = MinPrimaryEnergy(particle,couple->GetMaterial()); 285 if(particle == &part) { << 347 if(0.0 >= emin) { emin = eV; } 286 for(auto & v : *theLambdaTable) { << 348 else if(maxKinEnergy <= emin) { emin = 0.5*maxKinEnergy; } 287 if(nullptr != v) { << 349 G4int bin = 288 out << " Lambda table from "; << 350 G4int(nLambdaBins*std::log(maxKinEnergy/emin)/scale + 0.5); 289 G4double emin = v->Energy(0); << 351 if(bin < 3) { bin = 3; } 290 G4double emax = v->GetMaxEnergy(); << 352 aVector = new G4PhysicsLogVector(emin, maxKinEnergy, bin); 291 G4int nbin = G4int(v->GetVectorLengt << 353 292 if(emin > minKinEnergy) { out << "th << 354 // start not from zero 293 else { out << G4BestUnit(emin,"Energ << 355 } else if(!bVector) { 294 out << " to " << 356 aVector = 295 << G4BestUnit(emax,"Energy") << 357 new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nLambdaBins); 296 << ", " << G4lrint(nbin/std::log << 358 bVector = aVector; 297 << " bins/decade, spline: " << 359 } else { 298 << splineFlag << G4endl; << 360 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 } 361 } 320 } else { << 362 aVector->SetSpline(splineFlag); 321 out << " Used LambdaPrime table of << 363 modelManager->FillLambdaVector(aVector, couple, startFromNull); 322 << particle->GetParticleName() << 364 if(splineFlag) { aVector->FillSecondDerivatives(); } >> 365 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector); 323 } 366 } 324 } 367 } 325 StreamProcessInfo(out); << 326 modelManager->DumpModelList(out, verboseLeve << 327 368 328 if(verboseLevel > 2 && buildLambdaTable) { << 369 if(1 < verboseLevel) { 329 out << " LambdaTable address= " << th << 370 G4cout << "Lambda table is built for " 330 if(theLambdaTable && particle == &part) { << 371 << particle->GetParticleName() 331 out << (*theLambdaTable) << G4endl; << 372 << G4endl; 332 } << 333 } 373 } 334 } 374 } 335 375 336 //....oooOO0OOooo........oooOO0OOooo........oo 376 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 337 377 338 void G4VEmProcess::StartTracking(G4Track* trac << 378 void G4VEmProcess::PrintInfoDefinition() 339 { 379 { 340 // reset parameters for the new track << 380 if(verboseLevel > 0) { 341 currentParticle = track->GetParticleDefiniti << 381 G4cout << G4endl << GetProcessName() << ": for " 342 theNumberOfInteractionLengthLeft = -1.0; << 382 << particle->GetParticleName(); 343 mfpKinEnergy = DBL_MAX; << 383 if(integral) { G4cout << ", integral: 1 "; } 344 preStepLambda = 0.0; << 384 if(applyCuts) { G4cout << ", applyCuts: 1 "; } 345 << 385 G4cout << " SubType= " << GetProcessSubType();; 346 if(isIon) { massRatio = proton_mass_c2/curre << 386 if(biasFactor != 1.0) { G4cout << " BiasingFactor= " << biasFactor; } 347 << 387 G4cout << G4endl; 348 // forced biasing only for primary particles << 388 if(buildLambdaTable) { 349 if(biasManager) { << 389 G4cout << " Lambda tables from " 350 if(0 == track->GetParentID()) { << 390 << G4BestUnit(minKinEnergy,"Energy") 351 // primary particle << 391 << " to " 352 biasFlag = true; << 392 << G4BestUnit(maxKinEnergy,"Energy") 353 biasManager->ResetForcedInteraction(); << 393 << " in " << nLambdaBins << " bins, spline: " >> 394 << (G4LossTableManager::Instance())->SplineFlag() >> 395 << G4endl; 354 } 396 } >> 397 PrintInfo(); >> 398 modelManager->DumpModelList(verboseLevel); >> 399 } >> 400 >> 401 if(verboseLevel > 2 && buildLambdaTable) { >> 402 G4cout << " LambdaTable address= " << theLambdaTable << G4endl; >> 403 if(theLambdaTable) { G4cout << (*theLambdaTable) << G4endl; } 355 } 404 } 356 } 405 } 357 406 358 //....oooOO0OOooo........oooOO0OOooo........oo 407 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 359 408 360 G4double G4VEmProcess::PostStepGetPhysicalInte 409 G4double G4VEmProcess::PostStepGetPhysicalInteractionLength( 361 const G4Track& tr 410 const G4Track& track, 362 G4double previo 411 G4double previousStepSize, 363 G4ForceCondition* 412 G4ForceCondition* condition) 364 { 413 { >> 414 // condition is set to "Not Forced" 365 *condition = NotForced; 415 *condition = NotForced; 366 G4double x = DBL_MAX; 416 G4double x = DBL_MAX; 367 << 417 if(previousStepSize <= 0.0) { theNumberOfInteractionLengthLeft = -1.0; } 368 DefineMaterial(track.GetMaterialCutsCouple() << 418 InitialiseStep(track); 369 preStepKinEnergy = track.GetKineticEnergy(); << 419 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 420 384 // forced biasing only for primary particles 421 // forced biasing only for primary particles 385 if(biasManager) { 422 if(biasManager) { 386 if(0 == track.GetParentID()) { 423 if(0 == track.GetParentID()) { 387 if(biasFlag && << 424 if(0 == track.GetCurrentStepNumber()) { 388 biasManager->ForcedInteractionRegion( << 425 biasFlag = true; 389 return biasManager->GetStepLimit((G4in << 426 biasManager->ResetForcedInteraction(); >> 427 } >> 428 if(biasFlag && biasManager->ForcedInteractionRegion(currentCoupleIndex)) { >> 429 return biasManager->GetStepLimit(currentCoupleIndex, previousStepSize); 390 } 430 } 391 } 431 } 392 } 432 } 393 433 394 // compute mean free path 434 // compute mean free path >> 435 if(preStepKinEnergy < mfpKinEnergy) { >> 436 if (integral) { ComputeIntegralLambda(preStepKinEnergy); } >> 437 else { preStepLambda = GetCurrentLambda(preStepKinEnergy); } >> 438 if(preStepLambda <= 0.0) { mfpKinEnergy = 0.0; } >> 439 } 395 440 396 ComputeIntegralLambda(preStepKinEnergy, trac << 441 // non-zero cross sect}ion 397 << 442 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 443 if (theNumberOfInteractionLengthLeft < 0.0) { 407 << 408 // beggining of tracking (or just after 444 // beggining of tracking (or just after DoIt of this process) 409 theNumberOfInteractionLengthLeft = -G4Lo << 445 ResetNumberOfInteractionLengthLeft(); 410 theInitialNumberOfInteractionLength = th << 446 } else if(currentInteractionLength < DBL_MAX) { 411 << 447 // subtract NumberOfInteractionLengthLeft 412 } else { << 448 SubtractNumberOfInteractionLengthLeft(previousStepSize); 413 << 449 if(theNumberOfInteractionLengthLeft < 0.) 414 theNumberOfInteractionLengthLeft -= << 450 theNumberOfInteractionLengthLeft = perMillion; 415 previousStepSize/currentInteractionLen << 416 theNumberOfInteractionLengthLeft = << 417 std::max(theNumberOfInteractionLengthL << 418 } 451 } 419 452 420 // new mean free path and step limit for t << 453 // get mean free path and step limit 421 currentInteractionLength = 1.0/preStepLamb 454 currentInteractionLength = 1.0/preStepLambda; 422 x = theNumberOfInteractionLengthLeft * cur 455 x = theNumberOfInteractionLengthLeft * currentInteractionLength; 423 } << 456 #ifdef G4VERBOSE 424 return x; << 457 if (verboseLevel>2){ 425 } << 458 G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength "; 426 << 459 G4cout << "[ " << GetProcessName() << "]" << G4endl; 427 //....oooOO0OOooo........oooOO0OOooo........oo << 460 G4cout << " for " << currentParticle->GetParticleName() >> 461 << " in Material " << currentMaterial->GetName() >> 462 << " Ekin(MeV)= " << preStepKinEnergy/MeV >> 463 <<G4endl; >> 464 G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]" >> 465 << "InteractionLength= " << x/cm <<"[cm] " <<G4endl; >> 466 } >> 467 #endif 428 468 429 void G4VEmProcess::ComputeIntegralLambda(G4dou << 469 // zero cross section case 430 { << 470 } else { 431 if (fXSType == fEmNoIntegral) { << 471 if(theNumberOfInteractionLengthLeft > DBL_MIN && 432 preStepLambda = GetCurrentLambda(e, LogEki << 472 currentInteractionLength < DBL_MAX) { 433 473 434 } else if (fXSType == fEmIncreasing) { << 474 // subtract NumberOfInteractionLengthLeft 435 if(e*invLambdaFactor < mfpKinEnergy) { << 475 SubtractNumberOfInteractionLengthLeft(previousStepSize); 436 preStepLambda = GetCurrentLambda(e, LogE << 476 if(theNumberOfInteractionLengthLeft < 0.) 437 mfpKinEnergy = (preStepLambda > 0.0) ? e << 477 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 } 478 } 459 } else { << 479 currentInteractionLength = DBL_MAX; 460 preStepLambda = GetCurrentLambda(e, LogEki << 461 } 480 } >> 481 return x; 462 } 482 } 463 483 464 //....oooOO0OOooo........oooOO0OOooo........oo 484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 465 485 466 G4VParticleChange* G4VEmProcess::PostStepDoIt( 486 G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track, 467 << 487 const G4Step&) 468 { 488 { 469 // clear number of interaction lengths in an << 470 theNumberOfInteractionLengthLeft = -1.0; << 471 mfpKinEnergy = DBL_MAX; << 472 << 473 fParticleChange.InitializeForPostStep(track) 489 fParticleChange.InitializeForPostStep(track); 474 490 475 // Do not make anything if particle is stopp 491 // Do not make anything if particle is stopped, the annihilation then 476 // should be performed by the AtRestDoIt! 492 // should be performed by the AtRestDoIt! 477 if (track.GetTrackStatus() == fStopButAlive) 493 if (track.GetTrackStatus() == fStopButAlive) { return &fParticleChange; } 478 494 479 const G4double finalT = track.GetKineticEner << 495 G4double finalT = track.GetKineticEnergy(); 480 496 481 // forced process - should happen only once 497 // forced process - should happen only once per track 482 if(biasFlag) { 498 if(biasFlag) { 483 if(biasManager->ForcedInteractionRegion((G << 499 if(biasManager->ForcedInteractionRegion(currentCoupleIndex)) { 484 biasFlag = false; 500 biasFlag = false; 485 } 501 } 486 } 502 } 487 503 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 504 // Integral approach 494 if (fXSType != fEmNoIntegral) { << 505 if (integral) { 495 const G4double logFinalT = << 506 G4double lx = GetLambda(finalT, currentCouple); 496 track.GetDynamicParticle()->GetLogKineti << 507 if(preStepLambda<lx && 1 < verboseLevel) { 497 const G4double lx = std::max(GetCurrentLam << 508 G4cout << "WARING: for " << currentParticle->GetParticleName() 498 #ifdef G4VERBOSE << 509 << " and " << GetProcessName() 499 if(preStepLambda < lx && 1 < verboseLevel) << 510 << " E(MeV)= " << finalT/MeV 500 G4cout << "WARNING: for " << currentPart << 511 << " preLambda= " << preStepLambda << " < " 501 << " and " << GetProcessName() << << 512 << lx << " (postLambda) " 502 << " preLambda= " << preStepLambd << 513 << G4endl; 503 << " < " << lx << " (postLambda) << 504 } 514 } 505 #endif << 515 506 // if false interaction then use new cross << 516 if(preStepLambda*G4UniformRand() > lx) { 507 // if both values are zero - no interactio << 517 ClearNumberOfInteractionLengthLeft(); 508 if(preStepLambda*G4UniformRand() >= lx) { << 509 return &fParticleChange; 518 return &fParticleChange; 510 } 519 } 511 } 520 } 512 521 >> 522 SelectModel(finalT, currentCoupleIndex); >> 523 if(!currentModel->IsActive(finalT)) { return &fParticleChange; } >> 524 513 // define new weight for primary and seconda 525 // define new weight for primary and secondaries 514 G4double weight = fParticleChange.GetParentW 526 G4double weight = fParticleChange.GetParentWeight(); 515 if(weightFlag) { << 527 if(weightFlag) { weight /= biasFactor; } 516 weight /= biasFactor; << 528 fParticleChange.ProposeWeight(weight); 517 fParticleChange.ProposeWeight(weight); << 529 /* 518 } << 530 if(0 < verboseLevel) { 519 << 520 #ifdef G4VERBOSE << 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