Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4LossTableManager.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/G4LossTableManager.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4LossTableManager.cc (Version 10.1.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4LossTableManager.cc 85424 2014-10-29 08:23:44Z gcosmo $
                                                   >>  27 //
 26 // -------------------------------------------     28 // -------------------------------------------------------------------
 27 //                                                 29 //
 28 // GEANT4 Class file                               30 // GEANT4 Class file
 29 //                                                 31 //
 30 //                                                 32 //
 31 // File name:     G4LossTableManager               33 // File name:     G4LossTableManager
 32 //                                                 34 //
 33 // Author:        Vladimir Ivanchenko              35 // Author:        Vladimir Ivanchenko
 34 //                                                 36 //
 35 // Creation date: 03.01.2002                       37 // Creation date: 03.01.2002
 36 //                                                 38 //
 37 // Modifications: by V.Ivanchenko              <<  39 // Modifications:
 38 //                                                 40 //
                                                   >>  41 // 20-01-03 Migrade to cut per region (V.Ivanchenko)
                                                   >>  42 // 15-02-03 Lambda table can be scaled (V.Ivanchenko)
                                                   >>  43 // 17-02-03 Fix problem of store/restore tables (V.Ivanchenko)
                                                   >>  44 // 10-03-03 Add Ion registration (V.Ivanchenko)
                                                   >>  45 // 25-03-03 Add deregistration (V.Ivanchenko)
                                                   >>  46 // 02-04-03 Change messenger (V.Ivanchenko)
                                                   >>  47 // 26-04-03 Fix retrieve tables (V.Ivanchenko)
                                                   >>  48 // 13-05-03 Add calculation of precise range (V.Ivanchenko)
                                                   >>  49 // 23-07-03 Add exchange with G4EnergyLossTables (V.Ivanchenko)
                                                   >>  50 // 05-10-03 Add G4VEmProcesses registration and Verbose command (V.Ivanchenko)
                                                   >>  51 // 17-10-03 Add SetParameters method (V.Ivanchenko)
                                                   >>  52 // 23-10-03 Add control on inactive processes (V.Ivanchenko)
                                                   >>  53 // 04-11-03 Add checks in RetrievePhysicsTable (V.Ivanchenko)
                                                   >>  54 // 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko)
                                                   >>  55 // 14-01-04 Activate precise range calculation (V.Ivanchenko)
                                                   >>  56 // 10-03-04 Fix a problem of Precise Range table (V.Ivanchenko)
                                                   >>  57 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko)
                                                   >>  58 // 13-01-04 Fix problem which takes place for inactivate eIoni (V.Ivanchenko)
                                                   >>  59 // 25-01-04 Fix initialisation problem for ions (V.Ivanchenko)
                                                   >>  60 // 11-03-05 Shift verbose level by 1 (V.Ivantchenko)
                                                   >>  61 // 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko)
                                                   >>  62 // 20-01-06 Introduce G4EmTableType to remove repeating code (VI)
                                                   >>  63 // 23-03-06 Set flag isIonisation (VI)
                                                   >>  64 // 10-05-06 Add methods  SetMscStepLimitation, FacRange and MscFlag (VI)
                                                   >>  65 // 22-05-06 Add methods  Set/Get bremsTh (VI)
                                                   >>  66 // 05-06-06 Do not clear loss_table map between runs (VI)
                                                   >>  67 // 16-01-07 Create new energy loss table for e+,e-,mu+,mu- and 
                                                   >>  68 //          left ionisation table for further usage (VI)
                                                   >>  69 // 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko)
                                                   >>  70 // 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko)
                                                   >>  71 // 21-02-08 Added G4EmSaturation (V.Ivanchenko)
                                                   >>  72 // 12-04-10 Added PreparePhysicsTables and BuildPhysicsTables entries (V.Ivanchenko)
                                                   >>  73 // 04-06-13 (V.Ivanchenko) Adaptation for MT mode; new method LocalPhysicsTables; 
                                                   >>  74 //          ions expect G4GenericIon are not included in the map of energy loss
                                                   >>  75 //          processes for performnc reasons  
 39 //                                                 76 //
 40 // Class Description:                              77 // Class Description:
 41 //                                                 78 //
 42 // -------------------------------------------     79 // -------------------------------------------------------------------
 43 //                                                 80 //
 44 //....oooOO0OOooo........oooOO0OOooo........oo     81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 45 //....oooOO0OOooo........oooOO0OOooo........oo     82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 46                                                    83 
 47 #include "G4LossTableManager.hh"                   84 #include "G4LossTableManager.hh"
 48 #include "G4SystemOfUnits.hh"                      85 #include "G4SystemOfUnits.hh"
 49                                                << 
 50 #include "G4VMultipleScattering.hh"            << 
 51 #include "G4VEmProcess.hh"                     << 
 52                                                << 
 53 #include "G4EmParameters.hh"                       86 #include "G4EmParameters.hh"
 54 #include "G4EmSaturation.hh"                   <<  87 #include "G4EnergyLossMessenger.hh"
 55 #include "G4EmConfigurator.hh"                 << 
 56 #include "G4ElectronIonPair.hh"                << 
 57 #include "G4NIELCalculator.hh"                 << 
 58 #include "G4EmCorrections.hh"                  << 
 59 #include "G4LossTableBuilder.hh"               << 
 60 #include "G4VAtomDeexcitation.hh"              << 
 61 #include "G4VSubCutProducer.hh"                << 
 62                                                << 
 63 #include "G4PhysicsTable.hh"                       88 #include "G4PhysicsTable.hh"
 64 #include "G4ParticleDefinition.hh"                 89 #include "G4ParticleDefinition.hh"
 65 #include "G4MaterialCutsCouple.hh"                 90 #include "G4MaterialCutsCouple.hh"
 66 #include "G4ProcessManager.hh"                     91 #include "G4ProcessManager.hh"
 67 #include "G4Electron.hh"                           92 #include "G4Electron.hh"
 68 #include "G4Proton.hh"                             93 #include "G4Proton.hh"
                                                   >>  94 #include "G4VMultipleScattering.hh"
                                                   >>  95 #include "G4VEmProcess.hh"
 69 #include "G4ProductionCutsTable.hh"                96 #include "G4ProductionCutsTable.hh"
 70 #include "G4PhysicsTableHelper.hh"                 97 #include "G4PhysicsTableHelper.hh"
                                                   >>  98 #include "G4EmCorrections.hh"
                                                   >>  99 #include "G4EmSaturation.hh"
                                                   >> 100 #include "G4EmConfigurator.hh"
                                                   >> 101 #include "G4ElectronIonPair.hh"
 71 #include "G4EmTableType.hh"                       102 #include "G4EmTableType.hh"
                                                   >> 103 #include "G4LossTableBuilder.hh"
                                                   >> 104 #include "G4VAtomDeexcitation.hh"
                                                   >> 105 #include "G4VSubCutProducer.hh"
 72 #include "G4Region.hh"                            106 #include "G4Region.hh"
 73 #include "G4PhysicalConstants.hh"                 107 #include "G4PhysicalConstants.hh"
 74                                                << 108 #include "G4Threading.hh"
 75 #include "G4Gamma.hh"                          << 
 76 #include "G4Positron.hh"                       << 
 77 #include "G4OpticalPhoton.hh"                  << 
 78 #include "G4Neutron.hh"                        << 
 79 #include "G4MuonPlus.hh"                       << 
 80 #include "G4MuonMinus.hh"                      << 
 81 #include "G4GenericIon.hh"                     << 
 82                                                   109 
 83 //....oooOO0OOooo........oooOO0OOooo........oo    110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 84                                                   111 
 85 static std::once_flag applyOnce;               << 112 G4ThreadLocal G4LossTableManager* G4LossTableManager::instance = 0;
 86 G4ThreadLocal G4LossTableManager* G4LossTableM << 
 87                                                   113 
 88 G4LossTableManager* G4LossTableManager::Instan    114 G4LossTableManager* G4LossTableManager::Instance()
 89 {                                                 115 {
 90   if(nullptr == instance) {                    << 116   if(!instance) {
 91     static G4ThreadLocalSingleton<G4LossTableM    117     static G4ThreadLocalSingleton<G4LossTableManager> inst;
 92     instance = inst.Instance();                   118     instance = inst.Instance();
 93   }                                               119   }
 94   return instance;                                120   return instance;
 95 }                                                 121 }
 96                                                   122 
 97 //....oooOO0OOooo........oooOO0OOooo........oo    123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 98                                                   124 
 99 G4LossTableManager::~G4LossTableManager()         125 G4LossTableManager::~G4LossTableManager()
