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


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