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.0.p1)


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