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