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 10.0)


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