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.4.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 107364 2017-11-09 10:53:25Z 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 
 50 #include "G4VMultipleScattering.hh"                87 #include "G4VMultipleScattering.hh"
 51 #include "G4VEmProcess.hh"                         88 #include "G4VEmProcess.hh"
 52                                                    89 
 53 #include "G4EmParameters.hh"                       90 #include "G4EmParameters.hh"
 54 #include "G4EmSaturation.hh"                       91 #include "G4EmSaturation.hh"
 55 #include "G4EmConfigurator.hh"                     92 #include "G4EmConfigurator.hh"
 56 #include "G4ElectronIonPair.hh"                    93 #include "G4ElectronIonPair.hh"
 57 #include "G4NIELCalculator.hh"                 << 
 58 #include "G4EmCorrections.hh"                  << 
 59 #include "G4LossTableBuilder.hh"               << 
 60 #include "G4VAtomDeexcitation.hh"              << 
 61 #include "G4VSubCutProducer.hh"                << 
 62                                                    94 
 63 #include "G4PhysicsTable.hh"                       95 #include "G4PhysicsTable.hh"
 64 #include "G4ParticleDefinition.hh"                 96 #include "G4ParticleDefinition.hh"
 65 #include "G4MaterialCutsCouple.hh"                 97 #include "G4MaterialCutsCouple.hh"
 66 #include "G4ProcessManager.hh"                     98 #include "G4ProcessManager.hh"
 67 #include "G4Electron.hh"                           99 #include "G4Electron.hh"
 68 #include "G4Proton.hh"                            100 #include "G4Proton.hh"
 69 #include "G4ProductionCutsTable.hh"               101 #include "G4ProductionCutsTable.hh"
 70 #include "G4PhysicsTableHelper.hh"                102 #include "G4PhysicsTableHelper.hh"
 71 #include "G4EmTableType.hh"                       103 #include "G4EmTableType.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 #include "G4Gamma.hh"
 76 #include "G4Positron.hh"                          109 #include "G4Positron.hh"
 77 #include "G4OpticalPhoton.hh"                     110 #include "G4OpticalPhoton.hh"
 78 #include "G4Neutron.hh"                           111 #include "G4Neutron.hh"
 79 #include "G4MuonPlus.hh"                          112 #include "G4MuonPlus.hh"
 80 #include "G4MuonMinus.hh"                         113 #include "G4MuonMinus.hh"
 81 #include "G4GenericIon.hh"                     << 
 82                                                   114 
 83 //....oooOO0OOooo........oooOO0OOooo........oo    115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 84                                                   116 
 85 static std::once_flag applyOnce;               << 
 86 G4ThreadLocal G4LossTableManager* G4LossTableM    117 G4ThreadLocal G4LossTableManager* G4LossTableManager::instance = nullptr;
 87                                                   118 
 88 G4LossTableManager* G4LossTableManager::Instan    119 G4LossTableManager* G4LossTableManager::Instance()
 89 {                                                 120 {
 90   if(nullptr == instance) {                    << 121   if(!instance) {
 91     static G4ThreadLocalSingleton<G4LossTableM    122     static G4ThreadLocalSingleton<G4LossTableManager> inst;
 92     instance = inst.Instance();                   123     instance = inst.Instance();
 93   }                                               124   }
 94   return instance;                                125   return instance;
 95 }                                                 126 }
 96                                                   127 
 97 //....oooOO0OOooo........oooOO0OOooo........oo    128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
 98                                                   129 
 99 G4LossTableManager::~G4LossTableManager()         130 G4LossTableManager::~G4LossTableManager()
