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