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