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 9.3.p2)


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