Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4LossTableManager.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/utils/src/G4LossTableManager.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4LossTableManager.cc (Version 10.7.p4)


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