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