Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc (Version 8.1)


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