Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/run/src/G4VUserPhysicsList.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 /run/src/G4VUserPhysicsList.cc (Version 11.3.0) and /run/src/G4VUserPhysicsList.cc (Version 8.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4VUserPhysicsList implementation           << 
 27 //                                                 26 //
 28 // Original author: H.Kurashige (Kobe Universi <<  27 // $Id: G4VUserPhysicsList.cc,v 1.53 2006/06/29 21:14:07 gunter Exp $
 29 // ------------------------------------------- <<  28 // GEANT4 tag $Name: geant4-08-01-patch-01 $
                                                   >>  29 //
                                                   >>  30 // 
                                                   >>  31 // ------------------------------------------------------------
                                                   >>  32 //  GEANT 4 class header file 
                                                   >>  33 //
                                                   >>  34 // ------------------------------------------------------------
                                                   >>  35 //  History
                                                   >>  36 //       first version                    09 Jan 1998 by H.Kurashige
                                                   >>  37 //       Added SetEnergyRange             18 Jun 1998 by H.Kurashige 
                                                   >>  38 //       Change for short lived particles 27 Jun 1998 by H.Kurashige
                                                   >>  39 //       G4BestUnit on output             12 nov 1998 by M.Maire
                                                   >>  40 //       Added RemoveProcessManager        9 Feb 1999 by H.Kurashige
                                                   >>  41 //       Fixed RemoveProcessManager       15 Apr 1999 by H.Kurashige
                                                   >>  42 //       Removed ConstructAllParticles()  15 Apr 1999 by H.Kurashige
                                                   >>  43 //       Modified for CUTS per REGION     10 Oct 2002 by H.Kurashige
                                                   >>  44 //       Check if particle IsShortLived   18 Jun 2003 by V.Ivanchenko
                                                   >>  45 // ------------------------------------------------------------
 30                                                    46 
                                                   >>  47 #include "globals.hh"
 31 #include "G4VUserPhysicsList.hh"                   48 #include "G4VUserPhysicsList.hh"
 32                                                << 
 33 #include "G4Material.hh"                       << 
 34 #include "G4MaterialCutsCouple.hh"             << 
 35 #include "G4ParticleDefinition.hh"                 49 #include "G4ParticleDefinition.hh"
 36 #include "G4ParticleTable.hh"                  << 
 37 #include "G4PhysicsListHelper.hh"              << 
 38 #include "G4ProcessManager.hh"                     50 #include "G4ProcessManager.hh"
 39 #include "G4ProductionCuts.hh"                 <<  51 #include "G4ParticleTable.hh"
 40 #include "G4ProductionCutsTable.hh"                52 #include "G4ProductionCutsTable.hh"
 41 #include "G4Region.hh"                         <<  53 #include "G4Material.hh"
 42 #include "G4RegionStore.hh"                    <<  54 #include "G4UserPhysicsListMessenger.hh"
 43 #include "G4SystemOfUnits.hh"                  << 
 44 #include "G4UImanager.hh"                          55 #include "G4UImanager.hh"
 45 #include "G4UnitsTable.hh"                         56 #include "G4UnitsTable.hh"
 46 #include "G4UserPhysicsListMessenger.hh"       <<  57 #include "G4RegionStore.hh"
 47 #include "G4VTrackingManager.hh"               <<  58 #include "G4Region.hh"
 48 #include "G4ios.hh"                            <<  59 #include "G4ProductionCutsTable.hh"
 49 #include "globals.hh"                          <<  60 #include "G4ProductionCuts.hh"
                                                   >>  61 #include "G4MaterialCutsCouple.hh"
 50                                                    62 
 51 #include <fstream>                             <<  63 #include "G4ios.hh"
 52 #include <iomanip>                                 64 #include <iomanip>
 53 #include <unordered_set>                       <<  65 #include <fstream>
 54                                                << 
 55 // This static member is thread local. For eac << 
 56 // size of G4VUPLData instances.               << 
 57 //                                             << 
 58 #define G4MT_theMessenger ((this->subInstanceM << 
 59 #define G4MT_thePLHelper ((this->subInstanceMa << 
 60 #define fIsPhysicsTableBuilt \                 << 
 61   ((this->subInstanceManager.offset[this->g4vu << 
 62 #define fDisplayThreshold \                    << 
 63   ((this->subInstanceManager.offset[this->g4vu << 
 64 #define theParticleIterator \                  << 
 65   ((this->subInstanceManager.offset[this->g4vu << 
 66                                                << 
 67 // This field helps to use the class G4VUPLMan << 
 68 //                                             << 
 69 G4VUPLManager G4VUserPhysicsList::subInstanceM << 
 70                                                << 
 71 // ------------------------------------------- << 
 72 void G4VUPLData::initialize()                  << 
 73 {                                              << 
 74   _theParticleIterator = G4ParticleTable::GetP << 
 75   _theMessenger = nullptr;                     << 
 76   _thePLHelper = G4PhysicsListHelper::GetPhysi << 
 77   _fIsPhysicsTableBuilt = false;               << 
 78   _fDisplayThreshold = 0;                      << 
 79 }                                              << 
 80                                                    66 
 81 // ------------------------------------------- <<  67 ////////////////////////////////////////////////////////
 82 G4VUserPhysicsList::G4VUserPhysicsList()           68 G4VUserPhysicsList::G4VUserPhysicsList()
                                                   >>  69                    :verboseLevel(1),
                                                   >>  70         fRetrievePhysicsTable(false),
                                                   >>  71         fStoredInAscii(true),
                                                   >>  72         fIsCheckedForRetrievePhysicsTable(false),
                                                   >>  73         fIsRestoredCutValues(false),
                                                   >>  74                     directoryPhysicsTable("."),
                                                   >>  75                     fDisplayThreshold(0)
 83 {                                                  76 {
 84   g4vuplInstanceID = subInstanceManager.Create << 
 85   // default cut value  (1.0mm)                    77   // default cut value  (1.0mm)
 86   defaultCutValue = 1.0 * mm;                  <<  78   defaultCutValue = 1.0*mm;
 87                                                    79 
 88   // pointer to the particle table                 80   // pointer to the particle table
 89   theParticleTable = G4ParticleTable::GetParti     81   theParticleTable = G4ParticleTable::GetParticleTable();
                                                   >>  82   theParticleIterator = theParticleTable->GetIterator();
 90                                                    83 
 91   // pointer to the cuts table                     84   // pointer to the cuts table
 92   fCutsTable = G4ProductionCutsTable::GetProdu <<  85   fCutsTable =  G4ProductionCutsTable::GetProductionCutsTable();
 93                                                    86 
 94   // set energy range for SetCut calcuration       87   // set energy range for SetCut calcuration
 95   fCutsTable->SetEnergyRange(0.99 * keV, 100 * <<  88   fCutsTable->SetEnergyRange(0.99*keV, 100*TeV);
 96                                                    89 
 97   // UI Messenger                                  90   // UI Messenger
 98   G4MT_theMessenger = new G4UserPhysicsListMes <<  91   theMessenger = new G4UserPhysicsListMessenger(this);
 99                                                << 
100   // PhysicsListHelper                         << 
101   G4MT_thePLHelper->SetVerboseLevel(verboseLev << 
102                                                << 
103   fIsPhysicsTableBuilt = false;                << 
104   fDisplayThreshold = 0;                       << 
105 }                                                  92 }
106                                                    93 
107 // ------------------------------------------- <<  94 ////////////////////////////////////////////////////////
108 void G4VUserPhysicsList::InitializeWorker()    <<  95 G4VUserPhysicsList::~G4VUserPhysicsList()
109 {                                                  96 {
110   // Remember messengers are per-thread, so th <<  97   if (theMessenger != 0) {
111   // worker and due to the presence of "this"  <<  98     delete theMessenger;
112   // G4VUPLData::initialize()                  <<  99     theMessenger = 0;
113   G4MT_theMessenger = new G4UserPhysicsListMes << 100   }
114 }                                                 101 }
115                                                   102 
116 // ------------------------------------------- << 103 ////////////////////////////////////////////////////////
117 void G4VUserPhysicsList::TerminateWorker()     << 104 void G4VUserPhysicsList::SetVerboseLevel(G4int value)
118 {                                                 105 {
119   RemoveProcessManager();                      << 106   verboseLevel = value;
120   RemoveTrackingManager();                     << 107   // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList: 
121   delete G4MT_theMessenger;                    << 108   fCutsTable->SetVerboseLevel(value);
122   G4MT_theMessenger = nullptr;                 << 109 
                                                   >> 110 #ifdef G4VERBOSE
                                                   >> 111   if (verboseLevel >1){
                                                   >> 112     G4cout << "G4VUserPhysicsList::SetVerboseLevel  :";
                                                   >> 113     G4cout << " Verbose level is set to " << verboseLevel << G4endl;
                                                   >> 114   }
                                                   >> 115 #endif
123 }                                                 116 }
124                                                   117 
125 // ------------------------------------------- << 118 ////////////////////////////////////////////////////////
126 G4VUserPhysicsList::~G4VUserPhysicsList()      << 119 void G4VUserPhysicsList::AddProcessManager(G4ParticleDefinition* newParticle,
                                                   >> 120              G4ProcessManager*     newManager)
127 {                                                 121 {
128   delete G4MT_theMessenger;                    << 122   if (newParticle == 0) return;
129   G4MT_theMessenger = nullptr;                 << 123   if (newParticle->GetProcessManager() != 0) {
                                                   >> 124 #ifdef G4VERBOSE
                                                   >> 125     if (verboseLevel >1){
                                                   >> 126       G4cout << "G4VUserPhysicsList::AddProcessManager: ";
                                                   >> 127       G4cout  << newParticle->GetParticleName();
                                                   >> 128       G4cout << " already has ProcessManager " << G4endl;
                                                   >> 129     }
                                                   >> 130 #endif
                                                   >> 131     return;
                                                   >> 132   }
130                                                   133 
131   RemoveProcessManager();                      << 134   // create new process manager if newManager  == 0
132   RemoveTrackingManager();                     << 135   if (newManager  == 0){
                                                   >> 136     // Add ProcessManager
                                                   >> 137     if (newParticle->GetParticleType() == "nucleus") {
                                                   >> 138       // Create a copy of the process manager of "GenericIon" in case of "nucleus"
                                                   >> 139       G4ParticleDefinition* genericIon =
                                                   >> 140      (G4ParticleTable::GetParticleTable())->FindParticle("GenericIon");
133                                                   141 
134   // invoke DeleteAllParticle                  << 142       if (genericIon != 0) {
135   theParticleTable->DeleteAllParticles();      << 143   G4ProcessManager* ionMan = genericIon->GetProcessManager();
136 }                                              << 144   if (ionMan != 0) {
137                                                << 145     newManager = new G4ProcessManager(*ionMan);
138 // ------------------------------------------- << 146   } else {
139 G4VUserPhysicsList::G4VUserPhysicsList(const G << 147     // no process manager has been registered yet
140   : verboseLevel(right.verboseLevel),          << 148     newManager = new G4ProcessManager(newParticle);
141     defaultCutValue(right.defaultCutValue),    << 149   }
142     isSetDefaultCutValue(right.isSetDefaultCut << 150       } else {
143     fRetrievePhysicsTable(right.fRetrievePhysi << 151   // "GenericIon" does not exist
144     fStoredInAscii(right.fStoredInAscii),      << 152   newManager = new G4ProcessManager(newParticle);
145     fIsCheckedForRetrievePhysicsTable(right.fI << 153       }
146     fIsRestoredCutValues(right.fIsRestoredCutV << 
147     directoryPhysicsTable(right.directoryPhysi << 
148     fDisableCheckParticleList(right.fDisableCh << 
149 {                                              << 
150   g4vuplInstanceID = subInstanceManager.Create << 
151   // pointer to the particle table             << 
152   theParticleTable = G4ParticleTable::GetParti << 
153   theParticleIterator = theParticleTable->GetI << 
154   // pointer to the cuts table                 << 
155   fCutsTable = G4ProductionCutsTable::GetProdu << 
156                                                   154 
157   // UI Messenger                              << 155     } else {
158   G4MT_theMessenger = new G4UserPhysicsListMes << 156       // create process manager for particles other than "nucleus"
                                                   >> 157       newManager = new G4ProcessManager(newParticle);
                                                   >> 158     }
                                                   >> 159   }
159                                                   160 
160   // PhysicsListHelper                         << 161   // set particle type
161   G4MT_thePLHelper = G4PhysicsListHelper::GetP << 162   newManager->SetParticleType(newParticle);
162   G4MT_thePLHelper->SetVerboseLevel(verboseLev << 
163                                                   163 
164   fIsPhysicsTableBuilt =                       << 164   // add the process manager
165     right.GetSubInstanceManager().offset[right << 165   newParticle->SetProcessManager(newManager);
166   fDisplayThreshold =                          << 
167     right.GetSubInstanceManager().offset[right << 
168 }                                              << 
169                                                   166 
170 // ------------------------------------------- << 167 #ifdef G4VERBOSE
171 G4VUserPhysicsList& G4VUserPhysicsList::operat << 168  if (verboseLevel >2){
172 {                                              << 169     G4cout << "G4VUserPhysicsList::AddProcessManager: ";
173   if (this != &right) {                        << 170     G4cout  << "adds ProcessManager to ";
174     verboseLevel = right.verboseLevel;         << 171     G4cout  << newParticle->GetParticleName() << G4endl;
175     defaultCutValue = right.defaultCutValue;   << 172     newManager->DumpInfo();
176     isSetDefaultCutValue = right.isSetDefaultC << 173   }
177     fRetrievePhysicsTable = right.fRetrievePhy << 174 #endif
178     fStoredInAscii = right.fStoredInAscii;     << 175   if (newParticle->GetParticleType() == "nucleus") {
179     fIsCheckedForRetrievePhysicsTable = right. << 176     PreparePhysicsTable(newParticle);
180     fIsRestoredCutValues = right.fIsRestoredCu << 177     BuildPhysicsTable(newParticle);
181     directoryPhysicsTable = right.directoryPhy << 
182     fIsPhysicsTableBuilt =                     << 
183       right.GetSubInstanceManager().offset[rig << 
184     fDisplayThreshold =                        << 
185       right.GetSubInstanceManager().offset[rig << 
186     fDisableCheckParticleList = right.fDisable << 
187   }                                               178   }
188   return *this;                                << 
189 }                                                 179 }
190                                                   180 
191 // ------------------------------------------- << 
192 void G4VUserPhysicsList::AddProcessManager(G4P << 
193 {                                              << 
194   if (newParticle == nullptr) return;          << 
195   G4Exception("G4VUserPhysicsList::AddProcessM << 
196               "This method is obsolete");      << 
197 }                                              << 
198                                                   181 
199 // ------------------------------------------- << 182 ////////////////////////////////////////////////////////
200 void G4VUserPhysicsList::InitializeProcessMana    183 void G4VUserPhysicsList::InitializeProcessManager()
201 {                                                 184 {
202   // Request lock for particle table access. S << 
203   // this critical region.                     << 
204 #ifdef G4MULTITHREADED                         << 
205   G4MUTEXLOCK(&G4ParticleTable::particleTableM << 
206   G4ParticleTable::lockCount()++;              << 
207 #endif                                         << 
208   G4ParticleDefinition* gion = G4ParticleTable << 
209                                                << 
210   // loop over all particles in G4ParticleTabl    185   // loop over all particles in G4ParticleTable
211   theParticleIterator->reset();                   186   theParticleIterator->reset();
212   while ((*theParticleIterator)()) {           << 187   while( (*theParticleIterator)() ){
213     G4ParticleDefinition* particle = thePartic    188     G4ParticleDefinition* particle = theParticleIterator->value();
214     G4ProcessManager* pmanager = particle->Get    189     G4ProcessManager* pmanager = particle->GetProcessManager();
215                                                << 190     if  (pmanager==0) {
216     if (pmanager == nullptr) {                 << 191       // create process manager if the particle has no its one
217       // create process manager if the particl << 
218       pmanager = new G4ProcessManager(particle    192       pmanager = new G4ProcessManager(particle);
219       particle->SetProcessManager(pmanager);      193       particle->SetProcessManager(pmanager);
220       if (particle->GetMasterProcessManager()  << 
221         particle->SetMasterProcessManager(pman << 
222 #ifdef G4VERBOSE                               << 
223       if (verboseLevel > 2) {                  << 
224         G4cout << "G4VUserPhysicsList::Initial << 
225                   "ProcessManager to "         << 
226                << particle->GetParticleName()  << 
227       }                                        << 
228 #endif                                         << 
229     }                                             194     }
230   }                                               195   }
231                                                << 
232   if (gion != nullptr) {                       << 
233     G4ProcessManager* gionPM = gion->GetProces << 
234     // loop over all particles once again (thi << 
235     theParticleIterator->reset(false);         << 
236     while ((*theParticleIterator)()) {         << 
237       G4ParticleDefinition* particle = thePart << 
238       if (particle->IsGeneralIon()) {          << 
239         particle->SetProcessManager(gionPM);   << 
240 #ifdef G4VERBOSE                               << 
241         if (verboseLevel > 2) {                << 
242           G4cout << "G4VUserPhysicsList::Initi << 
243                     "ProcessManager to "       << 
244                  << particle->GetParticleName( << 
245         }                                      << 
246 #endif                                         << 
247       }                                        << 
248     }                                          << 
249   }                                            << 
250                                                << 
251   // release lock for particle table access    << 
252 #ifdef G4MULTITHREADED                         << 
253   G4MUTEXUNLOCK(&G4ParticleTable::particleTabl << 
254 #endif                                         << 
255 }                                                 196 }
256                                                   197 
257 // ------------------------------------------- << 198 ////////////////////////////////////////////////////////
258 void G4VUserPhysicsList::RemoveProcessManager(    199 void G4VUserPhysicsList::RemoveProcessManager()
259 {                                                 200 {
260   // Request lock for particle table access. S << 
261   // this critical region.                     << 
262 #ifdef G4MULTITHREADED                         << 
263   G4MUTEXLOCK(&G4ParticleTable::particleTableM << 
264   G4ParticleTable::lockCount()++;              << 
265 #endif                                         << 
266                                                << 
267   // loop over all particles in G4ParticleTabl    201   // loop over all particles in G4ParticleTable
268   theParticleIterator->reset();                   202   theParticleIterator->reset();
269   while ((*theParticleIterator)()) {           << 203   while( (*theParticleIterator)() ){
270     G4ParticleDefinition* particle = thePartic    204     G4ParticleDefinition* particle = theParticleIterator->value();
271     if (particle->GetInstanceID() < G4Particle << 205     G4ProcessManager* pmanager = particle->GetProcessManager();
272       if (particle->GetParticleSubType() != "g << 206     if  (pmanager!=0) delete pmanager;
273           || particle->GetParticleName() == "G << 207     particle->SetProcessManager(0);
274       {                                        << 208 #ifdef G4VERBOSE
275         G4ProcessManager* pmanager = particle- << 209     if (verboseLevel >2){
276                                                << 210       G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
277         delete pmanager;                       << 211       G4cout  << "remove ProcessManager from ";
278 #ifdef G4VERBOSE                               << 212       G4cout  << particle->GetParticleName() << G4endl;
279         if (verboseLevel > 2) {                << 
280           G4cout << "G4VUserPhysicsList::Remov << 
281           G4cout << "remove ProcessManager fro << 
282           G4cout << particle->GetParticleName( << 
283         }                                      << 
284 #endif                                         << 
285       }                                        << 
286       particle->SetProcessManager(nullptr);    << 
287     }                                             213     }
288   }                                            << 
289                                                << 
290   // release lock for particle table access    << 
291 #ifdef G4MULTITHREADED                         << 
292   G4MUTEXUNLOCK(&G4ParticleTable::particleTabl << 
293 #endif                                            214 #endif
                                                   >> 215   }
294 }                                                 216 }
295                                                   217 
296 // ------------------------------------------- << 218 
297 void G4VUserPhysicsList::RemoveTrackingManager << 219 ////////////////////////////////////////////////////////
                                                   >> 220 #include "G4Transportation.hh"
                                                   >> 221 void G4VUserPhysicsList::AddTransportation()
298 {                                                 222 {
299   // One tracking manager may be registered fo << 223   G4Transportation* theTransportationProcess= new G4Transportation();
300   // to delete every object only once.         << 224 
301   std::unordered_set<G4VTrackingManager*> trac << 225 #ifdef G4VERBOSE
                                                   >> 226     if (verboseLevel >2){
                                                   >> 227       G4cout << "G4VUserPhysicsList::AddTransportation()  "<< G4endl;
                                                   >> 228     }
                                                   >> 229 #endif
302                                                   230 
303   // loop over all particles in G4ParticleTabl    231   // loop over all particles in G4ParticleTable
304   theParticleIterator->reset();                   232   theParticleIterator->reset();
305   while ((*theParticleIterator)()) {           << 233   while( (*theParticleIterator)() ){
306     G4ParticleDefinition* particle = thePartic    234     G4ParticleDefinition* particle = theParticleIterator->value();
307     if (auto* trackingManager = particle->GetT << 235     G4ProcessManager* pmanager = particle->GetProcessManager();
308 #ifdef G4VERBOSE                               << 236     if (!particle->IsShortLived()) {
309       if (verboseLevel > 2) {                  << 237       // Add transportation process for all particles other than  "shortlived"
310         G4cout << "G4VUserPhysicsList::RemoveT << 238       if ( pmanager == 0) {
311         G4cout << "remove TrackingManager from << 239   // Error !! no process manager
312         G4cout << particle->GetParticleName()  << 240   G4String particleName = particle->GetParticleName();
                                                   >> 241   G4Exception("G4VUserPhysicsList::AddTransportation","No process manager",
                                                   >> 242         RunMustBeAborted, particleName );
                                                   >> 243       } else {
                                                   >> 244   // add transportation with ordering = ( -1, "first", "first" )
                                                   >> 245   pmanager ->AddProcess(theTransportationProcess);
                                                   >> 246   pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
                                                   >> 247   pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
313       }                                           248       }
314 #endif                                         << 249     } else {
315       trackingManagers.insert(trackingManager) << 250       // shortlived particle case
316       particle->SetTrackingManager(nullptr);   << 
317     }                                             251     }
318   }                                               252   }
319                                                << 
320   for (G4VTrackingManager* tm : trackingManage << 
321     delete tm;                                 << 
322   }                                            << 
323 }                                                 253 }
324                                                   254 
325 // ------------------------------------------- << 
326 void G4VUserPhysicsList::SetCuts()             << 
327 {                                              << 
328   if (!isSetDefaultCutValue) {                 << 
329     SetDefaultCutValue(defaultCutValue);       << 
330   }                                            << 
331                                                   255 
332 #ifdef G4VERBOSE                               << 256 ////////////////////////////////////////////////////////
333   if (verboseLevel > 1) {                      << 
334     G4cout << "G4VUserPhysicsList::SetCuts:    << 
335     G4cout << "Cut for gamma: " << GetCutValue << 
336     G4cout << "Cut  for e-: " << GetCutValue(" << 
337     G4cout << "Cut  for e+: " << GetCutValue(" << 
338     G4cout << "Cut  for proton: " << GetCutVal << 
339   }                                            << 
340 #endif                                         << 
341                                                << 
342   // dump Cut values if verboseLevel==3        << 
343   if (verboseLevel > 2) {                      << 
344     DumpCutValuesTable();                      << 
345   }                                            << 
346 }                                              << 
347                                                << 
348 // ------------------------------------------- << 
349 void G4VUserPhysicsList::SetDefaultCutValue(G4    257 void G4VUserPhysicsList::SetDefaultCutValue(G4double value)
350 {                                                 258 {
351   if (value < 0.0) {                           << 259    if (value<=0.0) {
352 #ifdef G4VERBOSE                                  260 #ifdef G4VERBOSE
353     if (verboseLevel > 0) {                    << 261      if (verboseLevel >0){
354       G4cout << "G4VUserPhysicsList::SetDefaul << 262        G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values";
355              << "  :" << value / mm << "[mm]"  << 263        G4cout << "  :" << value/mm << "[mm]" << G4endl;
356     }                                          << 264      }
357 #endif                                            265 #endif
358     return;                                    << 266    } else {
359   }                                            << 
360                                                << 
361   defaultCutValue = value;                     << 
362   isSetDefaultCutValue = true;                 << 
363                                                << 
364   // set cut values for gamma at first and for << 
365   SetCutValue(defaultCutValue, "gamma");       << 
366   SetCutValue(defaultCutValue, "e-");          << 
367   SetCutValue(defaultCutValue, "e+");          << 
368   SetCutValue(defaultCutValue, "proton");      << 
369                                                << 
370 #ifdef G4VERBOSE                                  267 #ifdef G4VERBOSE
371   if (verboseLevel > 1) {                      << 268      if (verboseLevel >1){
372     G4cout << "G4VUserPhysicsList::SetDefaultC << 269        G4cout << "G4VUserPhysicsList::SetDefaultCutValue:";
373            << "default cut value is changed to << 270        G4cout << "default cut value is changed to   :" ;
374   }                                            << 271        G4cout << value/mm << "[mm]" << G4endl;
                                                   >> 272      }
375 #endif                                            273 #endif
376 }                                              << 274      defaultCutValue = value;
377                                                   275 
378 // ------------------------------------------- << 276    }
379 G4double G4VUserPhysicsList::GetCutValue(const << 
380 {                                              << 
381   std::size_t nReg = (G4RegionStore::GetInstan << 
382   if (nReg == 0) {                             << 
383 #ifdef G4VERBOSE                               << 
384     if (verboseLevel > 0) {                    << 
385       G4cout << "G4VUserPhysicsList::GetCutVal << 
386              << " : No Default Region " << G4e << 
387     }                                          << 
388 #endif                                         << 
389     G4Exception("G4VUserPhysicsList::GetCutVal << 
390     return -1. * mm;                           << 
391   }                                            << 
392   G4Region* region = G4RegionStore::GetInstanc << 
393   return region->GetProductionCuts()->GetProdu << 
394 }                                                 277 }
395                                                   278 
396 // ------------------------------------------- << 279 
                                                   >> 280 ////////////////////////////////////////////////////////
397 void G4VUserPhysicsList::SetCutValue(G4double     281 void G4VUserPhysicsList::SetCutValue(G4double aCut, const G4String& name)
398 {                                                 282 {
399   SetParticleCuts(aCut, name);                 << 283   G4ParticleDefinition* particle = theParticleTable->FindParticle(name);
                                                   >> 284   if (particle != 0){
                                                   >> 285     if (!particle->IsShortLived()) {
                                                   >> 286       //set cut value
                                                   >> 287       SetParticleCuts( aCut ,particle );
                                                   >> 288     }
                                                   >> 289   }
400 }                                                 290 }
401                                                   291 
402 // ------------------------------------------- << 292 ////////////////////////////////////////////////////////
403 void G4VUserPhysicsList::SetCutValue(G4double  << 293 void G4VUserPhysicsList::SetCutValue
                                                   >> 294 (G4double aCut, const G4String& pname, const G4String& rname)
404 {                                                 295 {
                                                   >> 296   G4ParticleDefinition* particle = theParticleTable->FindParticle(pname);
405   G4Region* region = G4RegionStore::GetInstanc    297   G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
406   if (region != nullptr) {                     << 298   if (particle != 0 && region != 0){
407     // set cut value                           << 299     if (!particle->IsShortLived()) {
408     SetParticleCuts(aCut, pname, region);      << 300       //set cut value
409   }                                            << 301       SetParticleCuts( aCut ,particle, region );
410   else {                                       << 
411 #ifdef G4VERBOSE                               << 
412     if (verboseLevel > 0) {                    << 
413       G4cout << "G4VUserPhysicsList::SetCutVal << 
414              << " : No Region of " << rname << << 
415     }                                             302     }
416 #endif                                         << 
417   }                                               303   }
418 }                                                 304 }
419                                                   305 
420 // ------------------------------------------- << 306 
                                                   >> 307 
                                                   >> 308 ////////////////////////////////////////////////////////
421 void G4VUserPhysicsList::SetCutsWithDefault()     309 void G4VUserPhysicsList::SetCutsWithDefault()
422 {                                                 310 {
423   SetDefaultCutValue(defaultCutValue);         << 311   // default cut value
424   G4VUserPhysicsList::SetCuts();               << 312   G4double cut = defaultCutValue;
                                                   >> 313 
                                                   >> 314 #ifdef G4VERBOSE
                                                   >> 315   if (verboseLevel >1){
                                                   >> 316     G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
                                                   >> 317     G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
                                                   >> 318   }
                                                   >> 319 #endif
                                                   >> 320 
                                                   >> 321   // set cut values for gamma at first and for e- and e+
                                                   >> 322   SetCutValue(cut, "gamma");
                                                   >> 323   SetCutValue(cut, "e-");
                                                   >> 324   SetCutValue(cut, "e+");
                                                   >> 325 
                                                   >> 326   // dump Cut values if verboseLevel==3
                                                   >> 327   if (verboseLevel>2) {
                                                   >> 328     DumpCutValuesTable();
                                                   >> 329   }
425 }                                                 330 }
426                                                   331 
427 // ------------------------------------------- << 332 
                                                   >> 333 ////////////////////////////////////////////////////////
428 void G4VUserPhysicsList::SetCutsForRegion(G4do    334 void G4VUserPhysicsList::SetCutsForRegion(G4double aCut, const G4String& rname)
429 {                                                 335 {
430   // set cut values for gamma at first and for    336   // set cut values for gamma at first and for e- and e+
431   SetCutValue(aCut, "gamma", rname);              337   SetCutValue(aCut, "gamma", rname);
432   SetCutValue(aCut, "e-", rname);                 338   SetCutValue(aCut, "e-", rname);
433   SetCutValue(aCut, "e+", rname);                 339   SetCutValue(aCut, "e+", rname);
434   SetCutValue(aCut, "proton", rname);          << 
435 }                                                 340 }
436                                                   341 
437 // ------------------------------------------- << 
438 void G4VUserPhysicsList::SetParticleCuts(G4dou << 
439                                          G4Reg << 
440 {                                              << 
441   SetParticleCuts(cut, particle->GetParticleNa << 
442 }                                              << 
443                                                   342 
444 // ------------------------------------------- << 
445 void G4VUserPhysicsList::SetParticleCuts(G4dou << 
446                                          G4Reg << 
447 {                                              << 
448   if (cut < 0.0) {                             << 
449 #ifdef G4VERBOSE                               << 
450     if (verboseLevel > 0) {                    << 
451       G4cout << "G4VUserPhysicsList::SetPartic << 
452              << "  :" << cut / mm << "[mm]"    << 
453              << " for " << particleName << G4e << 
454     }                                          << 
455 #endif                                         << 
456     return;                                    << 
457   }                                            << 
458                                                << 
459   G4Region* world_region =                     << 
460     G4RegionStore::GetInstance()->GetRegion("D << 
461   if (region == nullptr) {                     << 
462     std::size_t nReg = G4RegionStore::GetInsta << 
463     if (nReg == 0) {                           << 
464 #ifdef G4VERBOSE                               << 
465       if (verboseLevel > 0) {                  << 
466         G4cout << "G4VUserPhysicsList::SetPart << 
467                << " : No Default Region " << G << 
468       }                                        << 
469 #endif                                         << 
470       G4Exception("G4VUserPhysicsList::SetPart << 
471                   "No Default Region");        << 
472       return;                                  << 
473     }                                          << 
474     region = world_region;                     << 
475   }                                            << 
476                                                << 
477   if (!isSetDefaultCutValue) {                 << 
478     SetDefaultCutValue(defaultCutValue);       << 
479   }                                            << 
480                                                   343 
                                                   >> 344 ////////////////////////////////////////////////////////
                                                   >> 345 ////////////////////////////////////////////////////////
                                                   >> 346 void G4VUserPhysicsList::SetParticleCuts( G4double cut, G4ParticleDefinition* particle, G4Region* region)
                                                   >> 347 {
                                                   >> 348   if(!region) region = (*(G4RegionStore::GetInstance()))[0];
481   G4ProductionCuts* pcuts = region->GetProduct    349   G4ProductionCuts* pcuts = region->GetProductionCuts();
482   if (region != world_region                   << 350   pcuts->SetProductionCut(cut,particle);
483       && pcuts == G4ProductionCutsTable::GetPr << 
484   {  // This region had no unique cuts yet but << 
485      // Need to create a new object before set << 
486     pcuts = new G4ProductionCuts(              << 
487       *(G4ProductionCutsTable::GetProductionCu << 
488     region->SetProductionCuts(pcuts);          << 
489   }                                            << 
490   pcuts->SetProductionCut(cut, particleName);  << 
491 #ifdef G4VERBOSE                               << 
492   if (verboseLevel > 2) {                      << 
493     G4cout << "G4VUserPhysicsList::SetParticle << 
494            << "  :" << cut / mm << "[mm]"      << 
495            << " for " << particleName << G4end << 
496   }                                            << 
497 #endif                                         << 
498 }                                                 351 }
499                                                   352 
500 // ------------------------------------------- << 353 ///////////////////////////////////////////////////////////////
501 void G4VUserPhysicsList::BuildPhysicsTable()      354 void G4VUserPhysicsList::BuildPhysicsTable()
502 {                                                 355 {
503   // Prepare Physics table for all particles   << 356   //Prepare Physics table for all particles 
504   theParticleIterator->reset();                   357   theParticleIterator->reset();
505   while ((*theParticleIterator)()) {           << 358   while( (*theParticleIterator)() ){
506     G4ParticleDefinition* particle = thePartic    359     G4ParticleDefinition* particle = theParticleIterator->value();
507     PreparePhysicsTable(particle);             << 360     PreparePhysicsTable(particle); 
508   }                                               361   }
509                                                   362 
510   // ask processes to prepare physics table    << 363   // ask processes to prepare physics table 
511   if (fRetrievePhysicsTable) {                    364   if (fRetrievePhysicsTable) {
512     fIsRestoredCutValues = fCutsTable->Retriev    365     fIsRestoredCutValues = fCutsTable->RetrieveCutsTable(directoryPhysicsTable, fStoredInAscii);
513     // check if retrieve Cut Table successfull    366     // check if retrieve Cut Table successfully
514     if (!fIsRestoredCutValues) {                  367     if (!fIsRestoredCutValues) {
515 #ifdef G4VERBOSE                                  368 #ifdef G4VERBOSE
516       if (verboseLevel > 0) {                  << 369       if (verboseLevel>0){
517         G4cout << "G4VUserPhysicsList::BuildPh << 370   G4cout << "G4VUserPhysicsList::BuildPhysicsTable";
518                << " Retrieve Cut Table failed  << 371   G4cout << " Retrieve Cut Table failed !!" << G4endl;
519       }                                        << 372       }
520 #endif                                         << 373 #endif  
521       G4Exception("G4VUserPhysicsList::BuildPh << 374       G4Exception("G4VUserPhysicsList::BuildPhysicsTable","Fail to Retreive",
522                   "Fail to retrieve Production << 375       RunMustBeAborted,"Production Cut Table can not be retreived");
523     }                                          << 376     } else {
524     else {                                     << 377 #ifdef G4VERBOSE
525 #ifdef G4VERBOSE                               << 378       if (verboseLevel>2){
526       if (verboseLevel > 2) {                  << 379   G4cout << "G4VUserPhysicsList::BuildPhysicsTable";
527         G4cout << "G4VUserPhysicsList::BuildPh << 380   G4cout << "  Retrieve Cut Table successfully " << G4endl;
528                << "  Retrieve Cut Table succes << 381       }
529       }                                        << 382 #endif 
530 #endif                                         << 383     }     
531     }                                          << 384   } else {
532   }                                            << 385 #ifdef G4VERBOSE
533   else {                                       << 386     if (verboseLevel>2){
534 #ifdef G4VERBOSE                               << 387       G4cout << "G4VUserPhysicsList::BuildPhysicsTable";
535     if (verboseLevel > 2) {                    << 388       G4cout << " does not retrieve Cut Table but calculate " << G4endl;
536       G4cout << "G4VUserPhysicsList::BuildPhys << 389     } 
537              << " does not retrieve Cut Table  << 390 #endif      
538     }                                          << 
539 #endif                                         << 
540   }                                               391   }
541                                                   392 
542   // Sets a value to particle                     393   // Sets a value to particle
543   // set cut values for gamma at first and for    394   // set cut values for gamma at first and for e- and e+
544   G4String particleName;                          395   G4String particleName;
545   G4ParticleDefinition* GammaP = theParticleTa    396   G4ParticleDefinition* GammaP = theParticleTable->FindParticle("gamma");
546   if (GammaP != nullptr) BuildPhysicsTable(Gam << 397   if(GammaP) BuildPhysicsTable(GammaP);
547   G4ParticleDefinition* EMinusP = theParticleT    398   G4ParticleDefinition* EMinusP = theParticleTable->FindParticle("e-");
548   if (EMinusP != nullptr) BuildPhysicsTable(EM << 399   if(EMinusP) BuildPhysicsTable(EMinusP);
549   G4ParticleDefinition* EPlusP = theParticleTa    400   G4ParticleDefinition* EPlusP = theParticleTable->FindParticle("e+");
550   if (EPlusP != nullptr) BuildPhysicsTable(EPl << 401   if(EPlusP) BuildPhysicsTable(EPlusP);
551   G4ParticleDefinition* ProtonP = theParticleT    402   G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
552   if (ProtonP != nullptr) BuildPhysicsTable(Pr << 403   if(ProtonP) BuildPhysicsTable(ProtonP);
                                                   >> 404 
553                                                   405 
554   theParticleIterator->reset();                   406   theParticleIterator->reset();
555   while ((*theParticleIterator)()) {           << 407   while( (*theParticleIterator)() ){
556     G4ParticleDefinition* particle = thePartic    408     G4ParticleDefinition* particle = theParticleIterator->value();
557     if (particle != GammaP && particle != EMin << 409     if( particle!=GammaP && 
558       BuildPhysicsTable(particle);             << 410   particle!=EMinusP && 
                                                   >> 411   particle!=EPlusP && 
                                                   >> 412   particle!=ProtonP   ){
                                                   >> 413       BuildPhysicsTable(particle); 
559     }                                             414     }
560   }                                               415   }
561                                                << 
562   // Set flag                                  << 
563   fIsPhysicsTableBuilt = true;                 << 
564 }                                                 416 }
565                                                << 417 ///////////////////////////////////////////////////////////////
566 // ------------------------------------------- << 
567 void G4VUserPhysicsList::BuildPhysicsTable(G4P    418 void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle)
568 {                                                 419 {
569   if (auto* trackingManager = particle->GetTra << 
570 #ifdef G4VERBOSE                               << 
571     if (verboseLevel > 2) {                    << 
572       G4cout << "G4VUserPhysicsList::BuildPhys << 
573              << "Calculate Physics Table for " << 
574              << " via custom TrackingManager"  << 
575     }                                          << 
576 #endif                                         << 
577     trackingManager->BuildPhysicsTable(*partic << 
578     return;                                    << 
579   }                                            << 
580                                                << 
581   // Change in order to share physics tables f << 
582                                                << 
583   if (particle->GetMasterProcessManager() == n << 
584 #ifdef G4VERBOSE                               << 
585     if (verboseLevel > 0) {                    << 
586       G4cout << "#### G4VUserPhysicsList::Buil << 
587              << particle->GetParticleName() << << 
588     }                                          << 
589 #endif                                         << 
590     return;                                    << 
591   }                                            << 
592   if (fRetrievePhysicsTable) {                    420   if (fRetrievePhysicsTable) {
593     if (!fIsRestoredCutValues) {               << 421     if ( !fIsRestoredCutValues){
594       // fail to retrieve cut tables           << 422       // fail to retreive cut tables
595 #ifdef G4VERBOSE                                  423 #ifdef G4VERBOSE
596       if (verboseLevel > 0) {                  << 424       if (verboseLevel>0){
597         G4cout << "G4VUserPhysicsList::BuildPh << 425   G4cout << "G4VUserPhysicsList::BuildPhysicsTable  ";
598                << "Physics table can not be re << 426   G4cout << "Physics table can not be retreived and will be calculated "<< G4endl;
599       }                                           427       }
600 #endif                                            428 #endif
601       fRetrievePhysicsTable = false;           << 429       fRetrievePhysicsTable = false; 
602     }                                          << 430 
603     else {                                     << 431     } else {
604 #ifdef G4VERBOSE                                  432 #ifdef G4VERBOSE
605       if (verboseLevel > 2) {                  << 433       if (verboseLevel>2){
606         G4cout << "G4VUserPhysicsList::BuildPh << 434   G4cout << "G4VUserPhysicsList::BuildPhysicsTable  ";
607                << " Retrieve Physics Table for << 435   G4cout << " Retrieve Physics Table for ";
                                                   >> 436   G4cout << particle->GetParticleName() << G4endl;
608       }                                           437       }
609 #endif                                            438 #endif
610       //  Retrieve PhysicsTable from files for    439       //  Retrieve PhysicsTable from files for proccesses
611       RetrievePhysicsTable(particle, directory    440       RetrievePhysicsTable(particle, directoryPhysicsTable, fStoredInAscii);
612     }                                             441     }
613   }                                               442   }
614                                                   443 
615 #ifdef G4VERBOSE                                  444 #ifdef G4VERBOSE
616   if (verboseLevel > 2) {                      << 445   if (verboseLevel>2){
617     G4cout << "G4VUserPhysicsList::BuildPhysic << 446     G4cout << "G4VUserPhysicsList::BuildPhysicsTable  ";
618            << "Calculate Physics Table for " < << 447     G4cout << "Calculate Physics Table for " << particle->GetParticleName() << G4endl;
619   }                                               448   }
620 #endif                                            449 #endif
621   // Rebuild the physics tables for every proc    450   // Rebuild the physics tables for every process for this particle type
622   // if particle is not ShortLived                451   // if particle is not ShortLived
623   if (!particle->IsShortLived()) {             << 452   if(!particle->IsShortLived()) {
624     G4ProcessManager* pManager = particle->Get << 453     G4ProcessVector* pVector = particle->GetProcessManager()->GetProcessList();
625     if (pManager == nullptr) {                 << 454     for (G4int j=0; j < pVector->size(); ++j) {
626 #ifdef G4VERBOSE                               << 455       (*pVector)[j]->BuildPhysicsTable(*particle);
627       if (verboseLevel > 0) {                  << 
628         G4cout << "G4VUserPhysicsList::BuildPh << 
629                << " : No Process Manager for " << 
630         G4cout << particle->GetParticleName()  << 
631       }                                        << 
632 #endif                                         << 
633       G4Exception("G4VUserPhysicsList::BuildPh << 
634                   "No process manager");       << 
635       return;                                  << 
636     }                                          << 
637                                                << 
638     // Get processes from master thread;       << 
639     G4ProcessManager* pManagerShadow = particl << 
640                                                << 
641     G4ProcessVector* pVector = pManager->GetPr << 
642     if (pVector == nullptr) {                  << 
643 #ifdef G4VERBOSE                               << 
644       if (verboseLevel > 0) {                  << 
645         G4cout << "G4VUserPhysicsList::BuildPh << 
646                << " : No Process Vector for "  << 
647       }                                        << 
648 #endif                                         << 
649       G4Exception("G4VUserPhysicsList::BuildPh << 
650                   "No process Vector");        << 
651       return;                                  << 
652     }                                          << 
653 #ifdef G4VERBOSE                               << 
654     if (verboseLevel > 2) {                    << 
655       G4cout << "G4VUserPhysicsList::BuildPhys << 
656              << G4endl;                        << 
657       G4cout << " ProcessManager : " << pManag << 
658              << G4endl;                        << 
659       for (G4int iv1 = 0; iv1 < (G4int)pVector << 
660         G4cout << "  " << iv1 << " - " << (*pV << 
661       }                                        << 
662       G4cout << "----------------------------- << 
663       G4ProcessVector* pVectorShadow = pManage << 
664                                                << 
665       for (G4int iv2 = 0; iv2 < (G4int)pVector << 
666         G4cout << "  " << iv2 << " - " << (*pV << 
667       }                                        << 
668     }                                             456     }
669 #endif                                         << 457   }
670     for (G4int j = 0; j < (G4int)pVector->size << 
671       // Andrea July 16th 2013 : migration to  << 
672       // Infer if we are in a worker thread or << 
673       // Master thread is the one in which the << 
674       // and process manager shadow pointers a << 
675       if (pManagerShadow == pManager) {        << 
676         (*pVector)[j]->BuildPhysicsTable(*part << 
677       }                                        << 
678       else {                                   << 
679         (*pVector)[j]->BuildWorkerPhysicsTable << 
680       }                                        << 
681                                                << 
682     }  // End loop on processes vector         << 
683   }  // End if short-lived                     << 
684 }                                                 458 }
685                                                   459 
686 // ------------------------------------------- << 460 ///////////////////////////////////////////////////////////////
687 void G4VUserPhysicsList::PreparePhysicsTable(G    461 void G4VUserPhysicsList::PreparePhysicsTable(G4ParticleDefinition* particle)
688 {                                                 462 {
689   if (auto* trackingManager = particle->GetTra << 
690     trackingManager->PreparePhysicsTable(*part << 
691     return;                                    << 
692   }                                            << 
693                                                << 
694   if ((particle->GetMasterProcessManager()) == << 
695     return;                                    << 
696   }                                            << 
697   // Prepare the physics tables for every proc    463   // Prepare the physics tables for every process for this particle type
698   // if particle is not ShortLived                464   // if particle is not ShortLived
699   if (!particle->IsShortLived()) {             << 465   if(!particle->IsShortLived()) {
700     G4ProcessManager* pManager = particle->Get << 466     G4ProcessVector* pVector = particle->GetProcessManager()->GetProcessList();
701     if (pManager == nullptr) {                 << 467     for (G4int j=0; j < pVector->size(); ++j) {
702 #ifdef G4VERBOSE                               << 468       (*pVector)[j]->PreparePhysicsTable(*particle);
703       if (verboseLevel > 0) {                  << 
704         G4cout << "G4VUserPhysicsList::Prepare << 
705                << ": No Process Manager for "  << 
706         G4cout << particle->GetParticleName()  << 
707       }                                        << 
708 #endif                                         << 
709       G4Exception("G4VUserPhysicsList::Prepare << 
710                   "No process manager");       << 
711       return;                                  << 
712     }                                             469     }
713                                                << 470   }
714     // Get processes from master thread        << 
715     G4ProcessManager* pManagerShadow = particl << 
716                                                << 
717     G4ProcessVector* pVector = pManager->GetPr << 
718     if (pVector == nullptr) {                  << 
719 #ifdef G4VERBOSE                               << 
720       if (verboseLevel > 0) {                  << 
721         G4cout << "G4VUserPhysicsList::Prepare << 
722                << ": No Process Vector for " < << 
723       }                                        << 
724 #endif                                         << 
725       G4Exception("G4VUserPhysicsList::Prepare << 
726                   "No process Vector");        << 
727       return;                                  << 
728     }                                          << 
729     for (G4int j = 0; j < (G4int)pVector->size << 
730       // Andrea July 16th 2013 : migration to  << 
731       // Infer if we are in a worker thread or << 
732       // Master thread is the one in which the << 
733       // and process manager shadow pointers a << 
734       if (pManagerShadow == pManager) {        << 
735         (*pVector)[j]->PreparePhysicsTable(*pa << 
736       }                                        << 
737       else {                                   << 
738         (*pVector)[j]->PrepareWorkerPhysicsTab << 
739       }                                        << 
740     }  // End loop on processes vector         << 
741   }  // End if pn ShortLived                   << 
742 }                                                 471 }
743                                                   472 
744 // ------------------------------------------- << 473 ///////////////////////////////////////////////////////////////
745 void G4VUserPhysicsList::BuildIntegralPhysicsT << 474 void  G4VUserPhysicsList::BuildIntegralPhysicsTable(G4VProcess* process,
746                                                << 475                 G4ParticleDefinition* particle)
747 {                                                 476 {
748   // TODO Should we change this function?      << 477   //*********************************************************************
749   //****************************************** << 478   // temporary addition to make the integral schema of electromagnetic
750   // Temporary addition to make the integral s << 
751   // processes work.                              479   // processes work.
                                                   >> 480   //
752                                                   481 
753   if ((process->GetProcessName() == "Imsc") || << 482   if ( (process->GetProcessName() == "Imsc") ||
754       || (process->GetProcessName() == "IeBrem << 483        (process->GetProcessName() == "IeIoni") ||
755       || (process->GetProcessName() == "IhIoni << 484        (process->GetProcessName() == "IeBrems") ||
756       || (process->GetProcessName() == "IMuBre << 485        (process->GetProcessName() == "Iannihil") ||
757   {                                            << 486        (process->GetProcessName() == "IhIoni") ||
758 #ifdef G4VERBOSE                               << 487        (process->GetProcessName() == "IMuIoni") ||
759     if (verboseLevel > 2) {                    << 488        (process->GetProcessName() == "IMuBrems") ||
760       G4cout << "G4VUserPhysicsList::BuildInte << 489        (process->GetProcessName() == "IMuPairProd")  ) {
761              << " BuildPhysicsTable is invoked << 490 #ifdef G4VERBOSE
762              << particle->GetParticleName() << << 491     if (verboseLevel>2){
                                                   >> 492       G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable  ";
                                                   >> 493       G4cout << " BuildPhysicsTable is invoked for ";
                                                   >> 494       G4cout << process->GetProcessName();
                                                   >> 495       G4cout << "(" << particle->GetParticleName() << ")" << G4endl;
763     }                                             496     }
764 #endif                                            497 #endif
765     process->BuildPhysicsTable(*particle);        498     process->BuildPhysicsTable(*particle);
766   }                                               499   }
767 }                                                 500 }
768                                                   501 
769 // ------------------------------------------- << 502 ///////////////////////////////////////////////////////////////
770 void G4VUserPhysicsList::DumpList() const         503 void G4VUserPhysicsList::DumpList() const
771 {                                                 504 {
772   theParticleIterator->reset();                   505   theParticleIterator->reset();
773   G4int idx = 0;                                  506   G4int idx = 0;
774   while ((*theParticleIterator)()) {           << 507   while( (*theParticleIterator)() ){
775     G4ParticleDefinition* particle = thePartic    508     G4ParticleDefinition* particle = theParticleIterator->value();
776     G4cout << particle->GetParticleName();        509     G4cout << particle->GetParticleName();
777     if ((idx++ % 4) == 3) {                       510     if ((idx++ % 4) == 3) {
778       G4cout << G4endl;                           511       G4cout << G4endl;
779     }                                          << 512     } else {
780     else {                                     << 
781       G4cout << ", ";                             513       G4cout << ", ";
782     }                                          << 514     }      
783   }                                               515   }
784   G4cout << G4endl;                               516   G4cout << G4endl;
785 }                                                 517 }
786                                                   518 
787 // ------------------------------------------- << 519 
788 void G4VUserPhysicsList::DumpCutValuesTable(G4 << 520 
789 {                                              << 521 ///////////////////////////////////////////////////////////////
790   fDisplayThreshold = flag;                    << 522 void G4VUserPhysicsList::DumpCutValuesTable(G4int nParticles) 
                                                   >> 523 { 
                                                   >> 524   fDisplayThreshold = nParticles; 
791 }                                                 525 }
792                                                   526 
793 // ------------------------------------------- << 527 ///////////////////////////////////////////////////////////////
794 void G4VUserPhysicsList::DumpCutValuesTableIfR    528 void G4VUserPhysicsList::DumpCutValuesTableIfRequested()
795 {                                                 529 {
796   if (fDisplayThreshold == 0) return;          << 530   if(fDisplayThreshold==0) return;
797   G4ProductionCutsTable::GetProductionCutsTabl    531   G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples();
798   fDisplayThreshold = 0;                          532   fDisplayThreshold = 0;
799 }                                                 533 }
800                                                   534 
801 // ------------------------------------------- << 535 
                                                   >> 536 ///////////////////////////////////////////////////////////////
                                                   >> 537 ///////////////////////////////////////////////////////////////
802 G4bool G4VUserPhysicsList::StorePhysicsTable(c    538 G4bool G4VUserPhysicsList::StorePhysicsTable(const G4String& directory)
803 {                                                 539 {
804   G4bool ascii = fStoredInAscii;               << 540   G4bool   ascii = fStoredInAscii;
805   G4String dir = directory;                    << 541   G4String dir   = directory;
806   if (dir.empty())                             << 542   if (dir.isNull()) dir = directoryPhysicsTable; 
807     dir = directoryPhysicsTable;               << 543   else directoryPhysicsTable = dir; 
808   else                                         << 544   
809     directoryPhysicsTable = dir;               << 
810                                                << 
811   // store CutsTable info                         545   // store CutsTable info
812   if (!fCutsTable->StoreCutsTable(dir, ascii))    546   if (!fCutsTable->StoreCutsTable(dir, ascii)) {
813     G4Exception("G4VUserPhysicsList::StorePhys << 547     G4Exception("G4VUserPhysicsList::StorePhysicsTable","Faile to store ",
814                 "Fail to store Cut Table");    << 548     JustWarning,"Cut Table can not be stored");   
815     return false;                                 549     return false;
816   }                                               550   }
817 #ifdef G4VERBOSE                               << 551 #ifdef G4VERBOSE  
818   if (verboseLevel > 2) {                      << 552   if (verboseLevel>2){
819     G4cout << "G4VUserPhysicsList::StorePhysic << 553     G4cout << "G4VUserPhysicsList::StorePhysicsTable   ";
820            << " Store material and cut values  << 554     G4cout << " Store material and cut values successfully" << G4endl;
821   }                                               555   }
822 #endif                                            556 #endif
823                                                   557 
824   G4bool success = true;                       << 558   G4bool success= true;
825                                                   559 
826   // loop over all particles in G4ParticleTabl << 560   // loop over all particles in G4ParticleTable 
827   theParticleIterator->reset();                   561   theParticleIterator->reset();
828   while ((*theParticleIterator)()) {           << 562   while( (*theParticleIterator)() ){
829     G4ParticleDefinition* particle = thePartic    563     G4ParticleDefinition* particle = theParticleIterator->value();
830     // Store physics tables for every process     564     // Store physics tables for every process for this particle type
831     G4ProcessVector* pVector = (particle->GetP    565     G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
832     for (G4int j = 0; j < (G4int)pVector->size << 566     G4int  j;
833       if (!(*pVector)[j]->StorePhysicsTable(pa << 567     for ( j=0; j < pVector->size(); ++j) {
834         G4String comment = "Fail to store phys << 568       if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){   
835         comment += (*pVector)[j]->GetProcessNa << 569   G4String comment =  "Fail to store for " + (*pVector)[j]->GetProcessName();
836         comment += "(" + particle->GetParticle << 570   comment += "(" + particle->GetParticleName()  + ")";
837         G4Exception("G4VUserPhysicsList::Store << 571   G4Exception("G4VUserPhysicsList::StorePhysicsTable","Faile to store ",
838         success = false;                       << 572         JustWarning,comment);   
                                                   >> 573   success = false;
839       }                                           574       }
840     }                                             575     }
841     // end loop over processes                    576     // end loop over processes
842   }                                               577   }
843   // end loop over particles                      578   // end loop over particles
844   return success;                                 579   return success;
845 }                                                 580 }
846                                                   581 
847 // ------------------------------------------- << 582 
848 void G4VUserPhysicsList::SetPhysicsTableRetrie << 583 
                                                   >> 584 ///////////////////////////////////////////////////////////////
                                                   >> 585 void  G4VUserPhysicsList::SetPhysicsTableRetrieved(const G4String& directory)
849 {                                                 586 {
850   fRetrievePhysicsTable = true;                   587   fRetrievePhysicsTable = true;
851   if (!directory.empty()) {                    << 588   if(!directory.isNull()) {
852     directoryPhysicsTable = directory;            589     directoryPhysicsTable = directory;
853   }                                               590   }
854   fIsCheckedForRetrievePhysicsTable = false;   << 591   fIsCheckedForRetrievePhysicsTable=false;
855   fIsRestoredCutValues = false;                   592   fIsRestoredCutValues = false;
856 }                                                 593 }
857                                                   594 
858 // ------------------------------------------- << 595 ///////////////////////////////////////////////////////////////
859 void G4VUserPhysicsList::RetrievePhysicsTable( << 596 void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle, 
860                                                << 597                 const G4String& directory,
                                                   >> 598                 G4bool          ascii)
861 {                                                 599 {
862   G4bool success[100];                         << 600   G4int  j;
                                                   >> 601   G4bool success[100];  
863   // Retrieve physics tables for every process    602   // Retrieve physics tables for every process for this particle type
864   G4ProcessVector* pVector = (particle->GetPro    603   G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
865   for (G4int j = 0; j < (G4int)pVector->size() << 604   for ( j=0; j < pVector->size(); ++j) {
866     success[j] = (*pVector)[j]->RetrievePhysic << 605     success[j] = 
                                                   >> 606        (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii);
867                                                   607 
868     if (!success[j]) {                            608     if (!success[j]) {
869 #ifdef G4VERBOSE                               << 609 #ifdef G4VERBOSE  
870       if (verboseLevel > 2) {                  << 610       if (verboseLevel>2){
871         G4cout << "G4VUserPhysicsList::Retriev << 611   G4cout << "G4VUserPhysicsList::RetrievePhysicsTable   ";
872                << " Fail to retrieve Physics T << 612   G4cout << " Fail to retrieve Physics Table for ";
873                << G4endl;                      << 613         G4cout << (*pVector)[j]->GetProcessName() << G4endl;
874         G4cout << "Calculate Physics Table for << 614   G4cout << "Calculate Physics Table for " << particle->GetParticleName() << G4endl;
875       }                                           615       }
876 #endif                                            616 #endif
877       (*pVector)[j]->BuildPhysicsTable(*partic    617       (*pVector)[j]->BuildPhysicsTable(*particle);
878     }                                             618     }
879   }                                               619   }
880   for (G4int j = 0; j < (G4int)pVector->size() << 620   for ( j=0; j < pVector->size(); ++j) {
881     // temporary addition to make the integral    621     // temporary addition to make the integral schema
882     if (!success[j]) BuildIntegralPhysicsTable << 622     if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle); 
883   }                                               623   }
884 }                                                 624 }
885                                                   625 
886 // ------------------------------------------- << 626 void G4VUserPhysicsList::ResetCuts()
                                                   >> 627 {
                                                   >> 628 #ifdef G4VERBOSE  
                                                   >> 629   if (verboseLevel>0){
                                                   >> 630     G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete.";
                                                   >> 631     G4cout << " This method gives no effect and you can remove it. "<< G4endl;
                                                   >> 632   }
                                                   >> 633 #endif
                                                   >> 634 }
                                                   >> 635 
887 void G4VUserPhysicsList::SetApplyCuts(G4bool v    636 void G4VUserPhysicsList::SetApplyCuts(G4bool value, const G4String& name)
888 {                                                 637 {
889 #ifdef G4VERBOSE                               << 638 #ifdef G4VERBOSE  
890   if (verboseLevel > 2) {                      << 639   if (verboseLevel>2){
891     G4cout << "G4VUserPhysicsList::SetApplyCut    640     G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
892   }                                               641   }
893 #endif                                            642 #endif
894   if (name == "all") {                         << 643   if(name=="all") {
895     theParticleTable->FindParticle("gamma")->S    644     theParticleTable->FindParticle("gamma")->SetApplyCutsFlag(value);
896     theParticleTable->FindParticle("e-")->SetA    645     theParticleTable->FindParticle("e-")->SetApplyCutsFlag(value);
897     theParticleTable->FindParticle("e+")->SetA    646     theParticleTable->FindParticle("e+")->SetApplyCutsFlag(value);
898     theParticleTable->FindParticle("proton")-> << 647   } else {
899   }                                            << 
900   else {                                       << 
901     theParticleTable->FindParticle(name)->SetA    648     theParticleTable->FindParticle(name)->SetApplyCutsFlag(value);
902   }                                               649   }
903 }                                                 650 }
904                                                   651 
905 // ------------------------------------------- << 
906 G4bool G4VUserPhysicsList::GetApplyCuts(const     652 G4bool G4VUserPhysicsList::GetApplyCuts(const G4String& name) const
907 {                                                 653 {
908   return theParticleTable->FindParticle(name)-    654   return theParticleTable->FindParticle(name)->GetApplyCutsFlag();
909 }                                                 655 }
910                                                   656 
911 // ------------------------------------------- << 
912 void G4VUserPhysicsList::CheckParticleList()   << 
913 {                                              << 
914   if (!fDisableCheckParticleList) {            << 
915     G4MT_thePLHelper->CheckParticleList();     << 
916   }                                            << 
917 }                                              << 
918                                                   657 
919 // ------------------------------------------- << 
920 void G4VUserPhysicsList::AddTransportation()   << 
921 {                                              << 
922   G4MT_thePLHelper->AddTransportation();       << 
923 }                                              << 
924                                                   658 
925 // ------------------------------------------- << 
926 void G4VUserPhysicsList::UseCoupledTransportat << 
927 {                                              << 
928   G4MT_thePLHelper->UseCoupledTransportation(v << 
929 }                                              << 
930                                                   659 
931 // ------------------------------------------- << 660 /// obsolete methods
932 G4bool G4VUserPhysicsList::RegisterProcess(G4V << 
933 {                                              << 
934   return G4MT_thePLHelper->RegisterProcess(pro << 
935 }                                              << 
936                                                   661 
937 // ------------------------------------------- << 662 
938 G4ParticleTable::G4PTblDicIterator* G4VUserPhy << 663 void G4VUserPhysicsList::DumpCutValues(const G4String &particle_name)
939 {                                                 664 {
940   return (subInstanceManager.offset[g4vuplInst << 665   G4cerr << "WARNING !" << G4endl;
                                                   >> 666   G4cerr << " Obsolete DumpCutValues() method is invoked for " << particle_name << G4endl;
                                                   >> 667   G4cerr << " Please use DumpCutValuesTable() instead." << G4endl;
                                                   >> 668   G4cerr << " This dummy method implementation will be removed soon." << G4endl;
                                                   >> 669   DumpCutValuesTable();
941 }                                                 670 }
942                                                   671 
943 // ------------------------------------------- << 672 void G4VUserPhysicsList::DumpCutValues(G4ParticleDefinition* )
944 void G4VUserPhysicsList::SetVerboseLevel(G4int << 
945 {                                                 673 {
946   verboseLevel = value;                        << 674   G4cerr << "WARNING !" << G4endl;
947   // set verboseLevel for G4ProductionCutsTabl << 675   G4cerr << " DumpCutValues() became obsolete." << G4endl;
948   // G4VUserPhysicsList:                       << 676   G4cerr << " Please use DumpCutValuesTable() instead." << G4endl;
949   fCutsTable->SetVerboseLevel(verboseLevel);   << 677   G4cerr << " This dummy method implementation will be removed soon." << G4endl;
                                                   >> 678   DumpCutValuesTable();
                                                   >> 679 }
950                                                   680 
951   G4MT_thePLHelper->SetVerboseLevel(verboseLev << 
952                                                   681 
953 #ifdef G4VERBOSE                               << 
954   if (verboseLevel > 1) {                      << 
955     G4cout << "G4VUserPhysicsList::SetVerboseL << 
956            << " Verbose level is set to " << v << 
957   }                                            << 
958 #endif                                         << 
959 }                                              << 
960                                                   682