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 // 28 // GEANT4 Class file 29 // GEANT4 Class file 29 // 30 // 30 // 31 // 31 // File name: G4VEnergyLossProcess 32 // File name: G4VEnergyLossProcess 32 // 33 // 33 // Author: Vladimir Ivanchenko 34 // Author: Vladimir Ivanchenko 34 // 35 // 35 // Creation date: 03.01.2002 36 // Creation date: 03.01.2002 36 // 37 // 37 // Modifications: Vladimir Ivanchenko 38 // Modifications: Vladimir Ivanchenko 38 // 39 // 39 // 40 // 40 // Class Description: 41 // Class Description: 41 // 42 // 42 // It is the unified energy loss process it ca 43 // It is the unified energy loss process it calculates the continuous 43 // energy loss for charged particles using a s 44 // energy loss for charged particles using a set of Energy Loss 44 // models valid for different energy regions. 45 // models valid for different energy regions. There are a possibility 45 // to create and access to dE/dx and range tab 46 // to create and access to dE/dx and range tables, or to calculate 46 // that information on fly. 47 // that information on fly. 47 // ------------------------------------------- 48 // ------------------------------------------------------------------- 48 // 49 // 49 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 50 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 51 52 52 #include "G4VEnergyLossProcess.hh" 53 #include "G4VEnergyLossProcess.hh" 53 #include "G4PhysicalConstants.hh" 54 #include "G4PhysicalConstants.hh" 54 #include "G4SystemOfUnits.hh" 55 #include "G4SystemOfUnits.hh" 55 #include "G4ProcessManager.hh" 56 #include "G4ProcessManager.hh" 56 #include "G4LossTableManager.hh" 57 #include "G4LossTableManager.hh" 57 #include "G4LossTableBuilder.hh" 58 #include "G4LossTableBuilder.hh" 58 #include "G4Step.hh" 59 #include "G4Step.hh" 59 #include "G4ParticleDefinition.hh" 60 #include "G4ParticleDefinition.hh" 60 #include "G4ParticleTable.hh" 61 #include "G4ParticleTable.hh" 61 #include "G4EmParameters.hh" << 62 #include "G4EmUtility.hh" << 63 #include "G4EmTableUtil.hh" << 64 #include "G4VEmModel.hh" 62 #include "G4VEmModel.hh" 65 #include "G4VEmFluctuationModel.hh" 63 #include "G4VEmFluctuationModel.hh" 66 #include "G4DataVector.hh" 64 #include "G4DataVector.hh" 67 #include "G4PhysicsLogVector.hh" 65 #include "G4PhysicsLogVector.hh" 68 #include "G4VParticleChange.hh" 66 #include "G4VParticleChange.hh" >> 67 #include "G4Gamma.hh" 69 #include "G4Electron.hh" 68 #include "G4Electron.hh" >> 69 #include "G4Positron.hh" 70 #include "G4ProcessManager.hh" 70 #include "G4ProcessManager.hh" 71 #include "G4UnitsTable.hh" 71 #include "G4UnitsTable.hh" >> 72 #include "G4ProductionCutsTable.hh" 72 #include "G4Region.hh" 73 #include "G4Region.hh" 73 #include "G4RegionStore.hh" 74 #include "G4RegionStore.hh" 74 #include "G4PhysicsTableHelper.hh" 75 #include "G4PhysicsTableHelper.hh" 75 #include "G4SafetyHelper.hh" 76 #include "G4SafetyHelper.hh" 76 #include "G4EmDataHandler.hh" << 77 #include "G4TransportationManager.hh" 77 #include "G4TransportationManager.hh" >> 78 #include "G4EmConfigurator.hh" 78 #include "G4VAtomDeexcitation.hh" 79 #include "G4VAtomDeexcitation.hh" 79 #include "G4VSubCutProducer.hh" 80 #include "G4VSubCutProducer.hh" 80 #include "G4EmBiasingManager.hh" 81 #include "G4EmBiasingManager.hh" 81 #include "G4Log.hh" 82 #include "G4Log.hh" 82 #include <iostream> 83 #include <iostream> 83 84 84 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 85 86 86 namespace << 87 { << 88 G4String tnames[7] = << 89 {"DEDX","Ionisation","DEDXnr","CSDARange", << 90 } << 91 << 92 << 93 G4VEnergyLossProcess::G4VEnergyLossProcess(con 87 G4VEnergyLossProcess::G4VEnergyLossProcess(const G4String& name, 94 G4P 88 G4ProcessType type): 95 G4VContinuousDiscreteProcess(name, type) << 89 G4VContinuousDiscreteProcess(name, type), >> 90 secondaryParticle(nullptr), >> 91 nSCoffRegions(0), >> 92 idxSCoffRegions(nullptr), >> 93 nProcesses(0), >> 94 theDEDXTable(nullptr), >> 95 theDEDXSubTable(nullptr), >> 96 theDEDXunRestrictedTable(nullptr), >> 97 theIonisationTable(nullptr), >> 98 theIonisationSubTable(nullptr), >> 99 theRangeTableForLoss(nullptr), >> 100 theCSDARangeTable(nullptr), >> 101 theSecondaryRangeTable(nullptr), >> 102 theInverseRangeTable(nullptr), >> 103 theLambdaTable(nullptr), >> 104 theSubLambdaTable(nullptr), >> 105 theDensityFactor(nullptr), >> 106 theDensityIdx(nullptr), >> 107 baseParticle(nullptr), >> 108 lossFluctuationFlag(true), >> 109 rndmStepFlag(false), >> 110 tablesAreBuilt(false), >> 111 integral(true), >> 112 isIon(false), >> 113 isIonisation(true), >> 114 useSubCutoff(false), >> 115 useDeexcitation(false), >> 116 currentCouple(nullptr), >> 117 mfpKinEnergy(0.0), >> 118 particle(nullptr) 96 { 119 { 97 theParameters = G4EmParameters::Instance(); 120 theParameters = G4EmParameters::Instance(); 98 SetVerboseLevel(1); 121 SetVerboseLevel(1); 99 122 100 // low energy limit 123 // low energy limit 101 lowestKinEnergy = theParameters->LowestElect << 124 lowestKinEnergy = theParameters->LowestElectronEnergy(); 102 << 125 preStepKinEnergy = 0.0; 103 // Size of tables << 126 preStepRangeEnergy = 0.0; 104 minKinEnergy = 0.1*CLHEP::keV; << 127 computedRange = DBL_MAX; 105 maxKinEnergy = 100.0*CLHEP::TeV; << 128 106 maxKinEnergyCSDA = 1.0*CLHEP::GeV; << 129 // Size of tables assuming spline >> 130 minKinEnergy = 0.1*keV; >> 131 maxKinEnergy = 100.0*TeV; 107 nBins = 84; 132 nBins = 84; >> 133 maxKinEnergyCSDA = 1.0*GeV; 108 nBinsCSDA = 35; 134 nBinsCSDA = 35; >> 135 actMinKinEnergy = actMaxKinEnergy = actBinning = actLinLossLimit >> 136 = actLossFluc = actIntegral = actStepFunc = false; 109 137 110 invLambdaFactor = 1.0/lambdaFactor; << 138 // default linear loss limit for spline 111 << 139 linLossLimit = 0.01; 112 // default linear loss limit << 140 dRoverRange = 0.2; 113 finalRange = 1.*CLHEP::mm; << 141 finalRange = CLHEP::mm; >> 142 >> 143 // default lambda factor >> 144 lambdaFactor = 0.8; >> 145 >> 146 // cross section biasing >> 147 biasFactor = 1.0; >> 148 >> 149 // particle types >> 150 theElectron = G4Electron::Electron(); >> 151 thePositron = G4Positron::Positron(); >> 152 theGamma = G4Gamma::Gamma(); >> 153 theGenericIon = nullptr; 114 154 115 // run time objects 155 // run time objects 116 pParticleChange = &fParticleChange; 156 pParticleChange = &fParticleChange; 117 fParticleChange.SetSecondaryWeightByProcess( 157 fParticleChange.SetSecondaryWeightByProcess(true); 118 modelManager = new G4EmModelManager(); 158 modelManager = new G4EmModelManager(); 119 safetyHelper = G4TransportationManager::GetT 159 safetyHelper = G4TransportationManager::GetTransportationManager() 120 ->GetSafetyHelper(); 160 ->GetSafetyHelper(); 121 aGPILSelection = CandidateForSelection; 161 aGPILSelection = CandidateForSelection; 122 162 123 // initialise model 163 // initialise model 124 lManager = G4LossTableManager::Instance(); 164 lManager = G4LossTableManager::Instance(); 125 lManager->Register(this); 165 lManager->Register(this); 126 isMaster = lManager->IsMaster(); << 166 fluctModel = nullptr; 127 << 167 currentModel = nullptr; 128 G4LossTableBuilder* bld = lManager->GetTable << 168 atomDeexcitation = nullptr; 129 theDensityFactor = bld->GetDensityFactors(); << 169 subcutProducer = nullptr; 130 theDensityIdx = bld->GetCoupleIndexes(); << 170 >> 171 biasManager = nullptr; >> 172 biasFlag = false; >> 173 weightFlag = false; >> 174 isMaster = true; >> 175 lastIdx = 0; >> 176 >> 177 idxDEDX = idxDEDXSub = idxDEDXunRestricted = idxIonisation = >> 178 idxIonisationSub = idxRange = idxCSDA = idxSecRange = >> 179 idxInverseRange = idxLambda = idxSubLambda = 0; >> 180 >> 181 scTracks.reserve(5); >> 182 secParticles.reserve(5); >> 183 >> 184 theCuts = theSubCuts = nullptr; >> 185 currentMaterial = nullptr; >> 186 currentCoupleIndex = basedCoupleIndex = 0; >> 187 massRatio = fFactor = reduceFactor = chargeSqRatio = 1.0; >> 188 preStepLambda = preStepScaledEnergy = fRange = 0.0; 131 189 132 scTracks.reserve(10); << 190 secID = biasID = subsecID = -1; 133 secParticles.reserve(12); << 134 emModels = new std::vector<G4VEmModel*>; << 135 } 191 } 136 192 137 //....oooOO0OOooo........oooOO0OOooo........oo 193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 138 194 139 G4VEnergyLossProcess::~G4VEnergyLossProcess() 195 G4VEnergyLossProcess::~G4VEnergyLossProcess() 140 { 196 { 141 if (isMaster) { << 197 /* 142 if(nullptr == baseParticle) { delete theDa << 198 G4cout << "** G4VEnergyLossProcess::~G4VEnergyLossProcess() for " 143 delete theEnergyOfCrossSectionMax; << 199 << GetProcessName() << " isMaster: " << isMaster 144 if(nullptr != fXSpeaks) { << 200 << " basePart: " << baseParticle 145 for(auto const & v : *fXSpeaks) { delete << 201 << G4endl; 146 delete fXSpeaks; << 202 */ >> 203 Clean(); >> 204 >> 205 // G4cout << " isIonisation " << isIonisation << " " >> 206 // << theDEDXTable << " " << theIonisationTable << G4endl; >> 207 >> 208 if (isMaster && !baseParticle) { >> 209 if(theDEDXTable) { >> 210 >> 211 //G4cout << " theIonisationTable " << theIonisationTable << G4endl; >> 212 if(theIonisationTable == theDEDXTable) { theIonisationTable = nullptr; } >> 213 //G4cout << " delete theDEDXTable " << theDEDXTable << G4endl; >> 214 theDEDXTable->clearAndDestroy(); >> 215 delete theDEDXTable; >> 216 theDEDXTable = nullptr; >> 217 if(theDEDXSubTable) { >> 218 if(theIonisationSubTable == theDEDXSubTable) >> 219 { theIonisationSubTable = nullptr; } >> 220 theDEDXSubTable->clearAndDestroy(); >> 221 delete theDEDXSubTable; >> 222 theDEDXSubTable = nullptr; >> 223 } >> 224 } >> 225 //G4cout << " theIonisationTable " << theIonisationTable << G4endl; >> 226 if(theIonisationTable) { >> 227 //G4cout << " delete theIonisationTable " << theIonisationTable << G4endl; >> 228 theIonisationTable->clearAndDestroy(); >> 229 delete theIonisationTable; >> 230 theIonisationTable = nullptr; >> 231 } >> 232 if(theIonisationSubTable) { >> 233 theIonisationSubTable->clearAndDestroy(); >> 234 delete theIonisationSubTable; >> 235 theIonisationSubTable = nullptr; >> 236 } >> 237 if(theDEDXunRestrictedTable && isIonisation) { >> 238 theDEDXunRestrictedTable->clearAndDestroy(); >> 239 delete theDEDXunRestrictedTable; >> 240 theDEDXunRestrictedTable = nullptr; >> 241 } >> 242 if(theCSDARangeTable && isIonisation) { >> 243 theCSDARangeTable->clearAndDestroy(); >> 244 delete theCSDARangeTable; >> 245 theCSDARangeTable = nullptr; >> 246 } >> 247 //G4cout << "delete RangeTable: " << theRangeTableForLoss << G4endl; >> 248 if(theRangeTableForLoss && isIonisation) { >> 249 theRangeTableForLoss->clearAndDestroy(); >> 250 delete theRangeTableForLoss; >> 251 theRangeTableForLoss = nullptr; >> 252 } >> 253 //G4cout << "delete InvRangeTable: " << theInverseRangeTable << G4endl; >> 254 if(theInverseRangeTable && isIonisation /*&& !isIon*/) { >> 255 theInverseRangeTable->clearAndDestroy(); >> 256 delete theInverseRangeTable; >> 257 theInverseRangeTable = nullptr; >> 258 } >> 259 //G4cout << "delete LambdaTable: " << theLambdaTable << G4endl; >> 260 if(theLambdaTable) { >> 261 theLambdaTable->clearAndDestroy(); >> 262 delete theLambdaTable; >> 263 theLambdaTable = nullptr; >> 264 } >> 265 if(theSubLambdaTable) { >> 266 theSubLambdaTable->clearAndDestroy(); >> 267 delete theSubLambdaTable; >> 268 theSubLambdaTable = nullptr; 147 } 269 } 148 } 270 } >> 271 149 delete modelManager; 272 delete modelManager; 150 delete biasManager; 273 delete biasManager; 151 delete scoffRegions; << 152 delete emModels; << 153 lManager->DeRegister(this); 274 lManager->DeRegister(this); >> 275 //G4cout << "** all removed" << G4endl; >> 276 } >> 277 >> 278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 279 >> 280 void G4VEnergyLossProcess::Clean() >> 281 { >> 282 /* >> 283 if(1 < verboseLevel) { >> 284 G4cout << "G4VEnergyLossProcess::Clear() for " << GetProcessName() >> 285 << G4endl; >> 286 } >> 287 */ >> 288 delete [] idxSCoffRegions; >> 289 >> 290 tablesAreBuilt = false; >> 291 >> 292 scProcesses.clear(); >> 293 nProcesses = 0; >> 294 >> 295 idxDEDX = idxDEDXSub = idxDEDXunRestricted = idxIonisation = >> 296 idxIonisationSub = idxRange = idxCSDA = idxSecRange = >> 297 idxInverseRange = idxLambda = idxSubLambda = 0; 154 } 298 } 155 299 156 //....oooOO0OOooo........oooOO0OOooo........oo 300 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 157 301 158 G4double G4VEnergyLossProcess::MinPrimaryEnerg 302 G4double G4VEnergyLossProcess::MinPrimaryEnergy(const G4ParticleDefinition*, 159 303 const G4Material*, 160 304 G4double cut) 161 { 305 { 162 return cut; 306 return cut; 163 } 307 } 164 308 165 //....oooOO0OOooo........oooOO0OOooo........oo 309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 166 310 167 void G4VEnergyLossProcess::AddEmModel(G4int or << 311 void G4VEnergyLossProcess::AddEmModel(G4int order, G4VEmModel* p, 168 G4VEmFlu 312 G4VEmFluctuationModel* fluc, 169 const G4 313 const G4Region* region) 170 { 314 { 171 if(nullptr == ptr) { return; } << 315 modelManager->AddEmModel(order, p, fluc, region); 172 G4VEmFluctuationModel* afluc = (nullptr == f << 316 if(p) { p->SetParticleChange(pParticleChange, fluc); } 173 modelManager->AddEmModel(order, ptr, afluc, << 317 } 174 ptr->SetParticleChange(pParticleChange, aflu << 318 >> 319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 320 >> 321 void G4VEnergyLossProcess::UpdateEmModel(const G4String& nam, >> 322 G4double emin, G4double emax) >> 323 { >> 324 modelManager->UpdateEmModel(nam, emin, emax); 175 } 325 } 176 326 177 //....oooOO0OOooo........oooOO0OOooo........oo 327 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 178 328 179 void G4VEnergyLossProcess::SetEmModel(G4VEmMod 329 void G4VEnergyLossProcess::SetEmModel(G4VEmModel* ptr, G4int) 180 { 330 { 181 if(nullptr == ptr) { return; } << 331 for(auto & em : emModels) { if(em == ptr) { return; } } 182 if(!emModels->empty()) { << 332 emModels.push_back(ptr); 183 for(auto & em : *emModels) { if(em == ptr) << 333 } 184 } << 334 185 emModels->push_back(ptr); << 335 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 336 >> 337 G4VEmModel* G4VEnergyLossProcess::EmModel(size_t index) const >> 338 { >> 339 return (index < emModels.size()) ? emModels[index] : nullptr; 186 } 340 } 187 341 188 //....oooOO0OOooo........oooOO0OOooo........oo 342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 189 343 190 void G4VEnergyLossProcess::SetDynamicMassCharg << 344 G4VEmModel* G4VEnergyLossProcess::GetModelByIndex(G4int idx, G4bool ver) const 191 << 192 { 345 { 193 massRatio = massratio; << 346 return modelManager->GetModel(idx, ver); 194 logMassRatio = G4Log(massRatio); << 347 } 195 fFactor = charge2ratio*biasFactor; << 348 196 if(baseMat) { fFactor *= (*theDensityFactor) << 349 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 197 chargeSqRatio = charge2ratio; << 350 198 reduceFactor = 1.0/(fFactor*massRatio); << 351 G4int G4VEnergyLossProcess::NumberOfModels() const >> 352 { >> 353 return modelManager->NumberOfModels(); 199 } 354 } 200 355 201 //....oooOO0OOooo........oooOO0OOooo........oo 356 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 202 357 203 void 358 void 204 G4VEnergyLossProcess::PreparePhysicsTable(cons 359 G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part) 205 { 360 { 206 particle = G4EmTableUtil::CheckIon(this, &pa << 361 if(1 < verboseLevel) { 207 verboseLe << 362 G4cout << "G4VEnergyLossProcess::PreparePhysicsTable for " >> 363 << GetProcessName() << " for " << part.GetParticleName() >> 364 << " " << this << G4endl; >> 365 } >> 366 isMaster = lManager->IsMaster(); >> 367 >> 368 currentCouple = nullptr; >> 369 preStepLambda = 0.0; >> 370 mfpKinEnergy = DBL_MAX; >> 371 fRange = DBL_MAX; >> 372 preStepKinEnergy = 0.0; >> 373 preStepRangeEnergy = 0.0; >> 374 chargeSqRatio = 1.0; >> 375 massRatio = 1.0; >> 376 reduceFactor = 1.0; >> 377 fFactor = 1.0; >> 378 lastIdx = 0; >> 379 >> 380 // Are particle defined? >> 381 if( !particle ) { particle = ∂ } >> 382 >> 383 if(part.GetParticleType() == "nucleus") { >> 384 >> 385 G4String pname = part.GetParticleName(); >> 386 if(pname != "deuteron" && pname != "triton" && >> 387 pname != "alpha+" && pname != "helium" && >> 388 pname != "hydrogen") { >> 389 >> 390 if(!theGenericIon) { >> 391 theGenericIon = >> 392 G4ParticleTable::GetParticleTable()->FindParticle("GenericIon"); >> 393 } >> 394 isIon = true; >> 395 if(theGenericIon && particle != theGenericIon) { >> 396 G4ProcessManager* pm = theGenericIon->GetProcessManager(); >> 397 G4ProcessVector* v = pm->GetAlongStepProcessVector(); >> 398 size_t n = v->size(); >> 399 for(size_t j=0; j<n; ++j) { >> 400 if((*v)[j] == this) { >> 401 particle = theGenericIon; >> 402 break; >> 403 } >> 404 } >> 405 } >> 406 } >> 407 } 208 408 209 if( particle != &part ) { 409 if( particle != &part ) { 210 if(!isIon) { lManager->RegisterExtraPartic << 410 if(!isIon) { >> 411 lManager->RegisterExtraParticle(&part, this); >> 412 } 211 if(1 < verboseLevel) { 413 if(1 < verboseLevel) { 212 G4cout << "### G4VEnergyLossProcess::Pre 414 G4cout << "### G4VEnergyLossProcess::PreparePhysicsTable()" 213 << " interrupted for " << GetProc << 415 << " interrupted for " 214 << part.GetParticleName() << " is << 416 << part.GetParticleName() << " isIon= " << isIon 215 << " spline=" << spline << G4endl << 417 << " particle " << particle << " GenericIon " << theGenericIon >> 418 << G4endl; 216 } 419 } 217 return; 420 return; 218 } 421 } 219 422 220 tablesAreBuilt = false; << 423 Clean(); 221 if (GetProcessSubType() == fIonisation) { Se << 424 lManager->PreparePhysicsTable(&part, this, isMaster); 222 << 223 G4LossTableBuilder* bld = lManager->GetTable 425 G4LossTableBuilder* bld = lManager->GetTableBuilder(); 224 lManager->PreparePhysicsTable(&part, this); << 225 426 226 // Base particle and set of models can be de 427 // Base particle and set of models can be defined here 227 InitialiseEnergyLossProcess(particle, basePa 428 InitialiseEnergyLossProcess(particle, baseParticle); 228 429 >> 430 const G4ProductionCutsTable* theCoupleTable= >> 431 G4ProductionCutsTable::GetProductionCutsTable(); >> 432 size_t n = theCoupleTable->GetTableSize(); >> 433 >> 434 theDEDXAtMaxEnergy.resize(n, 0.0); >> 435 theRangeAtMaxEnergy.resize(n, 0.0); >> 436 theEnergyOfCrossSectionMax.resize(n, 0.0); >> 437 theCrossSectionMax.resize(n, DBL_MAX); >> 438 229 // parameters of the process 439 // parameters of the process >> 440 if(!actIntegral) { integral = theParameters->Integral(); } 230 if(!actLossFluc) { lossFluctuationFlag = the 441 if(!actLossFluc) { lossFluctuationFlag = theParameters->LossFluctuation(); } 231 useCutAsFinalRange = theParameters->UseCutAs << 442 rndmStepFlag = theParameters->UseCutAsFinalRange(); 232 if(!actMinKinEnergy) { minKinEnergy = thePar 443 if(!actMinKinEnergy) { minKinEnergy = theParameters->MinKinEnergy(); } 233 if(!actMaxKinEnergy) { maxKinEnergy = thePar 444 if(!actMaxKinEnergy) { maxKinEnergy = theParameters->MaxKinEnergy(); } 234 if(!actBinning) { nBins = theParameters->Num << 445 if(!actBinning) { >> 446 nBins = theParameters->NumberOfBinsPerDecade() >> 447 *G4lrint(std::log10(maxKinEnergy/minKinEnergy)); >> 448 } 235 maxKinEnergyCSDA = theParameters->MaxEnergyF 449 maxKinEnergyCSDA = theParameters->MaxEnergyForCSDARange(); 236 nBinsCSDA = theParameters->NumberOfBinsPerDe 450 nBinsCSDA = theParameters->NumberOfBinsPerDecade() 237 *G4lrint(std::log10(maxKinEnergyCSDA/minKi 451 *G4lrint(std::log10(maxKinEnergyCSDA/minKinEnergy)); 238 if(!actLinLossLimit) { linLossLimit = thePar 452 if(!actLinLossLimit) { linLossLimit = theParameters->LinearLossLimit(); } 239 lambdaFactor = theParameters->LambdaFactor() 453 lambdaFactor = theParameters->LambdaFactor(); 240 invLambdaFactor = 1.0/lambdaFactor; << 241 if(isMaster) { SetVerboseLevel(theParameters 454 if(isMaster) { SetVerboseLevel(theParameters->Verbose()); } 242 else { SetVerboseLevel(theParameters->Worker << 455 else { SetVerboseLevel(theParameters->WorkerVerbose()); } 243 // integral option may be disabled << 244 if(!theParameters->Integral()) { fXSType = f << 245 456 246 theParameters->DefineRegParamForLoss(this); << 457 G4bool isElec = true; 247 << 458 if(particle->GetPDGMass() > CLHEP::MeV) { isElec = false; } 248 fRangeEnergy = 0.0; << 459 theParameters->DefineRegParamForLoss(this, isElec); 249 460 250 G4double initialCharge = particle->GetPDGCha 461 G4double initialCharge = particle->GetPDGCharge(); 251 G4double initialMass = particle->GetPDGMas 462 G4double initialMass = particle->GetPDGMass(); 252 463 253 theParameters->FillStepFunction(particle, th << 464 if (baseParticle) { 254 << 465 massRatio = (baseParticle->GetPDGMass())/initialMass; 255 // parameters for scaling from the base part << 256 if (nullptr != baseParticle) { << 257 massRatio = (baseParticle->GetPDGMass() << 258 logMassRatio = G4Log(massRatio); << 259 G4double q = initialCharge/baseParticle->G 466 G4double q = initialCharge/baseParticle->GetPDGCharge(); 260 chargeSqRatio = q*q; 467 chargeSqRatio = q*q; 261 if(chargeSqRatio > 0.0) { reduceFactor = 1 468 if(chargeSqRatio > 0.0) { reduceFactor = 1.0/(chargeSqRatio*massRatio); } 262 } 469 } 263 lowestKinEnergy = (initialMass < CLHEP::MeV) << 470 lowestKinEnergy = (initialMass < MeV) ? theParameters->LowestElectronEnergy() 264 ? theParameters->LowestElectronEnergy() << 265 : theParameters->LowestMuHadEnergy(); 471 : theParameters->LowestMuHadEnergy(); 266 472 267 // Tables preparation 473 // Tables preparation 268 if (isMaster && nullptr == baseParticle) { << 474 if (isMaster && !baseParticle) { 269 if(nullptr == theData) { theData = new G4E << 270 475 271 if(nullptr != theDEDXTable && isIonisation << 476 if(theDEDXTable && isIonisation) { 272 if(nullptr != theIonisationTable && theD << 477 if(theIonisationTable && theDEDXTable != theIonisationTable) { 273 theData->CleanTable(0); << 478 theDEDXTable->clearAndDestroy(); 274 theDEDXTable = theIonisationTable; << 479 delete theDEDXTable; 275 theIonisationTable = nullptr; << 480 theDEDXTable = theIonisationTable; 276 } << 481 } >> 482 if(theDEDXSubTable && theIonisationSubTable && >> 483 theDEDXSubTable != theIonisationSubTable) { >> 484 theDEDXSubTable->clearAndDestroy(); >> 485 delete theDEDXSubTable; >> 486 theDEDXSubTable = theIonisationSubTable; >> 487 } 277 } 488 } 278 489 279 theDEDXTable = theData->MakeTable(theDEDXT << 490 theDEDXTable = G4PhysicsTableHelper::PreparePhysicsTable(theDEDXTable); 280 bld->InitialiseBaseMaterials(theDEDXTable) 491 bld->InitialiseBaseMaterials(theDEDXTable); 281 theData->UpdateTable(theIonisationTable, 1 << 492 >> 493 if(theDEDXSubTable) { >> 494 theDEDXSubTable = >> 495 G4PhysicsTableHelper::PreparePhysicsTable(theDEDXSubTable); >> 496 } 282 497 283 if (theParameters->BuildCSDARange()) { 498 if (theParameters->BuildCSDARange()) { 284 theDEDXunRestrictedTable = theData->Make << 499 theDEDXunRestrictedTable = 285 if(isIonisation) { theCSDARangeTable = t << 500 G4PhysicsTableHelper::PreparePhysicsTable(theDEDXunRestrictedTable); >> 501 theCSDARangeTable = >> 502 G4PhysicsTableHelper::PreparePhysicsTable(theCSDARangeTable); 286 } 503 } 287 504 288 theLambdaTable = theData->MakeTable(4); << 505 theLambdaTable = G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable); >> 506 289 if(isIonisation) { 507 if(isIonisation) { 290 theRangeTableForLoss = theData->MakeTabl << 508 theRangeTableForLoss = 291 theInverseRangeTable = theData->MakeTabl << 509 G4PhysicsTableHelper::PreparePhysicsTable(theRangeTableForLoss); >> 510 theInverseRangeTable = >> 511 G4PhysicsTableHelper::PreparePhysicsTable(theInverseRangeTable); 292 } 512 } 293 } << 294 513 >> 514 if (nSCoffRegions && !lManager->SubCutProducer()) { >> 515 theDEDXSubTable = >> 516 G4PhysicsTableHelper::PreparePhysicsTable(theDEDXSubTable); >> 517 theSubLambdaTable = >> 518 G4PhysicsTableHelper::PreparePhysicsTable(theSubLambdaTable); >> 519 } >> 520 } >> 521 /* >> 522 G4cout << "** G4VEnergyLossProcess::PreparePhysicsTable() for " >> 523 << GetProcessName() << " and " << particle->GetParticleName() >> 524 << " isMaster: " << isMaster << " isIonisation: " >> 525 << isIonisation << G4endl; >> 526 G4cout << " theDEDX: " << theDEDXTable >> 527 << " theRange: " << theRangeTableForLoss >> 528 << " theInverse: " << theInverseRangeTable >> 529 << " theLambda: " << theLambdaTable << G4endl; >> 530 */ 295 // forced biasing 531 // forced biasing 296 if(nullptr != biasManager) { << 532 if(biasManager) { 297 biasManager->Initialise(part,GetProcessNam 533 biasManager->Initialise(part,GetProcessName(),verboseLevel); 298 biasFlag = false; 534 biasFlag = false; 299 } 535 } 300 baseMat = bld->GetBaseMaterialFlag(); << 536 301 numberOfModels = modelManager->NumberOfModel << 537 // defined ID of secondary particles 302 currentModel = modelManager->GetModel(0); << 538 if(isMaster) { 303 G4EmTableUtil::UpdateModels(this, modelManag << 539 G4String nam1 = GetProcessName(); 304 numberOfModels, << 540 G4String nam4 = nam1 + "_split"; 305 mainSecondaries, << 541 G4String nam5 = nam1 + "_subcut"; 306 theParameters->U << 542 secID = G4PhysicsModelCatalog::Register(nam1); 307 theCuts = modelManager->Initialise(particle, << 543 biasID = G4PhysicsModelCatalog::Register(nam4); 308 verboseLe << 544 subsecID= G4PhysicsModelCatalog::Register(nam5); 309 // subcut processor << 545 } 310 if(isIonisation) { << 546 311 subcutProducer = lManager->SubCutProducer( << 547 // initialisation of models >> 548 G4int nmod = modelManager->NumberOfModels(); >> 549 for(G4int i=0; i<nmod; ++i) { >> 550 G4VEmModel* mod = modelManager->GetModel(i); >> 551 mod->SetMasterThread(isMaster); >> 552 mod->SetAngularGeneratorFlag( >> 553 theParameters->UseAngularGeneratorForIonisation()); >> 554 if(mod->HighEnergyLimit() > maxKinEnergy) { >> 555 mod->SetHighEnergyLimit(maxKinEnergy); >> 556 } 312 } 557 } 313 if(1 == nSCoffRegions) { << 558 theCuts = modelManager->Initialise(particle, secondaryParticle, 314 if((*scoffRegions)[0]->GetName() == "Defau << 559 theParameters->MinSubRange(), 315 delete scoffRegions; << 560 verboseLevel); 316 scoffRegions = nullptr; << 561 317 nSCoffRegions = 0; << 562 // Sub Cutoff >> 563 if(nSCoffRegions > 0) { >> 564 if(theParameters->MinSubRange() < 1.0) { useSubCutoff = true; } >> 565 >> 566 theSubCuts = modelManager->SubCutoff(); >> 567 >> 568 idxSCoffRegions = new G4bool[n]; >> 569 for (size_t j=0; j<n; ++j) { >> 570 >> 571 const G4MaterialCutsCouple* couple = >> 572 theCoupleTable->GetMaterialCutsCouple(j); >> 573 const G4ProductionCuts* pcuts = couple->GetProductionCuts(); >> 574 >> 575 G4bool reg = false; >> 576 for(G4int i=0; i<nSCoffRegions; ++i) { >> 577 if( pcuts == scoffRegions[i]->GetProductionCuts()) { >> 578 reg = true; >> 579 break; >> 580 } >> 581 } >> 582 idxSCoffRegions[j] = reg; 318 } 583 } 319 } 584 } 320 585 321 if(1 < verboseLevel) { 586 if(1 < verboseLevel) { 322 G4cout << "G4VEnergyLossProcess::PrepearPh 587 G4cout << "G4VEnergyLossProcess::PrepearPhysicsTable() is done " 323 << " for " << GetProcessName() << " << 588 << " for local " << particle->GetParticleName() 324 << " isIon= " << isIon << " spline= << 589 << " isIon= " << isIon; 325 if(baseParticle) { 590 if(baseParticle) { 326 G4cout << "; base: " << baseParticle->Ge 591 G4cout << "; base: " << baseParticle->GetParticleName(); 327 } 592 } 328 G4cout << G4endl; << 329 G4cout << " chargeSqRatio= " << chargeSqRa 593 G4cout << " chargeSqRatio= " << chargeSqRatio 330 << " massRatio= " << massRatio 594 << " massRatio= " << massRatio 331 << " reduceFactor= " << reduceFacto 595 << " reduceFactor= " << reduceFactor << G4endl; 332 if (nSCoffRegions > 0) { << 596 if (nSCoffRegions) { 333 G4cout << " SubCut secondary production << 597 G4cout << " SubCutoff Regime is ON for regions: " << G4endl; 334 for (G4int i=0; i<nSCoffRegions; ++i) { 598 for (G4int i=0; i<nSCoffRegions; ++i) { 335 const G4Region* r = (*scoffRegions)[i] << 599 const G4Region* r = scoffRegions[i]; 336 G4cout << " " << r->GetName( 600 G4cout << " " << r->GetName() << G4endl; 337 } 601 } 338 } else if(nullptr != subcutProducer) { << 339 G4cout << " SubCut secondary production << 340 } 602 } 341 } 603 } 342 } 604 } 343 605 344 //....oooOO0OOooo........oooOO0OOooo........oo 606 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 345 607 346 void G4VEnergyLossProcess::BuildPhysicsTable(c 608 void G4VEnergyLossProcess::BuildPhysicsTable(const G4ParticleDefinition& part) 347 { 609 { 348 if(1 < verboseLevel) { 610 if(1 < verboseLevel) { 349 G4cout << "### G4VEnergyLossProcess::Build 611 G4cout << "### G4VEnergyLossProcess::BuildPhysicsTable() for " 350 << GetProcessName() 612 << GetProcessName() 351 << " and particle " << part.GetPart 613 << " and particle " << part.GetParticleName() 352 << "; the first particle " << parti << 614 << "; local: " << particle->GetParticleName(); 353 if(baseParticle) { 615 if(baseParticle) { 354 G4cout << "; base: " << baseParticle->Ge 616 G4cout << "; base: " << baseParticle->GetParticleName(); 355 } 617 } 356 G4cout << G4endl; << 618 G4cout << " TablesAreBuilt= " << tablesAreBuilt 357 G4cout << " TablesAreBuilt= " << tables << 619 << " isIon= " << isIon << " " << this << G4endl; 358 << " spline=" << spline << " ptr: " << 359 } 620 } 360 621 361 if(&part == particle) { 622 if(&part == particle) { >> 623 >> 624 G4LossTableBuilder* bld = lManager->GetTableBuilder(); 362 if(isMaster) { 625 if(isMaster) { >> 626 theDensityFactor = bld->GetDensityFactors(); >> 627 theDensityIdx = bld->GetCoupleIndexes(); 363 lManager->BuildPhysicsTable(particle, th 628 lManager->BuildPhysicsTable(particle, this); 364 629 365 } else { 630 } else { 366 const auto masterProcess = << 631 >> 632 const G4VEnergyLossProcess* masterProcess = 367 static_cast<const G4VEnergyLossProcess 633 static_cast<const G4VEnergyLossProcess*>(GetMasterProcess()); 368 634 369 numberOfModels = modelManager->NumberOfM << 635 // define density factors for worker thread 370 G4EmTableUtil::BuildLocalElossProcess(th << 636 bld->InitialiseBaseMaterials(masterProcess->DEDXTable()); 371 pa << 637 theDensityFactor = bld->GetDensityFactors(); >> 638 theDensityIdx = bld->GetCoupleIndexes(); >> 639 >> 640 // copy table pointers from master thread >> 641 SetDEDXTable(masterProcess->DEDXTable(),fRestricted); >> 642 SetDEDXTable(masterProcess->DEDXTableForSubsec(),fSubRestricted); >> 643 SetDEDXTable(masterProcess->DEDXunRestrictedTable(),fTotal); >> 644 SetDEDXTable(masterProcess->IonisationTable(),fIsIonisation); >> 645 SetDEDXTable(masterProcess->IonisationTableForSubsec(),fIsSubIonisation); >> 646 SetRangeTableForLoss(masterProcess->RangeTableForLoss()); >> 647 SetCSDARangeTable(masterProcess->CSDARangeTable()); >> 648 SetSecondaryRangeTable(masterProcess->SecondaryRangeTable()); >> 649 SetInverseRangeTable(masterProcess->InverseRangeTable()); >> 650 SetLambdaTable(masterProcess->LambdaTable()); >> 651 SetSubLambdaTable(masterProcess->SubLambdaTable()); >> 652 isIonisation = masterProcess->IsIonisationProcess(); >> 653 372 tablesAreBuilt = true; 654 tablesAreBuilt = true; 373 baseMat = masterProcess->UseBaseMaterial << 655 // local initialisation of models >> 656 G4bool printing = true; >> 657 G4int numberOfModels = modelManager->NumberOfModels(); >> 658 for(G4int i=0; i<numberOfModels; ++i) { >> 659 G4VEmModel* mod = GetModelByIndex(i, printing); >> 660 G4VEmModel* mod0= masterProcess->GetModelByIndex(i,printing); >> 661 mod->InitialiseLocal(particle, mod0); >> 662 } >> 663 374 lManager->LocalPhysicsTables(particle, t 664 lManager->LocalPhysicsTables(particle, this); 375 } 665 } 376 666 377 // needs to be done only once 667 // needs to be done only once 378 safetyHelper->InitialiseHelper(); 668 safetyHelper->InitialiseHelper(); 379 } 669 } 380 // Added tracking cut to avoid tracking arti << 381 // and identified deexcitation flag << 382 if(isIonisation) { << 383 atomDeexcitation = lManager->AtomDeexcitat << 384 if(nullptr != atomDeexcitation) { << 385 if(atomDeexcitation->IsPIXEActive()) { u << 386 } << 387 } << 388 << 389 // protection against double printout << 390 if(theParameters->IsPrintLocked()) { return; << 391 << 392 // explicitly defined printout by particle n 670 // explicitly defined printout by particle name 393 G4String num = part.GetParticleName(); 671 G4String num = part.GetParticleName(); 394 if(1 < verboseLevel || 672 if(1 < verboseLevel || 395 (0 < verboseLevel && (num == "e-" || 673 (0 < verboseLevel && (num == "e-" || 396 num == "e+" || n 674 num == "e+" || num == "mu+" || 397 num == "mu-" || n 675 num == "mu-" || num == "proton"|| 398 num == "pi+" || n 676 num == "pi+" || num == "pi-" || 399 num == "kaon+" || n 677 num == "kaon+" || num == "kaon-" || 400 num == "alpha" || n 678 num == "alpha" || num == "anti_proton" || 401 num == "GenericIon" << 679 num == "GenericIon"|| num == "alpha++" || 402 StreamInfo(G4cout, part); << 680 num == "alpha+" ))) >> 681 { >> 682 StreamInfo(G4cout, part); >> 683 } >> 684 >> 685 // Added tracking cut to avoid tracking artifacts >> 686 // identify deexcitation flag >> 687 if(isIonisation) { >> 688 atomDeexcitation = lManager->AtomDeexcitation(); >> 689 if(nSCoffRegions > 0) { subcutProducer = lManager->SubCutProducer(); } >> 690 if(atomDeexcitation) { >> 691 if(atomDeexcitation->IsPIXEActive()) { useDeexcitation = true; } >> 692 } 403 } 693 } >> 694 /* >> 695 G4cout << "** G4VEnergyLossProcess::BuildPhysicsTable() for " >> 696 << GetProcessName() << " and " << particle->GetParticleName() >> 697 << " isMaster: " << isMaster << " isIonisation: " >> 698 << isIonisation << G4endl; >> 699 G4cout << " theDEDX: " << theDEDXTable >> 700 << " theRange: " << theRangeTableForLoss >> 701 << " theInverse: " << theInverseRangeTable >> 702 << " theLambda: " << theLambdaTable << G4endl; >> 703 */ >> 704 //if(1 < verboseLevel || verb) { 404 if(1 < verboseLevel) { 705 if(1 < verboseLevel) { 405 G4cout << "### G4VEnergyLossProcess::Build 706 G4cout << "### G4VEnergyLossProcess::BuildPhysicsTable() done for " 406 << GetProcessName() 707 << GetProcessName() 407 << " and particle " << part.GetPart 708 << " and particle " << part.GetParticleName(); 408 if(isIonisation) { G4cout << " isIonisati << 709 if(isIonisation) { G4cout << " isIonisation flag = 1"; } 409 G4cout << " baseMat=" << baseMat << G4endl << 710 G4cout << G4endl; 410 } 711 } 411 } 712 } 412 713 413 //....oooOO0OOooo........oooOO0OOooo........oo 714 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 414 715 415 G4PhysicsTable* G4VEnergyLossProcess::BuildDED 716 G4PhysicsTable* G4VEnergyLossProcess::BuildDEDXTable(G4EmTableType tType) 416 { 717 { >> 718 if(1 < verboseLevel ) { >> 719 G4cout << "G4VEnergyLossProcess::BuildDEDXTable() of type " << tType >> 720 << " for " << GetProcessName() >> 721 << " and particle " << particle->GetParticleName() >> 722 << G4endl; >> 723 } 417 G4PhysicsTable* table = nullptr; 724 G4PhysicsTable* table = nullptr; 418 G4double emax = maxKinEnergy; 725 G4double emax = maxKinEnergy; 419 G4int bin = nBins; 726 G4int bin = nBins; 420 727 421 if(fTotal == tType) { 728 if(fTotal == tType) { 422 emax = maxKinEnergyCSDA; 729 emax = maxKinEnergyCSDA; 423 bin = nBinsCSDA; 730 bin = nBinsCSDA; 424 table = theDEDXunRestrictedTable; 731 table = theDEDXunRestrictedTable; 425 } else if(fRestricted == tType) { 732 } else if(fRestricted == tType) { 426 table = theDEDXTable; 733 table = theDEDXTable; >> 734 } else if(fSubRestricted == tType) { >> 735 table = theDEDXSubTable; 427 } else { 736 } else { 428 G4cout << "G4VEnergyLossProcess::BuildDEDX 737 G4cout << "G4VEnergyLossProcess::BuildDEDXTable WARNING: wrong type " 429 << tType << G4endl; 738 << tType << G4endl; 430 } 739 } >> 740 >> 741 // Access to materials >> 742 const G4ProductionCutsTable* theCoupleTable= >> 743 G4ProductionCutsTable::GetProductionCutsTable(); >> 744 size_t numOfCouples = theCoupleTable->GetTableSize(); >> 745 431 if(1 < verboseLevel) { 746 if(1 < verboseLevel) { 432 G4cout << "G4VEnergyLossProcess::BuildDEDX << 747 G4cout << numOfCouples << " materials" 433 << " for " << GetProcessName() << 748 << " minKinEnergy= " << minKinEnergy 434 << " and " << particle->GetParticle << 749 << " maxKinEnergy= " << emax 435 << "spline=" << spline << G4endl; << 750 << " nbin= " << bin >> 751 << " EmTableType= " << tType >> 752 << " table= " << table << " " << this >> 753 << G4endl; 436 } 754 } 437 if(nullptr == table) { return table; } << 755 if(!table) { return table; } 438 756 439 G4LossTableBuilder* bld = lManager->GetTable 757 G4LossTableBuilder* bld = lManager->GetTableBuilder(); 440 G4EmTableUtil::BuildDEDXTable(this, particle << 758 G4bool splineFlag = theParameters->Spline(); 441 table, minKinE << 759 G4PhysicsLogVector* aVector = nullptr; 442 verboseLevel, << 760 G4PhysicsLogVector* bVector = nullptr; >> 761 >> 762 for(size_t i=0; i<numOfCouples; ++i) { >> 763 >> 764 if(1 < verboseLevel) { >> 765 G4cout << "G4VEnergyLossProcess::BuildDEDXVector Idx= " << i >> 766 << " flagTable= " << table->GetFlag(i) >> 767 << " Flag= " << bld->GetFlag(i) << G4endl; >> 768 } >> 769 if(bld->GetFlag(i)) { >> 770 >> 771 // create physics vector and fill it >> 772 const G4MaterialCutsCouple* couple = >> 773 theCoupleTable->GetMaterialCutsCouple(i); >> 774 if((*table)[i]) { delete (*table)[i]; } >> 775 if(bVector) { >> 776 aVector = new G4PhysicsLogVector(*bVector); >> 777 } else { >> 778 bVector = new G4PhysicsLogVector(minKinEnergy, emax, bin); >> 779 aVector = bVector; >> 780 } >> 781 aVector->SetSpline(splineFlag); >> 782 >> 783 modelManager->FillDEDXVector(aVector, couple, tType); >> 784 if(splineFlag) { aVector->FillSecondDerivatives(); } >> 785 >> 786 // Insert vector for this material into the table >> 787 G4PhysicsTableHelper::SetPhysicsVector(table, i, aVector); >> 788 } >> 789 } >> 790 >> 791 if(1 < verboseLevel) { >> 792 G4cout << "G4VEnergyLossProcess::BuildDEDXTable(): table is built for " >> 793 << particle->GetParticleName() >> 794 << " and process " << GetProcessName() >> 795 << G4endl; >> 796 if(2 < verboseLevel) G4cout << (*table) << G4endl; >> 797 } >> 798 443 return table; 799 return table; 444 } 800 } 445 801 446 //....oooOO0OOooo........oooOO0OOooo........oo 802 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 447 803 448 G4PhysicsTable* G4VEnergyLossProcess::BuildLam << 804 G4PhysicsTable* G4VEnergyLossProcess::BuildLambdaTable(G4EmTableType tType) 449 { 805 { 450 if(nullptr == theLambdaTable) { return theLa << 806 G4PhysicsTable* table = nullptr; >> 807 >> 808 if(fRestricted == tType) { >> 809 table = theLambdaTable; >> 810 } else if(fSubRestricted == tType) { >> 811 table = theSubLambdaTable; >> 812 } else { >> 813 G4cout << "G4VEnergyLossProcess::BuildLambdaTable WARNING: wrong type " >> 814 << tType << G4endl; >> 815 } >> 816 >> 817 if(1 < verboseLevel) { >> 818 G4cout << "G4VEnergyLossProcess::BuildLambdaTable() of type " >> 819 << tType << " for process " >> 820 << GetProcessName() << " and particle " >> 821 << particle->GetParticleName() >> 822 << " EmTableType= " << tType >> 823 << " table= " << table >> 824 << G4endl; >> 825 } >> 826 if(!table) {return table;} >> 827 >> 828 // Access to materials >> 829 const G4ProductionCutsTable* theCoupleTable= >> 830 G4ProductionCutsTable::GetProductionCutsTable(); >> 831 size_t numOfCouples = theCoupleTable->GetTableSize(); 451 832 452 G4double scale = theParameters->MaxKinEnergy << 453 G4int nbin = << 454 theParameters->NumberOfBinsPerDecade()*G4l << 455 scale = nbin/G4Log(scale); << 456 << 457 G4LossTableBuilder* bld = lManager->GetTable 833 G4LossTableBuilder* bld = lManager->GetTableBuilder(); 458 G4EmTableUtil::BuildLambdaTable(this, partic << 834 theDensityFactor = bld->GetDensityFactors(); 459 bld, theLamb << 835 theDensityIdx = bld->GetCoupleIndexes(); 460 minKinEnergy << 836 461 verboseLevel << 837 G4bool splineFlag = theParameters->Spline(); 462 return theLambdaTable; << 838 G4PhysicsLogVector* aVector = nullptr; >> 839 G4double scale = G4Log(maxKinEnergy/minKinEnergy); >> 840 >> 841 for(size_t i=0; i<numOfCouples; ++i) { >> 842 >> 843 if (bld->GetFlag(i)) { >> 844 >> 845 // create physics vector and fill it >> 846 const G4MaterialCutsCouple* couple = >> 847 theCoupleTable->GetMaterialCutsCouple(i); >> 848 delete (*table)[i]; >> 849 >> 850 G4bool startNull = true; >> 851 G4double emin = >> 852 MinPrimaryEnergy(particle,couple->GetMaterial(),(*theCuts)[i]); >> 853 if(minKinEnergy > emin) { >> 854 emin = minKinEnergy; >> 855 startNull = false; >> 856 } >> 857 >> 858 G4double emax = maxKinEnergy; >> 859 if(emax <= emin) { emax = 2*emin; } >> 860 G4int bin = G4lrint(nBins*G4Log(emax/emin)/scale); >> 861 bin = std::max(bin, 3); >> 862 aVector = new G4PhysicsLogVector(emin, emax, bin); >> 863 aVector->SetSpline(splineFlag); >> 864 >> 865 modelManager->FillLambdaVector(aVector, couple, startNull, tType); >> 866 if(splineFlag) { aVector->FillSecondDerivatives(); } >> 867 >> 868 // Insert vector for this material into the table >> 869 G4PhysicsTableHelper::SetPhysicsVector(table, i, aVector); >> 870 } >> 871 } >> 872 >> 873 if(1 < verboseLevel) { >> 874 G4cout << "Lambda table is built for " >> 875 << particle->GetParticleName() >> 876 << G4endl; >> 877 } >> 878 >> 879 return table; 463 } 880 } 464 881 465 //....oooOO0OOooo........oooOO0OOooo........oo 882 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 466 883 467 void G4VEnergyLossProcess::StreamInfo(std::ost 884 void G4VEnergyLossProcess::StreamInfo(std::ostream& out, 468 const G4ParticleDefinition& pa 885 const G4ParticleDefinition& part, G4bool rst) const 469 { 886 { 470 G4String indent = (rst ? " " : ""); 887 G4String indent = (rst ? " " : ""); 471 out << std::setprecision(6); 888 out << std::setprecision(6); 472 out << G4endl << indent << GetProcessName() 889 out << G4endl << indent << GetProcessName() << ": "; 473 if (!rst) out << " for " << part.GetParticle 890 if (!rst) out << " for " << part.GetParticleName(); 474 out << " XStype:" << fXSType << 891 out << " SubType=" << GetProcessSubType() << G4endl 475 << " SubType=" << GetProcessSubType() < << 476 << " dE/dx and range tables from " 892 << " dE/dx and range tables from " 477 << G4BestUnit(minKinEnergy,"Energy") 893 << G4BestUnit(minKinEnergy,"Energy") 478 << " to " << G4BestUnit(maxKinEnergy,"En 894 << " to " << G4BestUnit(maxKinEnergy,"Energy") 479 << " in " << nBins << " bins" << G4endl 895 << " in " << nBins << " bins" << G4endl 480 << " Lambda tables from threshold t 896 << " Lambda tables from threshold to " 481 << G4BestUnit(maxKinEnergy,"Energy") 897 << G4BestUnit(maxKinEnergy,"Energy") 482 << ", " << theParameters->NumberOfBinsPe 898 << ", " << theParameters->NumberOfBinsPerDecade() 483 << " bins/decade, spline: " << spline << 899 << " bins/decade, spline: " >> 900 << theParameters->Spline() 484 << G4endl; 901 << G4endl; 485 if(nullptr != theRangeTableForLoss && isIoni << 902 if(theRangeTableForLoss && isIonisation) { 486 out << " StepFunction=(" << dRoverRan 903 out << " StepFunction=(" << dRoverRange << ", " 487 << finalRange/mm << " mm)" 904 << finalRange/mm << " mm)" 488 << ", integ: " << fXSType << 905 << ", integ: " << integral 489 << ", fluct: " << lossFluctuationFlag 906 << ", fluct: " << lossFluctuationFlag 490 << ", linLossLim= " << linLossLimit 907 << ", linLossLim= " << linLossLimit 491 << G4endl; 908 << G4endl; 492 } 909 } 493 StreamProcessInfo(out); 910 StreamProcessInfo(out); 494 modelManager->DumpModelList(out, verboseLeve 911 modelManager->DumpModelList(out, verboseLevel); 495 if(nullptr != theCSDARangeTable && isIonisat << 912 if(theCSDARangeTable && isIonisation) { 496 out << " CSDA range table up" 913 out << " CSDA range table up" 497 << " to " << G4BestUnit(maxKinEnergyCS 914 << " to " << G4BestUnit(maxKinEnergyCSDA,"Energy") 498 << " in " << nBinsCSDA << " bins" << G 915 << " in " << nBinsCSDA << " bins" << G4endl; 499 } 916 } 500 if(nSCoffRegions>0 && isIonisation) { 917 if(nSCoffRegions>0 && isIonisation) { 501 out << " Subcutoff sampling in " << n 918 out << " Subcutoff sampling in " << nSCoffRegions 502 << " regions" << G4endl; 919 << " regions" << G4endl; 503 } 920 } 504 if(2 < verboseLevel) { 921 if(2 < verboseLevel) { 505 for(std::size_t i=0; i<7; ++i) { << 922 out << " DEDXTable address= " << theDEDXTable << G4endl; 506 auto ta = theData->Table(i); << 923 if(theDEDXTable && isIonisation) out << (*theDEDXTable) << G4endl; 507 out << " " << tnames[i] << " addres << 924 out << "non restricted DEDXTable address= " 508 if(nullptr != ta) { out << *ta << G4endl << 925 << theDEDXunRestrictedTable << G4endl; >> 926 if(theDEDXunRestrictedTable && isIonisation) { >> 927 out << (*theDEDXunRestrictedTable) << G4endl; >> 928 } >> 929 if(theDEDXSubTable && isIonisation) { >> 930 out << (*theDEDXSubTable) << G4endl; >> 931 } >> 932 out << " CSDARangeTable address= " << theCSDARangeTable << G4endl; >> 933 if(theCSDARangeTable && isIonisation) { >> 934 out << (*theCSDARangeTable) << G4endl; >> 935 } >> 936 out << " RangeTableForLoss address= " << theRangeTableForLoss >> 937 << G4endl; >> 938 if(theRangeTableForLoss && isIonisation) { >> 939 out << (*theRangeTableForLoss) << G4endl; >> 940 } >> 941 out << " InverseRangeTable address= " << theInverseRangeTable >> 942 << G4endl; >> 943 if(theInverseRangeTable && isIonisation) { >> 944 out << (*theInverseRangeTable) << G4endl; >> 945 } >> 946 out << " LambdaTable address= " << theLambdaTable << G4endl; >> 947 if(theLambdaTable && isIonisation) { >> 948 out << (*theLambdaTable) << G4endl; >> 949 } >> 950 out << " SubLambdaTable address= " << theSubLambdaTable << G4endl; >> 951 if(theSubLambdaTable && isIonisation) { >> 952 out << (*theSubLambdaTable) << G4endl; 509 } 953 } 510 } 954 } 511 } 955 } 512 956 513 //....oooOO0OOooo........oooOO0OOooo........oo 957 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 514 958 515 void G4VEnergyLossProcess::ActivateSubCutoff(c << 959 void G4VEnergyLossProcess::ActivateSubCutoff(G4bool val, const G4Region* r) 516 { 960 { 517 if(nullptr == scoffRegions) { << 961 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 518 scoffRegions = new std::vector<const G4Reg << 962 const G4Region* reg = r; >> 963 if (!reg) { >> 964 reg = regionStore->GetRegion("DefaultRegionForTheWorld", false); 519 } 965 } >> 966 520 // the region is in the list 967 // the region is in the list 521 if(!scoffRegions->empty()) { << 968 if (nSCoffRegions > 0) { 522 for (auto & reg : *scoffRegions) { << 969 for (G4int i=0; i<nSCoffRegions; ++i) { 523 if (reg == r) { return; } << 970 if (reg == scoffRegions[i]) { >> 971 return; >> 972 } 524 } 973 } 525 } 974 } 526 // new region 975 // new region 527 scoffRegions->push_back(r); << 976 if(val) { 528 ++nSCoffRegions; << 977 scoffRegions.push_back(reg); 529 } << 978 ++nSCoffRegions; 530 << 531 //....oooOO0OOooo........oooOO0OOooo........oo << 532 << 533 G4bool G4VEnergyLossProcess::IsRegionForCubcut << 534 { << 535 if(0 == nSCoffRegions) { return true; } << 536 const G4Region* r = aTrack.GetVolume()->GetL << 537 for(auto & reg : *scoffRegions) { << 538 if(r == reg) { return true; } << 539 } 979 } 540 return false; << 541 } 980 } 542 981 543 //....oooOO0OOooo........oooOO0OOooo........oo 982 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 544 983 545 void G4VEnergyLossProcess::StartTracking(G4Tra 984 void G4VEnergyLossProcess::StartTracking(G4Track* track) 546 { 985 { >> 986 /* >> 987 G4cout << track->GetDefinition()->GetParticleName() >> 988 << " e(MeV)= " << track->GetKineticEnergy() >> 989 << " baseParticle " << baseParticle << " proc " << this; >> 990 if(particle) G4cout << " " << particle->GetParticleName(); >> 991 G4cout << " isIon= " << isIon << " dedx " << theDEDXTable <<G4endl; >> 992 */ 547 // reset parameters for the new track 993 // reset parameters for the new track 548 theNumberOfInteractionLengthLeft = -1.0; 994 theNumberOfInteractionLengthLeft = -1.0; 549 mfpKinEnergy = DBL_MAX; << 995 currentInteractionLength = mfpKinEnergy = DBL_MAX; 550 preStepLambda = 0.0; << 996 preStepRangeEnergy = 0.0; 551 currentCouple = nullptr; << 552 997 553 // reset ion 998 // reset ion 554 if(isIon) { 999 if(isIon) { 555 const G4double newmass = track->GetDefinit << 1000 chargeSqRatio = 0.5; 556 massRatio = (nullptr == baseParticle) ? CL << 1001 557 : baseParticle->GetPDGMass()/newmass; << 1002 G4double newmass = track->GetDefinition()->GetPDGMass(); 558 logMassRatio = G4Log(massRatio); << 1003 if(baseParticle) { >> 1004 massRatio = baseParticle->GetPDGMass()/newmass; >> 1005 } else if(theGenericIon) { >> 1006 massRatio = proton_mass_c2/newmass; >> 1007 } else { >> 1008 massRatio = 1.0; >> 1009 } 559 } 1010 } 560 // forced biasing only for primary particles 1011 // forced biasing only for primary particles 561 if(nullptr != biasManager) { << 1012 if(biasManager) { 562 if(0 == track->GetParentID()) { 1013 if(0 == track->GetParentID()) { >> 1014 // primary particle 563 biasFlag = true; 1015 biasFlag = true; 564 biasManager->ResetForcedInteraction(); 1016 biasManager->ResetForcedInteraction(); 565 } 1017 } 566 } 1018 } 567 } 1019 } 568 1020 569 //....oooOO0OOooo........oooOO0OOooo........oo 1021 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 570 1022 571 G4double G4VEnergyLossProcess::AlongStepGetPhy 1023 G4double G4VEnergyLossProcess::AlongStepGetPhysicalInteractionLength( 572 const G4Track& tr << 1024 const G4Track&,G4double,G4double,G4double&, 573 G4GPILSelection* 1025 G4GPILSelection* selection) 574 { 1026 { 575 G4double x = DBL_MAX; 1027 G4double x = DBL_MAX; 576 *selection = aGPILSelection; 1028 *selection = aGPILSelection; 577 if(isIonisation && currentModel->IsActive(pr 1029 if(isIonisation && currentModel->IsActive(preStepScaledEnergy)) { 578 GetScaledRangeForScaledEnergy(preStepScale << 1030 fRange = GetScaledRangeForScaledEnergy(preStepScaledEnergy)*reduceFactor; 579 x = (useCutAsFinalRange) ? std::min(finalR << 1031 G4double finR = (rndmStepFlag) ? std::min(finalRange, 580 currentCouple->GetProductionCuts()->GetP 1032 currentCouple->GetProductionCuts()->GetProductionCut(1)) : finalRange; 581 x = (fRange > x) ? fRange*dRoverRange + x* << 1033 x = (fRange > finR) ? 582 : fRange; << 1034 fRange*dRoverRange + finR*(1.0-dRoverRange)*(2.0-finR/fRange) : fRange; 583 /* << 1035 // if(particle->GetPDGMass() > 0.9*GeV) 584 G4cout<<"AlongStepGPIL: " << GetProcessN << 1036 /* 585 << " fRange=" << fRange << " finR=" << finR << 1037 G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy >> 1038 <<" range= "<<fRange << " idx= " << basedCoupleIndex >> 1039 << " finR= " << finR >> 1040 << " limit= " << x <<G4endl; >> 1041 G4cout << "massRatio= " << massRatio << " Q^2= " << chargeSqRatio >> 1042 << " finR= " << finR << " dRoverRange= " << dRoverRange >> 1043 << " finalRange= " << finalRange << G4endl; 586 */ 1044 */ 587 } 1045 } >> 1046 //G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy >> 1047 //<<" stepLimit= "<<x<<G4endl; 588 return x; 1048 return x; 589 } 1049 } 590 1050 591 //....oooOO0OOooo........oooOO0OOooo........oo 1051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 592 1052 593 G4double G4VEnergyLossProcess::PostStepGetPhys 1053 G4double G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength( 594 const G4Track& tr 1054 const G4Track& track, 595 G4double previo 1055 G4double previousStepSize, 596 G4ForceCondition* 1056 G4ForceCondition* condition) 597 { 1057 { 598 // condition is set to "Not Forced" 1058 // condition is set to "Not Forced" 599 *condition = NotForced; 1059 *condition = NotForced; 600 G4double x = DBL_MAX; 1060 G4double x = DBL_MAX; 601 1061 602 // initialisation of material, mass, charge, 1062 // initialisation of material, mass, charge, model 603 // at the beginning of the step 1063 // at the beginning of the step 604 DefineMaterial(track.GetMaterialCutsCouple() 1064 DefineMaterial(track.GetMaterialCutsCouple()); 605 preStepKinEnergy = track.GetKineticEne << 1065 preStepKinEnergy = track.GetKineticEnergy(); 606 preStepScaledEnergy = preStepKinEnergy*ma << 1066 preStepScaledEnergy = preStepKinEnergy*massRatio; 607 SelectModel(preStepScaledEnergy); 1067 SelectModel(preStepScaledEnergy); 608 1068 609 if(!currentModel->IsActive(preStepScaledEner 1069 if(!currentModel->IsActive(preStepScaledEnergy)) { 610 theNumberOfInteractionLengthLeft = -1.0; 1070 theNumberOfInteractionLengthLeft = -1.0; 611 mfpKinEnergy = DBL_MAX; << 612 preStepLambda = 0.0; << 613 currentInteractionLength = DBL_MAX; 1071 currentInteractionLength = DBL_MAX; 614 return x; << 1072 return x; 615 } 1073 } 616 1074 617 // change effective charge of a charged part << 1075 // change effective charge of an ion on fly 618 if(isIon) { 1076 if(isIon) { 619 const G4double q2 = currentModel->ChargeSq << 1077 G4double q2 = currentModel->ChargeSquareRatio(track); 620 fFactor = q2*biasFactor; << 1078 if(q2 != chargeSqRatio && q2 > 0.0) { 621 if(baseMat) { fFactor *= (*theDensityFacto << 1079 chargeSqRatio = q2; 622 reduceFactor = 1.0/(fFactor*massRatio); << 1080 fFactor = q2*biasFactor*(*theDensityFactor)[currentCoupleIndex]; 623 if (lossFluctuationFlag) { << 1081 reduceFactor = 1.0/(fFactor*massRatio); 624 auto fluc = currentModel->GetModelOfFluc << 625 fluc->SetParticleAndCharge(track.GetDefi << 626 } 1082 } 627 } 1083 } >> 1084 // if(particle->GetPDGMass() > 0.9*GeV) >> 1085 //G4cout << "q2= "<<chargeSqRatio << " massRatio= " << massRatio << G4endl; 628 1086 629 // forced biasing only for primary particles 1087 // forced biasing only for primary particles 630 if(biasManager) { 1088 if(biasManager) { 631 if(0 == track.GetParentID() && biasFlag && 1089 if(0 == track.GetParentID() && biasFlag && 632 biasManager->ForcedInteractionRegion((G << 1090 biasManager->ForcedInteractionRegion(currentCoupleIndex)) { 633 return biasManager->GetStepLimit((G4int) << 1091 return biasManager->GetStepLimit(currentCoupleIndex, previousStepSize); 634 } 1092 } 635 } 1093 } 636 1094 637 ComputeLambdaForScaledEnergy(preStepScaledEn << 1095 // compute mean free path 638 << 1096 if(preStepScaledEnergy < mfpKinEnergy) { 639 // zero cross section << 1097 if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); } 640 if(preStepLambda <= 0.0) { << 1098 else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); } 641 theNumberOfInteractionLengthLeft = -1.0; << 1099 642 currentInteractionLength = DBL_MAX; << 1100 // zero cross section 643 } else { << 1101 if(preStepLambda <= 0.0) { >> 1102 theNumberOfInteractionLengthLeft = -1.0; >> 1103 currentInteractionLength = DBL_MAX; >> 1104 } >> 1105 } 644 1106 645 // non-zero cross section << 1107 // non-zero cross section >> 1108 if(preStepLambda > 0.0) { 646 if (theNumberOfInteractionLengthLeft < 0.0 1109 if (theNumberOfInteractionLengthLeft < 0.0) { 647 1110 648 // beggining of tracking (or just after 1111 // beggining of tracking (or just after DoIt of this process) 649 theNumberOfInteractionLengthLeft = -G4Lo << 1112 theNumberOfInteractionLengthLeft = -G4Log( G4UniformRand() ); 650 theInitialNumberOfInteractionLength = th 1113 theInitialNumberOfInteractionLength = theNumberOfInteractionLengthLeft; 651 1114 652 } else if(currentInteractionLength < DBL_M 1115 } else if(currentInteractionLength < DBL_MAX) { 653 1116 654 // subtract NumberOfInteractionLengthLef 1117 // subtract NumberOfInteractionLengthLeft using previous step 655 theNumberOfInteractionLengthLeft -= 1118 theNumberOfInteractionLengthLeft -= 656 previousStepSize/currentInteractionLen 1119 previousStepSize/currentInteractionLength; 657 1120 658 theNumberOfInteractionLengthLeft = 1121 theNumberOfInteractionLengthLeft = 659 std::max(theNumberOfInteractionLengthL 1122 std::max(theNumberOfInteractionLengthLeft, 0.0); 660 } 1123 } 661 1124 662 // new mean free path and step limit 1125 // new mean free path and step limit 663 currentInteractionLength = 1.0/preStepLamb 1126 currentInteractionLength = 1.0/preStepLambda; 664 x = theNumberOfInteractionLengthLeft * cur 1127 x = theNumberOfInteractionLengthLeft * currentInteractionLength; 665 } 1128 } 666 #ifdef G4VERBOSE 1129 #ifdef G4VERBOSE 667 if (verboseLevel>2) { << 1130 if (verboseLevel>2){ >> 1131 // if(particle->GetPDGMass() > 0.9*GeV){ 668 G4cout << "G4VEnergyLossProcess::PostStepG 1132 G4cout << "G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength "; 669 G4cout << "[ " << GetProcessName() << "]" 1133 G4cout << "[ " << GetProcessName() << "]" << G4endl; 670 G4cout << " for " << track.GetDefinition() 1134 G4cout << " for " << track.GetDefinition()->GetParticleName() 671 << " in Material " << currentMate 1135 << " in Material " << currentMaterial->GetName() 672 << " Ekin(MeV)= " << preStepKinEner 1136 << " Ekin(MeV)= " << preStepKinEnergy/MeV 673 << " track material: " << track.Get << 1137 << " " << track.GetMaterial()->GetName() 674 <<G4endl; 1138 <<G4endl; 675 G4cout << "MeanFreePath = " << currentInte 1139 G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]" 676 << "InteractionLength= " << x/cm << 1140 << "InteractionLength= " << x/cm <<"[cm] " <<G4endl; 677 } 1141 } 678 #endif 1142 #endif 679 return x; 1143 return x; 680 } 1144 } 681 1145 682 //....oooOO0OOooo........oooOO0OOooo........oo 1146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 683 1147 684 void << 1148 void G4VEnergyLossProcess::ComputeLambdaForScaledEnergy(G4double e) 685 G4VEnergyLossProcess::ComputeLambdaForScaledEn << 686 { 1149 { 687 // cross section increased with energy << 1150 // condition to skip recomputation of cross section 688 if(fXSType == fEmIncreasing) { << 1151 G4double epeak = theEnergyOfCrossSectionMax[currentCoupleIndex]; 689 if(e*invLambdaFactor < mfpKinEnergy) { << 1152 if(e <= epeak && e/lambdaFactor >= mfpKinEnergy) { return; } 690 preStepLambda = GetLambdaForScaledEnergy << 1153 691 mfpKinEnergy = (preStepLambda > 0.0) ? e << 1154 // recomputation is needed 692 } << 1155 if (e <= epeak) { 693 << 1156 preStepLambda = GetLambdaForScaledEnergy(e); 694 // cross section has one peak << 1157 mfpKinEnergy = e; 695 } else if(fXSType == fEmOnePeak) { << 1158 696 const G4double epeak = (*theEnergyOfCrossS << 1159 } else { 697 if(e <= epeak) { << 1160 G4double e1 = e*lambdaFactor; 698 if(e*invLambdaFactor < mfpKinEnergy) { << 1161 if(e1 > epeak) { 699 preStepLambda = GetLambdaForScaledEner << 1162 preStepLambda = GetLambdaForScaledEnergy(e); 700 mfpKinEnergy = (preStepLambda > 0.0) ? << 1163 mfpKinEnergy = e; 701 } << 1164 G4double preStepLambda1 = GetLambdaForScaledEnergy(e1); 702 } else if(e < mfpKinEnergy) { << 1165 if(preStepLambda1 > preStepLambda) { 703 const G4double e1 = std::max(epeak, e*la << 704 mfpKinEnergy = e1; << 705 preStepLambda = GetLambdaForScaledEnergy << 706 } << 707 << 708 // cross section has more than one peaks << 709 } else if(fXSType == fEmTwoPeaks) { << 710 G4TwoPeaksXS* xs = (*fXSpeaks)[basedCouple << 711 const G4double e1peak = xs->e1peak; << 712 << 713 // below the 1st peak << 714 if(e <= e1peak) { << 715 if(e*invLambdaFactor < mfpKinEnergy) { << 716 preStepLambda = GetLambdaForScaledEner << 717 mfpKinEnergy = (preStepLambda > 0.0) ? << 718 } << 719 return; << 720 } << 721 const G4double e1deep = xs->e1deep; << 722 // above the 1st peak, below the deep << 723 if(e <= e1deep) { << 724 if(mfpKinEnergy >= e1deep || e <= mfpKin << 725 const G4double e1 = std::max(e1peak, e << 726 mfpKinEnergy = e1; << 727 preStepLambda = GetLambdaForScaledEner << 728 } << 729 return; << 730 } << 731 const G4double e2peak = xs->e2peak; << 732 // above the deep, below 2nd peak << 733 if(e <= e2peak) { << 734 if(e*invLambdaFactor < mfpKinEnergy) { << 735 mfpKinEnergy = e; << 736 preStepLambda = GetLambdaForScaledEner << 737 } << 738 return; << 739 } << 740 const G4double e2deep = xs->e2deep; << 741 // above the 2nd peak, below the deep << 742 if(e <= e2deep) { << 743 if(mfpKinEnergy >= e2deep || e <= mfpKin << 744 const G4double e1 = std::max(e2peak, e << 745 mfpKinEnergy = e1; 1166 mfpKinEnergy = e1; 746 preStepLambda = GetLambdaForScaledEner << 1167 preStepLambda = preStepLambda1; 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 } 1168 } 757 return; << 1169 } else { 758 } << 1170 preStepLambda = fFactor*theCrossSectionMax[currentCoupleIndex]; 759 // above 3d peak << 1171 mfpKinEnergy = epeak; 760 if(e <= mfpKinEnergy) { << 761 const G4double e1 = std::max(e3peak, e*l << 762 mfpKinEnergy = e1; << 763 preStepLambda = GetLambdaForScaledEnergy << 764 } 1172 } 765 // integral method is not used << 766 } else { << 767 preStepLambda = GetLambdaForScaledEnergy(e << 768 } 1173 } 769 } 1174 } 770 1175 771 //....oooOO0OOooo........oooOO0OOooo........oo 1176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 772 1177 773 G4VParticleChange* G4VEnergyLossProcess::Along 1178 G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track, 774 1179 const G4Step& step) 775 { 1180 { 776 fParticleChange.InitializeForAlongStep(track 1181 fParticleChange.InitializeForAlongStep(track); 777 // The process has range table - calculate e 1182 // The process has range table - calculate energy loss 778 if(!isIonisation || !currentModel->IsActive( 1183 if(!isIonisation || !currentModel->IsActive(preStepScaledEnergy)) { 779 return &fParticleChange; 1184 return &fParticleChange; 780 } 1185 } 781 1186 >> 1187 // Get the actual (true) Step length 782 G4double length = step.GetStepLength(); 1188 G4double length = step.GetStepLength(); >> 1189 if(length <= 0.0) { return &fParticleChange; } 783 G4double eloss = 0.0; 1190 G4double eloss = 0.0; 784 1191 785 /* << 1192 /* 786 if(-1 < verboseLevel) { 1193 if(-1 < verboseLevel) { 787 const G4ParticleDefinition* d = track.GetP 1194 const G4ParticleDefinition* d = track.GetParticleDefinition(); 788 G4cout << "AlongStepDoIt for " 1195 G4cout << "AlongStepDoIt for " 789 << GetProcessName() << " and partic << 1196 << GetProcessName() << " and particle " 790 << " eScaled(MeV)=" << preStepScal << 1197 << d->GetParticleName() 791 << " range(mm)=" << fRange/mm << " << 1198 << " eScaled(MeV)= " << preStepScaledEnergy/MeV 792 << " rf=" << reduceFactor << " q^ << 1199 << " range(mm)= " << fRange/mm 793 << " md=" << d->GetPDGMass() << " << 1200 << " s(mm)= " << length/mm 794 << " " << track.GetMaterial()->Get << 1201 << " rf= " << reduceFactor >> 1202 << " q^2= " << chargeSqRatio >> 1203 << " md= " << d->GetPDGMass() >> 1204 << " status= " << track.GetTrackStatus() >> 1205 << " " << track.GetMaterial()->GetName() >> 1206 << G4endl; 795 } 1207 } 796 */ 1208 */ >> 1209 797 const G4DynamicParticle* dynParticle = track 1210 const G4DynamicParticle* dynParticle = track.GetDynamicParticle(); 798 1211 799 // define new weight for primary and seconda 1212 // define new weight for primary and secondaries 800 G4double weight = fParticleChange.GetParentW 1213 G4double weight = fParticleChange.GetParentWeight(); 801 if(weightFlag) { 1214 if(weightFlag) { 802 weight /= biasFactor; 1215 weight /= biasFactor; 803 fParticleChange.ProposeWeight(weight); 1216 fParticleChange.ProposeWeight(weight); 804 } 1217 } 805 1218 806 // stopping, check actual range and kinetic << 1219 // stopping 807 if (length >= fRange || preStepKinEnergy <= 1220 if (length >= fRange || preStepKinEnergy <= lowestKinEnergy) { 808 eloss = preStepKinEnergy; 1221 eloss = preStepKinEnergy; 809 if (useDeexcitation) { 1222 if (useDeexcitation) { 810 atomDeexcitation->AlongStepDeexcitation( 1223 atomDeexcitation->AlongStepDeexcitation(scTracks, step, 811 << 1224 eloss, currentCoupleIndex); 812 if(scTracks.size() > 0) { FillSecondarie << 1225 if(scTracks.size() > 0) { FillSecondariesAlongStep(eloss, weight); } 813 eloss = std::max(eloss, 0.0); 1226 eloss = std::max(eloss, 0.0); 814 } 1227 } 815 fParticleChange.SetProposedKineticEnergy(0 1228 fParticleChange.SetProposedKineticEnergy(0.0); 816 fParticleChange.ProposeLocalEnergyDeposit( 1229 fParticleChange.ProposeLocalEnergyDeposit(eloss); 817 return &fParticleChange; 1230 return &fParticleChange; 818 } 1231 } 819 // zero step length with non-zero range << 1232 //G4cout << theDEDXTable << " idx= " << basedCoupleIndex 820 if(length <= 0.0) { return &fParticleChange; << 1233 // << " " << GetProcessName() << " "<< currentMaterial->GetName()<<G4endl; 821 << 1234 //if(particle->GetParticleName() == "e-")G4cout << (*theDEDXTable) <<G4endl; 822 // Short step 1235 // Short step 823 eloss = length*GetDEDXForScaledEnergy(preSte << 1236 eloss = GetDEDXForScaledEnergy(preStepScaledEnergy)*length; 824 LogSca << 1237 825 /* << 1238 //G4cout << "eloss= " << eloss << G4endl; 826 G4cout << "##### Short STEP: eloss= " << elo << 1239 827 << " Escaled=" << preStepScaledEnergy << 828 << " R=" << fRange << 829 << " L=" << length << 830 << " fFactor=" << fFactor << " minE=" << mi << 831 << " idxBase=" << basedCoupleIndex << G4end << 832 */ << 833 // Long step 1240 // Long step 834 if(eloss > preStepKinEnergy*linLossLimit) { 1241 if(eloss > preStepKinEnergy*linLossLimit) { 835 1242 836 const G4double x = (fRange - length)/reduc << 1243 G4double x = (fRange - length)/reduceFactor; 837 const G4double de = preStepKinEnergy - Sca << 1244 //G4cout << "x= " << x << " " << theInverseRangeTable << G4endl; 838 if(de > 0.0) { eloss = de; } << 1245 eloss = preStepKinEnergy - ScaledKinEnergyForLoss(x)/massRatio; >> 1246 839 /* 1247 /* 840 if(-1 < verboseLevel) 1248 if(-1 < verboseLevel) 841 G4cout << " Long STEP: rPre(mm)=" << 1249 G4cout << "Long STEP: rPre(mm)= " 842 << GetScaledRangeForScaledEnergy( 1250 << GetScaledRangeForScaledEnergy(preStepScaledEnergy)/mm 843 << " x(mm)=" << x/mm << 1251 << " rPost(mm)= " << x/mm 844 << " eloss(MeV)=" << eloss/MeV << 1252 << " ePre(MeV)= " << preStepScaledEnergy/MeV 845 << " rFactor=" << reduceFactor << 1253 << " eloss(MeV)= " << eloss/MeV 846 << " massRatio=" << massRatio << 1254 << " eloss0(MeV)= " >> 1255 << GetDEDXForScaledEnergy(preStepScaledEnergy)*length/MeV >> 1256 << " lim(MeV)= " << preStepKinEnergy*linLossLimit/MeV 847 << G4endl; 1257 << G4endl; 848 */ 1258 */ 849 } 1259 } 850 1260 851 /* << 1261 /* >> 1262 G4double eloss0 = eloss; 852 if(-1 < verboseLevel ) { 1263 if(-1 < verboseLevel ) { 853 G4cout << "Before fluct: eloss(MeV)= " << 1264 G4cout << "Before fluct: eloss(MeV)= " << eloss/MeV 854 << " e-eloss= " << preStepKinEnergy 1265 << " e-eloss= " << preStepKinEnergy-eloss 855 << " step(mm)= " << length/mm << " << 1266 << " step(mm)= " << length/mm 856 << " fluct= " << lossFluctuationFla << 1267 << " range(mm)= " << fRange/mm >> 1268 << " fluct= " << lossFluctuationFlag >> 1269 << G4endl; 857 } 1270 } 858 */ 1271 */ 859 1272 860 const G4double cut = (*theCuts)[currentCoupl << 1273 G4double cut = (*theCuts)[currentCoupleIndex]; 861 G4double esec = 0.0; 1274 G4double esec = 0.0; 862 1275 >> 1276 //G4cout << "cut= " << cut << " useSubCut= " << useSubCutoff << G4endl; >> 1277 >> 1278 // SubCutOff >> 1279 if(useSubCutoff && !subcutProducer) { >> 1280 if(idxSCoffRegions[currentCoupleIndex]) { >> 1281 >> 1282 G4bool yes = false; >> 1283 const G4StepPoint* prePoint = step.GetPreStepPoint(); >> 1284 >> 1285 // Check boundary >> 1286 if(prePoint->GetStepStatus() == fGeomBoundary) { yes = true; } >> 1287 >> 1288 // Check PrePoint >> 1289 else { >> 1290 G4double preSafety = prePoint->GetSafety(); >> 1291 G4double rcut = >> 1292 currentCouple->GetProductionCuts()->GetProductionCut(1); >> 1293 >> 1294 // recompute presafety >> 1295 if(preSafety < rcut) { >> 1296 preSafety = safetyHelper->ComputeSafety(prePoint->GetPosition(), >> 1297 rcut); >> 1298 } >> 1299 >> 1300 if(preSafety < rcut) { yes = true; } >> 1301 >> 1302 // Check PostPoint >> 1303 else { >> 1304 G4double postSafety = preSafety - length; >> 1305 if(postSafety < rcut) { >> 1306 postSafety = safetyHelper->ComputeSafety( >> 1307 step.GetPostStepPoint()->GetPosition(), rcut); >> 1308 if(postSafety < rcut) { yes = true; } >> 1309 } >> 1310 } >> 1311 } >> 1312 >> 1313 // Decided to start subcut sampling >> 1314 if(yes) { >> 1315 >> 1316 cut = (*theSubCuts)[currentCoupleIndex]; >> 1317 eloss -= GetSubDEDXForScaledEnergy(preStepScaledEnergy)*length; >> 1318 esec = SampleSubCutSecondaries(scTracks, step, >> 1319 currentModel,currentCoupleIndex); >> 1320 // add bremsstrahlung sampling >> 1321 /* >> 1322 if(nProcesses > 0) { >> 1323 for(G4int i=0; i<nProcesses; ++i) { >> 1324 (scProcesses[i])->SampleSubCutSecondaries( >> 1325 scTracks, step, (scProcesses[i])-> >> 1326 SelectModelForMaterial(preStepKinEnergy, currentCoupleIndex), >> 1327 currentCoupleIndex); >> 1328 } >> 1329 } >> 1330 */ >> 1331 } >> 1332 } >> 1333 } >> 1334 863 // Corrections, which cannot be tabulated 1335 // Corrections, which cannot be tabulated 864 if(isIon) { 1336 if(isIon) { >> 1337 G4double eadd = 0.0; >> 1338 G4double eloss_before = eloss; 865 currentModel->CorrectionsAlongStep(current 1339 currentModel->CorrectionsAlongStep(currentCouple, dynParticle, 866 length, << 1340 eloss, eadd, length); 867 eloss = std::max(eloss, 0.0); << 1341 if(eloss < 0.0) { eloss = 0.5*eloss_before; } 868 } 1342 } 869 1343 870 // Sample fluctuations if not full energy lo << 1344 // Sample fluctuations 871 if(eloss >= preStepKinEnergy) { << 1345 if (lossFluctuationFlag) { 872 eloss = preStepKinEnergy; << 873 << 874 } else if (lossFluctuationFlag) { << 875 const G4double tmax = currentModel->MaxSec << 876 const G4double tcut = std::min(cut, tmax); << 877 G4VEmFluctuationModel* fluc = currentModel 1346 G4VEmFluctuationModel* fluc = currentModel->GetModelOfFluctuations(); 878 eloss = fluc->SampleFluctuations(currentCo << 1347 if(eloss + esec < preStepKinEnergy) { 879 tcut, tma << 1348 880 /* << 1349 G4double tmax = 881 if(-1 < verboseLevel) << 1350 std::min(currentModel->MaxSecondaryKinEnergy(dynParticle),cut); >> 1351 eloss = fluc->SampleFluctuations(currentCouple,dynParticle, >> 1352 tmax,length,eloss); >> 1353 /* >> 1354 if(-1 < verboseLevel) 882 G4cout << "After fluct: eloss(MeV)= " << 1355 G4cout << "After fluct: eloss(MeV)= " << eloss/MeV 883 << " fluc= " << (eloss-eloss0)/Me 1356 << " fluc= " << (eloss-eloss0)/MeV 884 << " ChargeSqRatio= " << chargeSq 1357 << " ChargeSqRatio= " << chargeSqRatio 885 << " massRatio= " << massRatio << << 1358 << " massRatio= " << massRatio 886 */ << 1359 << " tmax= " << tmax >> 1360 << G4endl; >> 1361 */ >> 1362 } 887 } 1363 } 888 1364 889 // deexcitation 1365 // deexcitation 890 if (useDeexcitation) { 1366 if (useDeexcitation) { 891 G4double esecfluo = preStepKinEnergy; << 1367 G4double esecfluo = preStepKinEnergy - esec; 892 G4double de = esecfluo; 1368 G4double de = esecfluo; >> 1369 //G4double eloss0 = eloss; >> 1370 /* >> 1371 G4cout << "### 1: E(keV)= " << preStepKinEnergy/keV >> 1372 << " Efluomax(keV)= " << de/keV >> 1373 << " Eloss(keV)= " << eloss/keV << G4endl; >> 1374 */ 893 atomDeexcitation->AlongStepDeexcitation(sc 1375 atomDeexcitation->AlongStepDeexcitation(scTracks, step, 894 de << 1376 de, currentCoupleIndex); 895 1377 896 // sum of de-excitation energies 1378 // sum of de-excitation energies 897 esecfluo -= de; 1379 esecfluo -= de; 898 1380 899 // subtracted from energy loss 1381 // subtracted from energy loss 900 if(eloss >= esecfluo) { 1382 if(eloss >= esecfluo) { 901 esec += esecfluo; 1383 esec += esecfluo; 902 eloss -= esecfluo; 1384 eloss -= esecfluo; 903 } else { 1385 } else { 904 esec += esecfluo; 1386 esec += esecfluo; 905 eloss = 0.0; 1387 eloss = 0.0; 906 } 1388 } >> 1389 /* >> 1390 if(esecfluo > 0.0) { >> 1391 G4cout << "### 2: E(keV)= " << preStepKinEnergy/keV >> 1392 << " Esec(keV)= " << esec/keV >> 1393 << " Esecf(kV)= " << esecfluo/keV >> 1394 << " Eloss0(kV)= " << eloss0/keV >> 1395 << " Eloss(keV)= " << eloss/keV >> 1396 << G4endl; >> 1397 } >> 1398 */ 907 } 1399 } 908 if(nullptr != subcutProducer && IsRegionForC << 1400 if(subcutProducer && idxSCoffRegions[currentCoupleIndex]) { 909 subcutProducer->SampleSecondaries(step, sc 1401 subcutProducer->SampleSecondaries(step, scTracks, eloss, cut); 910 } 1402 } 911 // secondaries from atomic de-excitation and << 1403 if(scTracks.size() > 0) { FillSecondariesAlongStep(eloss, weight); } 912 if(!scTracks.empty()) { FillSecondariesAlong << 913 1404 914 // Energy balance 1405 // Energy balance 915 G4double finalT = preStepKinEnergy - eloss - 1406 G4double finalT = preStepKinEnergy - eloss - esec; 916 if (finalT <= lowestKinEnergy) { 1407 if (finalT <= lowestKinEnergy) { 917 eloss += finalT; 1408 eloss += finalT; 918 finalT = 0.0; 1409 finalT = 0.0; 919 } else if(isIon) { 1410 } else if(isIon) { 920 fParticleChange.SetProposedCharge( 1411 fParticleChange.SetProposedCharge( 921 currentModel->GetParticleCharge(track.Ge 1412 currentModel->GetParticleCharge(track.GetParticleDefinition(), 922 currentM 1413 currentMaterial,finalT)); 923 } 1414 } >> 1415 924 eloss = std::max(eloss, 0.0); 1416 eloss = std::max(eloss, 0.0); 925 1417 926 fParticleChange.SetProposedKineticEnergy(fin 1418 fParticleChange.SetProposedKineticEnergy(finalT); 927 fParticleChange.ProposeLocalEnergyDeposit(el 1419 fParticleChange.ProposeLocalEnergyDeposit(eloss); 928 /* 1420 /* 929 if(-1 < verboseLevel) { 1421 if(-1 < verboseLevel) { 930 G4double del = finalT + eloss + esec - pre 1422 G4double del = finalT + eloss + esec - preStepKinEnergy; 931 G4cout << "Final value eloss(MeV)= " << el 1423 G4cout << "Final value eloss(MeV)= " << eloss/MeV 932 << " preStepKinEnergy= " << preStep 1424 << " preStepKinEnergy= " << preStepKinEnergy 933 << " postStepKinEnergy= " << finalT 1425 << " postStepKinEnergy= " << finalT 934 << " de(keV)= " << del/keV 1426 << " de(keV)= " << del/keV 935 << " lossFlag= " << lossFluctuation 1427 << " lossFlag= " << lossFluctuationFlag 936 << " status= " << track.GetTrackSt 1428 << " status= " << track.GetTrackStatus() 937 << G4endl; 1429 << G4endl; 938 } 1430 } 939 */ 1431 */ 940 return &fParticleChange; 1432 return &fParticleChange; 941 } 1433 } 942 1434 943 //....oooOO0OOooo........oooOO0OOooo........oo 1435 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 944 1436 945 void G4VEnergyLossProcess::FillSecondariesAlon << 1437 void >> 1438 G4VEnergyLossProcess::FillSecondariesAlongStep(G4double&, G4double& weight) 946 { 1439 { 947 const std::size_t n0 = scTracks.size(); << 1440 G4int n0 = scTracks.size(); 948 G4double weight = wt; << 1441 949 // weight may be changed by biasing manager 1442 // weight may be changed by biasing manager 950 if(biasManager) { 1443 if(biasManager) { 951 if(biasManager->SecondaryBiasingRegion((G4 << 1444 if(biasManager->SecondaryBiasingRegion(currentCoupleIndex)) { 952 weight *= 1445 weight *= 953 biasManager->ApplySecondaryBiasing(scT << 1446 biasManager->ApplySecondaryBiasing(scTracks, currentCoupleIndex); 954 } 1447 } 955 } 1448 } 956 1449 957 // fill secondaries 1450 // fill secondaries 958 const std::size_t n = scTracks.size(); << 1451 G4int n = scTracks.size(); 959 fParticleChange.SetNumberOfSecondaries((G4in << 1452 fParticleChange.SetNumberOfSecondaries(n); 960 1453 961 for(std::size_t i=0; i<n; ++i) { << 1454 for(G4int i=0; i<n; ++i) { 962 G4Track* t = scTracks[i]; 1455 G4Track* t = scTracks[i]; 963 if(nullptr != t) { << 1456 if(t) { 964 t->SetWeight(weight); 1457 t->SetWeight(weight); 965 pParticleChange->AddSecondary(t); 1458 pParticleChange->AddSecondary(t); 966 G4int pdg = t->GetDefinition()->GetPDGEn << 1459 if(i >= n0) { t->SetCreatorModelIndex(biasID); } 967 if (i < n0) { << 1460 //G4cout << "Secondary(along step) has weight " << t->GetWeight() 968 if (pdg == 22) { << 1461 //<< ", kenergy " << t->GetKineticEnergy()/MeV << " MeV" <<G4endl; 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 } 1462 } 979 } 1463 } 980 scTracks.clear(); 1464 scTracks.clear(); 981 } 1465 } 982 1466 983 //....oooOO0OOooo........oooOO0OOooo........oo 1467 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 984 1468 >> 1469 G4double >> 1470 G4VEnergyLossProcess::SampleSubCutSecondaries(std::vector<G4Track*>& tracks, >> 1471 const G4Step& step, >> 1472 G4VEmModel* model, >> 1473 G4int idx) >> 1474 { >> 1475 // Fast check weather subcutoff can work >> 1476 G4double esec = 0.0; >> 1477 G4double subcut = (*theSubCuts)[idx]; >> 1478 G4double cut = (*theCuts)[idx]; >> 1479 if(cut <= subcut) { return esec; } >> 1480 >> 1481 const G4Track* track = step.GetTrack(); >> 1482 const G4DynamicParticle* dp = track->GetDynamicParticle(); >> 1483 G4double e = dp->GetKineticEnergy()*massRatio; >> 1484 G4double cross = (*theDensityFactor)[idx]*chargeSqRatio >> 1485 *(((*theSubLambdaTable)[(*theDensityIdx)[idx]])->Value(e, idxSubLambda)); >> 1486 G4double length = step.GetStepLength(); >> 1487 >> 1488 // negligible probability to get any interaction >> 1489 if(length*cross < perMillion) { return esec; } >> 1490 /* >> 1491 if(-1 < verboseLevel) >> 1492 G4cout << "<<< Subcutoff for " << GetProcessName() >> 1493 << " cross(1/mm)= " << cross*mm << ">>>" >> 1494 << " e(MeV)= " << preStepScaledEnergy >> 1495 << " matIdx= " << currentCoupleIndex >> 1496 << G4endl; >> 1497 */ >> 1498 >> 1499 // Sample subcutoff secondaries >> 1500 G4StepPoint* preStepPoint = step.GetPreStepPoint(); >> 1501 G4StepPoint* postStepPoint = step.GetPostStepPoint(); >> 1502 G4ThreeVector prepoint = preStepPoint->GetPosition(); >> 1503 G4ThreeVector dr = postStepPoint->GetPosition() - prepoint; >> 1504 G4double pretime = preStepPoint->GetGlobalTime(); >> 1505 G4double dt = postStepPoint->GetGlobalTime() - pretime; >> 1506 G4double fragment = 0.0; >> 1507 >> 1508 do { >> 1509 G4double del = -G4Log(G4UniformRand())/cross; >> 1510 fragment += del/length; >> 1511 if (fragment > 1.0) { break; } >> 1512 >> 1513 // sample secondaries >> 1514 secParticles.clear(); >> 1515 model->SampleSecondaries(&secParticles,track->GetMaterialCutsCouple(), >> 1516 dp,subcut,cut); >> 1517 >> 1518 // position of subcutoff particles >> 1519 G4ThreeVector r = prepoint + fragment*dr; >> 1520 std::vector<G4DynamicParticle*>::iterator it; >> 1521 for(it=secParticles.begin(); it!=secParticles.end(); ++it) { >> 1522 >> 1523 G4Track* t = new G4Track((*it), pretime + fragment*dt, r); >> 1524 t->SetTouchableHandle(track->GetTouchableHandle()); >> 1525 t->SetCreatorModelIndex(subsecID); >> 1526 tracks.push_back(t); >> 1527 esec += t->GetKineticEnergy(); >> 1528 if (t->GetParticleDefinition() == thePositron) { >> 1529 esec += 2.0*electron_mass_c2; >> 1530 } >> 1531 >> 1532 /* >> 1533 if(-1 < verboseLevel) >> 1534 G4cout << "New track " >> 1535 << t->GetParticleDefinition()->GetParticleName() >> 1536 << " e(keV)= " << t->GetKineticEnergy()/keV >> 1537 << " fragment= " << fragment >> 1538 << G4endl; >> 1539 */ >> 1540 } >> 1541 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko >> 1542 } while (fragment <= 1.0); >> 1543 return esec; >> 1544 } >> 1545 >> 1546 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1547 985 G4VParticleChange* G4VEnergyLossProcess::PostS 1548 G4VParticleChange* G4VEnergyLossProcess::PostStepDoIt(const G4Track& track, 986 1549 const G4Step& step) 987 { 1550 { 988 // clear number of interaction lengths in an << 1551 // In all cases clear number of interaction lengths 989 theNumberOfInteractionLengthLeft = -1.0; 1552 theNumberOfInteractionLengthLeft = -1.0; 990 mfpKinEnergy = DBL_MAX; << 1553 mfpKinEnergy = currentInteractionLength = DBL_MAX; 991 1554 992 fParticleChange.InitializeForPostStep(track) 1555 fParticleChange.InitializeForPostStep(track); 993 const G4double finalT = track.GetKineticEner << 1556 G4double finalT = track.GetKineticEnergy(); >> 1557 if(finalT <= lowestKinEnergy) { return &fParticleChange; } 994 1558 995 const G4double postStepScaledEnergy = finalT << 1559 G4double postStepScaledEnergy = finalT*massRatio; 996 SelectModel(postStepScaledEnergy); 1560 SelectModel(postStepScaledEnergy); 997 1561 998 if(!currentModel->IsActive(postStepScaledEne 1562 if(!currentModel->IsActive(postStepScaledEnergy)) { 999 return &fParticleChange; 1563 return &fParticleChange; 1000 } 1564 } 1001 /* 1565 /* 1002 if(1 < verboseLevel) { << 1566 if(-1 < verboseLevel) { 1003 G4cout<<GetProcessName()<<" PostStepDoIt: << 1567 G4cout << GetProcessName() >> 1568 << "::PostStepDoIt: E(MeV)= " << finalT/MeV >> 1569 << G4endl; 1004 } 1570 } 1005 */ 1571 */ >> 1572 1006 // forced process - should happen only once 1573 // forced process - should happen only once per track 1007 if(biasFlag) { 1574 if(biasFlag) { 1008 if(biasManager->ForcedInteractionRegion(( << 1575 if(biasManager->ForcedInteractionRegion(currentCoupleIndex)) { 1009 biasFlag = false; 1576 biasFlag = false; 1010 } 1577 } 1011 } 1578 } 1012 const G4DynamicParticle* dp = track.GetDyna << 1013 1579 1014 // Integral approach 1580 // Integral approach 1015 if (fXSType != fEmNoIntegral) { << 1581 if (integral) { 1016 const G4double logFinalT = dp->GetLogKine << 1582 G4double lx = GetLambdaForScaledEnergy(postStepScaledEnergy); 1017 G4double lx = GetLambdaForScaledEnergy(po << 1583 /* 1018 lo << 1584 if(preStepLambda<lx && 1 < verboseLevel) { 1019 lx = std::max(lx, 0.0); << 1585 G4cout << "WARNING: for " << particle->GetParticleName() 1020 << 1586 << " and " << GetProcessName() 1021 // if both lg and lx are zero then no int << 1587 << " E(MeV)= " << finalT/MeV 1022 if(preStepLambda*G4UniformRand() >= lx) { << 1588 << " preLambda= " << preStepLambda >> 1589 << " < " << lx << " (postLambda) " >> 1590 << G4endl; >> 1591 } >> 1592 */ >> 1593 if(lx <= 0.0 || preStepLambda*G4UniformRand() > lx) { 1023 return &fParticleChange; 1594 return &fParticleChange; 1024 } 1595 } 1025 } 1596 } 1026 1597 >> 1598 SelectModel(postStepScaledEnergy); >> 1599 1027 // define new weight for primary and second 1600 // define new weight for primary and secondaries 1028 G4double weight = fParticleChange.GetParent 1601 G4double weight = fParticleChange.GetParentWeight(); 1029 if(weightFlag) { 1602 if(weightFlag) { 1030 weight /= biasFactor; 1603 weight /= biasFactor; 1031 fParticleChange.ProposeWeight(weight); 1604 fParticleChange.ProposeWeight(weight); 1032 } 1605 } 1033 1606 1034 const G4double tcut = (*theCuts)[currentCou << 1607 const G4DynamicParticle* dynParticle = track.GetDynamicParticle(); >> 1608 G4double tcut = (*theCuts)[currentCoupleIndex]; 1035 1609 1036 // sample secondaries 1610 // sample secondaries 1037 secParticles.clear(); 1611 secParticles.clear(); 1038 currentModel->SampleSecondaries(&secParticl << 1612 //G4cout<< "@@@ Eprimary= "<<dynParticle->GetKineticEnergy()/MeV >> 1613 // << " cut= " << tcut/MeV << G4endl; >> 1614 currentModel->SampleSecondaries(&secParticles, currentCouple, >> 1615 dynParticle, tcut); 1039 1616 1040 const G4int num0 = (G4int)secParticles.size << 1617 G4int num0 = secParticles.size(); 1041 1618 1042 // bremsstrahlung splitting or Russian roul 1619 // bremsstrahlung splitting or Russian roulette 1043 if(biasManager) { 1620 if(biasManager) { 1044 if(biasManager->SecondaryBiasingRegion((G << 1621 if(biasManager->SecondaryBiasingRegion(currentCoupleIndex)) { 1045 G4double eloss = 0.0; 1622 G4double eloss = 0.0; 1046 weight *= biasManager->ApplySecondaryBi 1623 weight *= biasManager->ApplySecondaryBiasing( 1047 secPart 1624 secParticles, 1048 track, 1625 track, currentModel, 1049 &fParti 1626 &fParticleChange, eloss, 1050 (G4int) << 1627 currentCoupleIndex, tcut, 1051 step.Ge 1628 step.GetPostStepPoint()->GetSafety()); 1052 if(eloss > 0.0) { 1629 if(eloss > 0.0) { 1053 eloss += fParticleChange.GetLocalEner 1630 eloss += fParticleChange.GetLocalEnergyDeposit(); 1054 fParticleChange.ProposeLocalEnergyDep 1631 fParticleChange.ProposeLocalEnergyDeposit(eloss); 1055 } 1632 } 1056 } 1633 } 1057 } 1634 } 1058 1635 1059 // save secondaries 1636 // save secondaries 1060 const G4int num = (G4int)secParticles.size( << 1637 G4int num = secParticles.size(); 1061 if(num > 0) { 1638 if(num > 0) { 1062 1639 1063 fParticleChange.SetNumberOfSecondaries(nu 1640 fParticleChange.SetNumberOfSecondaries(num); 1064 G4double time = track.GetGlobalTime(); 1641 G4double time = track.GetGlobalTime(); 1065 1642 1066 G4int n1(0), n2(0); << 1067 if(num0 > mainSecondaries) { << 1068 currentModel->FillNumberOfSecondaries(n << 1069 } << 1070 << 1071 for (G4int i=0; i<num; ++i) { 1643 for (G4int i=0; i<num; ++i) { 1072 if(nullptr != secParticles[i]) { << 1644 if(secParticles[i]) { 1073 G4Track* t = new G4Track(secParticles 1645 G4Track* t = new G4Track(secParticles[i], time, track.GetPosition()); 1074 t->SetTouchableHandle(track.GetToucha 1646 t->SetTouchableHandle(track.GetTouchableHandle()); 1075 if (biasManager) { 1647 if (biasManager) { 1076 t->SetWeight(weight * biasManager-> 1648 t->SetWeight(weight * biasManager->GetWeight(i)); 1077 } else { 1649 } else { 1078 t->SetWeight(weight); 1650 t->SetWeight(weight); 1079 } 1651 } 1080 if(i < num0) { << 1652 if(i < num0) { t->SetCreatorModelIndex(secID); } 1081 t->SetCreatorModelID(secID); << 1653 else { t->SetCreatorModelIndex(biasID); } 1082 } else if(i < num0 + n1) { << 1083 t->SetCreatorModelID(tripletID); << 1084 } else { << 1085 t->SetCreatorModelID(biasID); << 1086 } << 1087 1654 1088 //G4cout << "Secondary(post step) has 1655 //G4cout << "Secondary(post step) has weight " << t->GetWeight() 1089 // << ", kenergy " << t->GetKin 1656 // << ", kenergy " << t->GetKineticEnergy()/MeV << " MeV" 1090 // << " time= " << time/ns << " 1657 // << " time= " << time/ns << " ns " << G4endl; 1091 pParticleChange->AddSecondary(t); 1658 pParticleChange->AddSecondary(t); 1092 } 1659 } 1093 } 1660 } 1094 } 1661 } 1095 1662 1096 if(0.0 == fParticleChange.GetProposedKineti 1663 if(0.0 == fParticleChange.GetProposedKineticEnergy() && 1097 fAlive == fParticleChange.GetTrackStatus 1664 fAlive == fParticleChange.GetTrackStatus()) { 1098 if(particle->GetProcessManager()->GetAtRe 1665 if(particle->GetProcessManager()->GetAtRestProcessVector()->size() > 0) 1099 { fParticleChange.ProposeTrackStatus 1666 { fParticleChange.ProposeTrackStatus(fStopButAlive); } 1100 else { fParticleChange.ProposeTrackStatus 1667 else { fParticleChange.ProposeTrackStatus(fStopAndKill); } 1101 } 1668 } 1102 1669 1103 /* 1670 /* 1104 if(-1 < verboseLevel) { 1671 if(-1 < verboseLevel) { 1105 G4cout << "::PostStepDoIt: Sample seconda 1672 G4cout << "::PostStepDoIt: Sample secondary; Efin= " 1106 << fParticleChange.GetProposedKineticEner 1673 << fParticleChange.GetProposedKineticEnergy()/MeV 1107 << " MeV; model= (" << currentMode 1674 << " MeV; model= (" << currentModel->LowEnergyLimit() 1108 << ", " << currentModel->HighEner 1675 << ", " << currentModel->HighEnergyLimit() << ")" 1109 << " preStepLambda= " << preStepL 1676 << " preStepLambda= " << preStepLambda 1110 << " dir= " << track.GetMomentumD 1677 << " dir= " << track.GetMomentumDirection() 1111 << " status= " << track.GetTrackS 1678 << " status= " << track.GetTrackStatus() 1112 << G4endl; 1679 << G4endl; 1113 } 1680 } 1114 */ 1681 */ 1115 return &fParticleChange; 1682 return &fParticleChange; 1116 } 1683 } 1117 1684 1118 //....oooOO0OOooo........oooOO0OOooo........o 1685 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1119 1686 1120 G4bool G4VEnergyLossProcess::StorePhysicsTabl 1687 G4bool G4VEnergyLossProcess::StorePhysicsTable( 1121 const G4ParticleDefinition* part, cons << 1688 const G4ParticleDefinition* part, const G4String& directory, >> 1689 G4bool ascii) 1122 { 1690 { 1123 if (!isMaster || nullptr != baseParticle || << 1691 G4bool res = true; 1124 for(std::size_t i=0; i<7; ++i) { << 1692 //G4cout << "G4VEnergyLossProcess::StorePhysicsTable: " << part->GetParticleName() 1125 // ionisation table only for ionisation p << 1693 // << " " << directory << " " << ascii << G4endl; 1126 if (nullptr == theData->Table(i) || (!isI << 1694 if (!isMaster || baseParticle || part != particle ) return res; 1127 continue; << 1695 1128 } << 1696 if(!StoreTable(part,theDEDXTable,ascii,directory,"DEDX")) 1129 if (-1 < verboseLevel) { << 1697 {res = false;} 1130 G4cout << "G4VEnergyLossProcess::StoreP << 1698 1131 << " " << particle->GetParticleName() << 1699 if(!StoreTable(part,theDEDXunRestrictedTable,ascii,directory,"DEDXnr")) 1132 << " " << GetProcessName() << 1700 {res = false;} 1133 << " " << tnames[i] << " " << theDat << 1701 1134 } << 1702 if(!StoreTable(part,theDEDXSubTable,ascii,directory,"SubDEDX")) 1135 if (!G4EmTableUtil::StoreTable(this, part << 1703 {res = false;} 1136 dir, tnames[i], verboseLevel, asci << 1704 1137 return false; << 1705 if(!StoreTable(part,theIonisationTable,ascii,directory,"Ionisation")) >> 1706 {res = false;} >> 1707 >> 1708 if(!StoreTable(part,theIonisationSubTable,ascii,directory,"SubIonisation")) >> 1709 {res = false;} >> 1710 >> 1711 if(isIonisation && >> 1712 !StoreTable(part,theCSDARangeTable,ascii,directory,"CSDARange")) >> 1713 {res = false;} >> 1714 >> 1715 if(isIonisation && >> 1716 !StoreTable(part,theRangeTableForLoss,ascii,directory,"Range")) >> 1717 {res = false;} >> 1718 >> 1719 if(isIonisation && >> 1720 !StoreTable(part,theInverseRangeTable,ascii,directory,"InverseRange")) >> 1721 {res = false;} >> 1722 >> 1723 if(!StoreTable(part,theLambdaTable,ascii,directory,"Lambda")) >> 1724 {res = false;} >> 1725 >> 1726 if(!StoreTable(part,theSubLambdaTable,ascii,directory,"SubLambda")) >> 1727 {res = false;} >> 1728 >> 1729 if ( !res ) { >> 1730 if(1 < verboseLevel) { >> 1731 G4cout << "Physics tables are stored for " >> 1732 << particle->GetParticleName() >> 1733 << " and process " << GetProcessName() >> 1734 << " in the directory <" << directory >> 1735 << "> " << G4endl; 1138 } 1736 } >> 1737 } else { >> 1738 G4cout << "Fail to store Physics Tables for " >> 1739 << particle->GetParticleName() >> 1740 << " and process " << GetProcessName() >> 1741 << " in the directory <" << directory >> 1742 << "> " << G4endl; 1139 } 1743 } 1140 return true; << 1744 return res; 1141 } 1745 } 1142 1746 1143 //....oooOO0OOooo........oooOO0OOooo........o 1747 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 1144 1748 1145 G4bool 1749 G4bool 1146 G4VEnergyLossProcess::RetrievePhysicsTable(co 1750 G4VEnergyLossProcess::RetrievePhysicsTable(const G4ParticleDefinition* part, 1147 co << 1751 const G4String& directory, >> 1752 G4bool ascii) 1148 { 1753 { 1149 if (!isMaster || nullptr != baseParticle || << 1754 G4bool res = true; 1150 for(std::size_t i=0; i<7; ++i) { << 1755 if (!isMaster) return res; 1151 // ionisation table only for ionisation p << 1756 const G4String particleName = part->GetParticleName(); 1152 if (!isIonisation && 1 == i) { continue; << 1757 1153 if(!G4EmTableUtil::RetrieveTable(this, pa << 1758 if(1 < verboseLevel) { 1154 verboseL << 1759 G4cout << "G4VEnergyLossProcess::RetrievePhysicsTable() for " 1155 return false; << 1760 << particleName << " and process " << GetProcessName() >> 1761 << "; tables_are_built= " << tablesAreBuilt >> 1762 << G4endl; >> 1763 } >> 1764 if(particle == part) { >> 1765 >> 1766 if ( !baseParticle ) { >> 1767 >> 1768 G4bool fpi = true; >> 1769 if(!RetrieveTable(part,theDEDXTable,ascii,directory,"DEDX",fpi)) >> 1770 {fpi = false;} >> 1771 >> 1772 // ionisation table keeps individual dEdx and not sum of sub-processes >> 1773 if(!RetrieveTable(part,theDEDXTable,ascii,directory,"Ionisation",false)) >> 1774 {fpi = false;} >> 1775 >> 1776 if(!RetrieveTable(part,theRangeTableForLoss,ascii,directory,"Range",fpi)) >> 1777 {res = false;} >> 1778 >> 1779 if(!RetrieveTable(part,theDEDXunRestrictedTable,ascii,directory, >> 1780 "DEDXnr",false)) >> 1781 {res = false;} >> 1782 >> 1783 if(!RetrieveTable(part,theCSDARangeTable,ascii,directory, >> 1784 "CSDARange",false)) >> 1785 {res = false;} >> 1786 >> 1787 if(!RetrieveTable(part,theInverseRangeTable,ascii,directory, >> 1788 "InverseRange",fpi)) >> 1789 {res = false;} >> 1790 >> 1791 if(!RetrieveTable(part,theLambdaTable,ascii,directory,"Lambda",true)) >> 1792 {res = false;} >> 1793 >> 1794 G4bool yes = false; >> 1795 if(nSCoffRegions > 0) {yes = true;} >> 1796 >> 1797 if(!RetrieveTable(part,theDEDXSubTable,ascii,directory,"SubDEDX",yes)) >> 1798 {res = false;} >> 1799 >> 1800 if(!RetrieveTable(part,theSubLambdaTable,ascii,directory, >> 1801 "SubLambda",yes)) >> 1802 {res = false;} >> 1803 >> 1804 if(!fpi) yes = false; >> 1805 if(!RetrieveTable(part,theIonisationSubTable,ascii,directory, >> 1806 "SubIonisation",yes)) >> 1807 {res = false;} 1156 } 1808 } 1157 } 1809 } >> 1810 >> 1811 return res; >> 1812 } >> 1813 >> 1814 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1815 >> 1816 G4bool G4VEnergyLossProcess::StoreTable(const G4ParticleDefinition* part, >> 1817 G4PhysicsTable* aTable, G4bool ascii, >> 1818 const G4String& directory, >> 1819 const G4String& tname) >> 1820 { >> 1821 //G4cout << "G4VEnergyLossProcess::StoreTable: " << aTable >> 1822 // << " " << directory << " " << tname << G4endl; >> 1823 G4bool res = true; >> 1824 if ( aTable ) { >> 1825 const G4String name = GetPhysicsTableFileName(part,directory,tname,ascii); >> 1826 G4cout << name << G4endl; >> 1827 //G4cout << *aTable << G4endl; >> 1828 if( !aTable->StorePhysicsTable(name,ascii)) res = false; >> 1829 } >> 1830 return res; >> 1831 } >> 1832 >> 1833 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1834 >> 1835 G4bool >> 1836 G4VEnergyLossProcess::RetrieveTable(const G4ParticleDefinition* part, >> 1837 G4PhysicsTable* aTable, >> 1838 G4bool ascii, >> 1839 const G4String& directory, >> 1840 const G4String& tname, >> 1841 G4bool mandatory) >> 1842 { >> 1843 G4bool isRetrieved = false; >> 1844 G4String filename = GetPhysicsTableFileName(part,directory,tname,ascii); >> 1845 if(aTable) { >> 1846 if(aTable->ExistPhysicsTable(filename)) { >> 1847 if(G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii)) { >> 1848 isRetrieved = true; >> 1849 if(theParameters->Spline()) { >> 1850 size_t n = aTable->length(); >> 1851 for(size_t i=0; i<n; ++i) { >> 1852 if((*aTable)[i]) { (*aTable)[i]->SetSpline(true); } >> 1853 } >> 1854 } >> 1855 if (0 < verboseLevel) { >> 1856 G4cout << tname << " table for " << part->GetParticleName() >> 1857 << " is Retrieved from <" << filename << ">" >> 1858 << G4endl; >> 1859 } >> 1860 } >> 1861 } >> 1862 } >> 1863 if(mandatory && !isRetrieved) { >> 1864 if(0 < verboseLevel) { >> 1865 G4cout << tname << " table for " << part->GetParticleName() >> 1866 << " from file <" >> 1867 << filename << "> is not Retrieved" >> 1868 << G4endl; >> 1869 } >> 1870 return false; >> 1871 } 1158 return true; 1872 return true; 1159 } 1873 } 1160 1874 1161 //....oooOO0OOooo........oooOO0OOooo........o 1875 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1162 1876 1163 G4double G4VEnergyLossProcess::GetDEDXDispers 1877 G4double G4VEnergyLossProcess::GetDEDXDispersion( 1164 const G4Mat 1878 const G4MaterialCutsCouple *couple, 1165 const G4Dyn 1879 const G4DynamicParticle* dp, 1166 G4dou 1880 G4double length) 1167 { 1881 { 1168 DefineMaterial(couple); 1882 DefineMaterial(couple); 1169 G4double ekin = dp->GetKineticEnergy(); 1883 G4double ekin = dp->GetKineticEnergy(); 1170 SelectModel(ekin*massRatio); 1884 SelectModel(ekin*massRatio); 1171 G4double tmax = currentModel->MaxSecondaryK 1885 G4double tmax = currentModel->MaxSecondaryKinEnergy(dp); 1172 G4double tcut = std::min(tmax,(*theCuts)[cu << 1886 tmax = std::min(tmax,(*theCuts)[currentCoupleIndex]); 1173 G4double d = 0.0; 1887 G4double d = 0.0; 1174 G4VEmFluctuationModel* fm = currentModel->G 1888 G4VEmFluctuationModel* fm = currentModel->GetModelOfFluctuations(); 1175 if(nullptr != fm) { d = fm->Dispersion(curr << 1889 if(fm) { d = fm->Dispersion(currentMaterial,dp,tmax,length); } 1176 return d; 1890 return d; 1177 } 1891 } 1178 1892 1179 //....oooOO0OOooo........oooOO0OOooo........o 1893 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1180 1894 1181 G4double << 1895 G4double G4VEnergyLossProcess::CrossSectionPerVolume( 1182 G4VEnergyLossProcess::CrossSectionPerVolume(G << 1896 G4double kineticEnergy, const G4MaterialCutsCouple* couple) 1183 c << 1184 G << 1185 { 1897 { 1186 // Cross section per volume is calculated 1898 // Cross section per volume is calculated 1187 DefineMaterial(couple); 1899 DefineMaterial(couple); 1188 G4double cross = 0.0; 1900 G4double cross = 0.0; 1189 if (nullptr != theLambdaTable) { << 1901 if(theLambdaTable) { 1190 cross = GetLambdaForScaledEnergy(kineticE << 1902 cross = GetLambdaForScaledEnergy(kineticEnergy*massRatio); 1191 logKinet << 1192 } else { 1903 } else { 1193 SelectModel(kineticEnergy*massRatio); 1904 SelectModel(kineticEnergy*massRatio); 1194 cross = (!baseMat) ? biasFactor : biasFac << 1905 cross = biasFactor*(*theDensityFactor)[currentCoupleIndex] 1195 cross *= (currentModel->CrossSectionPerVo << 1906 *(currentModel->CrossSectionPerVolume(currentMaterial, 1196 << 1907 particle, kineticEnergy, >> 1908 (*theCuts)[currentCoupleIndex])); 1197 } 1909 } 1198 return std::max(cross, 0.0); 1910 return std::max(cross, 0.0); 1199 } 1911 } 1200 1912 1201 //....oooOO0OOooo........oooOO0OOooo........o 1913 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1202 1914 1203 G4double G4VEnergyLossProcess::MeanFreePath(c 1915 G4double G4VEnergyLossProcess::MeanFreePath(const G4Track& track) 1204 { 1916 { 1205 DefineMaterial(track.GetMaterialCutsCouple( 1917 DefineMaterial(track.GetMaterialCutsCouple()); 1206 const G4double kinEnergy = track.GetKine << 1918 G4double cs = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio); 1207 const G4double logKinEnergy = track.GetDyna << 1208 const G4double cs = GetLambdaForScaledEnerg << 1209 << 1210 return (0.0 < cs) ? 1.0/cs : DBL_MAX; 1919 return (0.0 < cs) ? 1.0/cs : DBL_MAX; 1211 } 1920 } 1212 1921 1213 //....oooOO0OOooo........oooOO0OOooo........o 1922 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1214 1923 1215 G4double G4VEnergyLossProcess::ContinuousStep 1924 G4double G4VEnergyLossProcess::ContinuousStepLimit(const G4Track& track, 1216 1925 G4double x, G4double y, 1217 1926 G4double& z) 1218 { 1927 { 1219 return AlongStepGetPhysicalInteractionLengt << 1928 G4GPILSelection sel; >> 1929 return AlongStepGetPhysicalInteractionLength(track, x, y, z, &sel); 1220 } 1930 } 1221 1931 1222 //....oooOO0OOooo........oooOO0OOooo........o 1932 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1223 1933 1224 G4double G4VEnergyLossProcess::GetMeanFreePat 1934 G4double G4VEnergyLossProcess::GetMeanFreePath( 1225 const G4Track& t 1935 const G4Track& track, 1226 G4double, 1936 G4double, 1227 G4ForceCondition 1937 G4ForceCondition* condition) 1228 1938 1229 { 1939 { 1230 *condition = NotForced; 1940 *condition = NotForced; 1231 return MeanFreePath(track); 1941 return MeanFreePath(track); 1232 } 1942 } 1233 1943 1234 //....oooOO0OOooo........oooOO0OOooo........o 1944 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1235 1945 1236 G4double G4VEnergyLossProcess::GetContinuousS 1946 G4double G4VEnergyLossProcess::GetContinuousStepLimit( 1237 const G4Track&, 1947 const G4Track&, 1238 G4double, G4double, G4double& 1948 G4double, G4double, G4double&) 1239 { 1949 { 1240 return DBL_MAX; 1950 return DBL_MAX; 1241 } 1951 } 1242 1952 1243 //....oooOO0OOooo........oooOO0OOooo........o 1953 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1244 1954 1245 G4PhysicsVector* 1955 G4PhysicsVector* 1246 G4VEnergyLossProcess::LambdaPhysicsVector(con << 1956 G4VEnergyLossProcess::LambdaPhysicsVector(const G4MaterialCutsCouple*, 1247 G4d 1957 G4double) 1248 { 1958 { 1249 DefineMaterial(couple); << 1959 G4PhysicsVector* v = 1250 G4PhysicsVector* v = (*theLambdaTable)[base << 1960 new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins); 1251 return new G4PhysicsVector(*v); << 1961 v->SetSpline(theParameters->Spline()); >> 1962 return v; >> 1963 } >> 1964 >> 1965 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1966 >> 1967 void G4VEnergyLossProcess::AddCollaborativeProcess( >> 1968 G4VEnergyLossProcess* p) >> 1969 { >> 1970 G4bool add = true; >> 1971 if(p->GetProcessName() != "eBrem") { add = false; } >> 1972 if(add && nProcesses > 0) { >> 1973 for(G4int i=0; i<nProcesses; ++i) { >> 1974 if(p == scProcesses[i]) { >> 1975 add = false; >> 1976 break; >> 1977 } >> 1978 } >> 1979 } >> 1980 if(add) { >> 1981 scProcesses.push_back(p); >> 1982 ++nProcesses; >> 1983 if (1 < verboseLevel) { >> 1984 G4cout << "### The process " << p->GetProcessName() >> 1985 << " is added to the list of collaborative processes of " >> 1986 << GetProcessName() << G4endl; >> 1987 } >> 1988 } 1252 } 1989 } 1253 1990 1254 //....oooOO0OOooo........oooOO0OOooo........o 1991 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1255 1992 1256 void 1993 void 1257 G4VEnergyLossProcess::SetDEDXTable(G4PhysicsT 1994 G4VEnergyLossProcess::SetDEDXTable(G4PhysicsTable* p, G4EmTableType tType) 1258 { 1995 { 1259 if(1 < verboseLevel) { << 1260 G4cout << "### Set DEDX table " << p << " << 1261 << " " << theDEDXunRestrictedTable << << 1262 << " for " << particle->GetParticl << 1263 << " and process " << GetProcessNa << 1264 << " type=" << tType << " isIonisation:" << 1265 } << 1266 if(fTotal == tType) { 1996 if(fTotal == tType) { 1267 theDEDXunRestrictedTable = p; 1997 theDEDXunRestrictedTable = p; >> 1998 if(p) { >> 1999 size_t n = p->length(); >> 2000 G4PhysicsVector* pv = (*p)[0]; >> 2001 G4double emax = maxKinEnergyCSDA; >> 2002 >> 2003 G4LossTableBuilder* bld = lManager->GetTableBuilder(); >> 2004 theDensityFactor = bld->GetDensityFactors(); >> 2005 theDensityIdx = bld->GetCoupleIndexes(); >> 2006 >> 2007 for (size_t i=0; i<n; ++i) { >> 2008 G4double dedx = 0.0; >> 2009 pv = (*p)[i]; >> 2010 if(pv) { >> 2011 dedx = pv->Value(emax, idxDEDXunRestricted); >> 2012 } else { >> 2013 pv = (*p)[(*theDensityIdx)[i]]; >> 2014 if(pv) { >> 2015 dedx = >> 2016 pv->Value(emax, idxDEDXunRestricted)*(*theDensityFactor)[i]; >> 2017 } >> 2018 } >> 2019 theDEDXAtMaxEnergy[i] = dedx; >> 2020 //G4cout << "i= " << i << " emax(MeV)= " << emax/MeV<< " dedx= " >> 2021 // << dedx << G4endl; >> 2022 } >> 2023 } >> 2024 1268 } else if(fRestricted == tType) { 2025 } else if(fRestricted == tType) { >> 2026 /* >> 2027 G4cout<< "G4VEnergyLossProcess::SetDEDXTable " >> 2028 << particle->GetParticleName() >> 2029 << " oldTable " << theDEDXTable << " newTable " << p >> 2030 << " ion " << theIonisationTable >> 2031 << " IsMaster " << isMaster >> 2032 << " " << GetProcessName() << G4endl; >> 2033 G4cout << (*p) << G4endl; >> 2034 */ 1269 theDEDXTable = p; 2035 theDEDXTable = p; 1270 if(isMaster && nullptr == baseParticle) { << 2036 } else if(fSubRestricted == tType) { 1271 theData->UpdateTable(theDEDXTable, 0); << 2037 theDEDXSubTable = p; 1272 } << 1273 } else if(fIsIonisation == tType) { 2038 } else if(fIsIonisation == tType) { >> 2039 /* >> 2040 G4cout<< "G4VEnergyLossProcess::SetIonisationTable " >> 2041 << particle->GetParticleName() >> 2042 << " oldTable " << theDEDXTable << " newTable " << p >> 2043 << " ion " << theIonisationTable >> 2044 << " IsMaster " << isMaster >> 2045 << " " << GetProcessName() << G4endl; >> 2046 */ 1274 theIonisationTable = p; 2047 theIonisationTable = p; 1275 if(isMaster && nullptr == baseParticle) { << 2048 } else if(fIsSubIonisation == tType) { 1276 theData->UpdateTable(theIonisationTable << 2049 theIonisationSubTable = p; 1277 } << 1278 } 2050 } 1279 } 2051 } 1280 2052 1281 //....oooOO0OOooo........oooOO0OOooo........o 2053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1282 2054 1283 void G4VEnergyLossProcess::SetCSDARangeTable( 2055 void G4VEnergyLossProcess::SetCSDARangeTable(G4PhysicsTable* p) 1284 { 2056 { 1285 theCSDARangeTable = p; << 2057 theCSDARangeTable = p; >> 2058 >> 2059 if(p) { >> 2060 size_t n = p->length(); >> 2061 G4PhysicsVector* pv; >> 2062 G4double emax = maxKinEnergyCSDA; >> 2063 >> 2064 for (size_t i=0; i<n; ++i) { >> 2065 pv = (*p)[i]; >> 2066 G4double rmax = 0.0; >> 2067 if(pv) { rmax = pv->Value(emax, idxCSDA); } >> 2068 else { >> 2069 pv = (*p)[(*theDensityIdx)[i]]; >> 2070 if(pv) { rmax = pv->Value(emax, idxCSDA)/(*theDensityFactor)[i]; } >> 2071 } >> 2072 theRangeAtMaxEnergy[i] = rmax; >> 2073 //G4cout << "i= " << i << " Emax(MeV)= " << emax/MeV << " Rmax= " >> 2074 //<< rmax<< G4endl; >> 2075 } >> 2076 } 1286 } 2077 } 1287 2078 1288 //....oooOO0OOooo........oooOO0OOooo........o 2079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1289 2080 1290 void G4VEnergyLossProcess::SetRangeTableForLo 2081 void G4VEnergyLossProcess::SetRangeTableForLoss(G4PhysicsTable* p) 1291 { 2082 { 1292 theRangeTableForLoss = p; 2083 theRangeTableForLoss = p; >> 2084 if(1 < verboseLevel) { >> 2085 G4cout << "### Set Range table " << p >> 2086 << " for " << particle->GetParticleName() >> 2087 << " and process " << GetProcessName() << G4endl; >> 2088 } >> 2089 } >> 2090 >> 2091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 2092 >> 2093 void G4VEnergyLossProcess::SetSecondaryRangeTable(G4PhysicsTable* p) >> 2094 { >> 2095 theSecondaryRangeTable = p; >> 2096 if(1 < verboseLevel) { >> 2097 G4cout << "### Set SecondaryRange table " << p >> 2098 << " for " << particle->GetParticleName() >> 2099 << " and process " << GetProcessName() << G4endl; >> 2100 } 1293 } 2101 } 1294 2102 1295 //....oooOO0OOooo........oooOO0OOooo........o 2103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1296 2104 1297 void G4VEnergyLossProcess::SetInverseRangeTab 2105 void G4VEnergyLossProcess::SetInverseRangeTable(G4PhysicsTable* p) 1298 { 2106 { 1299 theInverseRangeTable = p; 2107 theInverseRangeTable = p; >> 2108 if(1 < verboseLevel) { >> 2109 G4cout << "### Set InverseRange table " << p >> 2110 << " for " << particle->GetParticleName() >> 2111 << " and process " << GetProcessName() << G4endl; >> 2112 } 1300 } 2113 } 1301 2114 1302 //....oooOO0OOooo........oooOO0OOooo........o 2115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1303 2116 1304 void G4VEnergyLossProcess::SetLambdaTable(G4P 2117 void G4VEnergyLossProcess::SetLambdaTable(G4PhysicsTable* p) 1305 { 2118 { 1306 if(1 < verboseLevel) { 2119 if(1 < verboseLevel) { 1307 G4cout << "### Set Lambda table " << p << << 2120 G4cout << "### Set Lambda table " << p 1308 << " for " << particle->GetParticl 2121 << " for " << particle->GetParticleName() 1309 << " and process " << GetProcessNa 2122 << " and process " << GetProcessName() << G4endl; >> 2123 //G4cout << *p << G4endl; 1310 } 2124 } 1311 theLambdaTable = p; << 2125 theLambdaTable = p; 1312 tablesAreBuilt = true; 2126 tablesAreBuilt = true; 1313 2127 1314 if(isMaster && nullptr != p) { << 2128 G4LossTableBuilder* bld = lManager->GetTableBuilder(); 1315 delete theEnergyOfCrossSectionMax; << 2129 theDensityFactor = bld->GetDensityFactors(); 1316 theEnergyOfCrossSectionMax = nullptr; << 2130 theDensityIdx = bld->GetCoupleIndexes(); 1317 if(fEmTwoPeaks == fXSType) { << 2131 1318 if(nullptr != fXSpeaks) { << 2132 if(theLambdaTable) { 1319 for(auto & ptr : *fXSpeaks) { delete ptr; } << 2133 size_t n = theLambdaTable->length(); 1320 delete fXSpeaks; << 2134 G4PhysicsVector* pv = (*theLambdaTable)[0]; >> 2135 G4double e, ss, smax, emax; >> 2136 >> 2137 size_t i; >> 2138 >> 2139 // first loop on existing vectors >> 2140 for (i=0; i<n; ++i) { >> 2141 pv = (*theLambdaTable)[i]; >> 2142 if(pv) { >> 2143 size_t nb = pv->GetVectorLength(); >> 2144 emax = DBL_MAX; >> 2145 smax = 0.0; >> 2146 if(nb > 0) { >> 2147 for (size_t j=0; j<nb; ++j) { >> 2148 e = pv->Energy(j); >> 2149 ss = (*pv)(j); >> 2150 if(ss > smax) { >> 2151 smax = ss; >> 2152 emax = e; >> 2153 } >> 2154 } >> 2155 } >> 2156 theEnergyOfCrossSectionMax[i] = emax; >> 2157 theCrossSectionMax[i] = smax; >> 2158 if(1 < verboseLevel) { >> 2159 G4cout << "For " << particle->GetParticleName() >> 2160 << " Max CS at i= " << i << " emax(MeV)= " << emax/MeV >> 2161 << " lambda= " << smax << G4endl; >> 2162 } 1321 } 2163 } 1322 G4LossTableBuilder* bld = lManager->Get << 1323 fXSpeaks = G4EmUtility::FillPeaksStruct << 1324 if(nullptr == fXSpeaks) { fXSType = fEm << 1325 } 2164 } 1326 if(fXSType == fEmOnePeak) { << 2165 // second loop using base materials 1327 theEnergyOfCrossSectionMax = G4EmUtilit << 2166 for (i=0; i<n; ++i) { 1328 if(nullptr == theEnergyOfCrossSectionMa << 2167 pv = (*theLambdaTable)[i]; >> 2168 if(!pv){ >> 2169 G4int j = (*theDensityIdx)[i]; >> 2170 theEnergyOfCrossSectionMax[i] = theEnergyOfCrossSectionMax[j]; >> 2171 theCrossSectionMax[i] = (*theDensityFactor)[i]*theCrossSectionMax[j]; >> 2172 } 1329 } 2173 } 1330 } 2174 } 1331 } 2175 } 1332 2176 1333 //....oooOO0OOooo........oooOO0OOooo........o 2177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1334 2178 1335 void G4VEnergyLossProcess::SetEnergyOfCrossSe << 2179 void G4VEnergyLossProcess::SetSubLambdaTable(G4PhysicsTable* p) 1336 { 2180 { 1337 theEnergyOfCrossSectionMax = p; << 2181 theSubLambdaTable = p; 1338 } << 2182 if(1 < verboseLevel) { 1339 << 2183 G4cout << "### Set SebLambda table " << p 1340 //....oooOO0OOooo........oooOO0OOooo........o << 2184 << " for " << particle->GetParticleName() 1341 << 2185 << " and process " << GetProcessName() << G4endl; 1342 void G4VEnergyLossProcess::SetTwoPeaksXS(std: << 2186 } 1343 { << 1344 fXSpeaks = ptr; << 1345 } 2187 } 1346 2188 1347 //....oooOO0OOooo........oooOO0OOooo........o 2189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1348 2190 1349 const G4Element* G4VEnergyLossProcess::GetCur 2191 const G4Element* G4VEnergyLossProcess::GetCurrentElement() const 1350 { 2192 { 1351 return (nullptr != currentModel) << 2193 const G4Element* elm = nullptr; 1352 ? currentModel->GetCurrentElement(current << 2194 if(currentModel) { elm = currentModel->GetCurrentElement(); } >> 2195 return elm; 1353 } 2196 } 1354 2197 1355 //....oooOO0OOooo........oooOO0OOooo........o 2198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1356 2199 1357 void G4VEnergyLossProcess::SetCrossSectionBia 2200 void G4VEnergyLossProcess::SetCrossSectionBiasingFactor(G4double f, 1358 2201 G4bool flag) 1359 { 2202 { 1360 if(f > 0.0) { 2203 if(f > 0.0) { 1361 biasFactor = f; 2204 biasFactor = f; 1362 weightFlag = flag; 2205 weightFlag = flag; 1363 if(1 < verboseLevel) { 2206 if(1 < verboseLevel) { 1364 G4cout << "### SetCrossSectionBiasingFa 2207 G4cout << "### SetCrossSectionBiasingFactor: for " 1365 << " process " << GetProcessName 2208 << " process " << GetProcessName() 1366 << " biasFactor= " << f << " wei 2209 << " biasFactor= " << f << " weightFlag= " << flag 1367 << G4endl; 2210 << G4endl; 1368 } 2211 } 1369 } 2212 } 1370 } 2213 } 1371 2214 1372 //....oooOO0OOooo........oooOO0OOooo........o 2215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1373 2216 1374 void G4VEnergyLossProcess::ActivateForcedInte << 2217 void 1375 << 2218 G4VEnergyLossProcess::ActivateForcedInteraction(G4double length, 1376 << 2219 const G4String& region, >> 2220 G4bool flag) 1377 { 2221 { 1378 if(nullptr == biasManager) { biasManager = << 2222 if(!biasManager) { biasManager = new G4EmBiasingManager(); } 1379 if(1 < verboseLevel) { 2223 if(1 < verboseLevel) { 1380 G4cout << "### ActivateForcedInteraction: 2224 G4cout << "### ActivateForcedInteraction: for " 1381 << " process " << GetProcessName() 2225 << " process " << GetProcessName() 1382 << " length(mm)= " << length/mm 2226 << " length(mm)= " << length/mm 1383 << " in G4Region <" << region 2227 << " in G4Region <" << region 1384 << "> weightFlag= " << flag 2228 << "> weightFlag= " << flag 1385 << G4endl; 2229 << G4endl; 1386 } 2230 } 1387 weightFlag = flag; 2231 weightFlag = flag; 1388 biasManager->ActivateForcedInteraction(leng 2232 biasManager->ActivateForcedInteraction(length, region); 1389 } 2233 } 1390 2234 1391 //....oooOO0OOooo........oooOO0OOooo........o 2235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1392 2236 1393 void 2237 void 1394 G4VEnergyLossProcess::ActivateSecondaryBiasin 2238 G4VEnergyLossProcess::ActivateSecondaryBiasing(const G4String& region, 1395 2239 G4double factor, 1396 2240 G4double energyLimit) 1397 { 2241 { 1398 if (0.0 <= factor) { 2242 if (0.0 <= factor) { >> 2243 1399 // Range cut can be applied only for e- 2244 // Range cut can be applied only for e- 1400 if(0.0 == factor && secondaryParticle != 2245 if(0.0 == factor && secondaryParticle != G4Electron::Electron()) 1401 { return; } 2246 { return; } 1402 2247 1403 if(nullptr == biasManager) { biasManager << 2248 if(!biasManager) { biasManager = new G4EmBiasingManager(); } 1404 biasManager->ActivateSecondaryBiasing(reg 2249 biasManager->ActivateSecondaryBiasing(region, factor, energyLimit); 1405 if(1 < verboseLevel) { 2250 if(1 < verboseLevel) { 1406 G4cout << "### ActivateSecondaryBiasing 2251 G4cout << "### ActivateSecondaryBiasing: for " 1407 << " process " << GetProcessName 2252 << " process " << GetProcessName() 1408 << " factor= " << factor 2253 << " factor= " << factor 1409 << " in G4Region <" << region 2254 << " in G4Region <" << region 1410 << "> energyLimit(MeV)= " << ene 2255 << "> energyLimit(MeV)= " << energyLimit/MeV 1411 << G4endl; 2256 << G4endl; 1412 } 2257 } 1413 } 2258 } 1414 } 2259 } 1415 2260 1416 //....oooOO0OOooo........oooOO0OOooo........o 2261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1417 2262 1418 void G4VEnergyLossProcess::SetIonisation(G4bo 2263 void G4VEnergyLossProcess::SetIonisation(G4bool val) 1419 { 2264 { 1420 isIonisation = val; 2265 isIonisation = val; 1421 aGPILSelection = (val) ? CandidateForSelect 2266 aGPILSelection = (val) ? CandidateForSelection : NotCandidateForSelection; 1422 } 2267 } 1423 2268 1424 //....oooOO0OOooo........oooOO0OOooo........o 2269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1425 2270 1426 void G4VEnergyLossProcess::SetLinearLossLimi 2271 void G4VEnergyLossProcess::SetLinearLossLimit(G4double val) 1427 { 2272 { 1428 if(0.0 < val && val < 1.0) { 2273 if(0.0 < val && val < 1.0) { 1429 linLossLimit = val; 2274 linLossLimit = val; 1430 actLinLossLimit = true; 2275 actLinLossLimit = true; 1431 } else { PrintWarning("SetLinearLossLimit", 2276 } else { PrintWarning("SetLinearLossLimit", val); } 1432 } 2277 } 1433 2278 1434 //....oooOO0OOooo........oooOO0OOooo........o 2279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1435 2280 1436 void G4VEnergyLossProcess::SetStepFunction(G4 << 2281 void >> 2282 G4VEnergyLossProcess::SetStepFunction(G4double v1, G4double v2, G4bool lock) 1437 { 2283 { 1438 if(0.0 < v1 && 0.0 < v2) { << 2284 if(actStepFunc) { return; } >> 2285 actStepFunc = lock; >> 2286 if(0.0 < v1 && 0.0 < v2 && v2 < 1.e+50) { 1439 dRoverRange = std::min(1.0, v1); 2287 dRoverRange = std::min(1.0, v1); 1440 finalRange = std::min(v2, 1.e+50); << 2288 finalRange = v2; >> 2289 } else if(v1 <= 0.0) { >> 2290 PrintWarning("SetStepFunction", v1); 1441 } else { 2291 } else { 1442 PrintWarning("SetStepFunctionV1", v1); << 2292 PrintWarning("SetStepFunction", v2); 1443 PrintWarning("SetStepFunctionV2", v2); << 1444 } 2293 } 1445 } 2294 } 1446 2295 1447 //....oooOO0OOooo........oooOO0OOooo........o 2296 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1448 2297 1449 void G4VEnergyLossProcess::SetLowestEnergyLim 2298 void G4VEnergyLossProcess::SetLowestEnergyLimit(G4double val) 1450 { 2299 { 1451 if(1.e-18 < val && val < 1.e+50) { lowestKi 2300 if(1.e-18 < val && val < 1.e+50) { lowestKinEnergy = val; } 1452 else { PrintWarning("SetLowestEnergyLimit", 2301 else { PrintWarning("SetLowestEnergyLimit", val); } 1453 } 2302 } 1454 2303 1455 //....oooOO0OOooo........oooOO0OOooo........o 2304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1456 2305 1457 void G4VEnergyLossProcess::SetDEDXBinning(G4i 2306 void G4VEnergyLossProcess::SetDEDXBinning(G4int n) 1458 { 2307 { 1459 if(2 < n && n < 1000000000) { 2308 if(2 < n && n < 1000000000) { 1460 nBins = n; 2309 nBins = n; 1461 actBinning = true; 2310 actBinning = true; 1462 } else { 2311 } else { 1463 G4double e = (G4double)n; 2312 G4double e = (G4double)n; 1464 PrintWarning("SetDEDXBinning", e); 2313 PrintWarning("SetDEDXBinning", e); 1465 } 2314 } 1466 } 2315 } 1467 2316 1468 //....oooOO0OOooo........oooOO0OOooo........o 2317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1469 2318 1470 void G4VEnergyLossProcess::SetMinKinEnergy(G4 2319 void G4VEnergyLossProcess::SetMinKinEnergy(G4double e) 1471 { 2320 { 1472 if(1.e-18 < e && e < maxKinEnergy) { 2321 if(1.e-18 < e && e < maxKinEnergy) { 1473 minKinEnergy = e; 2322 minKinEnergy = e; 1474 actMinKinEnergy = true; 2323 actMinKinEnergy = true; 1475 } else { PrintWarning("SetMinKinEnergy", e) 2324 } else { PrintWarning("SetMinKinEnergy", e); } 1476 } 2325 } 1477 2326 1478 //....oooOO0OOooo........oooOO0OOooo........o 2327 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1479 2328 1480 void G4VEnergyLossProcess::SetMaxKinEnergy(G4 2329 void G4VEnergyLossProcess::SetMaxKinEnergy(G4double e) 1481 { 2330 { 1482 if(minKinEnergy < e && e < 1.e+50) { 2331 if(minKinEnergy < e && e < 1.e+50) { 1483 maxKinEnergy = e; 2332 maxKinEnergy = e; 1484 actMaxKinEnergy = true; 2333 actMaxKinEnergy = true; 1485 if(e < maxKinEnergyCSDA) { maxKinEnergyCS 2334 if(e < maxKinEnergyCSDA) { maxKinEnergyCSDA = e; } 1486 } else { PrintWarning("SetMaxKinEnergy", e) 2335 } else { PrintWarning("SetMaxKinEnergy", e); } 1487 } 2336 } 1488 2337 1489 //....oooOO0OOooo........oooOO0OOooo........o 2338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1490 2339 1491 void G4VEnergyLossProcess::PrintWarning(const << 2340 void G4VEnergyLossProcess::PrintWarning(G4String tit, G4double val) 1492 { 2341 { 1493 G4String ss = "G4VEnergyLossProcess::" + ti 2342 G4String ss = "G4VEnergyLossProcess::" + tit; 1494 G4ExceptionDescription ed; 2343 G4ExceptionDescription ed; 1495 ed << "Parameter is out of range: " << val 2344 ed << "Parameter is out of range: " << val 1496 << " it will have no effect!\n" << " Pr 2345 << " it will have no effect!\n" << " Process " 1497 << GetProcessName() << " nbins= " << nB 2346 << GetProcessName() << " nbins= " << nBins 1498 << " Emin(keV)= " << minKinEnergy/keV 2347 << " Emin(keV)= " << minKinEnergy/keV 1499 << " Emax(GeV)= " << maxKinEnergy/GeV; 2348 << " Emax(GeV)= " << maxKinEnergy/GeV; 1500 G4Exception(ss, "em0044", JustWarning, ed); 2349 G4Exception(ss, "em0044", JustWarning, ed); 1501 } 2350 } 1502 2351 1503 //....oooOO0OOooo........oooOO0OOooo........o 2352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1504 2353 1505 void G4VEnergyLossProcess::ProcessDescription 2354 void G4VEnergyLossProcess::ProcessDescription(std::ostream& out) const 1506 { 2355 { 1507 if(nullptr != particle) { StreamInfo(out, * << 2356 if(particle) { StreamInfo(out, *particle, true); } 1508 } 2357 } 1509 2358 1510 //....oooOO0OOooo........oooOO0OOooo........o 2359 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1511 2360