100 {                                                 126 {
101   for (auto const & p : loss_vector) { delete  << 127   //G4cout << "### G4LossTableManager::~G4LossTableManager()" << G4endl;
102   for (auto const & p : msc_vector) { delete p << 128   for (G4int i=0; i<n_loss; ++i) {
103   for (auto const & p : emp_vector) { delete p << 129     //G4cout << "### eloss #" << i << G4endl;
104   for (auto const & p : p_vector) { delete p;  << 130     if( loss_vector[i] ) { 
105                                                << 131       delete loss_vector[i]; 
106   std::size_t mod = mod_vector.size();         << 132     }
107   std::size_t fmod = fmod_vector.size();       << 133   }
108   for (std::size_t a=0; a<mod; ++a) {          << 134   size_t msc = msc_vector.size();
109     if( nullptr != mod_vector[a] ) {           << 135   for (size_t j=0; j<msc; ++j) {
110       for (std::size_t b=0; b<fmod; ++b) {     << 136     if( msc_vector[j] ) { delete msc_vector[j]; }
111         if((G4VEmModel*)(fmod_vector[b]) == mo << 137   }
112           fmod_vector[b] = nullptr;            << 138   size_t emp = emp_vector.size();
113         }                                      << 139   for (size_t k=0; k<emp; ++k) {
                                                   >> 140     if( emp_vector[k] ) { delete emp_vector[k]; }
                                                   >> 141   }
                                                   >> 142   size_t mod = mod_vector.size();
                                                   >> 143   size_t fmod = fmod_vector.size();
                                                   >> 144   for (size_t a=0; a<mod; ++a) {
                                                   >> 145     if( mod_vector[a] ) { 
                                                   >> 146       for (size_t b=0; b<fmod; ++b) {
                                                   >> 147   if((G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) {
                                                   >> 148     fmod_vector[b] = 0;
                                                   >> 149   }
114       }                                           150       }
115       delete mod_vector[a];                       151       delete mod_vector[a]; 
116       mod_vector[a] = nullptr;                 << 
117     }                                             152     }
118   }                                               153   }
119   for (auto const & p : fmod_vector) { delete  << 154   for (size_t b=0; b<fmod; ++b) {
120                                                << 155     if( fmod_vector[b] ) { delete fmod_vector[b]; }
                                                   >> 156   }
121   Clear();                                        157   Clear();
                                                   >> 158   delete theMessenger;
122   delete tableBuilder;                            159   delete tableBuilder;
123   delete emCorrections;                           160   delete emCorrections;
                                                   >> 161   delete emSaturation;
124   delete emConfigurator;                          162   delete emConfigurator;
125   delete emElectronIonPair;                       163   delete emElectronIonPair;
126   delete nielCalculator;                       << 
127   delete atomDeexcitation;                        164   delete atomDeexcitation;
128   delete subcutProducer;                          165   delete subcutProducer;
129 }                                                 166 }
130                                                   167 
131 //....oooOO0OOooo........oooOO0OOooo........oo    168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
132                                                   169 
133 G4LossTableManager::G4LossTableManager()          170 G4LossTableManager::G4LossTableManager()
134 {                                                 171 {
135   theParameters = G4EmParameters::Instance();     172   theParameters = G4EmParameters::Instance();
136   theElectron = G4Electron::Electron();        << 173   n_loss = 0;
137                                                << 174   run = -1;
138   // only one thread is the master             << 175   startInitialisation = false;
139   std::call_once(applyOnce, [this]() { isMaste << 176   all_tables_are_built = false;
140   verbose = isMaster ? theParameters->Verbose( << 177   currentLoss = 0;
141                                                << 178   currentParticle = 0;
142   tableBuilder = new G4LossTableBuilder(isMast << 179   firstParticle = 0;
143   emCorrections = new G4EmCorrections(verbose) << 180   subCutoffFlag = false;
144                                                << 181   maxRangeVariation = 0.2;
145   std::size_t n = 70;                          << 182   maxFinalStep = CLHEP::mm;
146   loss_vector.reserve(n);                      << 183   integral = true;
147   part_vector.reserve(n);                      << 184   integralActive = false;
148   base_part_vector.reserve(n);                 << 185   stepFunctionActive = false;
149   dedx_vector.reserve(n);                      << 186   isMaster = true;
150   range_vector.reserve(n);                     << 187   verbose = theParameters->Verbose();
151   inv_range_vector.reserve(n);                 << 188   theMessenger = new G4EnergyLossMessenger();
152   tables_are_built.reserve(n);                 << 189   theElectron  = G4Electron::Electron();
153   isActive.reserve(n);                         << 190   theGenericIon= 0;
154   msc_vector.reserve(10);                      << 191   if(G4Threading::IsWorkerThread()) { 
155   emp_vector.reserve(16);                      << 192     verbose = theParameters->WorkerVerbose();
156   mod_vector.reserve(150);                     << 193     isMaster = false;
157   fmod_vector.reserve(60);                     << 194   }  
                                                   >> 195   tableBuilder = new G4LossTableBuilder();
                                                   >> 196   emCorrections= new G4EmCorrections(verbose);
                                                   >> 197   emSaturation = 0;
                                                   >> 198   emConfigurator = 0;
                                                   >> 199   emElectronIonPair = 0;
                                                   >> 200   atomDeexcitation = 0;
                                                   >> 201   subcutProducer = 0;
158 }                                                 202 }
159                                                   203 
160 //....oooOO0OOooo........oooOO0OOooo........oo    204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
161                                                   205 
162 void G4LossTableManager::Clear()                  206 void G4LossTableManager::Clear()
163 {                                                 207 {
164   all_tables_are_built = false;                   208   all_tables_are_built = false;
165   currentLoss = nullptr;                       << 209   currentLoss = 0;
166   currentParticle = nullptr;                   << 210   currentParticle = 0;
167   if(n_loss) {                                 << 211   if(n_loss)
168     dedx_vector.clear();                       << 212     {
169     range_vector.clear();                      << 213       dedx_vector.clear();
170     inv_range_vector.clear();                  << 214       range_vector.clear();
171     loss_map.clear();                          << 215       inv_range_vector.clear();
172     loss_vector.clear();                       << 216       loss_map.clear();
173     part_vector.clear();                       << 217       loss_vector.clear();
174     base_part_vector.clear();                  << 218       part_vector.clear();
175     tables_are_built.clear();                  << 219       base_part_vector.clear();
176     isActive.clear();                          << 220       tables_are_built.clear();
177     n_loss = 0;                                << 221       isActive.clear();
178   }                                            << 222       n_loss = 0;
                                                   >> 223     }
179 }                                                 224 }
180                                                   225 
181 //....oooOO0OOooo........oooOO0OOooo........oo    226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
182                                                   227 
183 void G4LossTableManager::Register(G4VEnergyLos    228 void G4LossTableManager::Register(G4VEnergyLossProcess* p)
184 {                                                 229 {
185   if (nullptr == p) { return; }                << 230   if(!p) { return; }
186   for (G4int i=0; i<n_loss; ++i) {                231   for (G4int i=0; i<n_loss; ++i) {
187     if(loss_vector[i] == p) { return; }           232     if(loss_vector[i] == p) { return; }
188   }                                               233   }
189   if(verbose > 1) {                               234   if(verbose > 1) {
190     G4cout << "G4LossTableManager::Register G4    235     G4cout << "G4LossTableManager::Register G4VEnergyLossProcess : " 
191            << p->GetProcessName() << "  idx= " << 236      << p->GetProcessName() << "  idx= " << n_loss << G4endl;
192   }                                               237   }
193   ++n_loss;                                       238   ++n_loss;
194   loss_vector.push_back(p);                       239   loss_vector.push_back(p);
195   part_vector.push_back(nullptr);              << 240   part_vector.push_back(0);
196   base_part_vector.push_back(nullptr);         << 241   base_part_vector.push_back(0);
197   dedx_vector.push_back(nullptr);              << 242   dedx_vector.push_back(0);
198   range_vector.push_back(nullptr);             << 243   range_vector.push_back(0);
199   inv_range_vector.push_back(nullptr);         << 244   inv_range_vector.push_back(0);
200   tables_are_built.push_back(false);              245   tables_are_built.push_back(false);
201   isActive.push_back(true);                       246   isActive.push_back(true);
202   all_tables_are_built = false;                   247   all_tables_are_built = false;
                                                   >> 248   if(subCutoffFlag)        { p->ActivateSubCutoff(true); }
                                                   >> 249   if(stepFunctionActive)   { p->SetStepFunction(maxRangeVariation, 
                                                   >> 250             maxFinalStep); }
                                                   >> 251   if(integralActive)       { p->SetIntegral(integral); }
203 }                                                 252 }
204                                                   253 
205 //....oooOO0OOooo........oooOO0OOooo........oo    254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
206                                                   255 
207 void G4LossTableManager::ResetParameters()        256 void G4LossTableManager::ResetParameters()
208 {                                                 257 {
209   // initialisation once per run               << 
210   if (!resetParam) { return; }                 << 
211   resetParam = false;                          << 
212   startInitialisation = true;                  << 
213   verbose = theParameters->Verbose();             258   verbose = theParameters->Verbose();
214   if(!isMaster) {                                 259   if(!isMaster) {
215     verbose = theParameters->WorkerVerbose();     260     verbose = theParameters->WorkerVerbose();
216   } else {                                     << 
217     if(verbose > 0) { theParameters->Dump(); } << 
218   }                                               261   }
219                                                << 262   tableBuilder->SetSplineFlag(theParameters->Spline());
220   tableBuilder->InitialiseBaseMaterials();     << 263   tableBuilder->SetInitialisationFlag(false); 
221   if (nullptr != nielCalculator) { nielCalcula << 
222                                                << 
223   emCorrections->SetVerbose(verbose);             264   emCorrections->SetVerbose(verbose); 
224   if(nullptr != emConfigurator) { emConfigurat << 265   if(emSaturation) { emSaturation->SetVerbose(verbose); } 
225   if(nullptr != emElectronIonPair) { emElectro << 266   if(emConfigurator) { emConfigurator->SetVerbose(verbose); };
226   if(nullptr != atomDeexcitation) {            << 267   if(emElectronIonPair) { emElectronIonPair->SetVerbose(verbose); };
                                                   >> 268   if(atomDeexcitation) {
227     atomDeexcitation->SetVerboseLevel(verbose)    269     atomDeexcitation->SetVerboseLevel(verbose);
228     atomDeexcitation->InitialiseAtomicDeexcita << 270     atomDeexcitation->SetFluo(theParameters->Fluo());
229   }                                            << 271     atomDeexcitation->SetAuger(theParameters->Auger());
230   if (1 < verbose) {                           << 272     atomDeexcitation->SetPIXE(theParameters->Pixe());
231     G4cout << "====== G4LossTableManager::Rese << 273     atomDeexcitation->SetIgnoreCuts(theParameters->DeexcitationIgnoreCut());
232            << " Nloss=" << loss_vector.size()  << 
233      << " run=" << run << " master=" << isMast << 
234      << G4endl;                                << 
235   }                                               274   }
236 }                                                 275 }
237                                                   276 
238 //....oooOO0OOooo........oooOO0OOooo........oo    277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
239                                                   278 
240 void G4LossTableManager::DeRegister(G4VEnergyL    279 void G4LossTableManager::DeRegister(G4VEnergyLossProcess* p)
241 {                                                 280 {
242   if (nullptr == p) { return; }                << 281   if(!p) { return; }
243   for (G4int i=0; i<n_loss; ++i) {                282   for (G4int i=0; i<n_loss; ++i) {
244     if(loss_vector[i] == p) {                  << 283     if(loss_vector[i] == p) { loss_vector[i] = 0; }
245       loss_vector[i] = nullptr;                << 
246       break;                                   << 
247     }                                          << 
248   }                                               284   }
249 }                                                 285 }
250                                                   286 
251 //....oooOO0OOooo........oooOO0OOooo........oo    287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
252                                                   288 
253 void G4LossTableManager::Register(G4VMultipleS    289 void G4LossTableManager::Register(G4VMultipleScattering* p)
254 {                                                 290 {
255   if (nullptr == p) { return; }                << 291   if(!p) { return; }
256   std::size_t n = msc_vector.size();           << 292   G4int n = msc_vector.size();
257   for (std::size_t i=0; i<n; ++i) {            << 293   for (G4int i=0; i<n; ++i) {
258     if(msc_vector[i] == p) { return; }            294     if(msc_vector[i] == p) { return; }
259   }                                               295   }
260   if(verbose > 1) {                               296   if(verbose > 1) {
261     G4cout << "G4LossTableManager::Register G4    297     G4cout << "G4LossTableManager::Register G4VMultipleScattering : " 
262            << p->GetProcessName() << "  idx= " << 298      << p->GetProcessName() << "  idx= " << msc_vector.size() << G4endl;
263   }                                               299   }
264   msc_vector.push_back(p);                        300   msc_vector.push_back(p);
265 }                                                 301 }
266                                                   302 
267 //....oooOO0OOooo........oooOO0OOooo........oo    303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
268                                                   304 
269 void G4LossTableManager::DeRegister(G4VMultipl    305 void G4LossTableManager::DeRegister(G4VMultipleScattering* p)
270 {                                                 306 {
271   if (nullptr == p) { return; }                << 307   if(!p) { return; }
272   std::size_t msc = msc_vector.size();         << 308   size_t msc = msc_vector.size();
273   for (std::size_t i=0; i<msc; ++i) {          << 309   for (size_t i=0; i<msc; ++i) {
274     if(msc_vector[i] == p) {                   << 310     if(msc_vector[i] == p) { msc_vector[i] = 0; }
275       msc_vector[i] = nullptr;                 << 
276       break;                                   << 
277     }                                          << 
278   }                                               311   }
279 }                                                 312 }
280                                                   313 
281 //....oooOO0OOooo........oooOO0OOooo........oo    314 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
282                                                   315 
283 void G4LossTableManager::Register(G4VEmProcess    316 void G4LossTableManager::Register(G4VEmProcess* p)
284 {                                                 317 {
285   if (nullptr == p) { return; }                << 318   if(!p) { return; }
286   std::size_t n = emp_vector.size();           << 319   G4int n = emp_vector.size();
287   for (std::size_t i=0; i<n; ++i) {            << 320   for (G4int i=0; i<n; ++i) {
288     if(emp_vector[i] == p) { return; }            321     if(emp_vector[i] == p) { return; }
289   }                                               322   }
290   if(verbose > 1) {                               323   if(verbose > 1) {
291     G4cout << "G4LossTableManager::Register G4    324     G4cout << "G4LossTableManager::Register G4VEmProcess : " 
292            << p->GetProcessName() << "  idx= " << 325      << p->GetProcessName() << "  idx= " << emp_vector.size() << G4endl;
293   }                                               326   }
294   emp_vector.push_back(p);                        327   emp_vector.push_back(p);
295 }                                                 328 }
296                                                   329 
297 //....oooOO0OOooo........oooOO0OOooo........oo    330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
298                                                   331 
299 void G4LossTableManager::DeRegister(G4VEmProce    332 void G4LossTableManager::DeRegister(G4VEmProcess* p)
300 {                                                 333 {
301   if (nullptr == p) { return; }                << 334   if(!p) { return; }
302   std::size_t emp = emp_vector.size();         << 335   size_t emp = emp_vector.size();
303   for (std::size_t i=0; i<emp; ++i) {          << 336   for (size_t i=0; i<emp; ++i) {
304     if(emp_vector[i] == p) {                   << 337     if(emp_vector[i] == p) { emp_vector[i] = 0; }
305       emp_vector[i] = nullptr;                 << 
306       break;                                   << 
307     }                                          << 
308   }                                            << 
309 }                                              << 
310                                                << 
311 //....oooOO0OOooo........oooOO0OOooo........oo << 
312                                                << 
313 void G4LossTableManager::Register(G4VProcess*  << 
314 {                                              << 
315   if (nullptr == p) { return; }                << 
316   std::size_t n = p_vector.size();             << 
317   for (std::size_t i=0; i<n; ++i) {            << 
318     if(p_vector[i] == p) { return; }           << 
319   }                                            << 
320   if(verbose > 1) {                            << 
321     G4cout << "G4LossTableManager::Register G4 << 
322            << p->GetProcessName() << "  idx= " << 
323   }                                            << 
324   p_vector.push_back(p);                       << 
325 }                                              << 
326                                                << 
327 //....oooOO0OOooo........oooOO0OOooo........oo << 
328                                                << 
329 void G4LossTableManager::DeRegister(G4VProcess << 
330 {                                              << 
331   if (nullptr == p) { return; }                << 
332   std::size_t emp = p_vector.size();           << 
333   for (std::size_t i=0; i<emp; ++i) {          << 
334     if(p_vector[i] == p) {                     << 
335       p_vector[i] = nullptr;                   << 
336       break;                                   << 
337     }                                          << 
338   }                                               338   }
339 }                                                 339 }
340                                                   340 
341 //....oooOO0OOooo........oooOO0OOooo........oo    341 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
342                                                   342 
343 void G4LossTableManager::Register(G4VEmModel*     343 void G4LossTableManager::Register(G4VEmModel* p)
344 {                                                 344 {
345   mod_vector.push_back(p);                        345   mod_vector.push_back(p);
346   if(verbose > 1) {                               346   if(verbose > 1) {
347     G4cout << "G4LossTableManager::Register G4    347     G4cout << "G4LossTableManager::Register G4VEmModel : " 
348            << p->GetName() << "  " << p << "   << 348      << p->GetName() << G4endl;
349   }                                               349   }
350 }                                                 350 }
351                                                   351 
352 //....oooOO0OOooo........oooOO0OOooo........oo    352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
353                                                   353 
354 void G4LossTableManager::DeRegister(G4VEmModel    354 void G4LossTableManager::DeRegister(G4VEmModel* p)
355 {                                                 355 {
356   //G4cout << "G4LossTableManager::DeRegister  << 356   size_t n = mod_vector.size();
357   std::size_t n = mod_vector.size();           << 357   for (size_t i=0; i<n; ++i) {
358   for (std::size_t i=0; i<n; ++i) {            << 358     if(mod_vector[i] == p) { mod_vector[i] = 0; }
359     if(mod_vector[i] == p) {                   << 
360       mod_vector[i] = nullptr;                 << 
361       break;                                   << 
362     }                                          << 
363   }                                               359   }
364 }                                                 360 }
365                                                   361 
366 //....oooOO0OOooo........oooOO0OOooo........oo    362 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
367                                                   363 
368 void G4LossTableManager::Register(G4VEmFluctua    364 void G4LossTableManager::Register(G4VEmFluctuationModel* p)
369 {                                                 365 {
370   fmod_vector.push_back(p);                       366   fmod_vector.push_back(p);
371   if(verbose > 1) {                               367   if(verbose > 1) {
372     G4cout << "G4LossTableManager::Register G4    368     G4cout << "G4LossTableManager::Register G4VEmFluctuationModel : " 
373            << p->GetName() << "  " << fmod_vec << 369      << p->GetName() << G4endl;
374   }                                               370   }
375 }                                                 371 }
376                                                   372 
377 //....oooOO0OOooo........oooOO0OOooo........oo    373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
378                                                   374 
379 void G4LossTableManager::DeRegister(G4VEmFluct    375 void G4LossTableManager::DeRegister(G4VEmFluctuationModel* p)
380 {                                                 376 {
381   std::size_t n = fmod_vector.size();          << 377   size_t n = fmod_vector.size();
382   for (std::size_t i=0; i<n; ++i) {            << 378   for (size_t i=0; i<n; ++i) {
383     if(fmod_vector[i] == p) { fmod_vector[i] = << 379     if(fmod_vector[i] == p) { fmod_vector[i] = 0; }
384   }                                               380   }
385 }                                                 381 }
386                                                   382 
387 //....oooOO0OOooo........oooOO0OOooo........oo    383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
388                                                   384 
389 void G4LossTableManager::RegisterExtraParticle    385 void G4LossTableManager::RegisterExtraParticle(
390      const G4ParticleDefinition* part,            386      const G4ParticleDefinition* part,
391      G4VEnergyLossProcess* p)                     387      G4VEnergyLossProcess* p)
392 {                                                 388 { 
393   if (nullptr == p || nullptr == part) { retur << 389   if(!p || !part) { return; }
394   for (G4int i=0; i<n_loss; ++i) {                390   for (G4int i=0; i<n_loss; ++i) {
395     if(loss_vector[i] == p) { return; }           391     if(loss_vector[i] == p) { return; }
396   }                                               392   }
397   if(verbose > 1) {                               393   if(verbose > 1) {
398     G4cout << "G4LossTableManager::RegisterExt    394     G4cout << "G4LossTableManager::RegisterExtraParticle "
399            << part->GetParticleName() << "  G4 << 395      << part->GetParticleName() << "  G4VEnergyLossProcess : " 
400            << p->GetProcessName() << "  idx= " << 396      << p->GetProcessName() << "  idx= " << n_loss << G4endl;
401   }                                               397   }
402   ++n_loss;                                       398   ++n_loss;
403   loss_vector.push_back(p);                       399   loss_vector.push_back(p);
404   part_vector.push_back(part);                    400   part_vector.push_back(part);
405   base_part_vector.push_back(p->BaseParticle()    401   base_part_vector.push_back(p->BaseParticle());
406   dedx_vector.push_back(nullptr);              << 402   dedx_vector.push_back(0);
407   range_vector.push_back(nullptr);             << 403   range_vector.push_back(0);
408   inv_range_vector.push_back(nullptr);         << 404   inv_range_vector.push_back(0);
409   tables_are_built.push_back(false);              405   tables_are_built.push_back(false);
410   all_tables_are_built = false;                   406   all_tables_are_built = false;
411 }                                                 407 }
412                                                   408 
413 //....oooOO0OOooo........oooOO0OOooo........oo << 
414                                                << 
415 G4VEnergyLossProcess*                          << 
416 G4LossTableManager::GetEnergyLossProcess(const << 
417 {                                              << 
418   if(aParticle != currentParticle) {           << 
419     currentParticle = aParticle;               << 
420     std::map<PD,G4VEnergyLossProcess*,std::les << 
421     if ((pos = loss_map.find(aParticle)) != lo << 
422       currentLoss = (*pos).second;             << 
423     } else {                                   << 
424       currentLoss = nullptr;                   << 
425       if(0.0 != aParticle->GetPDGCharge() &&   << 
426    (pos = loss_map.find(theGenericIon)) != los << 
427   currentLoss = (*pos).second;                 << 
428       }                                        << 
429     }                                          << 
430   }                                            << 
431   return currentLoss;                          << 
432 }                                              << 
433                                                << 
434 //....oooOO0OOooo........oooOO0OOooo........oo    409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
435                                                   410 
436 void                                              411 void 
437 G4LossTableManager::PreparePhysicsTable(const     412 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
438                                         G4VEne << 413           G4VEnergyLossProcess* p,
                                                   >> 414           G4bool theMaster)
439 {                                                 415 {
440   if (1 < verbose) {                              416   if (1 < verbose) {
441     G4cout << "G4LossTableManager::PreparePhys    417     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
442            << particle->GetParticleName()      << 418      << particle->GetParticleName() 
443            << " and " << p->GetProcessName() < << 419      << " and " << p->GetProcessName() << " run= " << run 
444            << "   loss_vector " << loss_vector << 420      << "   loss_vector " << loss_vector.size() << G4endl;
445      << " run=" << run << " master=" << isMast << 421   }
446      << G4endl;                                << 422 
                                                   >> 423   isMaster = theMaster;
                                                   >> 424 
                                                   >> 425   if(!startInitialisation) { 
                                                   >> 426     ResetParameters();
                                                   >> 427     if (1 < verbose) {
                                                   >> 428       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 429        << G4endl;
                                                   >> 430     } 
447   }                                               431   }
448                                                   432 
449   // start initialisation for the first run       433   // start initialisation for the first run
450   if( -1 == run ) {                               434   if( -1 == run ) {
451     if (nullptr != emConfigurator) { emConfigu << 435     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
452                                                   436 
453     // initialise particles for given process     437     // initialise particles for given process
454     for (G4int j=0; j<n_loss; ++j) {              438     for (G4int j=0; j<n_loss; ++j) {
455       if (p == loss_vector[j] && nullptr == pa << 439       if (p == loss_vector[j] && !part_vector[j]) { 
456         part_vector[j] = particle;             << 440   part_vector[j] = particle;
457         if (particle->GetParticleName() == "Ge << 441   if(particle->GetParticleName() == "GenericIon") {
458           theGenericIon = particle;            << 442     theGenericIon = particle;
459         }                                      << 443   }
460       }                                           444       }
461     }                                             445     }
462   }                                               446   }
463   ResetParameters();                           << 447   startInitialisation = true;
464 }                                                 448 }
465                                                   449 
466 //....oooOO0OOooo........oooOO0OOooo........oo    450 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
467                                                   451 
468 void                                              452 void 
469 G4LossTableManager::PreparePhysicsTable(const     453 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
470                                         G4VEmP << 454           G4VEmProcess* p, G4bool theMaster)
471 {                                                 455 {
472   if (1 < verbose) {                              456   if (1 < verbose) {
473     G4cout << "G4LossTableManager::PreparePhys    457     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
474            << particle->GetParticleName()      << 458      << particle->GetParticleName() 
475            << " and " << p->GetProcessName()   << 459      << " and " << p->GetProcessName() << G4endl;
476      << " run=" << run << " master=" << isMast << 460   }
477      << G4endl;                                << 461   isMaster = theMaster;
                                                   >> 462 
                                                   >> 463   if(!startInitialisation) { 
                                                   >> 464     ResetParameters(); 
                                                   >> 465     if (1 < verbose) {
                                                   >> 466       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 467        << G4endl;
                                                   >> 468     } 
478   }                                               469   }
479                                                   470 
480   // start initialisation for the first run       471   // start initialisation for the first run
481   if( -1 == run ) {                               472   if( -1 == run ) {
482     if (nullptr != emConfigurator) { emConfigu << 473     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
483   }                                               474   }
484                                                << 475   startInitialisation = true;
485   ResetParameters();                           << 
486 }                                                 476 }
487                                                   477 
488 //....oooOO0OOooo........oooOO0OOooo........oo    478 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
489                                                   479 
490 void                                              480 void 
491 G4LossTableManager::PreparePhysicsTable(const     481 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
492                                         G4VMul << 482           G4VMultipleScattering* p,
                                                   >> 483           G4bool theMaster)
493 {                                                 484 {
494   if (1 < verbose) {                              485   if (1 < verbose) {
495     G4cout << "G4LossTableManager::PreparePhys    486     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
496            << particle->GetParticleName()      << 487      << particle->GetParticleName() 
497            << " and " << p->GetProcessName()   << 488      << " and " << p->GetProcessName() << G4endl;
498      << " run=" << run << " master=" << isMast << 489   }
499      << G4endl;                                << 490 
                                                   >> 491   isMaster = theMaster;
                                                   >> 492 
                                                   >> 493   if(!startInitialisation) { 
                                                   >> 494     ResetParameters();
                                                   >> 495     if (1 < verbose) {
                                                   >> 496       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 497        << G4endl;
                                                   >> 498     } 
500   }                                               499   }
501                                                   500 
502   // start initialisation for the first run       501   // start initialisation for the first run
503   if ( -1 == run ) {                           << 502   if( -1 == run ) {
504     if (nullptr != emConfigurator) { emConfigu << 503     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
505   }                                               504   } 
506                                                << 505   startInitialisation = true;
507   ResetParameters();                           << 
508 }                                                 506 }
509                                                   507 
510 //....oooOO0OOooo........oooOO0OOooo........oo    508 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
511                                                   509 
512 void                                              510 void 
513 G4LossTableManager::BuildPhysicsTable(const G4    511 G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition*)
514 {                                                 512 {
515   if(-1 == run && startInitialisation) {          513   if(-1 == run && startInitialisation) {
516     if (nullptr != emConfigurator) { emConfigu << 514     if(emConfigurator) { emConfigurator->Clear(); }
517   }                                               515   }
518   if (startInitialisation) { resetParam = true << 
519 }                                                 516 }
520                                                   517 
521 //....oooOO0OOooo........oooOO0OOooo........oo    518 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
522                                                   519 
523 void G4LossTableManager::LocalPhysicsTables(      520 void G4LossTableManager::LocalPhysicsTables(
524      const G4ParticleDefinition* aParticle,       521      const G4ParticleDefinition* aParticle,
525      G4VEnergyLossProcess* p)                     522      G4VEnergyLossProcess* p)
526 {                                                 523 {
527   if (1 < verbose) {                           << 524   if(1 < verbose) {
528     G4cout << "### G4LossTableManager::LocalPh    525     G4cout << "### G4LossTableManager::LocalPhysicsTable() for "
529            << aParticle->GetParticleName()     << 526      << aParticle->GetParticleName()
530            << " and process " << p->GetProcess << 527        << " and process " << p->GetProcessName()
531            << G4endl;                          << 528      << G4endl;
532   }                                               529   }
533                                                   530 
534   if(-1 == run && startInitialisation) {          531   if(-1 == run && startInitialisation) {
535     if (nullptr != emConfigurator) { emConfigu << 532     if(emConfigurator) { emConfigurator->Clear(); }
536     firstParticle = aParticle;                    533     firstParticle = aParticle; 
537   }                                               534   }
538                                                   535 
539   if (startInitialisation) {                   << 536   if(startInitialisation) {
540     ++run;                                        537     ++run;
541     if (1 < verbose) {                         << 538     SetVerbose(verbose);
                                                   >> 539     if(1 < verbose) {
542       G4cout << "===== G4LossTableManager::Loc    540       G4cout << "===== G4LossTableManager::LocalPhysicsTable() for run "
543              << run << " =====" << G4endl;     << 541        << run << " =====" << G4endl;
544     }                                             542     }
545     currentParticle = nullptr;                 << 543     if(0 < verbose) { emSaturation->DumpG4BirksCoefficients(); }
                                                   >> 544     if(atomDeexcitation) {
                                                   >> 545       atomDeexcitation->InitialiseAtomicDeexcitation();
                                                   >> 546     }
                                                   >> 547     currentParticle = 0;
546     startInitialisation = false;                  548     startInitialisation = false;
547     resetParam = true;                         << 
548     for (G4int i=0; i<n_loss; ++i) {              549     for (G4int i=0; i<n_loss; ++i) {
549       if (nullptr != loss_vector[i]) {         << 550       if(loss_vector[i]) {
550         tables_are_built[i] = false;           << 551   tables_are_built[i] = false;
551       } else {                                    552       } else {
552         tables_are_built[i] = true;            << 553   tables_are_built[i] = true;
553         part_vector[i] = nullptr;              << 554         part_vector[i] = 0;
554       }                                           555       }
555     }                                             556     }
556   }                                               557   }
557                                                   558 
558   all_tables_are_built= true;                     559   all_tables_are_built= true;
559   for (G4int i=0; i<n_loss; ++i) {                560   for (G4int i=0; i<n_loss; ++i) {
560     if(p == loss_vector[i]) {                     561     if(p == loss_vector[i]) {
561       tables_are_built[i] = true;                 562       tables_are_built[i] = true;
562       isActive[i] = true;                         563       isActive[i] = true;
                                                   >> 564       /*
                                                   >> 565       const G4ProcessManager* pm = p->GetProcessManager();
                                                   >> 566       isActive[i] = false;
                                                   >> 567       if(pm) { isActive[i] = pm->GetProcessActivation(p); }
                                                   >> 568       */
563       part_vector[i] = p->Particle();             569       part_vector[i] = p->Particle(); 
564       base_part_vector[i] = p->BaseParticle();    570       base_part_vector[i] = p->BaseParticle(); 
565       dedx_vector[i] = p->DEDXTable();            571       dedx_vector[i] = p->DEDXTable();
566       range_vector[i] = p->RangeTableForLoss()    572       range_vector[i] = p->RangeTableForLoss();
567       inv_range_vector[i] = p->InverseRangeTab    573       inv_range_vector[i] = p->InverseRangeTable();
568       if(0 == run && p->IsIonisationProcess())    574       if(0 == run && p->IsIonisationProcess()) {
569         loss_map[part_vector[i]] = p;          << 575   loss_map[part_vector[i]] = loss_vector[i];
570       }                                           576       }
571                                                   577 
572       if(1 < verbose) {                           578       if(1 < verbose) { 
573         G4cout << i <<".   "<< p->GetProcessNa << 579   G4cout << i <<".   "<< p->GetProcessName(); 
574         if(part_vector[i]) {                   << 580   if(part_vector[i]) {
575           G4cout << "  for "  << part_vector[i << 581     G4cout << "  for "  << part_vector[i]->GetParticleName();
576         }                                      << 582   }
577         G4cout << "  active= " << isActive[i]  << 583   G4cout << "  active= " << isActive[i]
578                << "  table= " << tables_are_bu << 584          << "  table= " << tables_are_built[i]
579                << "  isIonisation= " << p->IsI << 585          << "  isIonisation= " << p->IsIonisationProcess()
580                << G4endl;                      << 586          << G4endl;
581       }                                           587       }
582       break;                                      588       break;
583     } else if(!tables_are_built[i]) {             589     } else if(!tables_are_built[i]) {
584       all_tables_are_built = false;               590       all_tables_are_built = false;
585     }                                             591     }
586   }                                               592   }
587                                                   593 
                                                   >> 594   // Set run time parameters 
                                                   >> 595   SetParameters(aParticle, p);
                                                   >> 596 
588   if(1 < verbose) {                               597   if(1 < verbose) {
589     G4cout << "### G4LossTableManager::LocalPh    598     G4cout << "### G4LossTableManager::LocalPhysicsTable end"
590            << G4endl;                          << 599      << G4endl;
591   }                                               600   }
592   if(all_tables_are_built) {                      601   if(all_tables_are_built) { 
593     if(1 < verbose) {                             602     if(1 < verbose) {
594       G4cout << "%%%%% All dEdx and Range tabl    603       G4cout << "%%%%% All dEdx and Range tables for worker are ready for run "
595              << run << " %%%%%" << G4endl;     << 604        << run << " %%%%%" << G4endl;
596     }                                             605     }
597   }                                               606   }
598 }                                                 607 }
599                                                   608 
600 //....oooOO0OOooo........oooOO0OOooo........oo    609 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
601                                                   610 
602 void G4LossTableManager::BuildPhysicsTable(       611 void G4LossTableManager::BuildPhysicsTable(
603      const G4ParticleDefinition* aParticle,       612      const G4ParticleDefinition* aParticle,
604      G4VEnergyLossProcess* p)                     613      G4VEnergyLossProcess* p)
605 {                                                 614 {
606   if(1 < verbose) {                               615   if(1 < verbose) {
607     G4cout << "### G4LossTableManager::BuildPh    616     G4cout << "### G4LossTableManager::BuildPhysicsTable() for "
608            << aParticle->GetParticleName()        617            << aParticle->GetParticleName()
609            << " and process " << p->GetProcess << 618      << " and process " << p->GetProcessName() << G4endl;
610   }                                               619   }
611   // clear configurator                           620   // clear configurator
612   if(-1 == run && startInitialisation) {          621   if(-1 == run && startInitialisation) {
613     if( nullptr != emConfigurator) { emConfigu << 622     if(emConfigurator) { emConfigurator->Clear(); }
614     firstParticle = aParticle;                    623     firstParticle = aParticle; 
615   }                                               624   }
616   if(startInitialisation) {                       625   if(startInitialisation) {
617     ++run;                                        626     ++run;
618     resetParam = true;                         << 
619     startInitialisation = false;               << 
620     if(1 < verbose) {                             627     if(1 < verbose) {
621       G4cout << "===== G4LossTableManager::Bui    628       G4cout << "===== G4LossTableManager::BuildPhysicsTable() for run "
622              << run << " ===== " << atomDeexci << 629        << run << " ===== " << atomDeexcitation << G4endl;
                                                   >> 630     }
                                                   >> 631     if(atomDeexcitation) {
                                                   >> 632       atomDeexcitation->InitialiseAtomicDeexcitation();
623     }                                             633     }
624     currentParticle = nullptr;                 << 634     currentParticle = 0;
625     all_tables_are_built = false;              << 635     all_tables_are_built= true;
                                                   >> 636   }
                                                   >> 637 
                                                   >> 638   // initialisation before any table is built
                                                   >> 639   if ( startInitialisation && aParticle == firstParticle ) {
626                                                   640 
                                                   >> 641     startInitialisation = false;
                                                   >> 642     if(1 < verbose) {
                                                   >> 643       G4cout << "### G4LossTableManager start initilisation for first particle "
                                                   >> 644        << firstParticle->GetParticleName() 
                                                   >> 645        << G4endl;
                                                   >> 646     }
627     for (G4int i=0; i<n_loss; ++i) {              647     for (G4int i=0; i<n_loss; ++i) {
628       G4VEnergyLossProcess* el = loss_vector[i    648       G4VEnergyLossProcess* el = loss_vector[i];
629                                                   649 
630       if(nullptr != el) {                      << 650       if(el) {
631         isActive[i] = true;                       651         isActive[i] = true;
632         part_vector[i] = el->Particle();       << 652   /*
633         base_part_vector[i] = el->BaseParticle << 653   const G4ProcessManager* pm = el->GetProcessManager();
634         tables_are_built[i] = false;           << 654         isActive[i] = false;
635         if(1 < verbose) {                      << 655         if(pm) { isActive[i] = pm->GetProcessActivation(el); }
636           G4cout << i <<".   "<< el->GetProces << 656   */
                                                   >> 657         base_part_vector[i] = el->BaseParticle(); 
                                                   >> 658         tables_are_built[i] = false;
                                                   >> 659   all_tables_are_built= false;
                                                   >> 660         if(!isActive[i]) { 
                                                   >> 661     el->SetIonisation(false); 
                                                   >> 662     tables_are_built[i] = true;
                                                   >> 663   }
                                                   >> 664   
                                                   >> 665   if(1 < verbose) { 
                                                   >> 666     G4cout << i <<".   "<< el->GetProcessName();
637           if(el->Particle()) {                    667           if(el->Particle()) {
638             G4cout << "  for "  << el->Particl << 668       G4cout << "  for "  << el->Particle()->GetParticleName();
639           }                                    << 669     }
640           G4cout << "  active= " << isActive[i << 670     G4cout << "  active= " << isActive[i]
641                  << "  table= " << tables_are_    671                  << "  table= " << tables_are_built[i]
642                  << "  isIonisation= " << el-> << 672      << "  isIonisation= " << el->IsIonisationProcess();
643           if(base_part_vector[i]) {            << 673     if(base_part_vector[i]) { 
644             G4cout << "  base particle "       << 674       G4cout << "  base particle " 
645                    << base_part_vector[i]->Get << 675        << base_part_vector[i]->GetParticleName();
646           }                                    << 676     }
647           G4cout << G4endl;                    << 677     G4cout << G4endl;
648         }                                      << 678   }
649       } else {                                    679       } else {
650         tables_are_built[i] = true;               680         tables_are_built[i] = true;
651         part_vector[i] = nullptr;              << 681         part_vector[i] = 0;
652         isActive[i] = false;                   << 682   isActive[i] = false;
653       }                                           683       }
654     }                                             684     }
655   }                                               685   }
656                                                   686 
657   if (all_tables_are_built) {                  << 687   // Set run time parameters 
658     theParameters->SetIsPrintedFlag(true);     << 688   SetParameters(aParticle, p);
659     return;                                    << 689 
660   }                                            << 690   if (all_tables_are_built) { return; }
661                                                   691 
662   // Build tables for given particle              692   // Build tables for given particle
663   all_tables_are_built = true;                    693   all_tables_are_built = true;
664                                                   694 
665   for(G4int i=0; i<n_loss; ++i) {                 695   for(G4int i=0; i<n_loss; ++i) {
666     if(p == loss_vector[i] && !tables_are_buil << 696     if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) {
667       const G4ParticleDefinition* curr_part =     697       const G4ParticleDefinition* curr_part = part_vector[i];
668       if(1 < verbose) {                           698       if(1 < verbose) {
669         G4cout << "### Build Table for " << p-    699         G4cout << "### Build Table for " << p->GetProcessName()
670                << " and " << curr_part->GetPar << 700                << " and " << curr_part->GetParticleName() << G4endl;
671                << "  " << tables_are_built[i]  << 
672                << G4endl;                      << 
673       }                                           701       }
674       G4VEnergyLossProcess* curr_proc = BuildT    702       G4VEnergyLossProcess* curr_proc = BuildTables(curr_part);
675       if(curr_proc) {                          << 703       if(curr_proc) { CopyTables(curr_part, curr_proc); }
676         CopyTables(curr_part, curr_proc);      << 
677         if(p == curr_proc && 0 == run && p->Is << 
678           loss_map[aParticle] = p;             << 
679           //G4cout << "G4LossTableManager::Bui << 
680           //     << aParticle->GetParticleName << 
681           //         << " added to map " << p  << 
682         }                                      << 
683       }                                        << 
684     }                                             704     }
685     if ( !tables_are_built[i] ) { all_tables_a    705     if ( !tables_are_built[i] ) { all_tables_are_built = false; }
686   }                                               706   }
                                                   >> 707   if(0 == run && p->IsIonisationProcess()) { loss_map[aParticle] = p; }
                                                   >> 708 
687   if(1 < verbose) {                               709   if(1 < verbose) {
688     G4cout << "### G4LossTableManager::BuildPh    710     G4cout << "### G4LossTableManager::BuildPhysicsTable end: "
689            << "all_tables_are_built= " << all_ << 711            << "all_tables_are_built= " << all_tables_are_built
690            << aParticle->GetParticleName() <<  << 712            << G4endl;
                                                   >> 713   }
                                                   >> 714   if(all_tables_are_built) { 
                                                   >> 715     if(1 < verbose) {
                                                   >> 716       G4cout << "%%%%% All dEdx and Range tables are built for master run= " 
                                                   >> 717        << run << " %%%%%" << G4endl;
                                                   >> 718     }
691   }                                               719   }
692 }                                                 720 }
693                                                   721 
694 //....oooOO0OOooo........oooOO0OOooo........oo    722 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
695                                                   723 
696 void G4LossTableManager::CopyTables(const G4Pa    724 void G4LossTableManager::CopyTables(const G4ParticleDefinition* part,
697                                     G4VEnergyL << 725             G4VEnergyLossProcess* base_proc)
698 {                                                 726 {
699   for (G4int j=0; j<n_loss; ++j) {                727   for (G4int j=0; j<n_loss; ++j) {
700                                                   728 
701     G4VEnergyLossProcess* proc = loss_vector[j    729     G4VEnergyLossProcess* proc = loss_vector[j];
702                                                   730 
703     if (!tables_are_built[j] && part == base_p    731     if (!tables_are_built[j] && part == base_part_vector[j]) {
704       tables_are_built[j] = true;                 732       tables_are_built[j] = true;
705       // for base particle approach only ionis << 
706       proc->SetDEDXTable(base_proc->Ionisation    733       proc->SetDEDXTable(base_proc->IonisationTable(),fRestricted);
                                                   >> 734       proc->SetDEDXTable(base_proc->DEDXTableForSubsec(),fSubRestricted);
707       proc->SetDEDXTable(base_proc->DEDXunRest    735       proc->SetDEDXTable(base_proc->DEDXunRestrictedTable(),fTotal);
708       proc->SetCSDARangeTable(base_proc->CSDAR    736       proc->SetCSDARangeTable(base_proc->CSDARangeTable());
709       proc->SetRangeTableForLoss(base_proc->Ra    737       proc->SetRangeTableForLoss(base_proc->RangeTableForLoss());
710       proc->SetInverseRangeTable(base_proc->In    738       proc->SetInverseRangeTable(base_proc->InverseRangeTable());
711       proc->SetLambdaTable(base_proc->LambdaTa    739       proc->SetLambdaTable(base_proc->LambdaTable());
                                                   >> 740       proc->SetSubLambdaTable(base_proc->SubLambdaTable());
                                                   >> 741       proc->SetIonisation(base_proc->IsIonisationProcess());
712       if(proc->IsIonisationProcess()) {           742       if(proc->IsIonisationProcess()) { 
713         range_vector[j] = base_proc->RangeTabl << 743   range_vector[j] = base_proc->RangeTableForLoss();
714         inv_range_vector[j] = base_proc->Inver << 744   inv_range_vector[j] = base_proc->InverseRangeTable();
715         loss_map[part_vector[j]] = proc;       << 745   loss_map[part_vector[j]] = proc; 
716         //G4cout << "G4LossTableManager::CopyT << 
717         //       << part_vector[j]->GetParticl << 
718         //       << " added to map " << proc < << 
719       }                                           746       }
720       if (1 < verbose) {                          747       if (1 < verbose) {
721          G4cout << "   CopyTables for " << pro << 748          G4cout << "For " << proc->GetProcessName()
722                 << " for " << part_vector[j]->    749                 << " for " << part_vector[j]->GetParticleName()
723                 << " base_part= " << part->Get    750                 << " base_part= " << part->GetParticleName()
724                 << " tables are assigned"      << 751                 << " tables are assigned "
725                 << G4endl;                        752                 << G4endl;
726       }                                           753       }
727     }                                             754     }
                                                   >> 755 
                                                   >> 756     if (theElectron == part && theElectron == proc->SecondaryParticle() ) {
                                                   >> 757       proc->SetSecondaryRangeTable(base_proc->RangeTableForLoss());
                                                   >> 758     }
728   }                                               759   }
729 }                                                 760 }
730                                                   761 
731 //....oooOO0OOooo........oooOO0OOooo........oo    762 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
732                                                   763 
733 G4VEnergyLossProcess* G4LossTableManager::Buil    764 G4VEnergyLossProcess* G4LossTableManager::BuildTables(
734                       const G4ParticleDefiniti    765                       const G4ParticleDefinition* aParticle)
735 {                                                 766 {
736   if(1 < verbose) {                               767   if(1 < verbose) {
737     G4cout << "   G4LossTableManager::BuildTab << 768     G4cout << "G4LossTableManager::BuildTables() for "
738            << aParticle->GetParticleName() <<     769            << aParticle->GetParticleName() << G4endl;
739   }                                               770   }
740                                                   771 
741   std::vector<G4PhysicsTable*> t_list;            772   std::vector<G4PhysicsTable*> t_list;  
742   std::vector<G4VEnergyLossProcess*> loss_list    773   std::vector<G4VEnergyLossProcess*> loss_list;
743   std::vector<G4bool> build_flags;                774   std::vector<G4bool> build_flags;
744   G4VEnergyLossProcess* em = nullptr;          << 775   G4VEnergyLossProcess* em = 0;
745   G4VEnergyLossProcess* p = nullptr;           << 776   G4VEnergyLossProcess* p = 0;
746   G4int iem = 0;                                  777   G4int iem = 0;
747   G4PhysicsTable* dedx = nullptr;              << 778   G4PhysicsTable* dedx = 0;
748   G4int i;                                        779   G4int i;
749                                                   780 
750   G4ProcessVector* pvec =                         781   G4ProcessVector* pvec = 
751     aParticle->GetProcessManager()->GetProcess    782     aParticle->GetProcessManager()->GetProcessList();
752   G4int nvec = (G4int)pvec->size();            << 783   G4int nvec = pvec->size();
753                                                   784 
754   for (i=0; i<n_loss; ++i) {                      785   for (i=0; i<n_loss; ++i) {
755     p = loss_vector[i];                           786     p = loss_vector[i];
756     if (nullptr != p) {                        << 787     if (p) {
757       G4bool yes = (aParticle == part_vector[i    788       G4bool yes = (aParticle == part_vector[i]);
758                                                   789 
759       // possible case of process sharing betw    790       // possible case of process sharing between particle/anti-particle
760       if(!yes) {                                  791       if(!yes) {
761         auto ptr = static_cast<G4VProcess*>(p) << 792         G4VProcess* ptr = static_cast<G4VProcess*>(p);
762         for(G4int j=0; j<nvec; ++j) {             793         for(G4int j=0; j<nvec; ++j) {
763           //G4cout << "j= " << j << " " << (*p    794           //G4cout << "j= " << j << " " << (*pvec)[j] << " " << ptr << G4endl;
764           if(ptr == (*pvec)[j]) {                 795           if(ptr == (*pvec)[j]) {
765             yes = true;                        << 796       yes = true;
766             break;                                797             break;
767           }                                    << 798     }
768         }                                      << 799   }
769       }                                           800       }      
770       // process belong to this particle          801       // process belong to this particle
771       if(yes && isActive[i]) {                    802       if(yes && isActive[i]) {
772         if (p->IsIonisationProcess() || !em) { << 803   if (p->IsIonisationProcess() || !em) {
773           em = p;                              << 804     em = p;
774           iem= i;                              << 805     iem= i;
775         }                                      << 806   }
776         // tables may be shared between partic << 807   // tables may be shared between particle/anti-particle
777         G4bool val = false;                    << 808   G4bool val = false;
778         if (!tables_are_built[i]) {            << 809   if (!tables_are_built[i]) {
779           val = true;                             810           val = true;
780           dedx = p->BuildDEDXTable(fRestricted << 811     dedx = p->BuildDEDXTable(fRestricted);
781           //G4cout << "===Build DEDX table for << 812     //G4cout << "Build DEDX table for " << p->GetProcessName()
782           // << " idx= " << i << " dedx:" << d << 813     // << " idx= " << i << dedx << " " << dedx->length() << G4endl;
783           p->SetDEDXTable(dedx,fRestricted);   << 814     p->SetDEDXTable(dedx,fRestricted);
784           tables_are_built[i] = true;          << 815     tables_are_built[i] = true;
785         } else {                               << 816   } else {
786           dedx = p->DEDXTable();                  817           dedx = p->DEDXTable();
787         }                                      << 818   }
788         t_list.push_back(dedx);                << 819   t_list.push_back(dedx);
789         loss_list.push_back(p);                << 820   loss_list.push_back(p);
790         build_flags.push_back(val);               821         build_flags.push_back(val);
791       }                                           822       }
792     }                                             823     }
793   }                                               824   }
794                                                   825 
795   G4int n_dedx = (G4int)t_list.size();         << 826   G4int n_dedx = t_list.size();
796   if (0 == n_dedx || !em) {                       827   if (0 == n_dedx || !em) {
797     G4cout << "G4LossTableManager WARNING: no     828     G4cout << "G4LossTableManager WARNING: no DEDX processes for " 
798            << aParticle->GetParticleName() <<  << 829      << aParticle->GetParticleName() << G4endl;
799     return nullptr;                            << 830     return 0;
800   }                                               831   }
801   G4int nSubRegions = em->NumberOfSubCutoffReg    832   G4int nSubRegions = em->NumberOfSubCutoffRegions();
802                                                   833 
803   if (1 < verbose) {                              834   if (1 < verbose) {
804     G4cout << "     Start to build the sum of  << 835     G4cout << "G4LossTableManager::BuildTables() start to build range tables"
                                                   >> 836            << " and the sum of " << n_dedx << " processes"
805            << " iem= " << iem << " em= " << em    837            << " iem= " << iem << " em= " << em->GetProcessName()
806            << " buildCSDARange= " << theParame    838            << " buildCSDARange= " << theParameters->BuildCSDARange()
807            << " nSubRegions= " << nSubRegions; << 839      << " nSubRegions= " << nSubRegions;
808     if(subcutProducer) {                          840     if(subcutProducer) { 
809       G4cout << " SubCutProducer " << subcutPr    841       G4cout << " SubCutProducer " << subcutProducer->GetName(); 
810     }                                             842     }
811     G4cout << G4endl;                             843     G4cout << G4endl;
812   }                                               844   }
813   // do not build tables if producer class is     845   // do not build tables if producer class is defined
814   if(subcutProducer) { nSubRegions = 0; }         846   if(subcutProducer) { nSubRegions = 0; }
815                                                   847 
816   dedx = em->DEDXTable();                      << 848   dedx = em->DEDXTable(); 
                                                   >> 849   em->SetIonisation(true);
817   em->SetDEDXTable(dedx, fIsIonisation);          850   em->SetDEDXTable(dedx, fIsIonisation);
818                                                   851 
819   if (1 < n_dedx) {                               852   if (1 < n_dedx) {
820     dedx = nullptr;                            << 853     dedx = 0;
821     dedx = G4PhysicsTableHelper::PreparePhysic    854     dedx = G4PhysicsTableHelper::PreparePhysicsTable(dedx);
822     tableBuilder->BuildDEDXTable(dedx, t_list)    855     tableBuilder->BuildDEDXTable(dedx, t_list);
823     em->SetDEDXTable(dedx, fRestricted);          856     em->SetDEDXTable(dedx, fRestricted);
824   }                                               857   }
825                                                   858 
                                                   >> 859   /*
                                                   >> 860   if(2==run && "e-" == aParticle->GetParticleName()) {
                                                   >> 861     G4cout << "G4LossTableManager::BuildTables for e- " << dedx << G4endl;
                                                   >> 862     G4cout << (*dedx) << G4endl;
                                                   >> 863     G4cout << "%%%%% Instance ID= " << (*dedx)[0]->GetInstanceID() << G4endl;
                                                   >> 864     G4cout << "%%%%% LastValue= " << (*dedx)[0]->GetLastValue() << G4endl;
                                                   >> 865     G4cout << "%%%%% 1.2 " << (*(dedx))[0]->Value(1.2) << G4endl;
                                                   >> 866   }
                                                   >> 867   */
826   dedx_vector[iem] = dedx;                        868   dedx_vector[iem] = dedx;
827                                                   869 
828   G4PhysicsTable* range = em->RangeTableForLos    870   G4PhysicsTable* range = em->RangeTableForLoss();
829   if(!range) range  = G4PhysicsTableHelper::Pr    871   if(!range) range  = G4PhysicsTableHelper::PreparePhysicsTable(range);
830   range_vector[iem] = range;                      872   range_vector[iem] = range;
831                                                   873 
832   G4PhysicsTable* invrange = em->InverseRangeT    874   G4PhysicsTable* invrange = em->InverseRangeTable();
833   if(!invrange) invrange = G4PhysicsTableHelpe    875   if(!invrange) invrange = G4PhysicsTableHelper::PreparePhysicsTable(invrange);
834   inv_range_vector[iem]  = invrange;              876   inv_range_vector[iem]  = invrange;
835                                                   877 
836   tableBuilder->BuildRangeTable(dedx, range);  << 878   tableBuilder->BuildRangeTable(dedx, range, true);
837   tableBuilder->BuildInverseRangeTable(range,  << 879   tableBuilder->BuildInverseRangeTable(range, invrange, true);
                                                   >> 880 
                                                   >> 881   //  if(1<verbose) G4cout << *dedx << G4endl;
838                                                   882 
839   em->SetRangeTableForLoss(range);                883   em->SetRangeTableForLoss(range);
840   em->SetInverseRangeTable(invrange);             884   em->SetInverseRangeTable(invrange);
841                                                   885 
                                                   >> 886   //  if(1<verbose) G4cout << *range << G4endl;
                                                   >> 887 
                                                   >> 888   std::vector<G4PhysicsTable*> listSub;
842   std::vector<G4PhysicsTable*> listCSDA;          889   std::vector<G4PhysicsTable*> listCSDA;
843                                                   890 
844   for (i=0; i<n_dedx; ++i) {                      891   for (i=0; i<n_dedx; ++i) {
845     p = loss_list[i];                             892     p = loss_list[i];
                                                   >> 893     if(p != em) { p->SetIonisation(false); }
846     if(build_flags[i]) {                          894     if(build_flags[i]) {
847       p->SetLambdaTable(p->BuildLambdaTable(fR    895       p->SetLambdaTable(p->BuildLambdaTable(fRestricted));
848     }                                             896     }
                                                   >> 897     if (0 < nSubRegions) {
                                                   >> 898       dedx = p->BuildDEDXTable(fSubRestricted);
                                                   >> 899       p->SetDEDXTable(dedx,fSubRestricted);
                                                   >> 900       listSub.push_back(dedx);
                                                   >> 901       if(build_flags[i]) {
                                                   >> 902   p->SetSubLambdaTable(p->BuildLambdaTable(fSubRestricted));
                                                   >> 903   if(p != em) { em->AddCollaborativeProcess(p); }
                                                   >> 904       }
                                                   >> 905     }
849     if(theParameters->BuildCSDARange()) {         906     if(theParameters->BuildCSDARange()) { 
850       dedx = p->BuildDEDXTable(fTotal);           907       dedx = p->BuildDEDXTable(fTotal);
851       p->SetDEDXTable(dedx,fTotal);               908       p->SetDEDXTable(dedx,fTotal);
852       listCSDA.push_back(dedx);                   909       listCSDA.push_back(dedx); 
853     }                                             910     }     
854   }                                               911   }
855                                                   912 
                                                   >> 913   if (0 < nSubRegions) {
                                                   >> 914     G4PhysicsTable* dedxSub = em->IonisationTableForSubsec();
                                                   >> 915     if (1 < listSub.size()) {
                                                   >> 916       em->SetDEDXTable(dedxSub, fIsSubIonisation);
                                                   >> 917       dedxSub = 0;
                                                   >> 918       dedxSub = G4PhysicsTableHelper::PreparePhysicsTable(dedxSub);
                                                   >> 919       tableBuilder->BuildDEDXTable(dedxSub, listSub);
                                                   >> 920       em->SetDEDXTable(dedxSub, fSubRestricted);
                                                   >> 921     }
                                                   >> 922   }
856   if(theParameters->BuildCSDARange()) {           923   if(theParameters->BuildCSDARange()) {
857     G4PhysicsTable* dedxCSDA = em->DEDXunRestr    924     G4PhysicsTable* dedxCSDA = em->DEDXunRestrictedTable();
858     if (1 < n_dedx) {                             925     if (1 < n_dedx) {
859       dedxCSDA = G4PhysicsTableHelper::Prepare << 926       dedxCSDA = 0;
                                                   >> 927       dedxCSDA  = G4PhysicsTableHelper::PreparePhysicsTable(dedxCSDA);
860       tableBuilder->BuildDEDXTable(dedxCSDA, l    928       tableBuilder->BuildDEDXTable(dedxCSDA, listCSDA);
861       em->SetDEDXTable(dedxCSDA,fTotal);          929       em->SetDEDXTable(dedxCSDA,fTotal);
862     }                                             930     }
863     G4PhysicsTable* rCSDA = em->CSDARangeTable    931     G4PhysicsTable* rCSDA = em->CSDARangeTable();
864     if(!rCSDA) { rCSDA = G4PhysicsTableHelper:    932     if(!rCSDA) { rCSDA = G4PhysicsTableHelper::PreparePhysicsTable(rCSDA); }
865     tableBuilder->BuildRangeTable(dedxCSDA, rC << 933     tableBuilder->BuildRangeTable(dedxCSDA, rCSDA, true);
866     em->SetCSDARangeTable(rCSDA);                 934     em->SetCSDARangeTable(rCSDA);
867   }                                               935   }
868                                                   936 
869   if (1 < verbose) {                              937   if (1 < verbose) {
870     G4cout << "G4LossTableManager::BuildTables    938     G4cout << "G4LossTableManager::BuildTables: Tables are built for "
871            << aParticle->GetParticleName()        939            << aParticle->GetParticleName()
872            << "; ionisation process: " << em-> << 940      << "; ionisation process: " << em->GetProcessName()
873            << "  " << em                       << 941      << "  " << em
874            << G4endl;                             942            << G4endl;
875   }                                               943   }
876   return em;                                      944   return em;
877 }                                                 945 }
878                                                   946 
879 //....oooOO0OOooo........oooOO0OOooo........oo    947 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
880                                                   948 
                                                   >> 949 G4EnergyLossMessenger* G4LossTableManager::GetMessenger()
                                                   >> 950 {
                                                   >> 951   return theMessenger;
                                                   >> 952 }
                                                   >> 953 
                                                   >> 954 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 955 
881 void G4LossTableManager::ParticleHaveNoLoss(      956 void G4LossTableManager::ParticleHaveNoLoss(
882      const G4ParticleDefinition* aParticle)       957      const G4ParticleDefinition* aParticle)
883 {                                                 958 {
884   G4ExceptionDescription ed;                      959   G4ExceptionDescription ed;
885   ed << "Energy loss process not found for " <    960   ed << "Energy loss process not found for " << aParticle->GetParticleName() 
886      << " !";                                     961      << " !";
887   G4Exception("G4LossTableManager::ParticleHav    962   G4Exception("G4LossTableManager::ParticleHaveNoLoss", "em0001",
888               FatalException, ed);             << 963         FatalException, ed);
                                                   >> 964 }
                                                   >> 965 
                                                   >> 966 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 967 
                                                   >> 968 G4bool G4LossTableManager::BuildCSDARange() const
                                                   >> 969 {
                                                   >> 970   return theParameters->BuildCSDARange();
                                                   >> 971 }
                                                   >> 972 
                                                   >> 973 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 974 
                                                   >> 975 void G4LossTableManager::SetLossFluctuations(G4bool /*val*/)
                                                   >> 976 {
                                                   >> 977 }
                                                   >> 978 
                                                   >> 979 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 980 
                                                   >> 981 void G4LossTableManager::SetSubCutoff(G4bool val, const G4Region* r)
                                                   >> 982 {
                                                   >> 983   subCutoffFlag = val;
                                                   >> 984   for(G4int i=0; i<n_loss; ++i) {
                                                   >> 985     if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); }
                                                   >> 986   }
                                                   >> 987 }
                                                   >> 988 
                                                   >> 989 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 990 
                                                   >> 991 void G4LossTableManager::SetIntegral(G4bool val)
                                                   >> 992 {
                                                   >> 993   integral = val;
                                                   >> 994   integralActive = true;
                                                   >> 995   for(G4int i=0; i<n_loss; ++i) {
                                                   >> 996     if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); }
                                                   >> 997   }
                                                   >> 998   size_t emp = emp_vector.size();
                                                   >> 999   for (size_t k=0; k<emp; ++k) {
                                                   >> 1000     if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); }
                                                   >> 1001   }
                                                   >> 1002 }
                                                   >> 1003 
                                                   >> 1004 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1005 
                                                   >> 1006 void G4LossTableManager::SetMinSubRange(G4double /*val*/)
                                                   >> 1007 {
                                                   >> 1008 }
                                                   >> 1009 
                                                   >> 1010 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1011 
                                                   >> 1012 void G4LossTableManager::SetRandomStep(G4bool /*val*/)
                                                   >> 1013 {
                                                   >> 1014 }
                                                   >> 1015 
                                                   >> 1016 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1017 
                                                   >> 1018 void G4LossTableManager::SetMinEnergy(G4double val)
                                                   >> 1019 {
                                                   >> 1020   theParameters->SetMinEnergy(val);
                                                   >> 1021 }
                                                   >> 1022 
                                                   >> 1023 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1024 
                                                   >> 1025 void G4LossTableManager::SetMaxEnergy(G4double val)
                                                   >> 1026 {
                                                   >> 1027   theParameters->SetMaxEnergy(val);
                                                   >> 1028 }
                                                   >> 1029 
                                                   >> 1030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1031 
                                                   >> 1032 void G4LossTableManager::SetMaxEnergyForCSDARange(G4double val)
                                                   >> 1033 {
                                                   >> 1034   theParameters->SetMaxEnergyForCSDARange(val);
                                                   >> 1035 }
                                                   >> 1036 
                                                   >> 1037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1038 
                                                   >> 1039 void G4LossTableManager::SetMaxEnergyForMuons(G4double val)
                                                   >> 1040 {
                                                   >> 1041   theParameters->SetMaxEnergy(val);
                                                   >> 1042 }
                                                   >> 1043 
                                                   >> 1044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1045 
                                                   >> 1046 void G4LossTableManager::SetDEDXBinning(G4int val)
                                                   >> 1047 {
                                                   >> 1048   theParameters->SetNumberOfBins(val);
                                                   >> 1049 }
                                                   >> 1050 
                                                   >> 1051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1052 
                                                   >> 1053 void G4LossTableManager::SetDEDXBinningForCSDARange(G4int /*n*/)
                                                   >> 1054 {
                                                   >> 1055 }
                                                   >> 1056 
                                                   >> 1057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1058 
                                                   >> 1059 void G4LossTableManager::SetLambdaBinning(G4int val)
                                                   >> 1060 {
                                                   >> 1061   theParameters->SetNumberOfBins(val);
                                                   >> 1062 }
                                                   >> 1063 
                                                   >> 1064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1065 
                                                   >> 1066 G4int G4LossTableManager::GetNumberOfBinsPerDecade() const
                                                   >> 1067 {
                                                   >> 1068   return theParameters->NumberOfBinsPerDecade();
                                                   >> 1069 }
                                                   >> 1070 
                                                   >> 1071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1072 
                                                   >> 1073 void G4LossTableManager::SetVerbose(G4int /*val*/)
                                                   >> 1074 {
                                                   >> 1075 }
                                                   >> 1076 
                                                   >> 1077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1078 
                                                   >> 1079 void G4LossTableManager::SetStepFunction(G4double v1, G4double v2)
                                                   >> 1080 {
                                                   >> 1081   if(0.0 < v1 && 0.0 < v2 && v2 < 1.e+50) { 
                                                   >> 1082     stepFunctionActive = true;
                                                   >> 1083     maxRangeVariation = v1;
                                                   >> 1084     maxFinalStep = v2;
                                                   >> 1085     for(G4int i=0; i<n_loss; ++i) {
                                                   >> 1086       if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); }
                                                   >> 1087     }
                                                   >> 1088   } else if(v1 <= 0.0) {
                                                   >> 1089     PrintEWarning("SetStepFunction", v1); 
                                                   >> 1090   } else {
                                                   >> 1091     PrintEWarning("SetStepFunction", v2); 
                                                   >> 1092   }
                                                   >> 1093 }
                                                   >> 1094 
                                                   >> 1095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1096 
                                                   >> 1097 void G4LossTableManager::SetLinearLossLimit(G4double /*val*/)
                                                   >> 1098 {
889 }                                                 1099 }
890                                                   1100 
891 //....oooOO0OOooo........oooOO0OOooo........oo    1101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
892                                                   1102 
893 void G4LossTableManager::SetVerbose(G4int val) << 1103 void G4LossTableManager::SetBuildCSDARange(G4bool /*val*/)
894 {                                                 1104 {
895   verbose = val;                               << 1105 }
                                                   >> 1106 
                                                   >> 1107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1108 
                                                   >> 1109 void 
                                                   >> 1110 G4LossTableManager::SetParameters(const G4ParticleDefinition* /*aParticle*/,
                                                   >> 1111           G4VEnergyLossProcess* p)
                                                   >> 1112 {
                                                   >> 1113   if(stepFunctionActive) { 
                                                   >> 1114     p->SetStepFunction(maxRangeVariation, maxFinalStep); 
                                                   >> 1115   }
                                                   >> 1116   if(integralActive)     { p->SetIntegral(integral); }
896 }                                                 1117 }
897                                                   1118 
898 //....oooOO0OOooo........oooOO0OOooo........oo    1119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
899                                                   1120 
900 const std::vector<G4VEnergyLossProcess*>&         1121 const std::vector<G4VEnergyLossProcess*>& 
901 G4LossTableManager::GetEnergyLossProcessVector    1122 G4LossTableManager::GetEnergyLossProcessVector()
902 {                                                 1123 {
903   return loss_vector;                             1124   return loss_vector;
904 }                                                 1125 }
905                                                   1126 
906 //....oooOO0OOooo........oooOO0OOooo........oo    1127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
907                                                   1128 
908 const std::vector<G4VEmProcess*>& G4LossTableM    1129 const std::vector<G4VEmProcess*>& G4LossTableManager::GetEmProcessVector()
909 {                                                 1130 {
910   return emp_vector;                              1131   return emp_vector;
911 }                                                 1132 }
912                                                   1133 
913 //....oooOO0OOooo........oooOO0OOooo........oo    1134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
914                                                   1135 
915 const std::vector<G4VMultipleScattering*>&        1136 const std::vector<G4VMultipleScattering*>& 
916 G4LossTableManager::GetMultipleScatteringVecto    1137 G4LossTableManager::GetMultipleScatteringVector()
917 {                                                 1138 {
918   return msc_vector;                              1139   return msc_vector;
919 }                                                 1140 }
920                                                   1141 
                                                   >> 1142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1143 
                                                   >> 1144 G4bool G4LossTableManager::IsMaster() const
                                                   >> 1145 {
                                                   >> 1146   return isMaster;
                                                   >> 1147 }
                                                   >> 1148 
                                                   >> 1149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1150 
                                                   >> 1151 G4double G4LossTableManager::MinKinEnergy() const
                                                   >> 1152 {
                                                   >> 1153   return theParameters->MinKinEnergy();
                                                   >> 1154 }
                                                   >> 1155 
                                                   >> 1156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1157 
                                                   >> 1158 G4double G4LossTableManager::MaxKinEnergy() const
                                                   >> 1159 {
                                                   >> 1160   return theParameters->MaxKinEnergy();
                                                   >> 1161 }
                                                   >> 1162 
                                                   >> 1163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1164 
                                                   >> 1165 G4EmCorrections* G4LossTableManager::EmCorrections() 
                                                   >> 1166 {
                                                   >> 1167   return emCorrections;
                                                   >> 1168 }
                                                   >> 1169 
921 //....oooOO0OOooo........oooOO0OOooo........oo    1170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
922                                                   1171 
923 G4EmSaturation* G4LossTableManager::EmSaturati    1172 G4EmSaturation* G4LossTableManager::EmSaturation()
924 {                                                 1173 {
925   return theParameters->GetEmSaturation();     << 1174   if(!emSaturation) { emSaturation = new G4EmSaturation(verbose); }
                                                   >> 1175   return emSaturation;
926 }                                                 1176 }
927                                                   1177 
928 //....oooOO0OOooo........oooOO0OOooo........oo    1178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
929                                                   1179 
930 G4EmConfigurator* G4LossTableManager::EmConfig    1180 G4EmConfigurator* G4LossTableManager::EmConfigurator()
931 {                                                 1181 {
932   if(!emConfigurator) {                        << 1182   if(!emConfigurator) { emConfigurator = new G4EmConfigurator(verbose); }
933     emConfigurator = new G4EmConfigurator(verb << 
934   }                                            << 
935   return emConfigurator;                          1183   return emConfigurator;
936 }                                                 1184 }
937                                                   1185 
938 //....oooOO0OOooo........oooOO0OOooo........oo    1186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
939                                                   1187 
940 G4ElectronIonPair* G4LossTableManager::Electro    1188 G4ElectronIonPair* G4LossTableManager::ElectronIonPair()
941 {                                                 1189 {
942   if(!emElectronIonPair) {                        1190   if(!emElectronIonPair) { 
943     emElectronIonPair = new G4ElectronIonPair(    1191     emElectronIonPair = new G4ElectronIonPair(verbose);
944   }                                               1192   }
945   return emElectronIonPair;                       1193   return emElectronIonPair;
946 }                                                 1194 }
947                                                   1195 
948 //....oooOO0OOooo........oooOO0OOooo........oo << 1196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
949                                                   1197 
950 void G4LossTableManager::SetNIELCalculator(G4N << 1198 G4VAtomDeexcitation* G4LossTableManager::AtomDeexcitation()
951 {                                                 1199 {
952   if(nullptr != ptr && ptr != nielCalculator)  << 1200   return atomDeexcitation;
953     delete nielCalculator;                     << 
954     nielCalculator = ptr;                      << 
955   }                                            << 
956 }                                                 1201 }
957                                                   1202 
958 //....oooOO0OOooo........oooOO0OOooo........oo << 1203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
959                                                   1204 
960 G4NIELCalculator* G4LossTableManager::NIELCalc << 1205 G4LossTableBuilder* G4LossTableManager::GetTableBuilder()
961 {                                                 1206 {
962   if(!nielCalculator) {                        << 1207   return tableBuilder;
963     nielCalculator = new G4NIELCalculator(null << 
964   }                                            << 
965   return nielCalculator;                       << 
966 }                                                 1208 }
967                                                   1209 
968 //....oooOO0OOooo........oooOO0OOooo........oo    1210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
969                                                   1211  
970 void G4LossTableManager::SetAtomDeexcitation(G    1212 void G4LossTableManager::SetAtomDeexcitation(G4VAtomDeexcitation* p)
971 {                                                 1213 {
972   if(atomDeexcitation != p) {                     1214   if(atomDeexcitation != p) {
973     delete atomDeexcitation;                      1215     delete atomDeexcitation;
974     atomDeexcitation = p;                         1216     atomDeexcitation = p;
975   }                                               1217   }
976 }                                                 1218 }
977                                                   1219 
978 //....oooOO0OOooo........oooOO0OOooo........oo    1220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
979                                                   1221 
980 void G4LossTableManager::SetSubCutProducer(G4V    1222 void G4LossTableManager::SetSubCutProducer(G4VSubCutProducer* p) 
981 {                                                 1223 {
982   if(subcutProducer != p) {                       1224   if(subcutProducer != p) {
983     delete subcutProducer;                        1225     delete subcutProducer;
984     subcutProducer = p;                           1226     subcutProducer = p;
985   }                                               1227   }
986 }                                                 1228 }
987                                                   1229 
                                                   >> 1230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1231 
                                                   >> 1232 G4VSubCutProducer* G4LossTableManager::SubCutProducer()
                                                   >> 1233 { 
                                                   >> 1234   return subcutProducer;
                                                   >> 1235 }
                                                   >> 1236 
                                                   >> 1237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1238 
                                                   >> 1239 G4VEnergyLossProcess* 
                                                   >> 1240 G4LossTableManager::GetEnergyLossProcess(const G4ParticleDefinition *aParticle)
                                                   >> 1241 {
                                                   >> 1242   //G4cout << aParticle << "  " << currentParticle 
                                                   >> 1243   //<< "  " << currentLoss << G4endl;
                                                   >> 1244   if(aParticle != currentParticle) {
                                                   >> 1245     currentParticle = aParticle;
                                                   >> 1246     std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;
                                                   >> 1247     if ((pos = loss_map.find(aParticle)) != loss_map.end()) {
                                                   >> 1248       currentLoss = (*pos).second;
                                                   >> 1249     } else {
                                                   >> 1250       currentLoss = 0;
                                                   >> 1251       if(aParticle->GetParticleType() == "nucleus") {
                                                   >> 1252   if ((pos = loss_map.find(theGenericIon)) != loss_map.end()) {
                                                   >> 1253     currentLoss = (*pos).second;
                                                   >> 1254   }
                                                   >> 1255       }
                                                   >> 1256     }
                                                   >> 1257   }
                                                   >> 1258   return currentLoss;
                                                   >> 1259 }
                                                   >> 1260 
                                                   >> 1261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1262 
                                                   >> 1263 G4double G4LossTableManager::GetDEDX(const G4ParticleDefinition *aParticle,
                                                   >> 1264              G4double kineticEnergy,
                                                   >> 1265              const G4MaterialCutsCouple *couple)
                                                   >> 1266 {
                                                   >> 1267   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1268   G4double x = 0.0;
                                                   >> 1269   if(currentLoss) { x = currentLoss->GetDEDX(kineticEnergy, couple); }
                                                   >> 1270   return x;
                                                   >> 1271 }
                                                   >> 1272 
                                                   >> 1273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1274 
                                                   >> 1275 G4double G4LossTableManager::GetSubDEDX(const G4ParticleDefinition *aParticle,
                                                   >> 1276           G4double kineticEnergy,
                                                   >> 1277           const G4MaterialCutsCouple *couple)
                                                   >> 1278 {
                                                   >> 1279   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1280   G4double x = 0.0;
                                                   >> 1281   if(currentLoss) { x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple); }
                                                   >> 1282   return x;
                                                   >> 1283 }
                                                   >> 1284 
                                                   >> 1285 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1286 
                                                   >> 1287 G4double G4LossTableManager::GetCSDARange(const G4ParticleDefinition *aParticle,
                                                   >> 1288             G4double kineticEnergy,
                                                   >> 1289             const G4MaterialCutsCouple *couple)
                                                   >> 1290 {
                                                   >> 1291   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1292   G4double x = DBL_MAX;
                                                   >> 1293   if(currentLoss) { x = currentLoss->GetCSDARange(kineticEnergy, couple); }
                                                   >> 1294   return x;
                                                   >> 1295 }
                                                   >> 1296 
                                                   >> 1297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1298 
                                                   >> 1299 G4double G4LossTableManager::GetRangeFromRestricteDEDX(
                                                   >> 1300                              const G4ParticleDefinition *aParticle,
                                                   >> 1301            G4double kineticEnergy,
                                                   >> 1302            const G4MaterialCutsCouple *couple)
                                                   >> 1303 {
                                                   >> 1304   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1305   G4double x = DBL_MAX;
                                                   >> 1306   if(currentLoss) { x = currentLoss->GetRangeForLoss(kineticEnergy, couple); }
                                                   >> 1307   return x;
                                                   >> 1308 }
                                                   >> 1309 
                                                   >> 1310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
                                                   >> 1311 
                                                   >> 1312 G4double G4LossTableManager::GetRange(const G4ParticleDefinition *aParticle,
                                                   >> 1313               G4double kineticEnergy,
                                                   >> 1314               const G4MaterialCutsCouple *couple)
                                                   >> 1315 {
                                                   >> 1316   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1317   G4double x = DBL_MAX;
                                                   >> 1318   if(currentLoss) {
                                                   >> 1319     x = currentLoss->GetRange(kineticEnergy, couple); 
                                                   >> 1320   }
                                                   >> 1321   return x;
                                                   >> 1322 }
                                                   >> 1323 
                                                   >> 1324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1325 
                                                   >> 1326 G4double G4LossTableManager::GetEnergy(const G4ParticleDefinition *aParticle,
                                                   >> 1327                G4double range,
                                                   >> 1328                const G4MaterialCutsCouple *couple)
                                                   >> 1329 {
                                                   >> 1330   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1331   G4double x = 0;
                                                   >> 1332   if(currentLoss) { x = currentLoss->GetKineticEnergy(range, couple); }
                                                   >> 1333   return x;
                                                   >> 1334 }
                                                   >> 1335 
                                                   >> 1336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 1337 
                                                   >> 1338 G4double G4LossTableManager::GetDEDXDispersion(
                                                   >> 1339                              const G4MaterialCutsCouple *couple,
                                                   >> 1340            const G4DynamicParticle* dp,
                                                   >> 1341            G4double& length)
                                                   >> 1342 {
                                                   >> 1343   const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
                                                   >> 1344   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
                                                   >> 1345   G4double x = 0.0;
                                                   >> 1346   if(currentLoss) { currentLoss->GetDEDXDispersion(couple, dp, length); }
                                                   >> 1347   return x;
                                                   >> 1348 }
                                                   >> 1349 
988 //....oooOO0OOooo........oooOO0OOooo........oo    1350 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
989                                                   1351 
990 void G4LossTableManager::PrintEWarning(G4Strin    1352 void G4LossTableManager::PrintEWarning(G4String tit, G4double /*val*/)
991 {                                                 1353 {
992   G4String ss = "G4LossTableManager::" + tit;     1354   G4String ss = "G4LossTableManager::" + tit; 
993   G4ExceptionDescription ed;                      1355   G4ExceptionDescription ed;
994   /*                                              1356   /*
995   ed << "Parameter is out of range: " << val      1357   ed << "Parameter is out of range: " << val 
996      << " it will have no effect!\n" << " ## "    1358      << " it will have no effect!\n" << " ## " 
997      << " nbins= " << nbinsLambda                 1359      << " nbins= " << nbinsLambda 
998      << " nbinsPerDecade= " << nbinsPerDecade     1360      << " nbinsPerDecade= " << nbinsPerDecade 
999      << " Emin(keV)= " << minKinEnergy/keV        1361      << " Emin(keV)= " << minKinEnergy/keV 
1000      << " Emax(GeV)= " << maxKinEnergy/GeV;      1362      << " Emax(GeV)= " << maxKinEnergy/GeV;
1001   */                                             1363   */
1002   G4Exception(ss, "em0044", JustWarning, ed);    1364   G4Exception(ss, "em0044", JustWarning, ed);
1003 }                                                1365 }
1004                                                  1366 
1005 //....oooOO0OOooo........oooOO0OOooo........o    1367 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1006                                               << 
1007 void G4LossTableManager::DumpHtml()           << 
1008 {                                             << 
1009   // Automatic generation of html documentati << 
1010   // List processes and models for the most i << 
1011   // particles in descending order of importa << 
1012   // NB. for model names with length > 18 cha << 
1013   //  to be edited by hand. Or modify G4EmMod << 
1014                                               << 
1015   char* dirName = std::getenv("G4PhysListDocD << 
1016   char* physList = std::getenv("G4PhysListNam << 
1017   if (dirName && physList) {                  << 
1018     G4String physListName = G4String(physList << 
1019     G4String pathName = G4String(dirName) + " << 
1020                                               << 
1021     std::ofstream outFile;                    << 
1022     outFile.open(pathName);                   << 
1023                                               << 
1024     outFile << physListName << G4endl;        << 
1025     outFile << std::string(physListName.lengt << 
1026                                               << 
1027     std::vector<G4ParticleDefinition*> partic << 
1028         G4Gamma::Gamma(),                     << 
1029         G4Electron::Electron(),               << 
1030         G4Positron::Positron(),               << 
1031         G4Proton::ProtonDefinition(),         << 
1032         G4MuonPlus::MuonPlusDefinition(),     << 
1033         G4MuonMinus::MuonMinusDefinition(),   << 
1034       };                                      << 
1035                                               << 
1036     std::vector<G4VEmProcess*> emproc_vector  << 
1037     std::vector<G4VEnergyLossProcess*> enloss << 
1038       GetEnergyLossProcessVector();           << 
1039     std::vector<G4VMultipleScattering*> mscat << 
1040       GetMultipleScatteringVector();          << 
1041                                               << 
1042     for (auto theParticle : particles) {      << 
1043       outFile << G4endl << "**" << theParticl << 
1044               << "**" << G4endl << G4endl <<  << 
1045                                               << 
1046       G4ProcessManager* pm = theParticle->Get << 
1047       G4ProcessVector*  pv = pm->GetProcessLi << 
1048       G4int plen = pm->GetProcessListLength() << 
1049                                               << 
1050       for (auto emproc : emproc_vector) {     << 
1051         for (G4int i = 0; i < plen; ++i) {    << 
1052           G4VProcess* proc = (*pv)[i];        << 
1053           if (proc == emproc) {               << 
1054             outFile << G4endl;                << 
1055             proc->ProcessDescription(outFile) << 
1056             break;                            << 
1057           }                                   << 
1058         }                                     << 
1059       }                                       << 
1060                                               << 
1061       for (auto mscproc : mscat_vector) {     << 
1062         for (G4int i = 0; i < plen; ++i) {    << 
1063           G4VProcess* proc = (*pv)[i];        << 
1064           if (proc == mscproc) {              << 
1065             outFile << G4endl;                << 
1066             proc->ProcessDescription(outFile) << 
1067             break;                            << 
1068           }                                   << 
1069         }                                     << 
1070       }                                       << 
1071                                               << 
1072       for (auto enlossproc : enloss_vector) { << 
1073         for (G4int i = 0; i < plen; ++i) {    << 
1074           G4VProcess* proc = (*pv)[i];        << 
1075           if (proc == enlossproc) {           << 
1076             outFile << G4endl;                << 
1077             proc->ProcessDescription(outFile) << 
1078             break;                            << 
1079           }                                   << 
1080         }                                     << 
1081       }                                       << 
1082     }                                         << 
1083     outFile.close();                          << 
1084   }                                           << 
1085 }                                             << 
1086                                               << 
1087 //....oooOO0OOooo........oooOO0OOooo........o << 
1088                                               << 
1089                                                  1368