100 {                                                 131 {
101   for (auto const & p : loss_vector) { delete  << 132   //G4cout << "### G4LossTableManager::~G4LossTableManager() "<< this << G4endl;
102   for (auto const & p : msc_vector) { delete p << 133   for (G4int i=0; i<n_loss; ++i) {
103   for (auto const & p : emp_vector) { delete p << 134     //G4cout << "### eloss #" << i << G4endl;
104   for (auto const & p : p_vector) { delete p;  << 135     if( loss_vector[i] ) { 
105                                                << 136       delete loss_vector[i]; 
106   std::size_t mod = mod_vector.size();         << 137     }
107   std::size_t fmod = fmod_vector.size();       << 138   }
108   for (std::size_t a=0; a<mod; ++a) {          << 139   size_t msc = msc_vector.size();
                                                   >> 140   for (size_t j=0; j<msc; ++j) {
                                                   >> 141     if( msc_vector[j] ) { delete msc_vector[j]; }
                                                   >> 142   }
                                                   >> 143   size_t emp = emp_vector.size();
                                                   >> 144   for (size_t k=0; k<emp; ++k) {
                                                   >> 145     if( emp_vector[k] ) { delete emp_vector[k]; }
                                                   >> 146   }
                                                   >> 147   size_t mod = mod_vector.size();
                                                   >> 148   size_t fmod = fmod_vector.size();
                                                   >> 149   //G4cout << "   Nmod" << mod << "  Nfluc= " << fmod << G4endl;
                                                   >> 150   for (size_t a=0; a<mod; ++a) {
                                                   >> 151     //G4cout << "Delete model #" << a << "  " <<  mod_vector[a] << G4endl;
109     if( nullptr != mod_vector[a] ) {              152     if( nullptr != mod_vector[a] ) { 
110       for (std::size_t b=0; b<fmod; ++b) {     << 153       for (size_t b=0; b<fmod; ++b) {
111         if((G4VEmModel*)(fmod_vector[b]) == mo    154         if((G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) {
112           fmod_vector[b] = nullptr;               155           fmod_vector[b] = nullptr;
113         }                                         156         }
114       }                                           157       }
115       delete mod_vector[a];                       158       delete mod_vector[a]; 
116       mod_vector[a] = nullptr;                    159       mod_vector[a] = nullptr;
117     }                                             160     }
118   }                                               161   }
119   for (auto const & p : fmod_vector) { delete  << 162   for (size_t b=0; b<fmod; ++b) {
120                                                << 163     if( fmod_vector[b] ) { delete fmod_vector[b]; }
                                                   >> 164   }
121   Clear();                                        165   Clear();
122   delete tableBuilder;                            166   delete tableBuilder;
123   delete emCorrections;                           167   delete emCorrections;
124   delete emConfigurator;                          168   delete emConfigurator;
125   delete emElectronIonPair;                       169   delete emElectronIonPair;
126   delete nielCalculator;                       << 
127   delete atomDeexcitation;                        170   delete atomDeexcitation;
128   delete subcutProducer;                          171   delete subcutProducer;
129 }                                                 172 }
130                                                   173 
131 //....oooOO0OOooo........oooOO0OOooo........oo    174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
132                                                   175 
133 G4LossTableManager::G4LossTableManager()          176 G4LossTableManager::G4LossTableManager()
134 {                                                 177 {
                                                   >> 178   //G4cout << "### G4LossTableManager::G4LossTableManager() " << this << G4endl;
135   theParameters = G4EmParameters::Instance();     179   theParameters = G4EmParameters::Instance();
136   theElectron = G4Electron::Electron();        << 180   n_loss = 0;
137                                                << 181   run = -1;
138   // only one thread is the master             << 182   startInitialisation = false;
139   std::call_once(applyOnce, [this]() { isMaste << 183   all_tables_are_built = false;
140   verbose = isMaster ? theParameters->Verbose( << 184   currentLoss = nullptr;
141                                                << 185   currentParticle = nullptr;
142   tableBuilder = new G4LossTableBuilder(isMast << 186   firstParticle = nullptr;
143   emCorrections = new G4EmCorrections(verbose) << 187   isMaster = true;
144                                                << 188   verbose = theParameters->Verbose();
145   std::size_t n = 70;                          << 189   theElectron  = G4Electron::Electron();
146   loss_vector.reserve(n);                      << 190   theGenericIon= nullptr;
147   part_vector.reserve(n);                      << 191   if(G4Threading::IsWorkerThread()) { 
148   base_part_vector.reserve(n);                 << 192     verbose = theParameters->WorkerVerbose();
149   dedx_vector.reserve(n);                      << 193     isMaster = false;
150   range_vector.reserve(n);                     << 194   }  
151   inv_range_vector.reserve(n);                 << 195   tableBuilder = new G4LossTableBuilder();
152   tables_are_built.reserve(n);                 << 196   emCorrections= new G4EmCorrections(verbose);
153   isActive.reserve(n);                         << 197   emConfigurator = nullptr;
154   msc_vector.reserve(10);                      << 198   emElectronIonPair = nullptr;
155   emp_vector.reserve(16);                      << 199   atomDeexcitation = nullptr;
156   mod_vector.reserve(150);                     << 200   subcutProducer = nullptr;
157   fmod_vector.reserve(60);                     << 201   gammaShark = nullptr;
158 }                                                 202 }
159                                                   203 
160 //....oooOO0OOooo........oooOO0OOooo........oo    204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
161                                                   205 
162 void G4LossTableManager::Clear()                  206 void G4LossTableManager::Clear()
163 {                                                 207 {
164   all_tables_are_built = false;                   208   all_tables_are_built = false;
165   currentLoss = nullptr;                          209   currentLoss = nullptr;
166   currentParticle = nullptr;                      210   currentParticle = nullptr;
167   if(n_loss) {                                 << 211   if(n_loss)
168     dedx_vector.clear();                       << 212     {
169     range_vector.clear();                      << 213       dedx_vector.clear();
170     inv_range_vector.clear();                  << 214       range_vector.clear();
171     loss_map.clear();                          << 215       inv_range_vector.clear();
172     loss_vector.clear();                       << 216       loss_map.clear();
173     part_vector.clear();                       << 217       loss_vector.clear();
174     base_part_vector.clear();                  << 218       part_vector.clear();
175     tables_are_built.clear();                  << 219       base_part_vector.clear();
176     isActive.clear();                          << 220       tables_are_built.clear();
177     n_loss = 0;                                << 221       isActive.clear();
178   }                                            << 222       n_loss = 0;
                                                   >> 223     }
179 }                                                 224 }
180                                                   225 
181 //....oooOO0OOooo........oooOO0OOooo........oo    226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
182                                                   227 
183 void G4LossTableManager::Register(G4VEnergyLos    228 void G4LossTableManager::Register(G4VEnergyLossProcess* p)
184 {                                                 229 {
185   if (nullptr == p) { return; }                << 230   if(!p) { return; }
186   for (G4int i=0; i<n_loss; ++i) {                231   for (G4int i=0; i<n_loss; ++i) {
187     if(loss_vector[i] == p) { return; }           232     if(loss_vector[i] == p) { return; }
188   }                                               233   }
189   if(verbose > 1) {                               234   if(verbose > 1) {
190     G4cout << "G4LossTableManager::Register G4    235     G4cout << "G4LossTableManager::Register G4VEnergyLossProcess : " 
191            << p->GetProcessName() << "  idx= "    236            << p->GetProcessName() << "  idx= " << n_loss << G4endl;
192   }                                               237   }
193   ++n_loss;                                       238   ++n_loss;
194   loss_vector.push_back(p);                       239   loss_vector.push_back(p);
195   part_vector.push_back(nullptr);                 240   part_vector.push_back(nullptr);
196   base_part_vector.push_back(nullptr);            241   base_part_vector.push_back(nullptr);
197   dedx_vector.push_back(nullptr);                 242   dedx_vector.push_back(nullptr);
198   range_vector.push_back(nullptr);                243   range_vector.push_back(nullptr);
199   inv_range_vector.push_back(nullptr);            244   inv_range_vector.push_back(nullptr);
200   tables_are_built.push_back(false);              245   tables_are_built.push_back(false);
201   isActive.push_back(true);                       246   isActive.push_back(true);
202   all_tables_are_built = false;                   247   all_tables_are_built = false;
203 }                                                 248 }
204                                                   249 
205 //....oooOO0OOooo........oooOO0OOooo........oo    250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
206                                                   251 
207 void G4LossTableManager::ResetParameters()        252 void G4LossTableManager::ResetParameters()
208 {                                                 253 {
209   // initialisation once per run               << 
210   if (!resetParam) { return; }                 << 
211   resetParam = false;                          << 
212   startInitialisation = true;                  << 
213   verbose = theParameters->Verbose();             254   verbose = theParameters->Verbose();
214   if(!isMaster) {                                 255   if(!isMaster) {
215     verbose = theParameters->WorkerVerbose();     256     verbose = theParameters->WorkerVerbose();
216   } else {                                     << 
217     if(verbose > 0) { theParameters->Dump(); } << 
218   }                                               257   }
219                                                << 258   tableBuilder->SetSplineFlag(theParameters->Spline());
220   tableBuilder->InitialiseBaseMaterials();     << 259   tableBuilder->SetInitialisationFlag(false); 
221   if (nullptr != nielCalculator) { nielCalcula << 
222                                                << 
223   emCorrections->SetVerbose(verbose);             260   emCorrections->SetVerbose(verbose); 
224   if(nullptr != emConfigurator) { emConfigurat << 261   if(emConfigurator) { emConfigurator->SetVerbose(verbose); };
225   if(nullptr != emElectronIonPair) { emElectro << 262   if(emElectronIonPair) { emElectronIonPair->SetVerbose(verbose); };
226   if(nullptr != atomDeexcitation) {            << 263   if(atomDeexcitation) {
227     atomDeexcitation->SetVerboseLevel(verbose)    264     atomDeexcitation->SetVerboseLevel(verbose);
228     atomDeexcitation->InitialiseAtomicDeexcita    265     atomDeexcitation->InitialiseAtomicDeexcitation();
229   }                                               266   }
230   if (1 < verbose) {                           << 
231     G4cout << "====== G4LossTableManager::Rese << 
232            << " Nloss=" << loss_vector.size()  << 
233      << " run=" << run << " master=" << isMast << 
234      << G4endl;                                << 
235   }                                            << 
236 }                                                 267 }
237                                                   268 
238 //....oooOO0OOooo........oooOO0OOooo........oo    269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
239                                                   270 
240 void G4LossTableManager::DeRegister(G4VEnergyL    271 void G4LossTableManager::DeRegister(G4VEnergyLossProcess* p)
241 {                                                 272 {
242   if (nullptr == p) { return; }                << 273   if(!p) { return; }
243   for (G4int i=0; i<n_loss; ++i) {                274   for (G4int i=0; i<n_loss; ++i) {
244     if(loss_vector[i] == p) {                  << 275     if(loss_vector[i] == p) { loss_vector[i] = nullptr; }
245       loss_vector[i] = nullptr;                << 
246       break;                                   << 
247     }                                          << 
248   }                                               276   }
249 }                                                 277 }
250                                                   278 
251 //....oooOO0OOooo........oooOO0OOooo........oo    279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
252                                                   280 
253 void G4LossTableManager::Register(G4VMultipleS    281 void G4LossTableManager::Register(G4VMultipleScattering* p)
254 {                                                 282 {
255   if (nullptr == p) { return; }                << 283   if(!p) { return; }
256   std::size_t n = msc_vector.size();           << 284   G4int n = msc_vector.size();
257   for (std::size_t i=0; i<n; ++i) {            << 285   for (G4int i=0; i<n; ++i) {
258     if(msc_vector[i] == p) { return; }            286     if(msc_vector[i] == p) { return; }
259   }                                               287   }
260   if(verbose > 1) {                               288   if(verbose > 1) {
261     G4cout << "G4LossTableManager::Register G4    289     G4cout << "G4LossTableManager::Register G4VMultipleScattering : " 
262            << p->GetProcessName() << "  idx= "    290            << p->GetProcessName() << "  idx= " << msc_vector.size() << G4endl;
263   }                                               291   }
264   msc_vector.push_back(p);                        292   msc_vector.push_back(p);
265 }                                                 293 }
266                                                   294 
267 //....oooOO0OOooo........oooOO0OOooo........oo    295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
268                                                   296 
269 void G4LossTableManager::DeRegister(G4VMultipl    297 void G4LossTableManager::DeRegister(G4VMultipleScattering* p)
270 {                                                 298 {
271   if (nullptr == p) { return; }                << 299   if(!p) { return; }
272   std::size_t msc = msc_vector.size();         << 300   size_t msc = msc_vector.size();
273   for (std::size_t i=0; i<msc; ++i) {          << 301   for (size_t i=0; i<msc; ++i) {
274     if(msc_vector[i] == p) {                   << 302     if(msc_vector[i] == p) { msc_vector[i] = nullptr; }
275       msc_vector[i] = nullptr;                 << 
276       break;                                   << 
277     }                                          << 
278   }                                               303   }
279 }                                                 304 }
280                                                   305 
281 //....oooOO0OOooo........oooOO0OOooo........oo    306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
282                                                   307 
283 void G4LossTableManager::Register(G4VEmProcess    308 void G4LossTableManager::Register(G4VEmProcess* p)
284 {                                                 309 {
285   if (nullptr == p) { return; }                << 310   if(!p) { return; }
286   std::size_t n = emp_vector.size();           << 311   G4int n = emp_vector.size();
287   for (std::size_t i=0; i<n; ++i) {            << 312   for (G4int i=0; i<n; ++i) {
288     if(emp_vector[i] == p) { return; }            313     if(emp_vector[i] == p) { return; }
289   }                                               314   }
290   if(verbose > 1) {                               315   if(verbose > 1) {
291     G4cout << "G4LossTableManager::Register G4    316     G4cout << "G4LossTableManager::Register G4VEmProcess : " 
292            << p->GetProcessName() << "  idx= "    317            << p->GetProcessName() << "  idx= " << emp_vector.size() << G4endl;
293   }                                               318   }
294   emp_vector.push_back(p);                        319   emp_vector.push_back(p);
295 }                                                 320 }
296                                                   321 
297 //....oooOO0OOooo........oooOO0OOooo........oo    322 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
298                                                   323 
299 void G4LossTableManager::DeRegister(G4VEmProce    324 void G4LossTableManager::DeRegister(G4VEmProcess* p)
300 {                                                 325 {
301   if (nullptr == p) { return; }                << 326   if(!p) { return; }
302   std::size_t emp = emp_vector.size();         << 327   size_t emp = emp_vector.size();
303   for (std::size_t i=0; i<emp; ++i) {          << 328   for (size_t i=0; i<emp; ++i) {
304     if(emp_vector[i] == p) {                   << 329     if(emp_vector[i] == p) { emp_vector[i] = nullptr; }
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   }                                               330   }
339 }                                                 331 }
340                                                   332 
341 //....oooOO0OOooo........oooOO0OOooo........oo    333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
342                                                   334 
343 void G4LossTableManager::Register(G4VEmModel*     335 void G4LossTableManager::Register(G4VEmModel* p)
344 {                                                 336 {
345   mod_vector.push_back(p);                        337   mod_vector.push_back(p);
346   if(verbose > 1) {                               338   if(verbose > 1) {
347     G4cout << "G4LossTableManager::Register G4    339     G4cout << "G4LossTableManager::Register G4VEmModel : " 
348            << p->GetName() << "  " << p << "      340            << p->GetName() << "  " << p << "  " << mod_vector.size() << G4endl;
349   }                                               341   }
350 }                                                 342 }
351                                                   343 
352 //....oooOO0OOooo........oooOO0OOooo........oo    344 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
353                                                   345 
354 void G4LossTableManager::DeRegister(G4VEmModel    346 void G4LossTableManager::DeRegister(G4VEmModel* p)
355 {                                                 347 {
356   //G4cout << "G4LossTableManager::DeRegister     348   //G4cout << "G4LossTableManager::DeRegister G4VEmModel : " << p << G4endl;
357   std::size_t n = mod_vector.size();           << 349   size_t n = mod_vector.size();
358   for (std::size_t i=0; i<n; ++i) {            << 350   for (size_t i=0; i<n; ++i) {
359     if(mod_vector[i] == p) {                      351     if(mod_vector[i] == p) { 
360       mod_vector[i] = nullptr;                    352       mod_vector[i] = nullptr; 
361       break;                                      353       break;
362     }                                             354     }
363   }                                               355   }
364 }                                                 356 }
365                                                   357 
366 //....oooOO0OOooo........oooOO0OOooo........oo    358 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
367                                                   359 
368 void G4LossTableManager::Register(G4VEmFluctua    360 void G4LossTableManager::Register(G4VEmFluctuationModel* p)
369 {                                                 361 {
370   fmod_vector.push_back(p);                       362   fmod_vector.push_back(p);
371   if(verbose > 1) {                               363   if(verbose > 1) {
372     G4cout << "G4LossTableManager::Register G4    364     G4cout << "G4LossTableManager::Register G4VEmFluctuationModel : " 
373            << p->GetName() << "  " << fmod_vec    365            << p->GetName() << "  " << fmod_vector.size() << G4endl;
374   }                                               366   }
375 }                                                 367 }
376                                                   368 
377 //....oooOO0OOooo........oooOO0OOooo........oo    369 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
378                                                   370 
379 void G4LossTableManager::DeRegister(G4VEmFluct    371 void G4LossTableManager::DeRegister(G4VEmFluctuationModel* p)
380 {                                                 372 {
381   std::size_t n = fmod_vector.size();          << 373   size_t n = fmod_vector.size();
382   for (std::size_t i=0; i<n; ++i) {            << 374   for (size_t i=0; i<n; ++i) {
383     if(fmod_vector[i] == p) { fmod_vector[i] =    375     if(fmod_vector[i] == p) { fmod_vector[i] = nullptr; }
384   }                                               376   }
385 }                                                 377 }
386                                                   378 
387 //....oooOO0OOooo........oooOO0OOooo........oo    379 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
388                                                   380 
389 void G4LossTableManager::RegisterExtraParticle    381 void G4LossTableManager::RegisterExtraParticle(
390      const G4ParticleDefinition* part,            382      const G4ParticleDefinition* part,
391      G4VEnergyLossProcess* p)                     383      G4VEnergyLossProcess* p)
392 {                                                 384 { 
393   if (nullptr == p || nullptr == part) { retur << 385   if(!p || !part) { return; }
394   for (G4int i=0; i<n_loss; ++i) {                386   for (G4int i=0; i<n_loss; ++i) {
395     if(loss_vector[i] == p) { return; }           387     if(loss_vector[i] == p) { return; }
396   }                                               388   }
397   if(verbose > 1) {                               389   if(verbose > 1) {
398     G4cout << "G4LossTableManager::RegisterExt    390     G4cout << "G4LossTableManager::RegisterExtraParticle "
399            << part->GetParticleName() << "  G4    391            << part->GetParticleName() << "  G4VEnergyLossProcess : " 
400            << p->GetProcessName() << "  idx= "    392            << p->GetProcessName() << "  idx= " << n_loss << G4endl;
401   }                                               393   }
402   ++n_loss;                                       394   ++n_loss;
403   loss_vector.push_back(p);                       395   loss_vector.push_back(p);
404   part_vector.push_back(part);                    396   part_vector.push_back(part);
405   base_part_vector.push_back(p->BaseParticle()    397   base_part_vector.push_back(p->BaseParticle());
406   dedx_vector.push_back(nullptr);                 398   dedx_vector.push_back(nullptr);
407   range_vector.push_back(nullptr);                399   range_vector.push_back(nullptr);
408   inv_range_vector.push_back(nullptr);            400   inv_range_vector.push_back(nullptr);
409   tables_are_built.push_back(false);              401   tables_are_built.push_back(false);
410   all_tables_are_built = false;                   402   all_tables_are_built = false;
411 }                                                 403 }
412                                                   404 
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    405 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
435                                                   406 
436 void                                              407 void 
437 G4LossTableManager::PreparePhysicsTable(const     408 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
438                                         G4VEne << 409                                         G4VEnergyLossProcess* p,
                                                   >> 410                                         G4bool theMaster)
439 {                                                 411 {
440   if (1 < verbose) {                              412   if (1 < verbose) {
441     G4cout << "G4LossTableManager::PreparePhys    413     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
442            << particle->GetParticleName()         414            << particle->GetParticleName() 
443            << " and " << p->GetProcessName() <    415            << " and " << p->GetProcessName() << " run= " << run 
444            << "   loss_vector " << loss_vector << 416            << "   loss_vector " << loss_vector.size() << G4endl;
445      << " run=" << run << " master=" << isMast << 417   }
446      << G4endl;                                << 418 
                                                   >> 419   isMaster = theMaster;
                                                   >> 420 
                                                   >> 421   if(!startInitialisation) { 
                                                   >> 422     ResetParameters();
                                                   >> 423     if (1 < verbose) {
                                                   >> 424       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 425              << G4endl;
                                                   >> 426     } 
447   }                                               427   }
448                                                   428 
449   // start initialisation for the first run       429   // start initialisation for the first run
450   if( -1 == run ) {                               430   if( -1 == run ) {
451     if (nullptr != emConfigurator) { emConfigu << 431     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
452                                                   432 
453     // initialise particles for given process     433     // initialise particles for given process
454     for (G4int j=0; j<n_loss; ++j) {              434     for (G4int j=0; j<n_loss; ++j) {
455       if (p == loss_vector[j] && nullptr == pa << 435       if (p == loss_vector[j] && !part_vector[j]) { 
456         part_vector[j] = particle;                436         part_vector[j] = particle;
457         if (particle->GetParticleName() == "Ge << 437         if(particle->GetParticleName() == "GenericIon") {
458           theGenericIon = particle;               438           theGenericIon = particle;
459         }                                         439         }
460       }                                           440       }
461     }                                             441     }
462   }                                               442   }
463   ResetParameters();                           << 443   startInitialisation = true;
464 }                                                 444 }
465                                                   445 
466 //....oooOO0OOooo........oooOO0OOooo........oo    446 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
467                                                   447 
468 void                                              448 void 
469 G4LossTableManager::PreparePhysicsTable(const     449 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
470                                         G4VEmP << 450                                         G4VEmProcess* p, G4bool theMaster)
471 {                                                 451 {
472   if (1 < verbose) {                              452   if (1 < verbose) {
473     G4cout << "G4LossTableManager::PreparePhys    453     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
474            << particle->GetParticleName()         454            << particle->GetParticleName() 
475            << " and " << p->GetProcessName()   << 455            << " and " << p->GetProcessName() << G4endl;
476      << " run=" << run << " master=" << isMast << 456   }
477      << G4endl;                                << 457   isMaster = theMaster;
                                                   >> 458 
                                                   >> 459   if(!startInitialisation) { 
                                                   >> 460     ResetParameters(); 
                                                   >> 461     if (1 < verbose) {
                                                   >> 462       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 463              << G4endl;
                                                   >> 464     } 
478   }                                               465   }
479                                                   466 
480   // start initialisation for the first run       467   // start initialisation for the first run
481   if( -1 == run ) {                               468   if( -1 == run ) {
482     if (nullptr != emConfigurator) { emConfigu << 469     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
483   }                                               470   }
484                                                << 471   startInitialisation = true;
485   ResetParameters();                           << 
486 }                                                 472 }
487                                                   473 
488 //....oooOO0OOooo........oooOO0OOooo........oo    474 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
489                                                   475 
490 void                                              476 void 
491 G4LossTableManager::PreparePhysicsTable(const     477 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
492                                         G4VMul << 478                                         G4VMultipleScattering* p,
                                                   >> 479                                         G4bool theMaster)
493 {                                                 480 {
494   if (1 < verbose) {                              481   if (1 < verbose) {
495     G4cout << "G4LossTableManager::PreparePhys    482     G4cout << "G4LossTableManager::PreparePhysicsTable for " 
496            << particle->GetParticleName()         483            << particle->GetParticleName() 
497            << " and " << p->GetProcessName()   << 484            << " and " << p->GetProcessName() << G4endl;
498      << " run=" << run << " master=" << isMast << 485   }
499      << G4endl;                                << 486 
                                                   >> 487   isMaster = theMaster;
                                                   >> 488 
                                                   >> 489   if(!startInitialisation) { 
                                                   >> 490     ResetParameters();
                                                   >> 491     if (1 < verbose) {
                                                   >> 492       G4cout << "====== G4LossTableManager::PreparePhysicsTable start ====="
                                                   >> 493              << G4endl;
                                                   >> 494     } 
500   }                                               495   }
501                                                   496 
502   // start initialisation for the first run       497   // start initialisation for the first run
503   if ( -1 == run ) {                           << 498   if( -1 == run ) {
504     if (nullptr != emConfigurator) { emConfigu << 499     if(emConfigurator) { emConfigurator->PrepareModels(particle, p); }
505   }                                               500   } 
506                                                << 501   startInitialisation = true;
507   ResetParameters();                           << 
508 }                                                 502 }
509                                                   503 
510 //....oooOO0OOooo........oooOO0OOooo........oo    504 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
511                                                   505 
512 void                                              506 void 
513 G4LossTableManager::BuildPhysicsTable(const G4    507 G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition*)
514 {                                                 508 {
515   if(-1 == run && startInitialisation) {          509   if(-1 == run && startInitialisation) {
516     if (nullptr != emConfigurator) { emConfigu << 510     if(emConfigurator) { emConfigurator->Clear(); }
517   }                                               511   }
518   if (startInitialisation) { resetParam = true << 
519 }                                                 512 }
520                                                   513 
521 //....oooOO0OOooo........oooOO0OOooo........oo    514 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
522                                                   515 
523 void G4LossTableManager::LocalPhysicsTables(      516 void G4LossTableManager::LocalPhysicsTables(
524      const G4ParticleDefinition* aParticle,       517      const G4ParticleDefinition* aParticle,
525      G4VEnergyLossProcess* p)                     518      G4VEnergyLossProcess* p)
526 {                                                 519 {
527   if (1 < verbose) {                           << 520   if(1 < verbose) {
528     G4cout << "### G4LossTableManager::LocalPh    521     G4cout << "### G4LossTableManager::LocalPhysicsTable() for "
529            << aParticle->GetParticleName()        522            << aParticle->GetParticleName()
530            << " and process " << p->GetProcess << 523      << " and process " << p->GetProcessName()
531            << G4endl;                             524            << G4endl;
532   }                                               525   }
533                                                   526 
534   if(-1 == run && startInitialisation) {          527   if(-1 == run && startInitialisation) {
535     if (nullptr != emConfigurator) { emConfigu << 528     if(emConfigurator) { emConfigurator->Clear(); }
536     firstParticle = aParticle;                    529     firstParticle = aParticle; 
537   }                                               530   }
538                                                   531 
539   if (startInitialisation) {                   << 532   if(startInitialisation) {
540     ++run;                                        533     ++run;
541     if (1 < verbose) {                         << 534     if(1 < verbose) {
542       G4cout << "===== G4LossTableManager::Loc    535       G4cout << "===== G4LossTableManager::LocalPhysicsTable() for run "
543              << run << " =====" << G4endl;        536              << run << " =====" << G4endl;
544     }                                             537     }
545     currentParticle = nullptr;                    538     currentParticle = nullptr;
546     startInitialisation = false;                  539     startInitialisation = false;
547     resetParam = true;                         << 
548     for (G4int i=0; i<n_loss; ++i) {              540     for (G4int i=0; i<n_loss; ++i) {
549       if (nullptr != loss_vector[i]) {         << 541       if(loss_vector[i]) {
550         tables_are_built[i] = false;              542         tables_are_built[i] = false;
551       } else {                                    543       } else {
552         tables_are_built[i] = true;               544         tables_are_built[i] = true;
553         part_vector[i] = nullptr;                 545         part_vector[i] = nullptr;
554       }                                           546       }
555     }                                             547     }
556   }                                               548   }
557                                                   549 
558   all_tables_are_built= true;                     550   all_tables_are_built= true;
559   for (G4int i=0; i<n_loss; ++i) {                551   for (G4int i=0; i<n_loss; ++i) {
560     if(p == loss_vector[i]) {                     552     if(p == loss_vector[i]) {
561       tables_are_built[i] = true;                 553       tables_are_built[i] = true;
562       isActive[i] = true;                         554       isActive[i] = true;
563       part_vector[i] = p->Particle();             555       part_vector[i] = p->Particle(); 
564       base_part_vector[i] = p->BaseParticle();    556       base_part_vector[i] = p->BaseParticle(); 
565       dedx_vector[i] = p->DEDXTable();            557       dedx_vector[i] = p->DEDXTable();
566       range_vector[i] = p->RangeTableForLoss()    558       range_vector[i] = p->RangeTableForLoss();
567       inv_range_vector[i] = p->InverseRangeTab    559       inv_range_vector[i] = p->InverseRangeTable();
568       if(0 == run && p->IsIonisationProcess())    560       if(0 == run && p->IsIonisationProcess()) {
569         loss_map[part_vector[i]] = p;             561         loss_map[part_vector[i]] = p;
                                                   >> 562   //G4cout << "G4LossTableManager::LocalPhysicsTable " << part_vector[i]->GetParticleName()
                                                   >> 563   //     << " added to map " << p << G4endl;
570       }                                           564       }
571                                                   565 
572       if(1 < verbose) {                           566       if(1 < verbose) { 
573         G4cout << i <<".   "<< p->GetProcessNa    567         G4cout << i <<".   "<< p->GetProcessName(); 
574         if(part_vector[i]) {                      568         if(part_vector[i]) {
575           G4cout << "  for "  << part_vector[i    569           G4cout << "  for "  << part_vector[i]->GetParticleName();
576         }                                         570         }
577         G4cout << "  active= " << isActive[i]     571         G4cout << "  active= " << isActive[i]
578                << "  table= " << tables_are_bu    572                << "  table= " << tables_are_built[i]
579                << "  isIonisation= " << p->IsI    573                << "  isIonisation= " << p->IsIonisationProcess()
580                << G4endl;                         574                << G4endl;
581       }                                           575       }
582       break;                                      576       break;
583     } else if(!tables_are_built[i]) {             577     } else if(!tables_are_built[i]) {
584       all_tables_are_built = false;               578       all_tables_are_built = false;
585     }                                             579     }
586   }                                               580   }
587                                                   581 
588   if(1 < verbose) {                               582   if(1 < verbose) {
589     G4cout << "### G4LossTableManager::LocalPh    583     G4cout << "### G4LossTableManager::LocalPhysicsTable end"
590            << G4endl;                             584            << G4endl;
591   }                                               585   }
592   if(all_tables_are_built) {                      586   if(all_tables_are_built) { 
593     if(1 < verbose) {                             587     if(1 < verbose) {
594       G4cout << "%%%%% All dEdx and Range tabl    588       G4cout << "%%%%% All dEdx and Range tables for worker are ready for run "
595              << run << " %%%%%" << G4endl;        589              << run << " %%%%%" << G4endl;
596     }                                             590     }
597   }                                               591   }
598 }                                                 592 }
599                                                   593 
600 //....oooOO0OOooo........oooOO0OOooo........oo    594 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
601                                                   595 
602 void G4LossTableManager::BuildPhysicsTable(       596 void G4LossTableManager::BuildPhysicsTable(
603      const G4ParticleDefinition* aParticle,       597      const G4ParticleDefinition* aParticle,
604      G4VEnergyLossProcess* p)                     598      G4VEnergyLossProcess* p)
605 {                                                 599 {
606   if(1 < verbose) {                               600   if(1 < verbose) {
607     G4cout << "### G4LossTableManager::BuildPh    601     G4cout << "### G4LossTableManager::BuildPhysicsTable() for "
608            << aParticle->GetParticleName()        602            << aParticle->GetParticleName()
609            << " and process " << p->GetProcess    603            << " and process " << p->GetProcessName() << G4endl;
610   }                                               604   }
611   // clear configurator                           605   // clear configurator
612   if(-1 == run && startInitialisation) {          606   if(-1 == run && startInitialisation) {
613     if( nullptr != emConfigurator) { emConfigu << 607     if(emConfigurator) { emConfigurator->Clear(); }
614     firstParticle = aParticle;                    608     firstParticle = aParticle; 
615   }                                               609   }
616   if(startInitialisation) {                       610   if(startInitialisation) {
617     ++run;                                        611     ++run;
618     resetParam = true;                         << 
619     startInitialisation = false;               << 
620     if(1 < verbose) {                             612     if(1 < verbose) {
621       G4cout << "===== G4LossTableManager::Bui    613       G4cout << "===== G4LossTableManager::BuildPhysicsTable() for run "
622              << run << " ===== " << atomDeexci    614              << run << " ===== " << atomDeexcitation << G4endl;
623     }                                             615     }
624     currentParticle = nullptr;                    616     currentParticle = nullptr;
625     all_tables_are_built = false;              << 617     all_tables_are_built= true;
                                                   >> 618   }
                                                   >> 619 
                                                   >> 620   // initialisation before any table is built
                                                   >> 621   if ( startInitialisation && aParticle == firstParticle ) {
626                                                   622 
                                                   >> 623     startInitialisation = false;
                                                   >> 624     if(1 < verbose) {
                                                   >> 625       G4cout << "### G4LossTableManager start initilisation for first particle "
                                                   >> 626              << firstParticle->GetParticleName() 
                                                   >> 627              << G4endl;
                                                   >> 628     }
627     for (G4int i=0; i<n_loss; ++i) {              629     for (G4int i=0; i<n_loss; ++i) {
628       G4VEnergyLossProcess* el = loss_vector[i    630       G4VEnergyLossProcess* el = loss_vector[i];
629                                                   631 
630       if(nullptr != el) {                      << 632       if(el) {
631         isActive[i] = true;                       633         isActive[i] = true;
632         part_vector[i] = el->Particle();       << 
633         base_part_vector[i] = el->BaseParticle    634         base_part_vector[i] = el->BaseParticle(); 
634         tables_are_built[i] = false;           << 635         tables_are_built[i] = false;
                                                   >> 636         all_tables_are_built= false;
                                                   >> 637         if(!isActive[i]) { 
                                                   >> 638           el->SetIonisation(false); 
                                                   >> 639           tables_are_built[i] = true;
                                                   >> 640         }
                                                   >> 641   
635         if(1 < verbose) {                         642         if(1 < verbose) { 
636           G4cout << i <<".   "<< el->GetProces    643           G4cout << i <<".   "<< el->GetProcessName();
637           if(el->Particle()) {                    644           if(el->Particle()) {
638             G4cout << "  for "  << el->Particl    645             G4cout << "  for "  << el->Particle()->GetParticleName();
639           }                                       646           }
640           G4cout << "  active= " << isActive[i    647           G4cout << "  active= " << isActive[i]
641                  << "  table= " << tables_are_    648                  << "  table= " << tables_are_built[i]
642                  << "  isIonisation= " << el->    649                  << "  isIonisation= " << el->IsIonisationProcess();
643           if(base_part_vector[i]) {               650           if(base_part_vector[i]) { 
644             G4cout << "  base particle "          651             G4cout << "  base particle " 
645                    << base_part_vector[i]->Get    652                    << base_part_vector[i]->GetParticleName();
646           }                                       653           }
647           G4cout << G4endl;                       654           G4cout << G4endl;
648         }                                         655         }
649       } else {                                    656       } else {
650         tables_are_built[i] = true;               657         tables_are_built[i] = true;
651         part_vector[i] = nullptr;                 658         part_vector[i] = nullptr;
652         isActive[i] = false;                      659         isActive[i] = false;
653       }                                           660       }
654     }                                             661     }
655   }                                               662   }
656                                                   663 
657   if (all_tables_are_built) {                  << 664  if (all_tables_are_built) { return; }
658     theParameters->SetIsPrintedFlag(true);     << 
659     return;                                    << 
660   }                                            << 
661                                                   665 
662   // Build tables for given particle              666   // Build tables for given particle
663   all_tables_are_built = true;                    667   all_tables_are_built = true;
664                                                   668 
665   for(G4int i=0; i<n_loss; ++i) {                 669   for(G4int i=0; i<n_loss; ++i) {
666     if(p == loss_vector[i] && !tables_are_buil << 670     if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) {
667       const G4ParticleDefinition* curr_part =     671       const G4ParticleDefinition* curr_part = part_vector[i];
668       if(1 < verbose) {                           672       if(1 < verbose) {
669         G4cout << "### Build Table for " << p-    673         G4cout << "### Build Table for " << p->GetProcessName()
670                << " and " << curr_part->GetPar    674                << " and " << curr_part->GetParticleName() 
671                << "  " << tables_are_built[i]  << 675          << "  " << tables_are_built[i] << "  " << base_part_vector[i] << G4endl;
672                << G4endl;                      << 
673       }                                           676       }
674       G4VEnergyLossProcess* curr_proc = BuildT    677       G4VEnergyLossProcess* curr_proc = BuildTables(curr_part);
675       if(curr_proc) {                             678       if(curr_proc) { 
676         CopyTables(curr_part, curr_proc);      << 679   CopyTables(curr_part, curr_proc); 
677         if(p == curr_proc && 0 == run && p->Is << 680   if(p == curr_proc && 0 == run && p->IsIonisationProcess()) { 
678           loss_map[aParticle] = p;             << 681     loss_map[aParticle] = p; 
679           //G4cout << "G4LossTableManager::Bui << 682     //G4cout << "G4LossTableManager::BuildPhysicsTable: " << aParticle->GetParticleName()
680           //     << aParticle->GetParticleName << 683     //   << " added to map " << p <<  G4endl;
681           //         << " added to map " << p  << 684   }
682         }                                      << 
683       }                                           685       }
684     }                                             686     }
685     if ( !tables_are_built[i] ) { all_tables_a    687     if ( !tables_are_built[i] ) { all_tables_are_built = false; }
686   }                                               688   }
687   if(1 < verbose) {                               689   if(1 < verbose) {
688     G4cout << "### G4LossTableManager::BuildPh    690     G4cout << "### G4LossTableManager::BuildPhysicsTable end: "
689            << "all_tables_are_built= " << all_    691            << "all_tables_are_built= " << all_tables_are_built << " "
690            << aParticle->GetParticleName() <<     692            << aParticle->GetParticleName() << " proc: " << p << G4endl;
691   }                                               693   }
                                                   >> 694   if(all_tables_are_built) { 
                                                   >> 695     if(1 < verbose) {
                                                   >> 696       G4cout << "%%%%% All dEdx and Range tables are built for master run= " 
                                                   >> 697              << run << " %%%%%" << G4endl;
                                                   >> 698     }
                                                   >> 699   }
692 }                                                 700 }
693                                                   701 
694 //....oooOO0OOooo........oooOO0OOooo........oo    702 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
695                                                   703 
696 void G4LossTableManager::CopyTables(const G4Pa    704 void G4LossTableManager::CopyTables(const G4ParticleDefinition* part,
697                                     G4VEnergyL    705                                     G4VEnergyLossProcess* base_proc)
698 {                                                 706 {
699   for (G4int j=0; j<n_loss; ++j) {                707   for (G4int j=0; j<n_loss; ++j) {
700                                                   708 
701     G4VEnergyLossProcess* proc = loss_vector[j    709     G4VEnergyLossProcess* proc = loss_vector[j];
702                                                   710 
703     if (!tables_are_built[j] && part == base_p    711     if (!tables_are_built[j] && part == base_part_vector[j]) {
704       tables_are_built[j] = true;                 712       tables_are_built[j] = true;
705       // for base particle approach only ionis << 
706       proc->SetDEDXTable(base_proc->Ionisation    713       proc->SetDEDXTable(base_proc->IonisationTable(),fRestricted);
                                                   >> 714       proc->SetDEDXTable(base_proc->DEDXTableForSubsec(),fSubRestricted);
707       proc->SetDEDXTable(base_proc->DEDXunRest    715       proc->SetDEDXTable(base_proc->DEDXunRestrictedTable(),fTotal);
708       proc->SetCSDARangeTable(base_proc->CSDAR    716       proc->SetCSDARangeTable(base_proc->CSDARangeTable());
709       proc->SetRangeTableForLoss(base_proc->Ra    717       proc->SetRangeTableForLoss(base_proc->RangeTableForLoss());
710       proc->SetInverseRangeTable(base_proc->In    718       proc->SetInverseRangeTable(base_proc->InverseRangeTable());
711       proc->SetLambdaTable(base_proc->LambdaTa    719       proc->SetLambdaTable(base_proc->LambdaTable());
                                                   >> 720       proc->SetSubLambdaTable(base_proc->SubLambdaTable());
                                                   >> 721       proc->SetIonisation(base_proc->IsIonisationProcess());
712       if(proc->IsIonisationProcess()) {           722       if(proc->IsIonisationProcess()) { 
713         range_vector[j] = base_proc->RangeTabl    723         range_vector[j] = base_proc->RangeTableForLoss();
714         inv_range_vector[j] = base_proc->Inver    724         inv_range_vector[j] = base_proc->InverseRangeTable();
715         loss_map[part_vector[j]] = proc;          725         loss_map[part_vector[j]] = proc; 
716         //G4cout << "G4LossTableManager::CopyT << 726   //G4cout << "G4LossTableManager::CopyTable " << part_vector[j]->GetParticleName()
717         //       << part_vector[j]->GetParticl << 727   //     << " added to map " << proc << G4endl;
718         //       << " added to map " << proc < << 
719       }                                           728       }
720       if (1 < verbose) {                          729       if (1 < verbose) {
721          G4cout << "   CopyTables for " << pro << 730          G4cout << "For " << proc->GetProcessName()
722                 << " for " << part_vector[j]->    731                 << " for " << part_vector[j]->GetParticleName()
723                 << " base_part= " << part->Get    732                 << " base_part= " << part->GetParticleName()
724                 << " tables are assigned"         733                 << " tables are assigned"
725                 << G4endl;                        734                 << G4endl;
726       }                                           735       }
727     }                                             736     }
                                                   >> 737 
                                                   >> 738     if (theElectron == part && theElectron == proc->SecondaryParticle() ) {
                                                   >> 739       proc->SetSecondaryRangeTable(base_proc->RangeTableForLoss());
                                                   >> 740     }
728   }                                               741   }
729 }                                                 742 }
730                                                   743 
731 //....oooOO0OOooo........oooOO0OOooo........oo    744 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
732                                                   745 
733 G4VEnergyLossProcess* G4LossTableManager::Buil    746 G4VEnergyLossProcess* G4LossTableManager::BuildTables(
734                       const G4ParticleDefiniti    747                       const G4ParticleDefinition* aParticle)
735 {                                                 748 {
736   if(1 < verbose) {                               749   if(1 < verbose) {
737     G4cout << "   G4LossTableManager::BuildTab << 750     G4cout << "G4LossTableManager::BuildTables() for "
738            << aParticle->GetParticleName() <<     751            << aParticle->GetParticleName() << G4endl;
739   }                                               752   }
740                                                   753 
741   std::vector<G4PhysicsTable*> t_list;            754   std::vector<G4PhysicsTable*> t_list;  
742   std::vector<G4VEnergyLossProcess*> loss_list    755   std::vector<G4VEnergyLossProcess*> loss_list;
743   std::vector<G4bool> build_flags;                756   std::vector<G4bool> build_flags;
744   G4VEnergyLossProcess* em = nullptr;             757   G4VEnergyLossProcess* em = nullptr;
745   G4VEnergyLossProcess* p = nullptr;              758   G4VEnergyLossProcess* p = nullptr;
746   G4int iem = 0;                                  759   G4int iem = 0;
747   G4PhysicsTable* dedx = nullptr;              << 760   G4PhysicsTable* dedx = 0;
748   G4int i;                                        761   G4int i;
749                                                   762 
750   G4ProcessVector* pvec =                         763   G4ProcessVector* pvec = 
751     aParticle->GetProcessManager()->GetProcess    764     aParticle->GetProcessManager()->GetProcessList();
752   G4int nvec = (G4int)pvec->size();            << 765   G4int nvec = pvec->size();
753                                                   766 
754   for (i=0; i<n_loss; ++i) {                      767   for (i=0; i<n_loss; ++i) {
755     p = loss_vector[i];                           768     p = loss_vector[i];
756     if (nullptr != p) {                        << 769     if (p) {
757       G4bool yes = (aParticle == part_vector[i    770       G4bool yes = (aParticle == part_vector[i]);
758                                                   771 
759       // possible case of process sharing betw    772       // possible case of process sharing between particle/anti-particle
760       if(!yes) {                                  773       if(!yes) {
761         auto ptr = static_cast<G4VProcess*>(p) << 774         G4VProcess* ptr = static_cast<G4VProcess*>(p);
762         for(G4int j=0; j<nvec; ++j) {             775         for(G4int j=0; j<nvec; ++j) {
763           //G4cout << "j= " << j << " " << (*p    776           //G4cout << "j= " << j << " " << (*pvec)[j] << " " << ptr << G4endl;
764           if(ptr == (*pvec)[j]) {                 777           if(ptr == (*pvec)[j]) {
765             yes = true;                           778             yes = true;
766             break;                                779             break;
767           }                                       780           }
768         }                                         781         }
769       }                                           782       }      
770       // process belong to this particle          783       // process belong to this particle
771       if(yes && isActive[i]) {                    784       if(yes && isActive[i]) {
772         if (p->IsIonisationProcess() || !em) {    785         if (p->IsIonisationProcess() || !em) {
773           em = p;                                 786           em = p;
774           iem= i;                                 787           iem= i;
775         }                                         788         }
776         // tables may be shared between partic    789         // tables may be shared between particle/anti-particle
777         G4bool val = false;                       790         G4bool val = false;
778         if (!tables_are_built[i]) {               791         if (!tables_are_built[i]) {
779           val = true;                             792           val = true;
780           dedx = p->BuildDEDXTable(fRestricted    793           dedx = p->BuildDEDXTable(fRestricted);
781           //G4cout << "===Build DEDX table for << 794           //G4cout << "Build DEDX table for " << p->GetProcessName()
782           // << " idx= " << i << " dedx:" << d << 795           // << " idx= " << i << dedx << " " << dedx->length() << G4endl;
783           p->SetDEDXTable(dedx,fRestricted);      796           p->SetDEDXTable(dedx,fRestricted);
784           tables_are_built[i] = true;             797           tables_are_built[i] = true;
785         } else {                                  798         } else {
786           dedx = p->DEDXTable();                  799           dedx = p->DEDXTable();
787         }                                         800         }
788         t_list.push_back(dedx);                   801         t_list.push_back(dedx);
789         loss_list.push_back(p);                   802         loss_list.push_back(p);
790         build_flags.push_back(val);               803         build_flags.push_back(val);
791       }                                           804       }
792     }                                             805     }
793   }                                               806   }
794                                                   807 
795   G4int n_dedx = (G4int)t_list.size();         << 808   G4int n_dedx = t_list.size();
796   if (0 == n_dedx || !em) {                       809   if (0 == n_dedx || !em) {
797     G4cout << "G4LossTableManager WARNING: no     810     G4cout << "G4LossTableManager WARNING: no DEDX processes for " 
798            << aParticle->GetParticleName() <<     811            << aParticle->GetParticleName() << G4endl;
799     return nullptr;                            << 812     return 0;
800   }                                               813   }
801   G4int nSubRegions = em->NumberOfSubCutoffReg    814   G4int nSubRegions = em->NumberOfSubCutoffRegions();
802                                                   815 
803   if (1 < verbose) {                              816   if (1 < verbose) {
804     G4cout << "     Start to build the sum of  << 817     G4cout << "G4LossTableManager::BuildTables() start to build range tables"
                                                   >> 818            << " and the sum of " << n_dedx << " processes"
805            << " iem= " << iem << " em= " << em    819            << " iem= " << iem << " em= " << em->GetProcessName()
806            << " buildCSDARange= " << theParame    820            << " buildCSDARange= " << theParameters->BuildCSDARange()
807            << " nSubRegions= " << nSubRegions;    821            << " nSubRegions= " << nSubRegions;
808     if(subcutProducer) {                          822     if(subcutProducer) { 
809       G4cout << " SubCutProducer " << subcutPr    823       G4cout << " SubCutProducer " << subcutProducer->GetName(); 
810     }                                             824     }
811     G4cout << G4endl;                             825     G4cout << G4endl;
812   }                                               826   }
813   // do not build tables if producer class is     827   // do not build tables if producer class is defined
814   if(subcutProducer) { nSubRegions = 0; }         828   if(subcutProducer) { nSubRegions = 0; }
815                                                   829 
816   dedx = em->DEDXTable();                      << 830   dedx = em->DEDXTable(); 
                                                   >> 831   em->SetIonisation(true);
817   em->SetDEDXTable(dedx, fIsIonisation);          832   em->SetDEDXTable(dedx, fIsIonisation);
818                                                   833 
819   if (1 < n_dedx) {                               834   if (1 < n_dedx) {
820     dedx = nullptr;                            << 835     dedx = 0;
821     dedx = G4PhysicsTableHelper::PreparePhysic    836     dedx = G4PhysicsTableHelper::PreparePhysicsTable(dedx);
822     tableBuilder->BuildDEDXTable(dedx, t_list)    837     tableBuilder->BuildDEDXTable(dedx, t_list);
823     em->SetDEDXTable(dedx, fRestricted);          838     em->SetDEDXTable(dedx, fRestricted);
824   }                                               839   }
825                                                   840 
                                                   >> 841   /*
                                                   >> 842   if(2==run && "e-" == aParticle->GetParticleName()) {
                                                   >> 843     G4cout << "G4LossTableManager::BuildTables for e- " << dedx << G4endl;
                                                   >> 844     G4cout << (*dedx) << G4endl;
                                                   >> 845     G4cout << "%%%%% Instance ID= " << (*dedx)[0]->GetInstanceID() << G4endl;
                                                   >> 846     G4cout << "%%%%% LastValue= " << (*dedx)[0]->GetLastValue() << G4endl;
                                                   >> 847     G4cout << "%%%%% 1.2 " << (*(dedx))[0]->Value(1.2) << G4endl;
                                                   >> 848   }
                                                   >> 849   */
826   dedx_vector[iem] = dedx;                        850   dedx_vector[iem] = dedx;
827                                                   851 
828   G4PhysicsTable* range = em->RangeTableForLos    852   G4PhysicsTable* range = em->RangeTableForLoss();
829   if(!range) range  = G4PhysicsTableHelper::Pr    853   if(!range) range  = G4PhysicsTableHelper::PreparePhysicsTable(range);
830   range_vector[iem] = range;                      854   range_vector[iem] = range;
831                                                   855 
832   G4PhysicsTable* invrange = em->InverseRangeT    856   G4PhysicsTable* invrange = em->InverseRangeTable();
833   if(!invrange) invrange = G4PhysicsTableHelpe    857   if(!invrange) invrange = G4PhysicsTableHelper::PreparePhysicsTable(invrange);
834   inv_range_vector[iem]  = invrange;              858   inv_range_vector[iem]  = invrange;
835                                                   859 
836   tableBuilder->BuildRangeTable(dedx, range);  << 860   tableBuilder->BuildRangeTable(dedx, range, true);
837   tableBuilder->BuildInverseRangeTable(range,  << 861   tableBuilder->BuildInverseRangeTable(range, invrange, true);
                                                   >> 862 
                                                   >> 863   //  if(1<verbose) G4cout << *dedx << G4endl;
838                                                   864 
839   em->SetRangeTableForLoss(range);                865   em->SetRangeTableForLoss(range);
840   em->SetInverseRangeTable(invrange);             866   em->SetInverseRangeTable(invrange);
841                                                   867 
                                                   >> 868   //  if(1<verbose) G4cout << *range << G4endl;
                                                   >> 869 
                                                   >> 870   std::vector<G4PhysicsTable*> listSub;
842   std::vector<G4PhysicsTable*> listCSDA;          871   std::vector<G4PhysicsTable*> listCSDA;
843                                                   872 
844   for (i=0; i<n_dedx; ++i) {                      873   for (i=0; i<n_dedx; ++i) {
845     p = loss_list[i];                             874     p = loss_list[i];
                                                   >> 875     if(p != em) { p->SetIonisation(false); }
846     if(build_flags[i]) {                          876     if(build_flags[i]) {
847       p->SetLambdaTable(p->BuildLambdaTable(fR    877       p->SetLambdaTable(p->BuildLambdaTable(fRestricted));
848     }                                             878     }
                                                   >> 879     if (0 < nSubRegions) {
                                                   >> 880       dedx = p->BuildDEDXTable(fSubRestricted);
                                                   >> 881       p->SetDEDXTable(dedx,fSubRestricted);
                                                   >> 882       listSub.push_back(dedx);
                                                   >> 883       if(build_flags[i]) {
                                                   >> 884         p->SetSubLambdaTable(p->BuildLambdaTable(fSubRestricted));
                                                   >> 885         if(p != em) { em->AddCollaborativeProcess(p); }
                                                   >> 886       }
                                                   >> 887     }
849     if(theParameters->BuildCSDARange()) {         888     if(theParameters->BuildCSDARange()) { 
850       dedx = p->BuildDEDXTable(fTotal);           889       dedx = p->BuildDEDXTable(fTotal);
851       p->SetDEDXTable(dedx,fTotal);               890       p->SetDEDXTable(dedx,fTotal);
852       listCSDA.push_back(dedx);                   891       listCSDA.push_back(dedx); 
853     }                                             892     }     
854   }                                               893   }
855                                                   894 
                                                   >> 895   if (0 < nSubRegions) {
                                                   >> 896     G4PhysicsTable* dedxSub = em->IonisationTableForSubsec();
                                                   >> 897     if (1 < listSub.size()) {
                                                   >> 898       em->SetDEDXTable(dedxSub, fIsSubIonisation);
                                                   >> 899       dedxSub = 0;
                                                   >> 900       dedxSub = G4PhysicsTableHelper::PreparePhysicsTable(dedxSub);
                                                   >> 901       tableBuilder->BuildDEDXTable(dedxSub, listSub);
                                                   >> 902       em->SetDEDXTable(dedxSub, fSubRestricted);
                                                   >> 903     }
                                                   >> 904   }
856   if(theParameters->BuildCSDARange()) {           905   if(theParameters->BuildCSDARange()) {
857     G4PhysicsTable* dedxCSDA = em->DEDXunRestr    906     G4PhysicsTable* dedxCSDA = em->DEDXunRestrictedTable();
858     if (1 < n_dedx) {                             907     if (1 < n_dedx) {
                                                   >> 908       dedxCSDA = nullptr;
859       dedxCSDA = G4PhysicsTableHelper::Prepare    909       dedxCSDA = G4PhysicsTableHelper::PreparePhysicsTable(dedxCSDA);
860       tableBuilder->BuildDEDXTable(dedxCSDA, l    910       tableBuilder->BuildDEDXTable(dedxCSDA, listCSDA);
861       em->SetDEDXTable(dedxCSDA,fTotal);          911       em->SetDEDXTable(dedxCSDA,fTotal);
862     }                                             912     }
863     G4PhysicsTable* rCSDA = em->CSDARangeTable    913     G4PhysicsTable* rCSDA = em->CSDARangeTable();
864     if(!rCSDA) { rCSDA = G4PhysicsTableHelper:    914     if(!rCSDA) { rCSDA = G4PhysicsTableHelper::PreparePhysicsTable(rCSDA); }
865     tableBuilder->BuildRangeTable(dedxCSDA, rC << 915     tableBuilder->BuildRangeTable(dedxCSDA, rCSDA, true);
866     em->SetCSDARangeTable(rCSDA);                 916     em->SetCSDARangeTable(rCSDA);
867   }                                               917   }
868                                                   918 
869   if (1 < verbose) {                              919   if (1 < verbose) {
870     G4cout << "G4LossTableManager::BuildTables    920     G4cout << "G4LossTableManager::BuildTables: Tables are built for "
871            << aParticle->GetParticleName()        921            << aParticle->GetParticleName()
872            << "; ionisation process: " << em->    922            << "; ionisation process: " << em->GetProcessName()
873            << "  " << em                          923            << "  " << em
874            << G4endl;                             924            << G4endl;
875   }                                               925   }
876   return em;                                      926   return em;
877 }                                                 927 }
878                                                   928 
879 //....oooOO0OOooo........oooOO0OOooo........oo    929 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
880                                                   930 
881 void G4LossTableManager::ParticleHaveNoLoss(      931 void G4LossTableManager::ParticleHaveNoLoss(
882      const G4ParticleDefinition* aParticle)       932      const G4ParticleDefinition* aParticle)
883 {                                                 933 {
884   G4ExceptionDescription ed;                      934   G4ExceptionDescription ed;
885   ed << "Energy loss process not found for " <    935   ed << "Energy loss process not found for " << aParticle->GetParticleName() 
886      << " !";                                     936      << " !";
887   G4Exception("G4LossTableManager::ParticleHav    937   G4Exception("G4LossTableManager::ParticleHaveNoLoss", "em0001",
888               FatalException, ed);                938               FatalException, ed);
889 }                                                 939 }
890                                                   940 
891 //....oooOO0OOooo........oooOO0OOooo........oo    941 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
892                                                   942 
893 void G4LossTableManager::SetVerbose(G4int val)    943 void G4LossTableManager::SetVerbose(G4int val)
894 {                                                 944 {
895   verbose = val;                                  945   verbose = val;
896 }                                                 946 }
897                                                   947 
898 //....oooOO0OOooo........oooOO0OOooo........oo    948 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
899                                                   949 
900 const std::vector<G4VEnergyLossProcess*>&         950 const std::vector<G4VEnergyLossProcess*>& 
901 G4LossTableManager::GetEnergyLossProcessVector    951 G4LossTableManager::GetEnergyLossProcessVector()
902 {                                                 952 {
903   return loss_vector;                             953   return loss_vector;
904 }                                                 954 }
905                                                   955 
906 //....oooOO0OOooo........oooOO0OOooo........oo    956 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
907                                                   957 
908 const std::vector<G4VEmProcess*>& G4LossTableM    958 const std::vector<G4VEmProcess*>& G4LossTableManager::GetEmProcessVector()
909 {                                                 959 {
910   return emp_vector;                              960   return emp_vector;
911 }                                                 961 }
912                                                   962 
913 //....oooOO0OOooo........oooOO0OOooo........oo    963 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
914                                                   964 
915 const std::vector<G4VMultipleScattering*>&        965 const std::vector<G4VMultipleScattering*>& 
916 G4LossTableManager::GetMultipleScatteringVecto    966 G4LossTableManager::GetMultipleScatteringVector()
917 {                                                 967 {
918   return msc_vector;                              968   return msc_vector;
919 }                                                 969 }
920                                                   970 
921 //....oooOO0OOooo........oooOO0OOooo........oo    971 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
922                                                   972 
923 G4EmSaturation* G4LossTableManager::EmSaturati    973 G4EmSaturation* G4LossTableManager::EmSaturation()
924 {                                                 974 {
925   return theParameters->GetEmSaturation();        975   return theParameters->GetEmSaturation();
926 }                                                 976 }
927                                                   977 
928 //....oooOO0OOooo........oooOO0OOooo........oo    978 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
929                                                   979 
930 G4EmConfigurator* G4LossTableManager::EmConfig    980 G4EmConfigurator* G4LossTableManager::EmConfigurator()
931 {                                                 981 {
932   if(!emConfigurator) {                        << 982   if(!emConfigurator) { emConfigurator = new G4EmConfigurator(verbose); }
933     emConfigurator = new G4EmConfigurator(verb << 
934   }                                            << 
935   return emConfigurator;                          983   return emConfigurator;
936 }                                                 984 }
937                                                   985 
938 //....oooOO0OOooo........oooOO0OOooo........oo    986 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
939                                                   987 
940 G4ElectronIonPair* G4LossTableManager::Electro    988 G4ElectronIonPair* G4LossTableManager::ElectronIonPair()
941 {                                                 989 {
942   if(!emElectronIonPair) {                        990   if(!emElectronIonPair) { 
943     emElectronIonPair = new G4ElectronIonPair(    991     emElectronIonPair = new G4ElectronIonPair(verbose);
944   }                                               992   }
945   return emElectronIonPair;                       993   return emElectronIonPair;
946 }                                                 994 }
947                                                   995 
948 //....oooOO0OOooo........oooOO0OOooo........oo << 
949                                                << 
950 void G4LossTableManager::SetNIELCalculator(G4N << 
951 {                                              << 
952   if(nullptr != ptr && ptr != nielCalculator)  << 
953     delete nielCalculator;                     << 
954     nielCalculator = ptr;                      << 
955   }                                            << 
956 }                                              << 
957                                                << 
958 //....oooOO0OOooo........oooOO0OOooo........oo << 
959                                                << 
960 G4NIELCalculator* G4LossTableManager::NIELCalc << 
961 {                                              << 
962   if(!nielCalculator) {                        << 
963     nielCalculator = new G4NIELCalculator(null << 
964   }                                            << 
965   return nielCalculator;                       << 
966 }                                              << 
967                                                << 
968 //....oooOO0OOooo........oooOO0OOooo........oo    996 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
969                                                   997  
970 void G4LossTableManager::SetAtomDeexcitation(G    998 void G4LossTableManager::SetAtomDeexcitation(G4VAtomDeexcitation* p)
971 {                                                 999 {
972   if(atomDeexcitation != p) {                     1000   if(atomDeexcitation != p) {
973     delete atomDeexcitation;                      1001     delete atomDeexcitation;
974     atomDeexcitation = p;                         1002     atomDeexcitation = p;
975   }                                               1003   }
976 }                                                 1004 }
977                                                   1005 
978 //....oooOO0OOooo........oooOO0OOooo........oo    1006 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
979                                                   1007 
980 void G4LossTableManager::SetSubCutProducer(G4V    1008 void G4LossTableManager::SetSubCutProducer(G4VSubCutProducer* p) 
981 {                                                 1009 {
982   if(subcutProducer != p) {                       1010   if(subcutProducer != p) {
983     delete subcutProducer;                        1011     delete subcutProducer;
984     subcutProducer = p;                           1012     subcutProducer = p;
985   }                                               1013   }
986 }                                                 1014 }
987                                                   1015 
988 //....oooOO0OOooo........oooOO0OOooo........oo    1016 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
989                                                   1017 
990 void G4LossTableManager::PrintEWarning(G4Strin    1018 void G4LossTableManager::PrintEWarning(G4String tit, G4double /*val*/)
991 {                                                 1019 {
992   G4String ss = "G4LossTableManager::" + tit;     1020   G4String ss = "G4LossTableManager::" + tit; 
993   G4ExceptionDescription ed;                      1021   G4ExceptionDescription ed;
994   /*                                              1022   /*
995   ed << "Parameter is out of range: " << val      1023   ed << "Parameter is out of range: " << val 
996      << " it will have no effect!\n" << " ## "    1024      << " it will have no effect!\n" << " ## " 
997      << " nbins= " << nbinsLambda                 1025      << " nbins= " << nbinsLambda 
998      << " nbinsPerDecade= " << nbinsPerDecade     1026      << " nbinsPerDecade= " << nbinsPerDecade 
999      << " Emin(keV)= " << minKinEnergy/keV        1027      << " Emin(keV)= " << minKinEnergy/keV 
1000      << " Emax(GeV)= " << maxKinEnergy/GeV;      1028      << " Emax(GeV)= " << maxKinEnergy/GeV;
1001   */                                             1029   */
1002   G4Exception(ss, "em0044", JustWarning, ed);    1030   G4Exception(ss, "em0044", JustWarning, ed);
1003 }                                                1031 }
1004                                                  1032 
1005 //....oooOO0OOooo........oooOO0OOooo........o    1033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1006                                                  1034 
1007 void G4LossTableManager::DumpHtml()              1035 void G4LossTableManager::DumpHtml()
1008 {                                                1036 {
1009   // Automatic generation of html documentati    1037   // Automatic generation of html documentation page for physics lists
1010   // List processes and models for the most i    1038   // List processes and models for the most important
1011   // particles in descending order of importa    1039   // particles in descending order of importance
1012   // NB. for model names with length > 18 cha << 
1013   //  to be edited by hand. Or modify G4EmMod << 
1014                                                  1040 
1015   char* dirName = std::getenv("G4PhysListDocD << 1041   char* dirName = getenv("G4PhysListDocDir");
1016   char* physList = std::getenv("G4PhysListNam << 1042   char* physListName = getenv("G4PhysListName");
1017   if (dirName && physList) {                  << 1043   if (dirName && physListName) {
1018     G4String physListName = G4String(physList << 1044     G4String pathName = G4String(dirName) + "/" + G4String(physListName) 
1019     G4String pathName = G4String(dirName) + " << 1045                                           + ".html";
1020                                                  1046 
1021     std::ofstream outFile;                       1047     std::ofstream outFile;
1022     outFile.open(pathName);                      1048     outFile.open(pathName);
1023                                                  1049    
1024     outFile << physListName << G4endl;        << 1050     outFile << "<html>\n";
1025     outFile << std::string(physListName.lengt << 1051     outFile << "<head>\n";
                                                   >> 1052     outFile << "<title>Physics List Summary</title>\n";
                                                   >> 1053     outFile << "</head>\n";
                                                   >> 1054     outFile << "<body>\n";
                                                   >> 1055     outFile << "<h2> Summary of Electromagnetic Processes, Models and Cross "
                                                   >> 1056             << "Sections for Physics List "
                                                   >> 1057             << G4String(physListName) << "</h2>\n";
                                                   >> 1058     outFile << "<ul>\n";
1026                                                  1059 
1027     std::vector<G4ParticleDefinition*> partic    1060     std::vector<G4ParticleDefinition*> particles {
1028         G4Gamma::Gamma(),                        1061         G4Gamma::Gamma(),
1029         G4Electron::Electron(),                  1062         G4Electron::Electron(),
1030         G4Positron::Positron(),                  1063         G4Positron::Positron(),
1031         G4Proton::ProtonDefinition(),            1064         G4Proton::ProtonDefinition(),
1032         G4MuonPlus::MuonPlusDefinition(),        1065         G4MuonPlus::MuonPlusDefinition(),
1033         G4MuonMinus::MuonMinusDefinition(),      1066         G4MuonMinus::MuonMinusDefinition(),
1034       };                                         1067       };
1035                                                  1068    
1036     std::vector<G4VEmProcess*> emproc_vector     1069     std::vector<G4VEmProcess*> emproc_vector = GetEmProcessVector();
1037     std::vector<G4VEnergyLossProcess*> enloss    1070     std::vector<G4VEnergyLossProcess*> enloss_vector = 
1038       GetEnergyLossProcessVector();              1071       GetEnergyLossProcessVector();
1039     std::vector<G4VMultipleScattering*> mscat    1072     std::vector<G4VMultipleScattering*> mscat_vector =
1040       GetMultipleScatteringVector();             1073       GetMultipleScatteringVector();
1041                                                  1074     
1042     for (auto theParticle : particles) {         1075     for (auto theParticle : particles) {
1043       outFile << G4endl << "**" << theParticl << 1076       outFile << "<li><h3>" << theParticle->GetParticleName() << "</h3><ul>\n";
1044               << "**" << G4endl << G4endl <<  << 
1045                                                  1077 
1046       G4ProcessManager* pm = theParticle->Get << 1078       G4ProcessManager* pm = theParticle->GetProcessManager();
1047       G4ProcessVector*  pv = pm->GetProcessLi    1079       G4ProcessVector*  pv = pm->GetProcessList();
1048       G4int plen = pm->GetProcessListLength()    1080       G4int plen = pm->GetProcessListLength();
1049                                                  1081 
1050       for (auto emproc : emproc_vector) {        1082       for (auto emproc : emproc_vector) {
1051         for (G4int i = 0; i < plen; ++i) {       1083         for (G4int i = 0; i < plen; ++i) {
1052           G4VProcess* proc = (*pv)[i];           1084           G4VProcess* proc = (*pv)[i];
1053           if (proc == emproc) {                  1085           if (proc == emproc) {
1054             outFile << G4endl;                << 1086             outFile << "<li>\n";
1055             proc->ProcessDescription(outFile)    1087             proc->ProcessDescription(outFile);
                                                   >> 1088             outFile << "</li>\n";
1056             break;                               1089             break;
1057           }                                      1090           }
1058         }                                        1091         }
1059       }                                          1092       }
1060                                                  1093 
1061       for (auto mscproc : mscat_vector) {        1094       for (auto mscproc : mscat_vector) {
1062         for (G4int i = 0; i < plen; ++i) {       1095         for (G4int i = 0; i < plen; ++i) {
1063           G4VProcess* proc = (*pv)[i];           1096           G4VProcess* proc = (*pv)[i];
1064           if (proc == mscproc) {                 1097           if (proc == mscproc) {
1065             outFile << G4endl;                << 1098             outFile << "<li>\n";
1066             proc->ProcessDescription(outFile)    1099             proc->ProcessDescription(outFile);
                                                   >> 1100             outFile << "</li>\n";
1067             break;                               1101             break;
1068           }                                      1102           }
1069         }                                        1103         }
1070       }                                          1104       }
1071                                                  1105 
1072       for (auto enlossproc : enloss_vector) {    1106       for (auto enlossproc : enloss_vector) {
1073         for (G4int i = 0; i < plen; ++i) {       1107         for (G4int i = 0; i < plen; ++i) {
1074           G4VProcess* proc = (*pv)[i];           1108           G4VProcess* proc = (*pv)[i];
1075           if (proc == enlossproc) {              1109           if (proc == enlossproc) {
1076             outFile << G4endl;                << 1110             outFile << "<li>\n";
1077             proc->ProcessDescription(outFile)    1111             proc->ProcessDescription(outFile);
                                                   >> 1112             outFile << "</li>\n";
1078             break;                               1113             break;
1079           }                                      1114           }
1080         }                                        1115         }
1081       }                                          1116       }
                                                   >> 1117       outFile << "</ul>\n";
                                                   >> 1118       outFile << "</li>\n";
1082     }                                            1119     }
                                                   >> 1120     outFile << "</ul>\n";
                                                   >> 1121     outFile << "</body>\n";
                                                   >> 1122     outFile << "</html>\n";
1083     outFile.close();                             1123     outFile.close();
1084   }                                              1124   }
1085 }                                                1125 }
1086                                                  1126 
1087 //....oooOO0OOooo........oooOO0OOooo........o    1127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
1088                                                  1128 
1089                                                  1129