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