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


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