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