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