Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // $Id: G4VEnergyLossProcess.cc,v 1.45 2004/12/09 10:38:02 vnivanch Exp $ >> 24 // GEANT4 tag $Name: geant4-07-00-patch-01 $ >> 25 // 26 // ------------------------------------------- 26 // ------------------------------------------------------------------- 27 // 27 // 28 // GEANT4 Class file 28 // GEANT4 Class file 29 // 29 // 30 // 30 // 31 // File name: G4VEnergyLossProcess 31 // File name: G4VEnergyLossProcess 32 // 32 // 33 // Author: Vladimir Ivanchenko 33 // Author: Vladimir Ivanchenko 34 // 34 // 35 // Creation date: 03.01.2002 35 // Creation date: 03.01.2002 36 // 36 // 37 // Modifications: Vladimir Ivanchenko << 37 // Modifications: 38 // 38 // >> 39 // 13-11-02 Minor fix - use normalised direction (V.Ivanchenko) >> 40 // 04-12-02 Minor change in PostStepDoIt (V.Ivanchenko) >> 41 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko) >> 42 // 26-12-02 Secondary production moved to derived classes (V.Ivanchenko) >> 43 // 04-01-03 Fix problem of very small steps for ions (V.Ivanchenko) >> 44 // 20-01-03 Migrade to cut per region (V.Ivanchenko) >> 45 // 24-01-03 Temporarily close a control on usage of couples (V.Ivanchenko) >> 46 // 24-01-03 Make models region aware (V.Ivanchenko) >> 47 // 05-02-03 Fix compilation warnings (V.Ivanchenko) >> 48 // 06-02-03 Add control on tmax in PostStepDoIt (V.Ivanchenko) >> 49 // 13-02-03 SubCutoffProcessors defined for regions (V.Ivanchenko) >> 50 // 15-02-03 Lambda table can be scaled (V.Ivanchenko) >> 51 // 17-02-03 Fix problem of store/restore tables (V.Ivanchenko) >> 52 // 18-02-03 Add control on CutCouple usage (V.Ivanchenko) >> 53 // 26-02-03 Simplify control on GenericIons (V.Ivanchenko) >> 54 // 06-03-03 Control on GenericIons using SubType + update verbose (V.Ivanchenko) >> 55 // 10-03-03 Add Ion registration (V.Ivanchenko) >> 56 // 22-03-03 Add Initialisation of cash (V.Ivanchenko) >> 57 // 26-03-03 Remove finalRange modification (V.Ivanchenko) >> 58 // 09-04-03 Fix problem of negative range limit for non integral (V.Ivanchenko) >> 59 // 26-04-03 Fix retrieve tables (V.Ivanchenko) >> 60 // 06-05-03 Set defalt finalRange = 1 mm (V.Ivanchenko) >> 61 // 12-05-03 Update range calculations + lowKinEnergy (V.Ivanchenko) >> 62 // 13-05-03 Add calculation of precise range (V.Ivanchenko) >> 63 // 23-05-03 Remove tracking cuts (V.Ivanchenko) >> 64 // 03-06-03 Fix initialisation problem for STD ionisation (V.Ivanchenko) >> 65 // 21-07-03 Add UpdateEmModel method (V.Ivanchenko) >> 66 // 03-11-03 Fix initialisation problem in RetrievePhysicsTable (V.Ivanchenko) >> 67 // 04-11-03 Add checks in RetrievePhysicsTable (V.Ivanchenko) >> 68 // 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko) >> 69 // 21-01-04 Migrade to G4ParticleChangeForLoss (V.Ivanchenko) >> 70 // 27-02-04 Fix problem of loss in low presure gases, cleanup precise range >> 71 // calculation, use functions ForLoss in AlongStepDoIt (V.Ivanchenko) >> 72 // 10-03-04 Fix a problem of Precise Range table (V.Ivanchenko) >> 73 // 19-03-04 Fix a problem energy below lowestKinEnergy (V.Ivanchenko) >> 74 // 31-03-04 Fix a problem of retrieve tables (V.Ivanchenko) >> 75 // 21-07-04 Check weather AtRest are active or not (V.Ivanchenko) >> 76 // 03-08-04 Add pointer of DEDX table to all processes (V.Ivanchenko) >> 77 // 06-08-04 Clear up names of member functions (V.Ivanchenko) >> 78 // 06-08-04 Clear up names of member functions (V.Ivanchenko) >> 79 // 27-08-04 Add NeedBuildTables method (V.Ivanchneko) >> 80 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivantchenko) 39 // 81 // 40 // Class Description: 82 // Class Description: 41 // 83 // 42 // It is the unified energy loss process it ca 84 // It is the unified energy loss process it calculates the continuous 43 // energy loss for charged particles using a s 85 // energy loss for charged particles using a set of Energy Loss 44 // models valid for different energy regions. 86 // models valid for different energy regions. There are a possibility 45 // to create and access to dE/dx and range tab 87 // to create and access to dE/dx and range tables, or to calculate 46 // that information on fly. 88 // that information on fly. 47 // ------------------------------------------- 89 // ------------------------------------------------------------------- 48 // 90 // 49 //....oooOO0OOooo........oooOO0OOooo........oo 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 50 //....oooOO0OOooo........oooOO0OOooo........oo 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 51 93 52 #include "G4VEnergyLossProcess.hh" 94 #include "G4VEnergyLossProcess.hh" 53 #include "G4PhysicalConstants.hh" << 54 #include "G4SystemOfUnits.hh" << 55 #include "G4ProcessManager.hh" << 56 #include "G4LossTableManager.hh" 95 #include "G4LossTableManager.hh" 57 #include "G4LossTableBuilder.hh" << 58 #include "G4Step.hh" 96 #include "G4Step.hh" 59 #include "G4ParticleDefinition.hh" 97 #include "G4ParticleDefinition.hh" 60 #include "G4ParticleTable.hh" << 61 #include "G4EmParameters.hh" << 62 #include "G4EmUtility.hh" << 63 #include "G4EmTableUtil.hh" << 64 #include "G4VEmModel.hh" 98 #include "G4VEmModel.hh" 65 #include "G4VEmFluctuationModel.hh" 99 #include "G4VEmFluctuationModel.hh" 66 #include "G4DataVector.hh" 100 #include "G4DataVector.hh" >> 101 #include "G4PhysicsTable.hh" >> 102 #include "G4PhysicsVector.hh" 67 #include "G4PhysicsLogVector.hh" 103 #include "G4PhysicsLogVector.hh" 68 #include "G4VParticleChange.hh" 104 #include "G4VParticleChange.hh" >> 105 #include "G4Gamma.hh" 69 #include "G4Electron.hh" 106 #include "G4Electron.hh" >> 107 #include "G4Positron.hh" >> 108 #include "G4Proton.hh" >> 109 #include "G4VSubCutoffProcessor.hh" 70 #include "G4ProcessManager.hh" 110 #include "G4ProcessManager.hh" 71 #include "G4UnitsTable.hh" 111 #include "G4UnitsTable.hh" >> 112 #include "G4GenericIon.hh" >> 113 #include "G4ProductionCutsTable.hh" 72 #include "G4Region.hh" 114 #include "G4Region.hh" 73 #include "G4RegionStore.hh" 115 #include "G4RegionStore.hh" 74 #include "G4PhysicsTableHelper.hh" 116 #include "G4PhysicsTableHelper.hh" 75 #include "G4SafetyHelper.hh" << 76 #include "G4EmDataHandler.hh" << 77 #include "G4TransportationManager.hh" << 78 #include "G4VAtomDeexcitation.hh" << 79 #include "G4VSubCutProducer.hh" << 80 #include "G4EmBiasingManager.hh" << 81 #include "G4Log.hh" << 82 #include <iostream> << 83 117 84 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 85 119 86 namespace << 120 G4VEnergyLossProcess::G4VEnergyLossProcess(const G4String& name, G4ProcessType type): 87 { << 121 G4VContinuousDiscreteProcess(name, type), 88 G4String tnames[7] = << 122 nSCoffRegions(0), 89 {"DEDX","Ionisation","DEDXnr","CSDARange", << 123 idxSCoffRegions(0), 90 } << 124 theDEDXTable(0), 91 << 125 theRangeTableForLoss(0), 92 << 126 theDEDXunRestrictedTable(0), 93 G4VEnergyLossProcess::G4VEnergyLossProcess(con << 127 thePreciseRangeTable(0), 94 G4P << 128 theSecondaryRangeTable(0), 95 G4VContinuousDiscreteProcess(name, type) << 129 theInverseRangeTable(0), 96 { << 130 theLambdaTable(0), 97 theParameters = G4EmParameters::Instance(); << 131 theSubLambdaTable(0), 98 SetVerboseLevel(1); << 132 theDEDXAtMaxEnergy(0), >> 133 theRangeAtMaxEnergy(0), >> 134 theEnergyOfCrossSectionMax(0), >> 135 theCrossSectionMax(0), >> 136 particle(0), >> 137 baseParticle(0), >> 138 secondaryParticle(0), >> 139 currentCouple(0), >> 140 nDEDXBins(90), >> 141 nDEDXBinsForRange(70), >> 142 nLambdaBins(90), >> 143 linLossLimit(0.05), >> 144 minSubRange(0.1), >> 145 defaultRoverRange(0.2), >> 146 defaultIntegralRange(1.0), >> 147 lambdaFactor(0.1), >> 148 mfpKinEnergy(0.0), >> 149 lossFluctuationFlag(true), >> 150 rndmStepFlag(false), >> 151 tablesAreBuilt(false), >> 152 integral(true), >> 153 meanFreePath(false), >> 154 aboveCSmax(true), >> 155 isIonisation(true) >> 156 { >> 157 >> 158 lowestKinEnergy = 1.*eV; >> 159 minKinEnergy = 0.1*keV; >> 160 maxKinEnergy = 100.0*GeV; >> 161 maxKinEnergyForRange = 1.0*GeV; 99 162 100 // low energy limit << 163 pParticleChange = &fParticleChange; 101 lowestKinEnergy = theParameters->LowestElect << 102 << 103 // Size of tables << 104 minKinEnergy = 0.1*CLHEP::keV; << 105 maxKinEnergy = 100.0*CLHEP::TeV; << 106 maxKinEnergyCSDA = 1.0*CLHEP::GeV; << 107 nBins = 84; << 108 nBinsCSDA = 35; << 109 << 110 invLambdaFactor = 1.0/lambdaFactor; << 111 164 112 // default linear loss limit << 165 // default dRoverRange and finalRange 113 finalRange = 1.*CLHEP::mm; << 166 SetStepFunction(defaultIntegralRange, 1.0*mm); >> 167 SetVerboseLevel(0); 114 168 115 // run time objects << 116 pParticleChange = &fParticleChange; << 117 fParticleChange.SetSecondaryWeightByProcess( << 118 modelManager = new G4EmModelManager(); 169 modelManager = new G4EmModelManager(); 119 safetyHelper = G4TransportationManager::GetT << 170 (G4LossTableManager::Instance())->Register(this); 120 ->GetSafetyHelper(); << 171 scoffProcessors.clear(); 121 aGPILSelection = CandidateForSelection; << 172 scoffRegions.clear(); 122 << 123 // initialise model << 124 lManager = G4LossTableManager::Instance(); << 125 lManager->Register(this); << 126 isMaster = lManager->IsMaster(); << 127 << 128 G4LossTableBuilder* bld = lManager->GetTable << 129 theDensityFactor = bld->GetDensityFactors(); << 130 theDensityIdx = bld->GetCoupleIndexes(); << 131 << 132 scTracks.reserve(10); << 133 secParticles.reserve(12); << 134 emModels = new std::vector<G4VEmModel*>; << 135 } 173 } 136 174 137 //....oooOO0OOooo........oooOO0OOooo........oo 175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 138 176 139 G4VEnergyLossProcess::~G4VEnergyLossProcess() 177 G4VEnergyLossProcess::~G4VEnergyLossProcess() 140 { 178 { 141 if (isMaster) { << 179 Clear(); 142 if(nullptr == baseParticle) { delete theDa << 180 143 delete theEnergyOfCrossSectionMax; << 181 if ( !baseParticle ) { 144 if(nullptr != fXSpeaks) { << 182 if(theDEDXTable && theRangeTableForLoss) theDEDXTable->clearAndDestroy(); 145 for(auto const & v : *fXSpeaks) { delete << 183 if(theDEDXunRestrictedTable && thePreciseRangeTable) 146 delete fXSpeaks; << 184 theDEDXunRestrictedTable->clearAndDestroy(); >> 185 if(thePreciseRangeTable) thePreciseRangeTable->clearAndDestroy(); >> 186 if(theRangeTableForLoss) theRangeTableForLoss->clearAndDestroy(); >> 187 if(theInverseRangeTable) theInverseRangeTable->clearAndDestroy(); >> 188 if(theLambdaTable) theLambdaTable->clearAndDestroy(); >> 189 if(theSubLambdaTable) theSubLambdaTable->clearAndDestroy(); >> 190 } >> 191 >> 192 if (nSCoffRegions) { >> 193 for (G4int i=0; i<nSCoffRegions; i++) { >> 194 if (scoffProcessors[i]) { >> 195 for (G4int j=i+1; j<nSCoffRegions; j++) { >> 196 if(scoffProcessors[i] == scoffProcessors[j]) scoffProcessors[j] = 0; >> 197 } >> 198 delete scoffProcessors[i]; >> 199 } 147 } 200 } >> 201 scoffProcessors.clear(); >> 202 scoffRegions.clear(); 148 } 203 } 149 delete modelManager; 204 delete modelManager; 150 delete biasManager; << 205 (G4LossTableManager::Instance())->DeRegister(this); 151 delete scoffRegions; << 152 delete emModels; << 153 lManager->DeRegister(this); << 154 } 206 } 155 207 156 //....oooOO0OOooo........oooOO0OOooo........oo 208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 157 209 158 G4double G4VEnergyLossProcess::MinPrimaryEnerg << 210 void G4VEnergyLossProcess::Clear() 159 << 160 << 161 { 211 { 162 return cut; << 212 if(0 < verboseLevel) { 163 } << 213 G4cout << "G4VEnergyLossProcess::Clear() for " << GetProcessName() << G4endl; >> 214 } 164 215 165 //....oooOO0OOooo........oooOO0OOooo........oo << 216 if(theDEDXAtMaxEnergy) delete [] theDEDXAtMaxEnergy; >> 217 if(theRangeAtMaxEnergy) delete [] theRangeAtMaxEnergy; >> 218 if(theEnergyOfCrossSectionMax) delete [] theEnergyOfCrossSectionMax; >> 219 if(theCrossSectionMax) delete [] theCrossSectionMax; 166 220 167 void G4VEnergyLossProcess::AddEmModel(G4int or << 221 theDEDXAtMaxEnergy = 0; 168 G4VEmFlu << 222 theRangeAtMaxEnergy = 0; 169 const G4 << 223 theEnergyOfCrossSectionMax = 0, 170 { << 224 theCrossSectionMax = 0, 171 if(nullptr == ptr) { return; } << 225 tablesAreBuilt = false; 172 G4VEmFluctuationModel* afluc = (nullptr == f << 173 modelManager->AddEmModel(order, ptr, afluc, << 174 ptr->SetParticleChange(pParticleChange, aflu << 175 } 226 } 176 227 177 //....oooOO0OOooo........oooOO0OOooo........oo 228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 178 229 179 void G4VEnergyLossProcess::SetEmModel(G4VEmMod << 230 void G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part) 180 { 231 { 181 if(nullptr == ptr) { return; } << 182 if(!emModels->empty()) { << 183 for(auto & em : *emModels) { if(em == ptr) << 184 } << 185 emModels->push_back(ptr); << 186 } << 187 << 188 //....oooOO0OOooo........oooOO0OOooo........oo << 189 232 190 void G4VEnergyLossProcess::SetDynamicMassCharg << 233 // Are particle defined? 191 << 234 if( !particle ) { 192 { << 235 if(part.GetParticleType() == "nucleus" && part.GetParticleSubType() == "generic") 193 massRatio = massratio; << 236 particle = G4GenericIon::GenericIon(); 194 logMassRatio = G4Log(massRatio); << 237 else particle = ∂ 195 fFactor = charge2ratio*biasFactor; << 238 } 196 if(baseMat) { fFactor *= (*theDensityFactor) << 197 chargeSqRatio = charge2ratio; << 198 reduceFactor = 1.0/(fFactor*massRatio); << 199 } << 200 239 201 //....oooOO0OOooo........oooOO0OOooo........oo << 240 if(0 < verboseLevel) { >> 241 G4cout << "G4VEnergyLossProcess::PreparePhysicsTable for " >> 242 << GetProcessName() >> 243 << " for " << part.GetParticleName() >> 244 << " local: " << particle->GetParticleName() >> 245 << G4endl; >> 246 } 202 247 203 void << 248 G4LossTableManager* lManager = G4LossTableManager::Instance(); 204 G4VEnergyLossProcess::PreparePhysicsTable(cons << 205 { << 206 particle = G4EmTableUtil::CheckIon(this, &pa << 207 verboseLe << 208 249 209 if( particle != &part ) { << 250 if (&part != particle) { 210 if(!isIon) { lManager->RegisterExtraPartic << 251 if (part.GetParticleType() == "nucleus") lManager->RegisterIon(&part, this); 211 if(1 < verboseLevel) { << 252 else lManager->RegisterExtraParticle(&part, this); 212 G4cout << "### G4VEnergyLossProcess::Pre << 213 << " interrupted for " << GetProc << 214 << part.GetParticleName() << " is << 215 << " spline=" << spline << G4endl << 216 } << 217 return; 253 return; 218 } 254 } 219 255 220 tablesAreBuilt = false; << 256 Clear(); 221 if (GetProcessSubType() == fIonisation) { Se << 222 257 223 G4LossTableBuilder* bld = lManager->GetTable << 258 currentCouple = 0; 224 lManager->PreparePhysicsTable(&part, this); << 259 preStepLambda = 0.0; >> 260 mfpKinEnergy = DBL_MAX; >> 261 preStepMFP = DBL_MAX; 225 262 226 // Base particle and set of models can be de 263 // Base particle and set of models can be defined here 227 InitialiseEnergyLossProcess(particle, basePa 264 InitialiseEnergyLossProcess(particle, baseParticle); 228 265 229 // parameters of the process << 266 // Tables preparation 230 if(!actLossFluc) { lossFluctuationFlag = the << 267 if (!baseParticle) { 231 useCutAsFinalRange = theParameters->UseCutAs << 268 232 if(!actMinKinEnergy) { minKinEnergy = thePar << 269 theDEDXTable = G4PhysicsTableHelper::PreparePhysicsTable(theDEDXTable); 233 if(!actMaxKinEnergy) { maxKinEnergy = thePar << 270 if (lManager->BuildPreciseRange()) { 234 if(!actBinning) { nBins = theParameters->Num << 271 theDEDXunRestrictedTable = G4PhysicsTableHelper::PreparePhysicsTable(theDEDXunRestrictedTable); 235 maxKinEnergyCSDA = theParameters->MaxEnergyF << 272 if (isIonisation) 236 nBinsCSDA = theParameters->NumberOfBinsPerDe << 273 thePreciseRangeTable = G4PhysicsTableHelper::PreparePhysicsTable(thePreciseRangeTable); 237 *G4lrint(std::log10(maxKinEnergyCSDA/minKi << 274 } 238 if(!actLinLossLimit) { linLossLimit = thePar << 239 lambdaFactor = theParameters->LambdaFactor() << 240 invLambdaFactor = 1.0/lambdaFactor; << 241 if(isMaster) { SetVerboseLevel(theParameters << 242 else { SetVerboseLevel(theParameters->Worker << 243 // integral option may be disabled << 244 if(!theParameters->Integral()) { fXSType = f << 245 << 246 theParameters->DefineRegParamForLoss(this); << 247 275 248 fRangeEnergy = 0.0; << 276 if (isIonisation) { >> 277 theRangeTableForLoss = G4PhysicsTableHelper::PreparePhysicsTable(theRangeTableForLoss); >> 278 theInverseRangeTable = G4PhysicsTableHelper::PreparePhysicsTable(theInverseRangeTable); >> 279 } >> 280 theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable); >> 281 if (nSCoffRegions) >> 282 theSubLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theSubLambdaTable); >> 283 } 249 284 250 G4double initialCharge = particle->GetPDGCha 285 G4double initialCharge = particle->GetPDGCharge(); 251 G4double initialMass = particle->GetPDGMas 286 G4double initialMass = particle->GetPDGMass(); >> 287 chargeSquare = initialCharge*initialCharge/(eplus*eplus); >> 288 chargeSqRatio = 1.0; >> 289 massRatio = 1.0; >> 290 reduceFactor = 1.0; 252 291 253 theParameters->FillStepFunction(particle, th << 292 if (baseParticle) { 254 << 293 massRatio = (baseParticle->GetPDGMass())/initialMass; 255 // parameters for scaling from the base part << 256 if (nullptr != baseParticle) { << 257 massRatio = (baseParticle->GetPDGMass() << 258 logMassRatio = G4Log(massRatio); << 259 G4double q = initialCharge/baseParticle->G 294 G4double q = initialCharge/baseParticle->GetPDGCharge(); 260 chargeSqRatio = q*q; 295 chargeSqRatio = q*q; 261 if(chargeSqRatio > 0.0) { reduceFactor = 1 << 296 reduceFactor = 1.0/(chargeSqRatio*massRatio); 262 } 297 } 263 lowestKinEnergy = (initialMass < CLHEP::MeV) << 264 ? theParameters->LowestElectronEnergy() << 265 : theParameters->LowestMuHadEnergy(); << 266 298 267 // Tables preparation << 299 theCuts = modelManager->Initialise(particle, secondaryParticle, minSubRange, verboseLevel); 268 if (isMaster && nullptr == baseParticle) { << 269 if(nullptr == theData) { theData = new G4E << 270 300 271 if(nullptr != theDEDXTable && isIonisation << 301 // Sub Cutoff Regime 272 if(nullptr != theIonisationTable && theD << 302 273 theData->CleanTable(0); << 303 idxSCoffRegions.clear(); 274 theDEDXTable = theIonisationTable; << 304 275 theIonisationTable = nullptr; << 305 const G4ProductionCutsTable* theCoupleTable= 276 } << 306 G4ProductionCutsTable::GetProductionCutsTable(); 277 } << 307 size_t numOfCouples = theCoupleTable->GetTableSize(); 278 << 308 279 theDEDXTable = theData->MakeTable(theDEDXT << 309 if (nSCoffRegions) { 280 bld->InitialiseBaseMaterials(theDEDXTable) << 310 const G4DataVector* theSubCuts = modelManager->SubCutoff(); 281 theData->UpdateTable(theIonisationTable, 1 << 311 282 << 312 for (G4int i=0; i<nSCoffRegions; i++) { 283 if (theParameters->BuildCSDARange()) { << 313 scoffProcessors[i]->Initialise(particle, secondaryParticle, theCuts, theSubCuts); 284 theDEDXunRestrictedTable = theData->Make << 285 if(isIonisation) { theCSDARangeTable = t << 286 } << 287 << 288 theLambdaTable = theData->MakeTable(4); << 289 if(isIonisation) { << 290 theRangeTableForLoss = theData->MakeTabl << 291 theInverseRangeTable = theData->MakeTabl << 292 } 314 } 293 } << 315 for (size_t j=0; j<numOfCouples; j++) { 294 316 295 // forced biasing << 317 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(j); 296 if(nullptr != biasManager) { << 318 const G4ProductionCuts* pcuts = couple->GetProductionCuts(); 297 biasManager->Initialise(part,GetProcessNam << 319 G4int reg = nSCoffRegions; 298 biasFlag = false; << 320 do {reg--;} while (reg && pcuts != (scoffRegions[reg]->GetProductionCuts())); 299 } << 321 idxSCoffRegions.push_back(reg); 300 baseMat = bld->GetBaseMaterialFlag(); << 301 numberOfModels = modelManager->NumberOfModel << 302 currentModel = modelManager->GetModel(0); << 303 G4EmTableUtil::UpdateModels(this, modelManag << 304 numberOfModels, << 305 mainSecondaries, << 306 theParameters->U << 307 theCuts = modelManager->Initialise(particle, << 308 verboseLe << 309 // subcut processor << 310 if(isIonisation) { << 311 subcutProducer = lManager->SubCutProducer( << 312 } << 313 if(1 == nSCoffRegions) { << 314 if((*scoffRegions)[0]->GetName() == "Defau << 315 delete scoffRegions; << 316 scoffRegions = nullptr; << 317 nSCoffRegions = 0; << 318 } 322 } 319 } 323 } 320 324 321 if(1 < verboseLevel) { << 325 lManager->EnergyLossProcessIsInitialised(particle, this); 322 G4cout << "G4VEnergyLossProcess::PrepearPh << 326 323 << " for " << GetProcessName() << " << 327 if (0 < verboseLevel) { 324 << " isIon= " << isIon << " spline= << 328 G4cout << "G4VEnergyLossProcess::Initialise() is done " 325 if(baseParticle) { << 329 << " chargeSqRatio= " << chargeSqRatio 326 G4cout << "; base: " << baseParticle->Ge << 327 } << 328 G4cout << G4endl; << 329 G4cout << " chargeSqRatio= " << chargeSqRa << 330 << " massRatio= " << massRatio 330 << " massRatio= " << massRatio 331 << " reduceFactor= " << reduceFacto 331 << " reduceFactor= " << reduceFactor << G4endl; 332 if (nSCoffRegions > 0) { << 332 if (nSCoffRegions) { 333 G4cout << " SubCut secondary production << 333 G4cout << " SubCutoff Regime is ON for regions: " << G4endl; 334 for (G4int i=0; i<nSCoffRegions; ++i) { << 334 for (G4int i=0; i<nSCoffRegions; i++) { 335 const G4Region* r = (*scoffRegions)[i] << 335 const G4Region* r = scoffRegions[i]; 336 G4cout << " " << r->GetName( << 336 G4cout << " " << r->GetName() << G4endl; 337 } 337 } 338 } else if(nullptr != subcutProducer) { << 339 G4cout << " SubCut secondary production << 340 } 338 } 341 } 339 } 342 } 340 } 343 341 344 //....oooOO0OOooo........oooOO0OOooo........oo 342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 345 343 346 void G4VEnergyLossProcess::BuildPhysicsTable(c 344 void G4VEnergyLossProcess::BuildPhysicsTable(const G4ParticleDefinition& part) 347 { 345 { 348 if(1 < verboseLevel) { << 346 if(0 < verboseLevel) { >> 347 // G4cout << "========================================================" << G4endl; 349 G4cout << "### G4VEnergyLossProcess::Build 348 G4cout << "### G4VEnergyLossProcess::BuildPhysicsTable() for " 350 << GetProcessName() 349 << GetProcessName() 351 << " and particle " << part.GetPart 350 << " and particle " << part.GetParticleName() 352 << "; the first particle " << parti << 351 << "; local: " << particle->GetParticleName(); 353 if(baseParticle) { << 352 if(baseParticle) G4cout << "; base: " << baseParticle->GetParticleName(); 354 G4cout << "; base: " << baseParticle->Ge << 355 } << 356 G4cout << G4endl; 353 G4cout << G4endl; 357 G4cout << " TablesAreBuilt= " << tables << 358 << " spline=" << spline << " ptr: " << 359 } 354 } 360 355 361 if(&part == particle) { << 356 if(!tablesAreBuilt && &part == particle) 362 if(isMaster) { << 357 G4LossTableManager::Instance()->BuildPhysicsTable(particle, this); 363 lManager->BuildPhysicsTable(particle, th << 364 << 365 } else { << 366 const auto masterProcess = << 367 static_cast<const G4VEnergyLossProcess << 368 << 369 numberOfModels = modelManager->NumberOfM << 370 G4EmTableUtil::BuildLocalElossProcess(th << 371 pa << 372 tablesAreBuilt = true; << 373 baseMat = masterProcess->UseBaseMaterial << 374 lManager->LocalPhysicsTables(particle, t << 375 } << 376 << 377 // needs to be done only once << 378 safetyHelper->InitialiseHelper(); << 379 } << 380 // Added tracking cut to avoid tracking arti << 381 // and identified deexcitation flag << 382 if(isIonisation) { << 383 atomDeexcitation = lManager->AtomDeexcitat << 384 if(nullptr != atomDeexcitation) { << 385 if(atomDeexcitation->IsPIXEActive()) { u << 386 } << 387 } << 388 358 389 // protection against double printout << 359 if(-1 < verboseLevel && (&part == particle) && !baseParticle) PrintInfoDefinition(); 390 if(theParameters->IsPrintLocked()) { return; << 360 391 << 361 if(0 < verboseLevel) { 392 // explicitly defined printout by particle n << 393 G4String num = part.GetParticleName(); << 394 if(1 < verboseLevel || << 395 (0 < verboseLevel && (num == "e-" || << 396 num == "e+" || n << 397 num == "mu-" || n << 398 num == "pi+" || n << 399 num == "kaon+" || n << 400 num == "alpha" || n << 401 num == "GenericIon" << 402 StreamInfo(G4cout, part); << 403 } << 404 if(1 < verboseLevel) { << 405 G4cout << "### G4VEnergyLossProcess::Build 362 G4cout << "### G4VEnergyLossProcess::BuildPhysicsTable() done for " 406 << GetProcessName() 363 << GetProcessName() 407 << " and particle " << part.GetPart << 364 << " and particle " << part.GetParticleName() 408 if(isIonisation) { G4cout << " isIonisati << 365 << G4endl; 409 G4cout << " baseMat=" << baseMat << G4endl << 410 } 366 } 411 } 367 } 412 368 413 //....oooOO0OOooo........oooOO0OOooo........oo 369 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 414 370 415 G4PhysicsTable* G4VEnergyLossProcess::BuildDED << 371 void G4VEnergyLossProcess::AddEmModel(G4int order, G4VEmModel* p, G4VEmFluctuationModel* fluc, >> 372 const G4Region* region) 416 { 373 { 417 G4PhysicsTable* table = nullptr; << 374 modelManager->AddEmModel(order, p, fluc, region); 418 G4double emax = maxKinEnergy; << 419 G4int bin = nBins; << 420 << 421 if(fTotal == tType) { << 422 emax = maxKinEnergyCSDA; << 423 bin = nBinsCSDA; << 424 table = theDEDXunRestrictedTable; << 425 } else if(fRestricted == tType) { << 426 table = theDEDXTable; << 427 } else { << 428 G4cout << "G4VEnergyLossProcess::BuildDEDX << 429 << tType << G4endl; << 430 } << 431 if(1 < verboseLevel) { << 432 G4cout << "G4VEnergyLossProcess::BuildDEDX << 433 << " for " << GetProcessName() << 434 << " and " << particle->GetParticle << 435 << "spline=" << spline << G4endl; << 436 } << 437 if(nullptr == table) { return table; } << 438 << 439 G4LossTableBuilder* bld = lManager->GetTable << 440 G4EmTableUtil::BuildDEDXTable(this, particle << 441 table, minKinE << 442 verboseLevel, << 443 return table; << 444 } 375 } 445 376 446 //....oooOO0OOooo........oooOO0OOooo........oo 377 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 447 378 448 G4PhysicsTable* G4VEnergyLossProcess::BuildLam << 379 void G4VEnergyLossProcess::UpdateEmModel(const G4String& nam, G4double emin, G4double emax) 449 { 380 { 450 if(nullptr == theLambdaTable) { return theLa << 381 modelManager->UpdateEmModel(nam, emin, emax); 451 << 452 G4double scale = theParameters->MaxKinEnergy << 453 G4int nbin = << 454 theParameters->NumberOfBinsPerDecade()*G4l << 455 scale = nbin/G4Log(scale); << 456 << 457 G4LossTableBuilder* bld = lManager->GetTable << 458 G4EmTableUtil::BuildLambdaTable(this, partic << 459 bld, theLamb << 460 minKinEnergy << 461 verboseLevel << 462 return theLambdaTable; << 463 } 382 } 464 383 465 //....oooOO0OOooo........oooOO0OOooo........oo 384 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 466 385 467 void G4VEnergyLossProcess::StreamInfo(std::ost << 386 void G4VEnergyLossProcess::AddSubCutoffProcessor(G4VSubCutoffProcessor* p, 468 const G4ParticleDefinition& pa << 387 const G4Region* r) 469 { 388 { 470 G4String indent = (rst ? " " : ""); << 389 if( !p ) { 471 out << std::setprecision(6); << 390 G4cout << "G4VEnergyLossProcess::AddSubCutoffProcessor WARNING: no SubCutoffProcessor defined." 472 out << G4endl << indent << GetProcessName() << 391 << G4endl; 473 if (!rst) out << " for " << part.GetParticle << 392 return; 474 out << " XStype:" << fXSType << 475 << " SubType=" << GetProcessSubType() < << 476 << " dE/dx and range tables from " << 477 << G4BestUnit(minKinEnergy,"Energy") << 478 << " to " << G4BestUnit(maxKinEnergy,"En << 479 << " in " << nBins << " bins" << G4endl << 480 << " Lambda tables from threshold t << 481 << G4BestUnit(maxKinEnergy,"Energy") << 482 << ", " << theParameters->NumberOfBinsPe << 483 << " bins/decade, spline: " << spline << 484 << G4endl; << 485 if(nullptr != theRangeTableForLoss && isIoni << 486 out << " StepFunction=(" << dRoverRan << 487 << finalRange/mm << " mm)" << 488 << ", integ: " << fXSType << 489 << ", fluct: " << lossFluctuationFlag << 490 << ", linLossLim= " << linLossLimit << 491 << G4endl; << 492 } << 493 StreamProcessInfo(out); << 494 modelManager->DumpModelList(out, verboseLeve << 495 if(nullptr != theCSDARangeTable && isIonisat << 496 out << " CSDA range table up" << 497 << " to " << G4BestUnit(maxKinEnergyCS << 498 << " in " << nBinsCSDA << " bins" << G << 499 } << 500 if(nSCoffRegions>0 && isIonisation) { << 501 out << " Subcutoff sampling in " << n << 502 << " regions" << G4endl; << 503 } 393 } 504 if(2 < verboseLevel) { << 394 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 505 for(std::size_t i=0; i<7; ++i) { << 395 if (!r) r = regionStore->GetRegion("DefaultRegionForTheWorld", false); 506 auto ta = theData->Table(i); << 396 if (nSCoffRegions) { 507 out << " " << tnames[i] << " addres << 397 for (G4int i=0; i<nSCoffRegions; i++) { 508 if(nullptr != ta) { out << *ta << G4endl << 398 if (r == scoffRegions[i]) { >> 399 if ( scoffProcessors[i] ) delete scoffProcessors[i]; >> 400 scoffProcessors[i] = p; >> 401 return; >> 402 } 509 } 403 } 510 } 404 } >> 405 scoffProcessors.push_back(p); >> 406 scoffRegions.push_back(r); >> 407 nSCoffRegions++; 511 } 408 } 512 409 513 //....oooOO0OOooo........oooOO0OOooo........oo 410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 514 411 515 void G4VEnergyLossProcess::ActivateSubCutoff(c << 412 G4PhysicsTable* G4VEnergyLossProcess::BuildDEDXTable() 516 { 413 { 517 if(nullptr == scoffRegions) { << 414 518 scoffRegions = new std::vector<const G4Reg << 415 if(0 < verboseLevel) { >> 416 G4cout << "G4VEnergyLossProcess::BuildDEDXTable() for " >> 417 << GetProcessName() >> 418 << " and particle " << particle->GetParticleName() >> 419 << G4endl; 519 } 420 } 520 // the region is in the list << 421 521 if(!scoffRegions->empty()) { << 422 // Access to materials 522 for (auto & reg : *scoffRegions) { << 423 const G4ProductionCutsTable* theCoupleTable= 523 if (reg == r) { return; } << 424 G4ProductionCutsTable::GetProductionCutsTable(); 524 } << 425 size_t numOfCouples = theCoupleTable->GetTableSize(); >> 426 >> 427 if(0 < verboseLevel) { >> 428 G4cout << numOfCouples << " materials" >> 429 << " minKinEnergy= " << minKinEnergy >> 430 << " maxKinEnergy= " << maxKinEnergy >> 431 << G4endl; 525 } 432 } 526 // new region << 527 scoffRegions->push_back(r); << 528 ++nSCoffRegions; << 529 } << 530 433 531 //....oooOO0OOooo........oooOO0OOooo........oo << 434 for(size_t i=0; i<numOfCouples; i++) { 532 435 533 G4bool G4VEnergyLossProcess::IsRegionForCubcut << 436 if(1 < verboseLevel) 534 { << 437 G4cout << "G4VEnergyLossProcess::BuildDEDXVector flag= " << theDEDXTable->GetFlag(i) << G4endl; 535 if(0 == nSCoffRegions) { return true; } << 536 const G4Region* r = aTrack.GetVolume()->GetL << 537 for(auto & reg : *scoffRegions) { << 538 if(r == reg) { return true; } << 539 } << 540 return false; << 541 } << 542 438 543 //....oooOO0OOooo........oooOO0OOooo........oo << 439 if (theDEDXTable->GetFlag(i)) { 544 440 545 void G4VEnergyLossProcess::StartTracking(G4Tra << 441 // create physics vector and fill it 546 { << 442 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); 547 // reset parameters for the new track << 443 G4PhysicsVector* aVector = DEDXPhysicsVector(couple); 548 theNumberOfInteractionLengthLeft = -1.0; << 444 modelManager->FillDEDXVector(aVector, couple); 549 mfpKinEnergy = DBL_MAX; << 550 preStepLambda = 0.0; << 551 currentCouple = nullptr; << 552 445 553 // reset ion << 446 // Insert vector for this material into the table 554 if(isIon) { << 447 G4PhysicsTableHelper::SetPhysicsVector(theDEDXTable, i, aVector); 555 const G4double newmass = track->GetDefinit << 556 massRatio = (nullptr == baseParticle) ? CL << 557 : baseParticle->GetPDGMass()/newmass; << 558 logMassRatio = G4Log(massRatio); << 559 } << 560 // forced biasing only for primary particles << 561 if(nullptr != biasManager) { << 562 if(0 == track->GetParentID()) { << 563 biasFlag = true; << 564 biasManager->ResetForcedInteraction(); << 565 } 448 } 566 } 449 } 567 } << 568 << 569 //....oooOO0OOooo........oooOO0OOooo........oo << 570 450 571 G4double G4VEnergyLossProcess::AlongStepGetPhy << 451 if(0 < verboseLevel) { 572 const G4Track& tr << 452 G4cout << "G4VEnergyLossProcess::BuildDEDXTable(): table is built for " 573 G4GPILSelection* << 453 << particle->GetParticleName() 574 { << 454 << G4endl; 575 G4double x = DBL_MAX; << 455 if(2 < verboseLevel) G4cout << (*theDEDXTable) << G4endl; 576 *selection = aGPILSelection; << 577 if(isIonisation && currentModel->IsActive(pr << 578 GetScaledRangeForScaledEnergy(preStepScale << 579 x = (useCutAsFinalRange) ? std::min(finalR << 580 currentCouple->GetProductionCuts()->GetP << 581 x = (fRange > x) ? fRange*dRoverRange + x* << 582 : fRange; << 583 /* << 584 G4cout<<"AlongStepGPIL: " << GetProcessN << 585 << " fRange=" << fRange << " finR=" << finR << 586 */ << 587 } 456 } 588 return x; << 457 >> 458 return theDEDXTable; 589 } 459 } 590 460 591 //....oooOO0OOooo........oooOO0OOooo........oo 461 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 592 462 593 G4double G4VEnergyLossProcess::PostStepGetPhys << 463 G4PhysicsTable* G4VEnergyLossProcess::BuildDEDXTableForPreciseRange() 594 const G4Track& tr << 595 G4double previo << 596 G4ForceCondition* << 597 { 464 { 598 // condition is set to "Not Forced" << 599 *condition = NotForced; << 600 G4double x = DBL_MAX; << 601 465 602 // initialisation of material, mass, charge, << 466 if(0 < verboseLevel) { 603 // at the beginning of the step << 467 G4cout << "G4VEnergyLossProcess::BuildDEDXTableForPreciseRange() for " 604 DefineMaterial(track.GetMaterialCutsCouple() << 468 << GetProcessName() 605 preStepKinEnergy = track.GetKineticEne << 469 << " and particle " << particle->GetParticleName() 606 preStepScaledEnergy = preStepKinEnergy*ma << 470 << G4endl; 607 SelectModel(preStepScaledEnergy); << 471 } 608 472 609 if(!currentModel->IsActive(preStepScaledEner << 473 // Access to materials 610 theNumberOfInteractionLengthLeft = -1.0; << 474 const G4ProductionCutsTable* theCoupleTable= 611 mfpKinEnergy = DBL_MAX; << 475 G4ProductionCutsTable::GetProductionCutsTable(); 612 preStepLambda = 0.0; << 476 size_t numOfCouples = theCoupleTable->GetTableSize(); 613 currentInteractionLength = DBL_MAX; << 477 614 return x; << 478 if(0 < verboseLevel) { >> 479 G4cout << numOfCouples << " materials" >> 480 << " minKinEnergy= " << minKinEnergy >> 481 << " maxKinEnergy= " << maxKinEnergy >> 482 << G4endl; 615 } 483 } 616 484 617 // change effective charge of a charged part << 485 for(size_t i=0; i<numOfCouples; i++) { 618 if(isIon) { << 486 619 const G4double q2 = currentModel->ChargeSq << 487 if (theDEDXunRestrictedTable->GetFlag(i)) { 620 fFactor = q2*biasFactor; << 488 621 if(baseMat) { fFactor *= (*theDensityFacto << 489 // create physics vector and fill it 622 reduceFactor = 1.0/(fFactor*massRatio); << 490 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); 623 if (lossFluctuationFlag) { << 491 G4PhysicsVector* aVector = DEDXPhysicsVectorForPreciseRange(couple); 624 auto fluc = currentModel->GetModelOfFluc << 492 modelManager->FillDEDXVectorForPreciseRange(aVector, couple); 625 fluc->SetParticleAndCharge(track.GetDefi << 493 >> 494 // Insert vector for this material into the table >> 495 G4PhysicsTableHelper::SetPhysicsVector(theDEDXunRestrictedTable, i, aVector); 626 } 496 } 627 } 497 } 628 498 629 // forced biasing only for primary particles << 499 if(0 < verboseLevel) { 630 if(biasManager) { << 500 G4cout << "G4VEnergyLossProcess::BuildDEDXTableForPreciseRange(): table is built for " 631 if(0 == track.GetParentID() && biasFlag && << 501 << particle->GetParticleName() 632 biasManager->ForcedInteractionRegion((G << 502 << G4endl; 633 return biasManager->GetStepLimit((G4int) << 503 if(2 < verboseLevel) G4cout << (*theDEDXunRestrictedTable) << G4endl; 634 } << 635 } 504 } 636 505 637 ComputeLambdaForScaledEnergy(preStepScaledEn << 506 return theDEDXunRestrictedTable; 638 << 507 } 639 // zero cross section << 640 if(preStepLambda <= 0.0) { << 641 theNumberOfInteractionLengthLeft = -1.0; << 642 currentInteractionLength = DBL_MAX; << 643 } else { << 644 508 645 // non-zero cross section << 509 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 646 if (theNumberOfInteractionLengthLeft < 0.0 << 647 510 648 // beggining of tracking (or just after << 511 G4PhysicsTable* G4VEnergyLossProcess::BuildLambdaTable() 649 theNumberOfInteractionLengthLeft = -G4Lo << 512 { 650 theInitialNumberOfInteractionLength = th << 513 >> 514 if(0 < verboseLevel) { >> 515 G4cout << "G4VEnergyLossProcess::BuildLambdaTable() for process " >> 516 << GetProcessName() << " and particle " >> 517 << particle->GetParticleName() >> 518 << G4endl; >> 519 } 651 520 652 } else if(currentInteractionLength < DBL_M << 521 // Access to materials >> 522 const G4ProductionCutsTable* theCoupleTable= >> 523 G4ProductionCutsTable::GetProductionCutsTable(); >> 524 size_t numOfCouples = theCoupleTable->GetTableSize(); 653 525 654 // subtract NumberOfInteractionLengthLef << 526 for(size_t i=0; i<numOfCouples; i++) { 655 theNumberOfInteractionLengthLeft -= << 656 previousStepSize/currentInteractionLen << 657 527 658 theNumberOfInteractionLengthLeft = << 528 if (theLambdaTable->GetFlag(i)) { 659 std::max(theNumberOfInteractionLengthL << 529 660 } << 530 // create physics vector and fill it >> 531 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); >> 532 G4PhysicsVector* aVector = LambdaPhysicsVector(couple); >> 533 modelManager->FillLambdaVector(aVector, couple); 661 534 662 // new mean free path and step limit << 535 // Insert vector for this material into the table 663 currentInteractionLength = 1.0/preStepLamb << 536 G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector); 664 x = theNumberOfInteractionLengthLeft * cur << 537 } 665 } 538 } 666 #ifdef G4VERBOSE << 539 667 if (verboseLevel>2) { << 540 if(0 < verboseLevel) { 668 G4cout << "G4VEnergyLossProcess::PostStepG << 541 G4cout << "Lambda table is built for " 669 G4cout << "[ " << GetProcessName() << "]" << 542 << particle->GetParticleName() 670 G4cout << " for " << track.GetDefinition() << 543 << G4endl; 671 << " in Material " << currentMate << 672 << " Ekin(MeV)= " << preStepKinEner << 673 << " track material: " << track.Get << 674 <<G4endl; << 675 G4cout << "MeanFreePath = " << currentInte << 676 << "InteractionLength= " << x/cm << << 677 } 544 } 678 #endif << 545 679 return x; << 546 return theLambdaTable; 680 } 547 } 681 548 682 //....oooOO0OOooo........oooOO0OOooo........oo 549 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 683 550 684 void << 551 G4PhysicsTable* G4VEnergyLossProcess::BuildLambdaSubTable() 685 G4VEnergyLossProcess::ComputeLambdaForScaledEn << 686 { 552 { 687 // cross section increased with energy << 553 if(0 < verboseLevel) { 688 if(fXSType == fEmIncreasing) { << 554 G4cout << "G4VEnergyLossProcess::BuildLambdaSubTable() for process " 689 if(e*invLambdaFactor < mfpKinEnergy) { << 555 << GetProcessName() << " and particle " 690 preStepLambda = GetLambdaForScaledEnergy << 556 << particle->GetParticleName() << G4endl; 691 mfpKinEnergy = (preStepLambda > 0.0) ? e << 557 } 692 } << 693 558 694 // cross section has one peak << 559 // Access to materials 695 } else if(fXSType == fEmOnePeak) { << 560 const G4ProductionCutsTable* theCoupleTable= 696 const G4double epeak = (*theEnergyOfCrossS << 561 G4ProductionCutsTable::GetProductionCutsTable(); 697 if(e <= epeak) { << 562 size_t numOfCouples = theCoupleTable->GetTableSize(); 698 if(e*invLambdaFactor < mfpKinEnergy) { << 563 699 preStepLambda = GetLambdaForScaledEner << 564 for(size_t i=0; i<numOfCouples; i++) { 700 mfpKinEnergy = (preStepLambda > 0.0) ? << 565 701 } << 566 if (theSubLambdaTable->GetFlag(i)) { 702 } else if(e < mfpKinEnergy) { << 567 703 const G4double e1 = std::max(epeak, e*la << 568 // create physics vector and fill it 704 mfpKinEnergy = e1; << 569 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); 705 preStepLambda = GetLambdaForScaledEnergy << 570 G4PhysicsVector* aVector = SubLambdaPhysicsVector(couple); 706 } << 571 modelManager->FillSubLambdaVector(aVector, couple); 707 << 572 708 // cross section has more than one peaks << 573 // Insert vector for this material into the table 709 } else if(fXSType == fEmTwoPeaks) { << 574 G4PhysicsTableHelper::SetPhysicsVector(theSubLambdaTable, i, aVector); 710 G4TwoPeaksXS* xs = (*fXSpeaks)[basedCouple << 711 const G4double e1peak = xs->e1peak; << 712 << 713 // below the 1st peak << 714 if(e <= e1peak) { << 715 if(e*invLambdaFactor < mfpKinEnergy) { << 716 preStepLambda = GetLambdaForScaledEner << 717 mfpKinEnergy = (preStepLambda > 0.0) ? << 718 } << 719 return; << 720 } << 721 const G4double e1deep = xs->e1deep; << 722 // above the 1st peak, below the deep << 723 if(e <= e1deep) { << 724 if(mfpKinEnergy >= e1deep || e <= mfpKin << 725 const G4double e1 = std::max(e1peak, e << 726 mfpKinEnergy = e1; << 727 preStepLambda = GetLambdaForScaledEner << 728 } << 729 return; << 730 } << 731 const G4double e2peak = xs->e2peak; << 732 // above the deep, below 2nd peak << 733 if(e <= e2peak) { << 734 if(e*invLambdaFactor < mfpKinEnergy) { << 735 mfpKinEnergy = e; << 736 preStepLambda = GetLambdaForScaledEner << 737 } << 738 return; << 739 } << 740 const G4double e2deep = xs->e2deep; << 741 // above the 2nd peak, below the deep << 742 if(e <= e2deep) { << 743 if(mfpKinEnergy >= e2deep || e <= mfpKin << 744 const G4double e1 = std::max(e2peak, e << 745 mfpKinEnergy = e1; << 746 preStepLambda = GetLambdaForScaledEner << 747 } << 748 return; << 749 } << 750 const G4double e3peak = xs->e3peak; << 751 // above the deep, below 3d peak << 752 if(e <= e3peak) { << 753 if(e*invLambdaFactor < mfpKinEnergy) { << 754 mfpKinEnergy = e; << 755 preStepLambda = GetLambdaForScaledEner << 756 } << 757 return; << 758 } << 759 // above 3d peak << 760 if(e <= mfpKinEnergy) { << 761 const G4double e1 = std::max(e3peak, e*l << 762 mfpKinEnergy = e1; << 763 preStepLambda = GetLambdaForScaledEnergy << 764 } 575 } 765 // integral method is not used << 766 } else { << 767 preStepLambda = GetLambdaForScaledEnergy(e << 768 } 576 } >> 577 >> 578 if(0 < verboseLevel) { >> 579 G4cout << "Table is built for " >> 580 << particle->GetParticleName() >> 581 << G4endl; >> 582 } >> 583 >> 584 return theSubLambdaTable; 769 } 585 } 770 586 >> 587 771 //....oooOO0OOooo........oooOO0OOooo........oo 588 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 772 589 773 G4VParticleChange* G4VEnergyLossProcess::Along 590 G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track, 774 591 const G4Step& step) 775 { 592 { 776 fParticleChange.InitializeForAlongStep(track 593 fParticleChange.InitializeForAlongStep(track); 777 // The process has range table - calculate e 594 // The process has range table - calculate energy loss 778 if(!isIonisation || !currentModel->IsActive( << 595 if(!theRangeTableForLoss) return &fParticleChange; 779 return &fParticleChange; << 780 } << 781 596 >> 597 // Get the actual (true) Step length 782 G4double length = step.GetStepLength(); 598 G4double length = step.GetStepLength(); 783 G4double eloss = 0.0; 599 G4double eloss = 0.0; 784 << 600 785 /* << 601 /* 786 if(-1 < verboseLevel) { 602 if(-1 < verboseLevel) { 787 const G4ParticleDefinition* d = track.GetP << 603 const G4ParticleDefinition* d = track.GetDefinition(); 788 G4cout << "AlongStepDoIt for " 604 G4cout << "AlongStepDoIt for " 789 << GetProcessName() << " and partic << 605 << GetProcessName() << " and particle " 790 << " eScaled(MeV)=" << preStepScal << 606 << d->GetParticleName() 791 << " range(mm)=" << fRange/mm << " << 607 << " eScaled(MeV)= " << preStepScaledEnergy/MeV 792 << " rf=" << reduceFactor << " q^ << 608 << " slim(mm)= " << fRange/mm 793 << " md=" << d->GetPDGMass() << " << 609 << " s(mm)= " << length/mm 794 << " " << track.GetMaterial()->Get << 610 << " q^2= " << chargeSqRatio >> 611 << " md= " << d->GetPDGMass() >> 612 << G4endl; 795 } 613 } 796 */ 614 */ 797 const G4DynamicParticle* dynParticle = track << 798 615 799 // define new weight for primary and seconda << 616 // stopping 800 G4double weight = fParticleChange.GetParentW << 617 if (length >= fRange) { 801 if(weightFlag) { << 802 weight /= biasFactor; << 803 fParticleChange.ProposeWeight(weight); << 804 } << 805 << 806 // stopping, check actual range and kinetic << 807 if (length >= fRange || preStepKinEnergy <= << 808 eloss = preStepKinEnergy; 618 eloss = preStepKinEnergy; 809 if (useDeexcitation) { << 810 atomDeexcitation->AlongStepDeexcitation( << 811 << 812 if(scTracks.size() > 0) { FillSecondarie << 813 eloss = std::max(eloss, 0.0); << 814 } << 815 fParticleChange.SetProposedKineticEnergy(0 << 816 fParticleChange.ProposeLocalEnergyDeposit( << 817 return &fParticleChange; << 818 } << 819 // zero step length with non-zero range << 820 if(length <= 0.0) { return &fParticleChange; << 821 619 822 // Short step 620 // Short step 823 eloss = length*GetDEDXForScaledEnergy(preSte << 621 } else if( length <= linLossLimit * fRange ) { 824 LogSca << 622 eloss = GetDEDXForScaledEnergy(preStepScaledEnergy)*length; 825 /* << 623 826 G4cout << "##### Short STEP: eloss= " << elo << 827 << " Escaled=" << preStepScaledEnergy << 828 << " R=" << fRange << 829 << " L=" << length << 830 << " fFactor=" << fFactor << " minE=" << mi << 831 << " idxBase=" << basedCoupleIndex << G4end << 832 */ << 833 // Long step 624 // Long step 834 if(eloss > preStepKinEnergy*linLossLimit) { << 625 } else { >> 626 G4double r = GetScaledRangeForScaledEnergy(preStepScaledEnergy); >> 627 G4double x = r - length/reduceFactor; >> 628 if(x < 0.0) { >> 629 G4cout << "WARNING! G4VEnergyLossProcess::AlongStepDoIt: x= " << x >> 630 << " for eScaled(MeV)= " << preStepScaledEnergy/MeV >> 631 << " step(mm)= " << length/mm >> 632 << " for " << track.GetDefinition()->GetParticleName() >> 633 << G4endl; >> 634 x = 0.0; >> 635 } >> 636 eloss = (ScaledKinEnergyForLoss(r) - ScaledKinEnergyForLoss(x))/massRatio; 835 637 836 const G4double x = (fRange - length)/reduc << 837 const G4double de = preStepKinEnergy - Sca << 838 if(de > 0.0) { eloss = de; } << 839 /* 638 /* 840 if(-1 < verboseLevel) << 639 if(-1 < verboseLevel) { 841 G4cout << " Long STEP: rPre(mm)=" << 640 G4cout << "Long STEP: rPre(mm)= " << r/mm 842 << GetScaledRangeForScaledEnergy( << 641 << " rPost(mm)= " << x/mm 843 << " x(mm)=" << x/mm << 642 << " ePre(MeV)= " << preStepScaledEnergy/MeV 844 << " eloss(MeV)=" << eloss/MeV << 643 << " eloss(MeV)= " << eloss/MeV 845 << " rFactor=" << reduceFactor << 644 << " eloss0(MeV)= " 846 << " massRatio=" << massRatio << 645 << GetDEDXForScaledEnergy(preStepScaledEnergy)*length/MeV 847 << G4endl; 646 << G4endl; >> 647 } 848 */ 648 */ >> 649 849 } 650 } 850 651 >> 652 const G4DynamicParticle* dynParticle = track.GetDynamicParticle(); >> 653 G4double tmax = MaxSecondaryEnergy(dynParticle); >> 654 tmax = std::min(tmax,(*theCuts)[currentMaterialIndex]); 851 /* 655 /* 852 if(-1 < verboseLevel ) { << 656 G4double eloss0 = eloss; >> 657 if(-1 < verboseLevel) { 853 G4cout << "Before fluct: eloss(MeV)= " << 658 G4cout << "Before fluct: eloss(MeV)= " << eloss/MeV >> 659 << " tmax= " << tmax 854 << " e-eloss= " << preStepKinEnergy 660 << " e-eloss= " << preStepKinEnergy-eloss 855 << " step(mm)= " << length/mm << " << 661 << G4endl; 856 << " fluct= " << lossFluctuationFla << 857 } 662 } 858 */ 663 */ 859 664 860 const G4double cut = (*theCuts)[currentCoupl << 665 // Sample fluctuations 861 G4double esec = 0.0; << 666 if (lossFluctuationFlag && eloss + lowestKinEnergy <= preStepKinEnergy) { 862 667 863 // Corrections, which cannot be tabulated << 668 eloss = modelManager->SampleFluctuations(currentMaterial, dynParticle, 864 if(isIon) { << 669 tmax, length, eloss, preStepScaledEnergy, 865 currentModel->CorrectionsAlongStep(current << 670 currentMaterialIndex); 866 length, << 671 } 867 eloss = std::max(eloss, 0.0); << 672 /* >> 673 if(-1 < verboseLevel) { >> 674 G4cout << "After fluct: eloss(MeV)= " << eloss/MeV >> 675 << " fluc= " << (eloss-eloss0)/MeV >> 676 << " currentChargeSquare= " << chargeSquare >> 677 << " massRatio= " << massRatio >> 678 << G4endl; 868 } 679 } >> 680 */ 869 681 870 // Sample fluctuations if not full energy lo << 682 G4double finalT = preStepKinEnergy - eloss; 871 if(eloss >= preStepKinEnergy) { << 683 if (finalT <= lowestKinEnergy) finalT = 0.0; 872 eloss = preStepKinEnergy; << 684 eloss = preStepKinEnergy-finalT; 873 685 874 } else if (lossFluctuationFlag) { << 686 fParticleChange.SetProposedKineticEnergy(finalT); 875 const G4double tmax = currentModel->MaxSec << 876 const G4double tcut = std::min(cut, tmax); << 877 G4VEmFluctuationModel* fluc = currentModel << 878 eloss = fluc->SampleFluctuations(currentCo << 879 tcut, tma << 880 /* << 881 if(-1 < verboseLevel) << 882 G4cout << "After fluct: eloss(MeV)= " << << 883 << " fluc= " << (eloss-eloss0)/Me << 884 << " ChargeSqRatio= " << chargeSq << 885 << " massRatio= " << massRatio << << 886 */ << 887 } << 888 687 889 // deexcitation << 688 // Subcutoff and/or deexcitation 890 if (useDeexcitation) { << 689 std::vector<G4Track*>* newp = 891 G4double esecfluo = preStepKinEnergy; << 690 SecondariesAlongStep(step, tmax, eloss, preStepScaledEnergy); 892 G4double de = esecfluo; << 691 893 atomDeexcitation->AlongStepDeexcitation(sc << 692 if(newp) { 894 de << 693 895 << 694 G4int n = newp->size(); 896 // sum of de-excitation energies << 695 if(n > 0) { 897 esecfluo -= de; << 696 fParticleChange.SetNumberOfSecondaries(n); 898 << 697 G4Track* t; 899 // subtracted from energy loss << 698 G4double e; 900 if(eloss >= esecfluo) { << 699 for (G4int i=0; i<n; i++) { 901 esec += esecfluo; << 700 t = (*newp)[i]; 902 eloss -= esecfluo; << 701 e = t->GetKineticEnergy(); 903 } else { << 702 const G4ParticleDefinition* pd = t->GetDefinition(); 904 esec += esecfluo; << 703 if (pd != G4Positron::Positron() ) e += electron_mass_c2; 905 eloss = 0.0; << 704 if (e > eloss) e = eloss; 906 } << 907 } << 908 if(nullptr != subcutProducer && IsRegionForC << 909 subcutProducer->SampleSecondaries(step, sc << 910 } << 911 // secondaries from atomic de-excitation and << 912 if(!scTracks.empty()) { FillSecondariesAlong << 913 705 914 // Energy balance << 706 eloss -= e; 915 G4double finalT = preStepKinEnergy - eloss - << 707 pParticleChange->AddSecondary(t); 916 if (finalT <= lowestKinEnergy) { << 708 } 917 eloss += finalT; << 709 } 918 finalT = 0.0; << 710 delete newp; 919 } else if(isIon) { << 920 fParticleChange.SetProposedCharge( << 921 currentModel->GetParticleCharge(track.Ge << 922 currentM << 923 } 711 } 924 eloss = std::max(eloss, 0.0); << 925 << 926 fParticleChange.SetProposedKineticEnergy(fin << 927 fParticleChange.ProposeLocalEnergyDeposit(el << 928 /* 712 /* 929 if(-1 < verboseLevel) { 713 if(-1 < verboseLevel) { 930 G4double del = finalT + eloss + esec - pre << 931 G4cout << "Final value eloss(MeV)= " << el 714 G4cout << "Final value eloss(MeV)= " << eloss/MeV 932 << " preStepKinEnergy= " << preStep 715 << " preStepKinEnergy= " << preStepKinEnergy 933 << " postStepKinEnergy= " << finalT 716 << " postStepKinEnergy= " << finalT 934 << " de(keV)= " << del/keV << 935 << " lossFlag= " << lossFluctuation 717 << " lossFlag= " << lossFluctuationFlag 936 << " status= " << track.GetTrackSt << 937 << G4endl; 718 << G4endl; 938 } 719 } 939 */ 720 */ >> 721 fParticleChange.ProposeLocalEnergyDeposit(eloss); >> 722 940 return &fParticleChange; 723 return &fParticleChange; 941 } 724 } 942 725 943 //....oooOO0OOooo........oooOO0OOooo........oo 726 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 944 727 945 void G4VEnergyLossProcess::FillSecondariesAlon << 728 G4VParticleChange* G4VEnergyLossProcess::PostStepDoIt(const G4Track& track, >> 729 const G4Step& step) 946 { 730 { 947 const std::size_t n0 = scTracks.size(); << 731 fParticleChange.InitializeForPostStep(track); 948 G4double weight = wt; << 732 G4double finalT = track.GetKineticEnergy(); 949 // weight may be changed by biasing manager << 733 G4double postStepScaledEnergy = finalT*massRatio; 950 if(biasManager) { << 734 951 if(biasManager->SecondaryBiasingRegion((G4 << 735 // Integral approach 952 weight *= << 736 if (integral) { 953 biasManager->ApplySecondaryBiasing(scT << 737 G4double lx = GetLambdaForScaledEnergy(postStepScaledEnergy); 954 } << 738 if(preStepLambda<lx && 0 < verboseLevel) { 955 } << 739 G4cout << "WARING: for " << particle->GetParticleName() 956 << 740 << " and " << GetProcessName() 957 // fill secondaries << 741 << " E(MeV)= " << finalT/MeV 958 const std::size_t n = scTracks.size(); << 742 << " preLambda= " << preStepLambda << " < " << lx << " (postLambda) " 959 fParticleChange.SetNumberOfSecondaries((G4in << 743 << G4endl; 960 << 744 } 961 for(std::size_t i=0; i<n; ++i) { << 745 if(preStepLambda*G4UniformRand() > lx) 962 G4Track* t = scTracks[i]; << 746 return G4VContinuousDiscreteProcess::PostStepDoIt(track,step); 963 if(nullptr != t) { << 747 } 964 t->SetWeight(weight); << 748 965 pParticleChange->AddSecondary(t); << 749 G4VEmModel* currentModel = SelectModel(postStepScaledEnergy); 966 G4int pdg = t->GetDefinition()->GetPDGEn << 750 G4double tcut = (*theCuts)[currentMaterialIndex]; 967 if (i < n0) { << 751 const G4DynamicParticle* dynParticle = track.GetDynamicParticle(); 968 if (pdg == 22) { << 752 G4double tmax = currentModel->MaxSecondaryEnergy(dynParticle); 969 t->SetCreatorModelID(gpixeID); << 753 970 } else if (pdg == 11) { << 754 if (tcut < tmax) 971 t->SetCreatorModelID(epixeID); << 755 SecondariesPostStep(currentModel,currentCouple,dynParticle,tcut,finalT); 972 } else { << 756 973 t->SetCreatorModelID(biasID); << 757 /* 974 } << 758 if(-1 < verboseLevel) { 975 } else { << 759 const G4ParticleDefinition* pd = dynParticle->GetDefinition(); 976 t->SetCreatorModelID(biasID); << 760 G4cout << GetProcessName() 977 } << 761 << "::PostStepDoIt: Sample secondary; E= " << finalT/MeV >> 762 << " MeV; model= (" << currentModel->LowEnergyLimit(pd) >> 763 << ", " << currentModel->HighEnergyLimit(pd) << ")" >> 764 << " preStepLambda= " << preStepLambda >> 765 << G4endl; >> 766 } >> 767 */ >> 768 // if (finalT <= 0.0) finalT = 0.0; >> 769 >> 770 if (finalT <= lowestKinEnergy) { >> 771 fParticleChange.SetProposedKineticEnergy(0.0); >> 772 return &fParticleChange; >> 773 } >> 774 >> 775 fParticleChange.SetProposedKineticEnergy(finalT); >> 776 >> 777 return G4VContinuousDiscreteProcess::PostStepDoIt(track,step); >> 778 } >> 779 >> 780 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 781 >> 782 void G4VEnergyLossProcess::PrintInfoDefinition() >> 783 { >> 784 if(-1 < verboseLevel) { >> 785 G4cout << G4endl << GetProcessName() << ": tables are built for " >> 786 << particle->GetParticleName() >> 787 << G4endl >> 788 << " dE/dx and range tables from " >> 789 << G4BestUnit(minKinEnergy,"Energy") >> 790 << " to " << G4BestUnit(maxKinEnergy,"Energy") >> 791 << " in " << nDEDXBins << " bins." << G4endl >> 792 << " Lambda tables from threshold to " >> 793 << G4BestUnit(maxKinEnergy,"Energy") >> 794 << " in " << nLambdaBins << " bins." >> 795 << G4endl; >> 796 if(theRangeTableForLoss) { >> 797 G4cout << " Step function: finalRange(mm)= " << finalRange/mm >> 798 << ", dRoverRange= " << dRoverRange >> 799 << ", integral: " << integral >> 800 << G4endl; >> 801 } >> 802 if(thePreciseRangeTable) { >> 803 G4cout << " Precise range table up" >> 804 << " to " << G4BestUnit(maxKinEnergyForRange,"Energy") >> 805 << " in " << nDEDXBinsForRange << " bins." << G4endl; >> 806 } >> 807 >> 808 if(2 < verboseLevel) { >> 809 G4cout << "DEDXTable address= " << theDEDXTable << G4endl; >> 810 if(theDEDXTable) G4cout << (*theDEDXTable) << G4endl; >> 811 G4cout << "non restricted DEDXTable address= " << theDEDXunRestrictedTable << G4endl; >> 812 if(theDEDXunRestrictedTable) G4cout << (*theDEDXunRestrictedTable) << G4endl; >> 813 G4cout << "PreciseRangeTable address= " << thePreciseRangeTable << G4endl; >> 814 if(thePreciseRangeTable) G4cout << (*thePreciseRangeTable) << G4endl; >> 815 G4cout << "RangeTableForLoss address= " << theRangeTableForLoss << G4endl; >> 816 if(theRangeTableForLoss) G4cout << (*theRangeTableForLoss) << G4endl; >> 817 G4cout << "InverseRangeTable address= " << theInverseRangeTable << G4endl; >> 818 if(theInverseRangeTable) G4cout << (*theInverseRangeTable) << G4endl; >> 819 G4cout << "LambdaTable address= " << theLambdaTable << G4endl; >> 820 if(theLambdaTable) G4cout << (*theLambdaTable) << G4endl; >> 821 G4cout << "SubLambdaTable address= " << theSubLambdaTable << G4endl; >> 822 if(theSubLambdaTable) G4cout << (*theSubLambdaTable) << G4endl; 978 } 823 } 979 } 824 } 980 scTracks.clear(); << 981 } 825 } 982 826 983 //....oooOO0OOooo........oooOO0OOooo........oo 827 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 984 828 985 G4VParticleChange* G4VEnergyLossProcess::PostS << 829 void G4VEnergyLossProcess::SetDEDXTable(G4PhysicsTable* p) 986 << 987 { 830 { 988 // clear number of interaction lengths in an << 831 if(theDEDXTable != p) theDEDXTable = p; 989 theNumberOfInteractionLengthLeft = -1.0; << 832 } 990 mfpKinEnergy = DBL_MAX; << 991 833 992 fParticleChange.InitializeForPostStep(track) << 834 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 993 const G4double finalT = track.GetKineticEner << 994 835 995 const G4double postStepScaledEnergy = finalT << 836 void G4VEnergyLossProcess::SetDEDXunRestrictedTable(G4PhysicsTable* p) 996 SelectModel(postStepScaledEnergy); << 837 { >> 838 if(theDEDXunRestrictedTable != p) theDEDXunRestrictedTable = p; >> 839 if(p) { >> 840 size_t n = p->length(); >> 841 G4PhysicsVector* pv = (*p)[0]; >> 842 G4double emax = maxKinEnergyForRange; >> 843 G4bool b; >> 844 theDEDXAtMaxEnergy = new G4double [n]; 997 845 998 if(!currentModel->IsActive(postStepScaledEne << 846 for (size_t i=0; i<n; i++) { 999 return &fParticleChange; << 847 pv = (*p)[i]; 1000 } << 848 G4double dedx = pv->GetValue(emax, b); 1001 /* << 849 theDEDXAtMaxEnergy[i] = dedx; 1002 if(1 < verboseLevel) { << 850 //G4cout << "i= " << i << " emax(MeV)= " << emax/MeV<< " dedx= " << dedx << G4endl; 1003 G4cout<<GetProcessName()<<" PostStepDoIt: << 1004 } << 1005 */ << 1006 // forced process - should happen only once << 1007 if(biasFlag) { << 1008 if(biasManager->ForcedInteractionRegion(( << 1009 biasFlag = false; << 1010 } 851 } 1011 } 852 } 1012 const G4DynamicParticle* dp = track.GetDyna << 853 } 1013 854 1014 // Integral approach << 855 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1015 if (fXSType != fEmNoIntegral) { << 856 1016 const G4double logFinalT = dp->GetLogKine << 857 void G4VEnergyLossProcess::SetPreciseRangeTable(G4PhysicsTable* p) 1017 G4double lx = GetLambdaForScaledEnergy(po << 858 { 1018 lo << 859 if(thePreciseRangeTable != p) thePreciseRangeTable = p; 1019 lx = std::max(lx, 0.0); << 860 1020 << 861 if(p) { 1021 // if both lg and lx are zero then no int << 862 size_t n = p->length(); 1022 if(preStepLambda*G4UniformRand() >= lx) { << 863 G4PhysicsVector* pv = (*p)[0]; 1023 return &fParticleChange; << 864 G4double emax = maxKinEnergyForRange; >> 865 G4bool b; >> 866 theRangeAtMaxEnergy = new G4double [n]; >> 867 >> 868 for (size_t i=0; i<n; i++) { >> 869 pv = (*p)[i]; >> 870 G4double r2 = pv->GetValue(emax, b); >> 871 theRangeAtMaxEnergy[i] = r2; >> 872 //G4cout << "i= " << i << " e2(MeV)= " << emax/MeV << " r2= " << r2<< G4endl; 1024 } 873 } 1025 } 874 } >> 875 } 1026 876 1027 // define new weight for primary and second << 877 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1028 G4double weight = fParticleChange.GetParent << 878 1029 if(weightFlag) { << 879 void G4VEnergyLossProcess::SetRangeTableForLoss(G4PhysicsTable* p) 1030 weight /= biasFactor; << 880 { 1031 fParticleChange.ProposeWeight(weight); << 881 if(theRangeTableForLoss != p) { 1032 } << 882 theRangeTableForLoss = p; 1033 << 883 if(0 < verboseLevel) { 1034 const G4double tcut = (*theCuts)[currentCou << 884 G4cout << "### Set Range table " << p << " for " << particle->GetParticleName() 1035 << 885 << " and process " << GetProcessName() << G4endl; 1036 // sample secondaries << 1037 secParticles.clear(); << 1038 currentModel->SampleSecondaries(&secParticl << 1039 << 1040 const G4int num0 = (G4int)secParticles.size << 1041 << 1042 // bremsstrahlung splitting or Russian roul << 1043 if(biasManager) { << 1044 if(biasManager->SecondaryBiasingRegion((G << 1045 G4double eloss = 0.0; << 1046 weight *= biasManager->ApplySecondaryBi << 1047 secPart << 1048 track, << 1049 &fParti << 1050 (G4int) << 1051 step.Ge << 1052 if(eloss > 0.0) { << 1053 eloss += fParticleChange.GetLocalEner << 1054 fParticleChange.ProposeLocalEnergyDep << 1055 } << 1056 } 886 } 1057 } 887 } >> 888 } 1058 889 1059 // save secondaries << 890 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1060 const G4int num = (G4int)secParticles.size( << 1061 if(num > 0) { << 1062 << 1063 fParticleChange.SetNumberOfSecondaries(nu << 1064 G4double time = track.GetGlobalTime(); << 1065 << 1066 G4int n1(0), n2(0); << 1067 if(num0 > mainSecondaries) { << 1068 currentModel->FillNumberOfSecondaries(n << 1069 } << 1070 << 1071 for (G4int i=0; i<num; ++i) { << 1072 if(nullptr != secParticles[i]) { << 1073 G4Track* t = new G4Track(secParticles << 1074 t->SetTouchableHandle(track.GetToucha << 1075 if (biasManager) { << 1076 t->SetWeight(weight * biasManager-> << 1077 } else { << 1078 t->SetWeight(weight); << 1079 } << 1080 if(i < num0) { << 1081 t->SetCreatorModelID(secID); << 1082 } else if(i < num0 + n1) { << 1083 t->SetCreatorModelID(tripletID); << 1084 } else { << 1085 t->SetCreatorModelID(biasID); << 1086 } << 1087 891 1088 //G4cout << "Secondary(post step) has << 892 void G4VEnergyLossProcess::SetSecondaryRangeTable(G4PhysicsTable* p) 1089 // << ", kenergy " << t->GetKin << 893 { 1090 // << " time= " << time/ns << " << 894 theSecondaryRangeTable = p; 1091 pParticleChange->AddSecondary(t); << 895 } 1092 } << 896 >> 897 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 898 >> 899 void G4VEnergyLossProcess::SetInverseRangeTable(G4PhysicsTable* p) >> 900 { >> 901 if(theInverseRangeTable != p) { >> 902 theInverseRangeTable = p; >> 903 if(0 < verboseLevel) { >> 904 G4cout << "### Set InverseRange table " << p << " for " << particle->GetParticleName() >> 905 << " and process " << GetProcessName() << G4endl; 1093 } 906 } 1094 } 907 } >> 908 } 1095 909 1096 if(0.0 == fParticleChange.GetProposedKineti << 910 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1097 fAlive == fParticleChange.GetTrackStatus << 911 1098 if(particle->GetProcessManager()->GetAtRe << 912 void G4VEnergyLossProcess::SetLambdaTable(G4PhysicsTable* p) 1099 { fParticleChange.ProposeTrackStatus << 913 { 1100 else { fParticleChange.ProposeTrackStatus << 914 if(1 < verboseLevel) { >> 915 G4cout << "### Set Lambda table " << p << " for " << particle->GetParticleName() >> 916 << " and process " << GetProcessName() << G4endl; 1101 } 917 } >> 918 if(theLambdaTable != p) theLambdaTable = p; >> 919 tablesAreBuilt = true; 1102 920 1103 /* << 921 if(p) { 1104 if(-1 < verboseLevel) { << 922 size_t n = p->length(); 1105 G4cout << "::PostStepDoIt: Sample seconda << 923 G4PhysicsVector* pv = (*p)[0]; 1106 << fParticleChange.GetProposedKineticEner << 924 size_t nb = pv->GetVectorLength(); 1107 << " MeV; model= (" << currentMode << 925 G4double emax = pv->GetLowEdgeEnergy(nb); 1108 << ", " << currentModel->HighEner << 926 G4double e, s, smax = 0.0; 1109 << " preStepLambda= " << preStepL << 927 theEnergyOfCrossSectionMax = new G4double [n]; 1110 << " dir= " << track.GetMomentumD << 928 theCrossSectionMax = new G4double [n]; 1111 << " status= " << track.GetTrackS << 929 G4bool b; 1112 << G4endl; << 930 >> 931 for (size_t i=0; i<n; i++) { >> 932 pv = (*p)[i]; >> 933 smax = 0.0; >> 934 for (size_t j=0; j<nb; j++) { >> 935 e = pv->GetLowEdgeEnergy(j); >> 936 s = pv->GetValue(e,b); >> 937 if(s > smax) { >> 938 smax = s; >> 939 emax = e; >> 940 } >> 941 } >> 942 theEnergyOfCrossSectionMax[i] = emax; >> 943 theCrossSectionMax[i] = smax; >> 944 if(1 < verboseLevel) { >> 945 G4cout << "For " << particle->GetParticleName() >> 946 << " Max CS at i= " << i << " emax(MeV)= " << emax/MeV >> 947 << " lambda= " << smax << G4endl; >> 948 } >> 949 } 1113 } 950 } 1114 */ << 1115 return &fParticleChange; << 1116 } 951 } 1117 952 1118 //....oooOO0OOooo........oooOO0OOooo........o 953 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1119 954 1120 G4bool G4VEnergyLossProcess::StorePhysicsTabl << 955 void G4VEnergyLossProcess::SetSubLambdaTable(G4PhysicsTable* p) 1121 const G4ParticleDefinition* part, cons << 1122 { 956 { 1123 if (!isMaster || nullptr != baseParticle || << 957 if(theSubLambdaTable != p) theSubLambdaTable = p; 1124 for(std::size_t i=0; i<7; ++i) { << 958 1125 // ionisation table only for ionisation p << 959 if (nSCoffRegions) { 1126 if (nullptr == theData->Table(i) || (!isI << 960 for (G4int i=0; i<nSCoffRegions; i++) { 1127 continue; << 961 scoffProcessors[i]->SetLambdaSubTable(theSubLambdaTable); 1128 } << 1129 if (-1 < verboseLevel) { << 1130 G4cout << "G4VEnergyLossProcess::StoreP << 1131 << " " << particle->GetParticleName() << 1132 << " " << GetProcessName() << 1133 << " " << tnames[i] << " " << theDat << 1134 } << 1135 if (!G4EmTableUtil::StoreTable(this, part << 1136 dir, tnames[i], verboseLevel, asci << 1137 return false; << 1138 } 962 } 1139 } 963 } 1140 return true; << 1141 } 964 } 1142 965 1143 //....oooOO0OOooo........oooOO0OOooo........o << 966 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1144 967 1145 G4bool << 968 G4PhysicsVector* G4VEnergyLossProcess::DEDXPhysicsVector(const G4MaterialCutsCouple*) 1146 G4VEnergyLossProcess::RetrievePhysicsTable(co << 1147 co << 1148 { 969 { 1149 if (!isMaster || nullptr != baseParticle || << 970 G4int nbins = nDEDXBins; 1150 for(std::size_t i=0; i<7; ++i) { << 971 G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nbins); 1151 // ionisation table only for ionisation p << 972 return v; 1152 if (!isIonisation && 1 == i) { continue; << 1153 if(!G4EmTableUtil::RetrieveTable(this, pa << 1154 verboseL << 1155 return false; << 1156 } << 1157 } << 1158 return true; << 1159 } 973 } 1160 974 1161 //....oooOO0OOooo........oooOO0OOooo........o 975 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1162 976 1163 G4double G4VEnergyLossProcess::GetDEDXDispers << 977 G4PhysicsVector* G4VEnergyLossProcess::DEDXPhysicsVectorForPreciseRange( 1164 const G4Mat << 978 const G4MaterialCutsCouple*) 1165 const G4Dyn << 1166 G4dou << 1167 { 979 { 1168 DefineMaterial(couple); << 980 G4int nbins = nDEDXBinsForRange; 1169 G4double ekin = dp->GetKineticEnergy(); << 981 G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergyForRange, nbins); 1170 SelectModel(ekin*massRatio); << 982 return v; 1171 G4double tmax = currentModel->MaxSecondaryK << 1172 G4double tcut = std::min(tmax,(*theCuts)[cu << 1173 G4double d = 0.0; << 1174 G4VEmFluctuationModel* fm = currentModel->G << 1175 if(nullptr != fm) { d = fm->Dispersion(curr << 1176 return d; << 1177 } 983 } 1178 984 1179 //....oooOO0OOooo........oooOO0OOooo........o 985 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1180 986 1181 G4double << 987 G4PhysicsVector* G4VEnergyLossProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* couple) 1182 G4VEnergyLossProcess::CrossSectionPerVolume(G << 1183 c << 1184 G << 1185 { 988 { 1186 // Cross section per volume is calculated << 989 G4double cut = (*theCuts)[couple->GetIndex()]; >> 990 G4int nbins = nLambdaBins; >> 991 G4double tmin = std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut), >> 992 minKinEnergy); >> 993 if(tmin >= maxKinEnergy) tmin = 0.5*maxKinEnergy; >> 994 G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nbins); >> 995 return v; >> 996 } >> 997 >> 998 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 999 >> 1000 G4PhysicsVector* G4VEnergyLossProcess::SubLambdaPhysicsVector(const G4MaterialCutsCouple* couple) >> 1001 { >> 1002 return LambdaPhysicsVector(couple); >> 1003 } >> 1004 >> 1005 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1006 >> 1007 G4double G4VEnergyLossProcess::MicroscopicCrossSection(G4double kineticEnergy, >> 1008 const G4MaterialCutsCouple* couple) >> 1009 { >> 1010 // Cross section per atom is calculated 1187 DefineMaterial(couple); 1011 DefineMaterial(couple); 1188 G4double cross = 0.0; 1012 G4double cross = 0.0; 1189 if (nullptr != theLambdaTable) { << 1013 G4bool b; 1190 cross = GetLambdaForScaledEnergy(kineticE << 1014 if(theLambdaTable) { 1191 logKinet << 1015 cross = (((*theLambdaTable)[currentMaterialIndex])-> 1192 } else { << 1016 GetValue(kineticEnergy, b)); 1193 SelectModel(kineticEnergy*massRatio); << 1017 1194 cross = (!baseMat) ? biasFactor : biasFac << 1018 cross /= currentMaterial->GetTotNbOfAtomsPerVolume(); 1195 cross *= (currentModel->CrossSectionPerVo << 1196 << 1197 } 1019 } 1198 return std::max(cross, 0.0); << 1020 >> 1021 return cross; 1199 } 1022 } 1200 1023 1201 //....oooOO0OOooo........oooOO0OOooo........o 1024 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1202 1025 1203 G4double G4VEnergyLossProcess::MeanFreePath(c << 1026 G4double G4VEnergyLossProcess::MeanFreePath(const G4Track& track, >> 1027 G4double s, >> 1028 G4ForceCondition* cond) 1204 { 1029 { 1205 DefineMaterial(track.GetMaterialCutsCouple( << 1030 return GetMeanFreePath(track, s, cond); 1206 const G4double kinEnergy = track.GetKine << 1207 const G4double logKinEnergy = track.GetDyna << 1208 const G4double cs = GetLambdaForScaledEnerg << 1209 << 1210 return (0.0 < cs) ? 1.0/cs : DBL_MAX; << 1211 } 1031 } 1212 1032 1213 //....oooOO0OOooo........oooOO0OOooo........o 1033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1214 1034 1215 G4double G4VEnergyLossProcess::ContinuousStep << 1035 G4double G4VEnergyLossProcess::ContinuousStepLimit(const G4Track& track, 1216 << 1036 G4double x, G4double y, G4double& z) 1217 << 1218 { 1037 { 1219 return AlongStepGetPhysicalInteractionLengt << 1038 return GetContinuousStepLimit(track, x, y, z); 1220 } 1039 } 1221 1040 1222 //....oooOO0OOooo........oooOO0OOooo........o 1041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1223 1042 1224 G4double G4VEnergyLossProcess::GetMeanFreePat << 1043 void G4VEnergyLossProcess::SetStepLimits(G4double v1, G4double v2) 1225 const G4Track& t << 1226 G4double, << 1227 G4ForceCondition << 1228 << 1229 { 1044 { 1230 *condition = NotForced; << 1045 dRoverRange = v1; 1231 return MeanFreePath(track); << 1046 finalRange = v2; >> 1047 if (dRoverRange > 1.0) dRoverRange = 1.0; 1232 } 1048 } 1233 1049 1234 //....oooOO0OOooo........oooOO0OOooo........o 1050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1235 1051 1236 G4double G4VEnergyLossProcess::GetContinuousS << 1052 void G4VEnergyLossProcess::SetIntegral(G4bool val) 1237 const G4Track&, << 1238 G4double, G4double, G4double& << 1239 { 1053 { 1240 return DBL_MAX; << 1054 if(integral != val) { >> 1055 if(val) dRoverRange = defaultIntegralRange; >> 1056 else dRoverRange = defaultRoverRange; >> 1057 } >> 1058 integral = val; 1241 } 1059 } 1242 1060 1243 //....oooOO0OOooo........oooOO0OOooo........o 1061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1244 1062 1245 G4PhysicsVector* << 1063 void G4VEnergyLossProcess::SetStepFunction(G4double v1, G4double v2) 1246 G4VEnergyLossProcess::LambdaPhysicsVector(con << 1247 G4d << 1248 { 1064 { 1249 DefineMaterial(couple); << 1065 dRoverRange = v1; 1250 G4PhysicsVector* v = (*theLambdaTable)[base << 1066 finalRange = v2; 1251 return new G4PhysicsVector(*v); << 1067 if (dRoverRange > 0.999) dRoverRange = 1.0; 1252 } 1068 } 1253 1069 1254 //....oooOO0OOooo........oooOO0OOooo........o 1070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1255 1071 1256 void << 1072 void G4VEnergyLossProcess::SetParticle(const G4ParticleDefinition* p) 1257 G4VEnergyLossProcess::SetDEDXTable(G4PhysicsT << 1258 { 1073 { 1259 if(1 < verboseLevel) { << 1074 particle = p; 1260 G4cout << "### Set DEDX table " << p << " << 1261 << " " << theDEDXunRestrictedTable << << 1262 << " for " << particle->GetParticl << 1263 << " and process " << GetProcessNa << 1264 << " type=" << tType << " isIonisation:" << 1265 } << 1266 if(fTotal == tType) { << 1267 theDEDXunRestrictedTable = p; << 1268 } else if(fRestricted == tType) { << 1269 theDEDXTable = p; << 1270 if(isMaster && nullptr == baseParticle) { << 1271 theData->UpdateTable(theDEDXTable, 0); << 1272 } << 1273 } else if(fIsIonisation == tType) { << 1274 theIonisationTable = p; << 1275 if(isMaster && nullptr == baseParticle) { << 1276 theData->UpdateTable(theIonisationTable << 1277 } << 1278 } << 1279 } 1075 } 1280 1076 1281 //....oooOO0OOooo........oooOO0OOooo........o 1077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1282 1078 1283 void G4VEnergyLossProcess::SetCSDARangeTable( << 1079 void G4VEnergyLossProcess::SetBaseParticle(const G4ParticleDefinition* p) 1284 { 1080 { 1285 theCSDARangeTable = p; << 1081 baseParticle = p; 1286 } 1082 } 1287 1083 1288 //....oooOO0OOooo........oooOO0OOooo........o 1084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1289 1085 1290 void G4VEnergyLossProcess::SetRangeTableForLo << 1086 void G4VEnergyLossProcess::SetSecondaryParticle(const G4ParticleDefinition* p) 1291 { 1087 { 1292 theRangeTableForLoss = p; << 1088 secondaryParticle = p; 1293 } 1089 } 1294 1090 1295 //....oooOO0OOooo........oooOO0OOooo........o 1091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1296 1092 1297 void G4VEnergyLossProcess::SetInverseRangeTab << 1093 G4bool G4VEnergyLossProcess::StorePhysicsTable(const G4ParticleDefinition* part, >> 1094 const G4String& directory, >> 1095 G4bool ascii) 1298 { 1096 { 1299 theInverseRangeTable = p; << 1097 G4bool res = true; >> 1098 if ( baseParticle || part != particle ) return res; >> 1099 >> 1100 if ( theDEDXTable && theRangeTableForLoss ) { >> 1101 const G4String name = GetPhysicsTableFileName(part,directory,"DEDX",ascii); >> 1102 if( !theDEDXTable->StorePhysicsTable(name,ascii)) res = false; >> 1103 } >> 1104 >> 1105 if ( theDEDXunRestrictedTable && thePreciseRangeTable ) { >> 1106 const G4String name = GetPhysicsTableFileName(part,directory,"DEDXnr",ascii); >> 1107 if( !theDEDXTable->StorePhysicsTable(name,ascii)) res = false; >> 1108 } >> 1109 >> 1110 if ( thePreciseRangeTable ) { >> 1111 const G4String name = GetPhysicsTableFileName(part,directory,"PreciseRange",ascii); >> 1112 if( !thePreciseRangeTable->StorePhysicsTable(name,ascii)) res = false; >> 1113 } >> 1114 >> 1115 if ( theRangeTableForLoss ) { >> 1116 const G4String name = GetPhysicsTableFileName(part,directory,"Range",ascii); >> 1117 if( !theRangeTableForLoss->StorePhysicsTable(name,ascii)) res = false; >> 1118 } >> 1119 >> 1120 if ( theInverseRangeTable ) { >> 1121 const G4String name = GetPhysicsTableFileName(part,directory,"InverseRange",ascii); >> 1122 if( !theInverseRangeTable->StorePhysicsTable(name,ascii)) res = false; >> 1123 } >> 1124 >> 1125 if ( theLambdaTable ) { >> 1126 const G4String name = GetPhysicsTableFileName(part,directory,"Lambda",ascii); >> 1127 if( !theLambdaTable->StorePhysicsTable(name,ascii)) res = false; >> 1128 } >> 1129 >> 1130 if ( theSubLambdaTable ) { >> 1131 const G4String name = GetPhysicsTableFileName(part,directory,"SubLambda",ascii); >> 1132 if( !theSubLambdaTable->StorePhysicsTable(name,ascii)) res = false; >> 1133 } >> 1134 if ( res ) { >> 1135 G4cout << "Physics tables are stored for " << particle->GetParticleName() >> 1136 << " and process " << GetProcessName() >> 1137 << " in the directory <" << directory >> 1138 << "> " << G4endl; >> 1139 } else { >> 1140 G4cout << "Fail to store Physics Tables for " << particle->GetParticleName() >> 1141 << " and process " << GetProcessName() >> 1142 << " in the directory <" << directory >> 1143 << "> " << G4endl; >> 1144 } >> 1145 return res; 1300 } 1146 } 1301 1147 1302 //....oooOO0OOooo........oooOO0OOooo........o << 1148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 1303 1149 1304 void G4VEnergyLossProcess::SetLambdaTable(G4P << 1150 G4bool G4VEnergyLossProcess::RetrievePhysicsTable(const G4ParticleDefinition* part, >> 1151 const G4String& directory, >> 1152 G4bool ascii) 1305 { 1153 { 1306 if(1 < verboseLevel) { << 1154 G4bool res = true; 1307 G4cout << "### Set Lambda table " << p << << 1155 const G4String particleName = part->GetParticleName(); 1308 << " for " << particle->GetParticl << 1156 1309 << " and process " << GetProcessNa << 1157 if(0 < verboseLevel) { >> 1158 // G4cout << "========================================================" << G4endl; >> 1159 G4cout << "G4VEnergyLossProcess::RetrievePhysicsTable() for " >> 1160 << particleName << " and process " << GetProcessName() >> 1161 << "; tables_are_built= " << tablesAreBuilt >> 1162 << G4endl; 1310 } 1163 } 1311 theLambdaTable = p; << 1164 if(particle == part) { 1312 tablesAreBuilt = true; << 1313 1165 1314 if(isMaster && nullptr != p) { << 1166 G4bool yes = true; 1315 delete theEnergyOfCrossSectionMax; << 1167 G4bool fpi = true; 1316 theEnergyOfCrossSectionMax = nullptr; << 1168 if ( !baseParticle ) { 1317 if(fEmTwoPeaks == fXSType) { << 1169 G4String filename; 1318 if(nullptr != fXSpeaks) { << 1170 1319 for(auto & ptr : *fXSpeaks) { delete ptr; } << 1171 filename = GetPhysicsTableFileName(part,directory,"DEDX",ascii); 1320 delete fXSpeaks; << 1172 yes = theDEDXTable->ExistPhysicsTable(filename); >> 1173 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theDEDXTable,filename,ascii); >> 1174 if(yes) { >> 1175 if (-1 < verboseLevel) { >> 1176 G4cout << "DEDX table for " << particleName << " is Retrieved from <" >> 1177 << filename << ">" >> 1178 << G4endl; >> 1179 } >> 1180 } else { >> 1181 fpi = false; >> 1182 if (0 < verboseLevel) { >> 1183 G4cout << "DEDX table for " << particleName << " from file <" >> 1184 << filename << "> is not Retrieved" >> 1185 << G4endl; >> 1186 } >> 1187 } >> 1188 >> 1189 filename = GetPhysicsTableFileName(part,directory,"Range",ascii); >> 1190 yes = theRangeTableForLoss->ExistPhysicsTable(filename); >> 1191 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theRangeTableForLoss,filename,ascii); >> 1192 if(yes) { >> 1193 if (-1 < verboseLevel) { >> 1194 G4cout << "Range table for loss for " << particleName << " is Retrieved from <" >> 1195 << filename << ">" >> 1196 << G4endl; >> 1197 } >> 1198 } else { >> 1199 if(fpi) { >> 1200 res = false; >> 1201 G4cout << "Range table for loss for " << particleName << " from file <" >> 1202 << filename << "> is not Retrieved" >> 1203 << G4endl; >> 1204 } >> 1205 } >> 1206 >> 1207 filename = GetPhysicsTableFileName(part,directory,"DEDXnr",ascii); >> 1208 yes = theDEDXunRestrictedTable->ExistPhysicsTable(filename); >> 1209 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theDEDXunRestrictedTable,filename,ascii); >> 1210 if(yes) { >> 1211 if (-1 < verboseLevel) { >> 1212 G4cout << "Non-restricted DEDX table for " << particleName << " is Retrieved from <" >> 1213 << filename << ">" >> 1214 << G4endl; >> 1215 } >> 1216 } else { >> 1217 if (0 < verboseLevel) { >> 1218 G4cout << "Non-restricted DEDX table for " << particleName << " from file <" >> 1219 << filename << "> is not Retrieved" >> 1220 << G4endl; >> 1221 } >> 1222 } >> 1223 >> 1224 filename = GetPhysicsTableFileName(part,directory,"PreciseRange",ascii); >> 1225 yes = thePreciseRangeTable->ExistPhysicsTable(filename); >> 1226 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(thePreciseRangeTable,filename,ascii); >> 1227 if(yes) { >> 1228 if (-1 < verboseLevel) { >> 1229 G4cout << "Precise Range table for " << particleName << " is Retrieved from <" >> 1230 << filename << ">" >> 1231 << G4endl; >> 1232 } >> 1233 } else { >> 1234 G4cout << "Precise Range table for loss for " << particleName << " does not exist" >> 1235 << G4endl; >> 1236 } >> 1237 >> 1238 filename = GetPhysicsTableFileName(part,directory,"InverseRange",ascii); >> 1239 yes = theInverseRangeTable->ExistPhysicsTable(filename); >> 1240 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theInverseRangeTable,filename,ascii); >> 1241 if(yes) { >> 1242 if (-1 < verboseLevel) { >> 1243 G4cout << "InverseRange table for " << particleName << " is Retrieved from <" >> 1244 << filename << ">" >> 1245 << G4endl; >> 1246 } >> 1247 } else { >> 1248 if(fpi) { >> 1249 res = false; >> 1250 G4cout << "InverseRange table for " << particleName << " from file <" >> 1251 << filename << "> is not Retrieved" >> 1252 << G4endl; >> 1253 >> 1254 } >> 1255 } >> 1256 >> 1257 filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii); >> 1258 yes = theLambdaTable->ExistPhysicsTable(filename); >> 1259 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,filename,ascii); >> 1260 if(yes) { >> 1261 if (-1 < verboseLevel) { >> 1262 G4cout << "Lambda table for " << particleName << " is Retrieved from <" >> 1263 << filename << ">" >> 1264 << G4endl; >> 1265 } >> 1266 } else { >> 1267 if(fpi) { >> 1268 res = false; >> 1269 G4cout << "Lambda table for " << particleName << " from file <" >> 1270 << filename << "> is not Retrieved" >> 1271 << G4endl; >> 1272 } >> 1273 } >> 1274 >> 1275 filename = GetPhysicsTableFileName(part,directory,"SubLambda",ascii); >> 1276 yes = theSubLambdaTable->ExistPhysicsTable(filename); >> 1277 if(yes) yes = G4PhysicsTableHelper::RetrievePhysicsTable(theSubLambdaTable,filename,ascii); >> 1278 if(yes) { >> 1279 if (-1 < verboseLevel) { >> 1280 G4cout << "SubLambda table for " << particleName << " is Retrieved from <" >> 1281 << filename << ">" >> 1282 << G4endl; >> 1283 } >> 1284 } else { >> 1285 if(nSCoffRegions) { >> 1286 res=false; >> 1287 G4cout << "SubLambda table for " << particleName << " from file <" >> 1288 << filename << "> is not Retrieved" >> 1289 << G4endl; >> 1290 } 1321 } 1291 } 1322 G4LossTableBuilder* bld = lManager->Get << 1323 fXSpeaks = G4EmUtility::FillPeaksStruct << 1324 if(nullptr == fXSpeaks) { fXSType = fEm << 1325 } << 1326 if(fXSType == fEmOnePeak) { << 1327 theEnergyOfCrossSectionMax = G4EmUtilit << 1328 if(nullptr == theEnergyOfCrossSectionMa << 1329 } 1292 } 1330 } 1293 } >> 1294 >> 1295 return res; 1331 } 1296 } 1332 1297 1333 //....oooOO0OOooo........oooOO0OOooo........o 1298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1334 1299 1335 void G4VEnergyLossProcess::SetEnergyOfCrossSe << 1300 void G4VEnergyLossProcess::SetLinearLossLimit(G4double val) 1336 { 1301 { 1337 theEnergyOfCrossSectionMax = p; << 1302 linLossLimit = val; 1338 } 1303 } 1339 1304 1340 //....oooOO0OOooo........oooOO0OOooo........o 1305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1341 1306 1342 void G4VEnergyLossProcess::SetTwoPeaksXS(std: << 1307 void G4VEnergyLossProcess::SetLossFluctuations(G4bool val) 1343 { 1308 { 1344 fXSpeaks = ptr; << 1309 lossFluctuationFlag = val; 1345 } 1310 } 1346 1311 1347 //....oooOO0OOooo........oooOO0OOooo........o 1312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1348 1313 1349 const G4Element* G4VEnergyLossProcess::GetCur << 1314 void G4VEnergyLossProcess::SetSubCutoff(G4bool) >> 1315 {} >> 1316 >> 1317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1318 >> 1319 void G4VEnergyLossProcess::SetMinSubRange(G4double val) 1350 { 1320 { 1351 return (nullptr != currentModel) << 1321 minSubRange = val; 1352 ? currentModel->GetCurrentElement(current << 1353 } 1322 } 1354 1323 1355 //....oooOO0OOooo........oooOO0OOooo........o 1324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1356 1325 1357 void G4VEnergyLossProcess::SetCrossSectionBia << 1326 G4bool G4VEnergyLossProcess::TablesAreBuilt() const 1358 << 1359 { 1327 { 1360 if(f > 0.0) { << 1328 return tablesAreBuilt; 1361 biasFactor = f; << 1362 weightFlag = flag; << 1363 if(1 < verboseLevel) { << 1364 G4cout << "### SetCrossSectionBiasingFa << 1365 << " process " << GetProcessName << 1366 << " biasFactor= " << f << " wei << 1367 << G4endl; << 1368 } << 1369 } << 1370 } 1329 } 1371 1330 1372 //....oooOO0OOooo........oooOO0OOooo........o 1331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1373 1332 1374 void G4VEnergyLossProcess::ActivateForcedInte << 1333 G4int G4VEnergyLossProcess::NumberOfSubCutoffRegions() const 1375 << 1376 << 1377 { 1334 { 1378 if(nullptr == biasManager) { biasManager = << 1335 return nSCoffRegions; 1379 if(1 < verboseLevel) { << 1380 G4cout << "### ActivateForcedInteraction: << 1381 << " process " << GetProcessName() << 1382 << " length(mm)= " << length/mm << 1383 << " in G4Region <" << region << 1384 << "> weightFlag= " << flag << 1385 << G4endl; << 1386 } << 1387 weightFlag = flag; << 1388 biasManager->ActivateForcedInteraction(leng << 1389 } 1336 } 1390 1337 1391 //....oooOO0OOooo........oooOO0OOooo........o 1338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1392 1339 1393 void << 1340 void G4VEnergyLossProcess::SetDEDXBinning(G4int nbins) 1394 G4VEnergyLossProcess::ActivateSecondaryBiasin << 1341 { 1395 << 1342 nDEDXBins = nbins; 1396 << 1397 { << 1398 if (0.0 <= factor) { << 1399 // Range cut can be applied only for e- << 1400 if(0.0 == factor && secondaryParticle != << 1401 { return; } << 1402 << 1403 if(nullptr == biasManager) { biasManager << 1404 biasManager->ActivateSecondaryBiasing(reg << 1405 if(1 < verboseLevel) { << 1406 G4cout << "### ActivateSecondaryBiasing << 1407 << " process " << GetProcessName << 1408 << " factor= " << factor << 1409 << " in G4Region <" << region << 1410 << "> energyLimit(MeV)= " << ene << 1411 << G4endl; << 1412 } << 1413 } << 1414 } 1343 } 1415 1344 1416 //....oooOO0OOooo........oooOO0OOooo........o 1345 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1417 1346 1418 void G4VEnergyLossProcess::SetIonisation(G4bo << 1347 void G4VEnergyLossProcess::SetDEDXBinningForPreciseRange(G4int nbins) 1419 { 1348 { 1420 isIonisation = val; << 1349 nDEDXBinsForRange = nbins; 1421 aGPILSelection = (val) ? CandidateForSelect << 1422 } 1350 } 1423 1351 1424 //....oooOO0OOooo........oooOO0OOooo........o 1352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1425 1353 1426 void G4VEnergyLossProcess::SetLinearLossLimi << 1354 void G4VEnergyLossProcess::SetLambdaBinning(G4int nbins) 1427 { 1355 { 1428 if(0.0 < val && val < 1.0) { << 1356 nLambdaBins = nbins; 1429 linLossLimit = val; << 1430 actLinLossLimit = true; << 1431 } else { PrintWarning("SetLinearLossLimit", << 1432 } 1357 } 1433 1358 1434 //....oooOO0OOooo........oooOO0OOooo........o 1359 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1435 1360 1436 void G4VEnergyLossProcess::SetStepFunction(G4 << 1361 G4double G4VEnergyLossProcess::MinKinEnergy() const 1437 { 1362 { 1438 if(0.0 < v1 && 0.0 < v2) { << 1363 return minKinEnergy; 1439 dRoverRange = std::min(1.0, v1); << 1440 finalRange = std::min(v2, 1.e+50); << 1441 } else { << 1442 PrintWarning("SetStepFunctionV1", v1); << 1443 PrintWarning("SetStepFunctionV2", v2); << 1444 } << 1445 } 1364 } 1446 1365 1447 //....oooOO0OOooo........oooOO0OOooo........o 1366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1448 1367 1449 void G4VEnergyLossProcess::SetLowestEnergyLim << 1368 void G4VEnergyLossProcess::SetMinKinEnergy(G4double e) 1450 { 1369 { 1451 if(1.e-18 < val && val < 1.e+50) { lowestKi << 1370 minKinEnergy = e; 1452 else { PrintWarning("SetLowestEnergyLimit", << 1453 } 1371 } 1454 1372 1455 //....oooOO0OOooo........oooOO0OOooo........o 1373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1456 1374 1457 void G4VEnergyLossProcess::SetDEDXBinning(G4i << 1375 void G4VEnergyLossProcess::SetMaxKinEnergy(G4double e) 1458 { 1376 { 1459 if(2 < n && n < 1000000000) { << 1377 maxKinEnergy = e; 1460 nBins = n; << 1378 if(e < maxKinEnergyForRange) maxKinEnergyForRange = e; 1461 actBinning = true; << 1462 } else { << 1463 G4double e = (G4double)n; << 1464 PrintWarning("SetDEDXBinning", e); << 1465 } << 1466 } 1379 } 1467 1380 1468 //....oooOO0OOooo........oooOO0OOooo........o 1381 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1469 1382 1470 void G4VEnergyLossProcess::SetMinKinEnergy(G4 << 1383 void G4VEnergyLossProcess::SetMaxKinEnergyForPreciseRange(G4double e) 1471 { 1384 { 1472 if(1.e-18 < e && e < maxKinEnergy) { << 1385 maxKinEnergyForRange = e; 1473 minKinEnergy = e; << 1474 actMinKinEnergy = true; << 1475 } else { PrintWarning("SetMinKinEnergy", e) << 1476 } 1386 } 1477 1387 1478 //....oooOO0OOooo........oooOO0OOooo........o 1388 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1479 1389 1480 void G4VEnergyLossProcess::SetMaxKinEnergy(G4 << 1390 G4double G4VEnergyLossProcess::MaxKinEnergy() const 1481 { 1391 { 1482 if(minKinEnergy < e && e < 1.e+50) { << 1392 return maxKinEnergy; 1483 maxKinEnergy = e; << 1484 actMaxKinEnergy = true; << 1485 if(e < maxKinEnergyCSDA) { maxKinEnergyCS << 1486 } else { PrintWarning("SetMaxKinEnergy", e) << 1487 } 1393 } 1488 1394 1489 //....oooOO0OOooo........oooOO0OOooo........o 1395 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1490 1396 1491 void G4VEnergyLossProcess::PrintWarning(const << 1397 void G4VEnergyLossProcess::ActivateFluorescence(G4bool, const G4Region*) >> 1398 {} >> 1399 >> 1400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1401 >> 1402 void G4VEnergyLossProcess::ActivateAugerElectronProduction(G4bool, const G4Region*) >> 1403 >> 1404 {} >> 1405 >> 1406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1407 >> 1408 void G4VEnergyLossProcess::SetLambdaFactor(G4double val) >> 1409 { >> 1410 if(val > 0.0 && val <= 1.0) lambdaFactor = val; >> 1411 } >> 1412 >> 1413 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1414 >> 1415 void G4VEnergyLossProcess::SetIonisation(G4bool val) 1492 { 1416 { 1493 G4String ss = "G4VEnergyLossProcess::" + ti << 1417 isIonisation = val; 1494 G4ExceptionDescription ed; << 1495 ed << "Parameter is out of range: " << val << 1496 << " it will have no effect!\n" << " Pr << 1497 << GetProcessName() << " nbins= " << nB << 1498 << " Emin(keV)= " << minKinEnergy/keV << 1499 << " Emax(GeV)= " << maxKinEnergy/GeV; << 1500 G4Exception(ss, "em0044", JustWarning, ed); << 1501 } 1418 } 1502 1419 1503 //....oooOO0OOooo........oooOO0OOooo........o 1420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1504 1421 1505 void G4VEnergyLossProcess::ProcessDescription << 1422 G4bool G4VEnergyLossProcess::IsIonisationProcess() const 1506 { 1423 { 1507 if(nullptr != particle) { StreamInfo(out, * << 1424 return isIonisation; 1508 } 1425 } 1509 1426 1510 //....oooOO0OOooo........oooOO0OOooo........o 1427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1428 1511 1429