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 10.7.p3)


  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 //
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 // ------------------------------------------------------------
                                                   >>  30 //  GEANT 4 class header file
                                                   >>  31 //
                                                   >>  32 // ------------------------------------------------------------
                                                   >>  33 //  History
                                                   >>  34 //       first version                    09 Jan 1998 by H.Kurashige
                                                   >>  35 //       Added SetEnergyRange             18 Jun 1998 by H.Kurashige
                                                   >>  36 //       Change for short lived particles 27 Jun 1998 by H.Kurashige
                                                   >>  37 //       G4BestUnit on output             12 nov 1998 by M.Maire
                                                   >>  38 //       Added RemoveProcessManager        9 Feb 1999 by H.Kurashige
                                                   >>  39 //       Fixed RemoveProcessManager       15 Apr 1999 by H.Kurashige
                                                   >>  40 //       Removed ConstructAllParticles()  15 Apr 1999 by H.Kurashige
                                                   >>  41 //       Modified for CUTS per REGION     10 Oct 2002 by H.Kurashige
                                                   >>  42 //       Check if particle IsShortLived   18 Jun 2003 by V.Ivanchenko
                                                   >>  43 //       Modify PreparePhysicsList        18 Jan 2006 by H.Kurashige
                                                   >>  44 //       Added PhysicsListHelper           29 APr. 2011 H.Kurashige
                                                   >>  45 //       Added default impelmentation of SetCuts 10 June 2011 H.Kurashige
                                                   >>  46 //           SetCuts is not 'pure virtual' any more
                                                   >>  47 //       Transformation for G4MT         26 Mar 2013 A. Dotti
                                                   >>  48 //           PL is shared by threads. Adding a method for workers
                                                   >>  49 //           To initialize thread specific data
                                                   >>  50 // ------------------------------------------------------------
 30                                                    51 
                                                   >>  52 #include <fstream>
                                                   >>  53 #include <iomanip>
                                                   >>  54 
                                                   >>  55 #include "G4PhysicsListHelper.hh"
 31 #include "G4VUserPhysicsList.hh"                   56 #include "G4VUserPhysicsList.hh"
 32                                                    57 
                                                   >>  58 // Andrea Dotti (Jan 13, 2013), transformation for G4MT
                                                   >>  59 #include "G4VEnergyLossProcess.hh"
                                                   >>  60 #include "G4VMultipleScattering.hh"
                                                   >>  61 
 33 #include "G4Material.hh"                           62 #include "G4Material.hh"
 34 #include "G4MaterialCutsCouple.hh"                 63 #include "G4MaterialCutsCouple.hh"
 35 #include "G4ParticleDefinition.hh"                 64 #include "G4ParticleDefinition.hh"
 36 #include "G4ParticleTable.hh"                      65 #include "G4ParticleTable.hh"
 37 #include "G4PhysicsListHelper.hh"              << 
 38 #include "G4ProcessManager.hh"                     66 #include "G4ProcessManager.hh"
 39 #include "G4ProductionCuts.hh"                     67 #include "G4ProductionCuts.hh"
 40 #include "G4ProductionCutsTable.hh"                68 #include "G4ProductionCutsTable.hh"
 41 #include "G4Region.hh"                             69 #include "G4Region.hh"
 42 #include "G4RegionStore.hh"                        70 #include "G4RegionStore.hh"
 43 #include "G4SystemOfUnits.hh"                      71 #include "G4SystemOfUnits.hh"
 44 #include "G4UImanager.hh"                          72 #include "G4UImanager.hh"
 45 #include "G4UnitsTable.hh"                         73 #include "G4UnitsTable.hh"
 46 #include "G4UserPhysicsListMessenger.hh"           74 #include "G4UserPhysicsListMessenger.hh"
 47 #include "G4VTrackingManager.hh"               << 
 48 #include "G4ios.hh"                                75 #include "G4ios.hh"
 49 #include "globals.hh"                              76 #include "globals.hh"
 50                                                    77 
 51 #include <fstream>                             << 
 52 #include <iomanip>                             << 
 53 #include <unordered_set>                       << 
 54                                                << 
 55 // This static member is thread local. For eac     78 // This static member is thread local. For each thread, it holds the array
 56 // size of G4VUPLData instances.                   79 // size of G4VUPLData instances.
 57 //                                                 80 //
 58 #define G4MT_theMessenger ((this->subInstanceM <<  81 #define G4MT_theMessenger                                                      \
 59 #define G4MT_thePLHelper ((this->subInstanceMa <<  82   ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
 60 #define fIsPhysicsTableBuilt \                 <<  83 #define G4MT_thePLHelper                                                       \
 61   ((this->subInstanceManager.offset[this->g4vu <<  84   ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
 62 #define fDisplayThreshold \                    <<  85 #define fIsPhysicsTableBuilt                                                   \
                                                   >>  86   ((this->subInstanceManager.offset[this->g4vuplInstanceID])                   \
                                                   >>  87      ._fIsPhysicsTableBuilt)
                                                   >>  88 #define fDisplayThreshold                                                      \
 63   ((this->subInstanceManager.offset[this->g4vu     89   ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
 64 #define theParticleIterator \                  <<  90 #define theParticleIterator                                                    \
 65   ((this->subInstanceManager.offset[this->g4vu <<  91   ((this->subInstanceManager.offset[this->g4vuplInstanceID])                   \
                                                   >>  92      ._theParticleIterator)
 66                                                    93 
 67 // This field helps to use the class G4VUPLMan     94 // This field helps to use the class G4VUPLManager
 68 //                                                 95 //
 69 G4VUPLManager G4VUserPhysicsList::subInstanceM     96 G4VUPLManager G4VUserPhysicsList::subInstanceManager;
 70                                                    97 
 71 // ------------------------------------------- << 
 72 void G4VUPLData::initialize()                      98 void G4VUPLData::initialize()
 73 {                                                  99 {
 74   _theParticleIterator = G4ParticleTable::GetP << 100   _theParticleIterator  = G4ParticleTable::GetParticleTable()->GetIterator();
 75   _theMessenger = nullptr;                     << 101   _theMessenger         = 0;
 76   _thePLHelper = G4PhysicsListHelper::GetPhysi << 102   _thePLHelper          = G4PhysicsListHelper::GetPhysicsListHelper();
 77   _fIsPhysicsTableBuilt = false;                  103   _fIsPhysicsTableBuilt = false;
 78   _fDisplayThreshold = 0;                      << 104   _fDisplayThreshold    = 0;
 79 }                                                 105 }
 80                                                   106 
 81 // ------------------------------------------- << 107 ////////////////////////////////////////////////////////
 82 G4VUserPhysicsList::G4VUserPhysicsList()          108 G4VUserPhysicsList::G4VUserPhysicsList()
                                                   >> 109   : verboseLevel(1)
                                                   >> 110   , defaultCutValue(1.0 * mm)
                                                   >> 111   , isSetDefaultCutValue(false)
                                                   >> 112   , fRetrievePhysicsTable(false)
                                                   >> 113   , fStoredInAscii(true)
                                                   >> 114   , fIsCheckedForRetrievePhysicsTable(false)
                                                   >> 115   , fIsRestoredCutValues(false)
                                                   >> 116   , directoryPhysicsTable(".")
                                                   >> 117   ,
                                                   >> 118   // fDisplayThreshold(0),
                                                   >> 119   // fIsPhysicsTableBuilt(false),
                                                   >> 120   fDisableCheckParticleList(false)
 83 {                                                 121 {
 84   g4vuplInstanceID = subInstanceManager.Create    122   g4vuplInstanceID = subInstanceManager.CreateSubInstance();  // AND
 85   // default cut value  (1.0mm)                   123   // default cut value  (1.0mm)
 86   defaultCutValue = 1.0 * mm;                     124   defaultCutValue = 1.0 * mm;
 87                                                   125 
 88   // pointer to the particle table                126   // pointer to the particle table
 89   theParticleTable = G4ParticleTable::GetParti    127   theParticleTable = G4ParticleTable::GetParticleTable();
                                                   >> 128   // theParticleIterator = theParticleTable->GetIterator();
 90                                                   129 
 91   // pointer to the cuts table                    130   // pointer to the cuts table
 92   fCutsTable = G4ProductionCutsTable::GetProdu    131   fCutsTable = G4ProductionCutsTable::GetProductionCutsTable();
 93                                                   132 
 94   // set energy range for SetCut calcuration      133   // set energy range for SetCut calcuration
 95   fCutsTable->SetEnergyRange(0.99 * keV, 100 *    134   fCutsTable->SetEnergyRange(0.99 * keV, 100 * TeV);
 96                                                   135 
 97   // UI Messenger                                 136   // UI Messenger
                                                   >> 137   // theMessenger = new G4UserPhysicsListMessenger(this);
 98   G4MT_theMessenger = new G4UserPhysicsListMes    138   G4MT_theMessenger = new G4UserPhysicsListMessenger(this);  // AND
 99                                                   139 
100   // PhysicsListHelper                            140   // PhysicsListHelper
                                                   >> 141   // thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
                                                   >> 142   // thePLHelper->SetVerboseLevel(verboseLevel);
                                                   >> 143   // G4MT_thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper(); //AND
101   G4MT_thePLHelper->SetVerboseLevel(verboseLev    144   G4MT_thePLHelper->SetVerboseLevel(verboseLevel);  // AND
102                                                   145 
103   fIsPhysicsTableBuilt = false;                   146   fIsPhysicsTableBuilt = false;
104   fDisplayThreshold = 0;                       << 147   fDisplayThreshold    = 0;
105 }                                                 148 }
106                                                   149 
107 // ------------------------------------------- << 
108 void G4VUserPhysicsList::InitializeWorker()       150 void G4VUserPhysicsList::InitializeWorker()
109 {                                                 151 {
110   // Remember messengers are per-thread, so th << 152   // Remember messengers are per-thread, so this needs to be done by each worker
111   // worker and due to the presence of "this"  << 153   // and due to the presence of "this" cannot be done in
112   // G4VUPLData::initialize()                     154   // G4VUPLData::initialize()
113   G4MT_theMessenger = new G4UserPhysicsListMes    155   G4MT_theMessenger = new G4UserPhysicsListMessenger(this);
114 }                                                 156 }
115                                                   157 
116 // ------------------------------------------- << 
117 void G4VUserPhysicsList::TerminateWorker()        158 void G4VUserPhysicsList::TerminateWorker()
118 {                                                 159 {
119   RemoveProcessManager();                         160   RemoveProcessManager();
120   RemoveTrackingManager();                     << 
121   delete G4MT_theMessenger;                       161   delete G4MT_theMessenger;
122   G4MT_theMessenger = nullptr;                    162   G4MT_theMessenger = nullptr;
123 }                                                 163 }
124                                                << 164 ////////////////////////////////////////////////////////
125 // ------------------------------------------- << 
126 G4VUserPhysicsList::~G4VUserPhysicsList()         165 G4VUserPhysicsList::~G4VUserPhysicsList()
127 {                                                 166 {
128   delete G4MT_theMessenger;                    << 167   if(G4MT_theMessenger != 0)
129   G4MT_theMessenger = nullptr;                 << 168   {
130                                                << 169     delete G4MT_theMessenger;
                                                   >> 170     G4MT_theMessenger = 0;
                                                   >> 171   }
131   RemoveProcessManager();                         172   RemoveProcessManager();
132   RemoveTrackingManager();                     << 
133                                                   173 
134   // invoke DeleteAllParticle                     174   // invoke DeleteAllParticle
135   theParticleTable->DeleteAllParticles();         175   theParticleTable->DeleteAllParticles();
136 }                                                 176 }
137                                                   177 
138 // ------------------------------------------- << 178 ////////////////////////////////////////////////////////
139 G4VUserPhysicsList::G4VUserPhysicsList(const G    179 G4VUserPhysicsList::G4VUserPhysicsList(const G4VUserPhysicsList& right)
140   : verboseLevel(right.verboseLevel),          << 180   : verboseLevel(right.verboseLevel)
141     defaultCutValue(right.defaultCutValue),    << 181   , defaultCutValue(right.defaultCutValue)
142     isSetDefaultCutValue(right.isSetDefaultCut << 182   , isSetDefaultCutValue(right.isSetDefaultCutValue)
143     fRetrievePhysicsTable(right.fRetrievePhysi << 183   , fRetrievePhysicsTable(right.fRetrievePhysicsTable)
144     fStoredInAscii(right.fStoredInAscii),      << 184   , fStoredInAscii(right.fStoredInAscii)
145     fIsCheckedForRetrievePhysicsTable(right.fI << 185   , fIsCheckedForRetrievePhysicsTable(right.fIsCheckedForRetrievePhysicsTable)
146     fIsRestoredCutValues(right.fIsRestoredCutV << 186   , fIsRestoredCutValues(right.fIsRestoredCutValues)
147     directoryPhysicsTable(right.directoryPhysi << 187   , directoryPhysicsTable(right.directoryPhysicsTable)
148     fDisableCheckParticleList(right.fDisableCh << 188   ,
                                                   >> 189   // fDisplayThreshold(right.fDisplayThreshold),
                                                   >> 190   // fIsPhysicsTableBuilt(right.fIsPhysicsTableBuilt),
                                                   >> 191   fDisableCheckParticleList(right.fDisableCheckParticleList)
149 {                                                 192 {
150   g4vuplInstanceID = subInstanceManager.Create << 193   g4vuplInstanceID = subInstanceManager.CreateSubInstance();  // AND
151   // pointer to the particle table                194   // pointer to the particle table
152   theParticleTable = G4ParticleTable::GetParti << 195   theParticleTable    = G4ParticleTable::GetParticleTable();
153   theParticleIterator = theParticleTable->GetI    196   theParticleIterator = theParticleTable->GetIterator();
154   // pointer to the cuts table                    197   // pointer to the cuts table
155   fCutsTable = G4ProductionCutsTable::GetProdu    198   fCutsTable = G4ProductionCutsTable::GetProductionCutsTable();
156                                                   199 
157   // UI Messenger                                 200   // UI Messenger
158   G4MT_theMessenger = new G4UserPhysicsListMes << 201   // theMessenger = new G4UserPhysicsListMessenger(this);
                                                   >> 202   G4MT_theMessenger = new G4UserPhysicsListMessenger(this);  // AND
159                                                   203 
160   // PhysicsListHelper                            204   // PhysicsListHelper
161   G4MT_thePLHelper = G4PhysicsListHelper::GetP << 205   // thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
162   G4MT_thePLHelper->SetVerboseLevel(verboseLev << 206   // thePLHelper->SetVerboseLevel(verboseLevel);
163                                                << 207   G4MT_thePLHelper = G4PhysicsListHelper::GetPhysicsListHelper();  // AND
164   fIsPhysicsTableBuilt =                       << 208   G4MT_thePLHelper->SetVerboseLevel(verboseLevel);                 // AND
165     right.GetSubInstanceManager().offset[right << 209 
166   fDisplayThreshold =                          << 210   fIsPhysicsTableBuilt = right.GetSubInstanceManager()
167     right.GetSubInstanceManager().offset[right << 211                            .offset[right.GetInstanceID()]
168 }                                              << 212                            ._fIsPhysicsTableBuilt;
169                                                << 213   fDisplayThreshold = right.GetSubInstanceManager()
170 // ------------------------------------------- << 214                         .offset[right.GetInstanceID()]
171 G4VUserPhysicsList& G4VUserPhysicsList::operat << 215                         ._fDisplayThreshold;
172 {                                              << 216 }
173   if (this != &right) {                        << 217 
174     verboseLevel = right.verboseLevel;         << 218 ////////////////////////////////////////////////////////
175     defaultCutValue = right.defaultCutValue;   << 219 G4VUserPhysicsList& G4VUserPhysicsList::operator=(
176     isSetDefaultCutValue = right.isSetDefaultC << 220   const G4VUserPhysicsList& right)
177     fRetrievePhysicsTable = right.fRetrievePhy << 221 {
178     fStoredInAscii = right.fStoredInAscii;     << 222   if(this != &right)
                                                   >> 223   {
                                                   >> 224     verboseLevel                      = right.verboseLevel;
                                                   >> 225     defaultCutValue                   = right.defaultCutValue;
                                                   >> 226     isSetDefaultCutValue              = right.isSetDefaultCutValue;
                                                   >> 227     fRetrievePhysicsTable             = right.fRetrievePhysicsTable;
                                                   >> 228     fStoredInAscii                    = right.fStoredInAscii;
179     fIsCheckedForRetrievePhysicsTable = right.    229     fIsCheckedForRetrievePhysicsTable = right.fIsCheckedForRetrievePhysicsTable;
180     fIsRestoredCutValues = right.fIsRestoredCu << 230     fIsRestoredCutValues              = right.fIsRestoredCutValues;
181     directoryPhysicsTable = right.directoryPhy << 231     directoryPhysicsTable             = right.directoryPhysicsTable;
182     fIsPhysicsTableBuilt =                     << 232     // fDisplayThreshold = right.fDisplayThreshold;
183       right.GetSubInstanceManager().offset[rig << 233     fIsPhysicsTableBuilt = right.GetSubInstanceManager()
184     fDisplayThreshold =                        << 234                              .offset[right.GetInstanceID()]
185       right.GetSubInstanceManager().offset[rig << 235                              ._fIsPhysicsTableBuilt;
                                                   >> 236     fDisplayThreshold = right.GetSubInstanceManager()
                                                   >> 237                           .offset[right.GetInstanceID()]
                                                   >> 238                           ._fDisplayThreshold;
                                                   >> 239     // fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
186     fDisableCheckParticleList = right.fDisable    240     fDisableCheckParticleList = right.fDisableCheckParticleList;
187   }                                               241   }
188   return *this;                                   242   return *this;
189 }                                                 243 }
190                                                   244 
191 // ------------------------------------------- << 245 ////////////////////////////////////////////////////////
192 void G4VUserPhysicsList::AddProcessManager(G4P << 246 void G4VUserPhysicsList::AddProcessManager(G4ParticleDefinition* newParticle,
                                                   >> 247                                            G4ProcessManager*)
193 {                                                 248 {
194   if (newParticle == nullptr) return;          << 249   if(newParticle == 0)
                                                   >> 250     return;
195   G4Exception("G4VUserPhysicsList::AddProcessM    251   G4Exception("G4VUserPhysicsList::AddProcessManager", "Run0252", JustWarning,
196               "This method is obsolete");         252               "This method is obsolete");
197 }                                                 253 }
198                                                   254 
199 // ------------------------------------------- << 255 ////////////////////////////////////////////////////////
200 void G4VUserPhysicsList::InitializeProcessMana    256 void G4VUserPhysicsList::InitializeProcessManager()
201 {                                                 257 {
202   // Request lock for particle table access. S << 258   // Request lock for particle table accesses. Some changes are inside
203   // this critical region.                        259   // this critical region.
204 #ifdef G4MULTITHREADED                            260 #ifdef G4MULTITHREADED
205   G4MUTEXLOCK(&G4ParticleTable::particleTableM    261   G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
206   G4ParticleTable::lockCount()++;                 262   G4ParticleTable::lockCount()++;
207 #endif                                            263 #endif
208   G4ParticleDefinition* gion = G4ParticleTable << 264   G4ParticleDefinition* gion =
                                                   >> 265     G4ParticleTable::GetParticleTable()->GetGenericIon();
209                                                   266 
210   // loop over all particles in G4ParticleTabl    267   // loop over all particles in G4ParticleTable
211   theParticleIterator->reset();                   268   theParticleIterator->reset();
212   while ((*theParticleIterator)()) {           << 269   while((*theParticleIterator)())
                                                   >> 270   {
213     G4ParticleDefinition* particle = thePartic    271     G4ParticleDefinition* particle = theParticleIterator->value();
214     G4ProcessManager* pmanager = particle->Get << 272     G4ProcessManager* pmanager     = particle->GetProcessManager();
215                                                   273 
216     if (pmanager == nullptr) {                 << 274     if(pmanager == 0)
                                                   >> 275     {
217       // create process manager if the particl    276       // create process manager if the particle does not have its own.
218       pmanager = new G4ProcessManager(particle    277       pmanager = new G4ProcessManager(particle);
219       particle->SetProcessManager(pmanager);      278       particle->SetProcessManager(pmanager);
220       if (particle->GetMasterProcessManager()  << 279       if(particle->GetMasterProcessManager() == 0)
221         particle->SetMasterProcessManager(pman    280         particle->SetMasterProcessManager(pmanager);
222 #ifdef G4VERBOSE                                  281 #ifdef G4VERBOSE
223       if (verboseLevel > 2) {                  << 282       if(verboseLevel > 2)
                                                   >> 283       {
224         G4cout << "G4VUserPhysicsList::Initial    284         G4cout << "G4VUserPhysicsList::InitializeProcessManager: creating "
225                   "ProcessManager to "            285                   "ProcessManager to "
226                << particle->GetParticleName()     286                << particle->GetParticleName() << G4endl;
227       }                                           287       }
228 #endif                                            288 #endif
229     }                                             289     }
230   }                                               290   }
231                                                   291 
232   if (gion != nullptr) {                       << 292   if(gion)
                                                   >> 293   {
233     G4ProcessManager* gionPM = gion->GetProces    294     G4ProcessManager* gionPM = gion->GetProcessManager();
234     // loop over all particles once again (thi    295     // loop over all particles once again (this time, with all general ions)
235     theParticleIterator->reset(false);            296     theParticleIterator->reset(false);
236     while ((*theParticleIterator)()) {         << 297     while((*theParticleIterator)())
                                                   >> 298     {
237       G4ParticleDefinition* particle = thePart    299       G4ParticleDefinition* particle = theParticleIterator->value();
238       if (particle->IsGeneralIon()) {          << 300       if(particle->IsGeneralIon())
                                                   >> 301       {
239         particle->SetProcessManager(gionPM);      302         particle->SetProcessManager(gionPM);
240 #ifdef G4VERBOSE                                  303 #ifdef G4VERBOSE
241         if (verboseLevel > 2) {                << 304         if(verboseLevel > 2)
                                                   >> 305         {
242           G4cout << "G4VUserPhysicsList::Initi    306           G4cout << "G4VUserPhysicsList::InitializeProcessManager: copying "
243                     "ProcessManager to "          307                     "ProcessManager to "
244                  << particle->GetParticleName(    308                  << particle->GetParticleName() << G4endl;
245         }                                         309         }
246 #endif                                            310 #endif
247       }                                           311       }
248     }                                             312     }
249   }                                               313   }
250                                                   314 
251   // release lock for particle table access    << 315   // release lock for particle table accesses.
252 #ifdef G4MULTITHREADED                            316 #ifdef G4MULTITHREADED
253   G4MUTEXUNLOCK(&G4ParticleTable::particleTabl    317   G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
254 #endif                                            318 #endif
                                                   >> 319   //  G4cout << "Particle table is released by
                                                   >> 320   //  G4VUserPhysicsList::InitializeProcessManager" << G4endl;
255 }                                                 321 }
256                                                   322 
257 // ------------------------------------------- << 323 /////////////////////////////////////////////////////////
258 void G4VUserPhysicsList::RemoveProcessManager(    324 void G4VUserPhysicsList::RemoveProcessManager()
259 {                                                 325 {
260   // Request lock for particle table access. S << 326   // Request lock for particle table accesses. Some changes are inside
261   // this critical region.                        327   // this critical region.
262 #ifdef G4MULTITHREADED                            328 #ifdef G4MULTITHREADED
263   G4MUTEXLOCK(&G4ParticleTable::particleTableM    329   G4MUTEXLOCK(&G4ParticleTable::particleTableMutex());
264   G4ParticleTable::lockCount()++;                 330   G4ParticleTable::lockCount()++;
265 #endif                                            331 #endif
                                                   >> 332   //  G4cout << "Particle table is held by
                                                   >> 333   //  G4VUserPhysicsList::InitializeProcessManager"
                                                   >> 334   //  << G4endl;
266                                                   335 
267   // loop over all particles in G4ParticleTabl    336   // loop over all particles in G4ParticleTable
268   theParticleIterator->reset();                   337   theParticleIterator->reset();
269   while ((*theParticleIterator)()) {           << 338   while((*theParticleIterator)())
                                                   >> 339   {
270     G4ParticleDefinition* particle = thePartic    340     G4ParticleDefinition* particle = theParticleIterator->value();
271     if (particle->GetInstanceID() < G4Particle << 341     if(particle->GetInstanceID() <
272       if (particle->GetParticleSubType() != "g << 342        G4ParticleDefinitionSubInstanceManager::slavetotalspace())
273           || particle->GetParticleName() == "G << 343     {
                                                   >> 344       if(particle->GetParticleSubType() != "generic" ||
                                                   >> 345          particle->GetParticleName() == "GenericIon")
274       {                                           346       {
275         G4ProcessManager* pmanager = particle-    347         G4ProcessManager* pmanager = particle->GetProcessManager();
276                                                << 348         if(pmanager != 0)
277         delete pmanager;                       << 349           delete pmanager;
278 #ifdef G4VERBOSE                                  350 #ifdef G4VERBOSE
279         if (verboseLevel > 2) {                << 351         if(verboseLevel > 2)
                                                   >> 352         {
280           G4cout << "G4VUserPhysicsList::Remov    353           G4cout << "G4VUserPhysicsList::RemoveProcessManager: ";
281           G4cout << "remove ProcessManager fro    354           G4cout << "remove ProcessManager from ";
282           G4cout << particle->GetParticleName(    355           G4cout << particle->GetParticleName() << G4endl;
283         }                                         356         }
284 #endif                                            357 #endif
285       }                                           358       }
286       particle->SetProcessManager(nullptr);    << 359       particle->SetProcessManager(0);
287     }                                             360     }
288   }                                               361   }
289                                                   362 
290   // release lock for particle table access    << 363   // release lock for particle table accesses.
291 #ifdef G4MULTITHREADED                            364 #ifdef G4MULTITHREADED
292   G4MUTEXUNLOCK(&G4ParticleTable::particleTabl    365   G4MUTEXUNLOCK(&G4ParticleTable::particleTableMutex());
293 #endif                                            366 #endif
                                                   >> 367   //  G4cout << "Particle table is released by
                                                   >> 368   //  G4VUserPhysicsList::InitializeProcessManager" << G4endl;
294 }                                                 369 }
295                                                   370 
296 // ------------------------------------------- << 371 ////////////////////////////////////////////////////////
297 void G4VUserPhysicsList::RemoveTrackingManager << 
298 {                                              << 
299   // One tracking manager may be registered fo << 
300   // to delete every object only once.         << 
301   std::unordered_set<G4VTrackingManager*> trac << 
302                                                << 
303   // loop over all particles in G4ParticleTabl << 
304   theParticleIterator->reset();                << 
305   while ((*theParticleIterator)()) {           << 
306     G4ParticleDefinition* particle = thePartic << 
307     if (auto* trackingManager = particle->GetT << 
308 #ifdef G4VERBOSE                               << 
309       if (verboseLevel > 2) {                  << 
310         G4cout << "G4VUserPhysicsList::RemoveT << 
311         G4cout << "remove TrackingManager from << 
312         G4cout << particle->GetParticleName()  << 
313       }                                        << 
314 #endif                                         << 
315       trackingManagers.insert(trackingManager) << 
316       particle->SetTrackingManager(nullptr);   << 
317     }                                          << 
318   }                                            << 
319                                                << 
320   for (G4VTrackingManager* tm : trackingManage << 
321     delete tm;                                 << 
322   }                                            << 
323 }                                              << 
324                                                << 
325 // ------------------------------------------- << 
326 void G4VUserPhysicsList::SetCuts()                372 void G4VUserPhysicsList::SetCuts()
327 {                                                 373 {
328   if (!isSetDefaultCutValue) {                 << 374   if(!isSetDefaultCutValue)
                                                   >> 375   {
329     SetDefaultCutValue(defaultCutValue);          376     SetDefaultCutValue(defaultCutValue);
330   }                                               377   }
331                                                   378 
332 #ifdef G4VERBOSE                                  379 #ifdef G4VERBOSE
333   if (verboseLevel > 1) {                      << 380   if(verboseLevel > 1)
                                                   >> 381   {
334     G4cout << "G4VUserPhysicsList::SetCuts:       382     G4cout << "G4VUserPhysicsList::SetCuts:   " << G4endl;
335     G4cout << "Cut for gamma: " << GetCutValue << 383     G4cout << "Cut for gamma: " << GetCutValue("gamma") / mm << "[mm]"
                                                   >> 384            << G4endl;
336     G4cout << "Cut  for e-: " << GetCutValue("    385     G4cout << "Cut  for e-: " << GetCutValue("e-") / mm << "[mm]" << G4endl;
337     G4cout << "Cut  for e+: " << GetCutValue("    386     G4cout << "Cut  for e+: " << GetCutValue("e+") / mm << "[mm]" << G4endl;
338     G4cout << "Cut  for proton: " << GetCutVal << 387     G4cout << "Cut  for proton: " << GetCutValue("proton") / mm << "[mm]"
                                                   >> 388            << G4endl;
339   }                                               389   }
340 #endif                                            390 #endif
341                                                   391 
342   // dump Cut values if verboseLevel==3           392   // dump Cut values if verboseLevel==3
343   if (verboseLevel > 2) {                      << 393   if(verboseLevel > 2)
                                                   >> 394   {
344     DumpCutValuesTable();                         395     DumpCutValuesTable();
345   }                                               396   }
346 }                                                 397 }
347                                                   398 
348 // ------------------------------------------- << 399 ////////////////////////////////////////////////////////
349 void G4VUserPhysicsList::SetDefaultCutValue(G4    400 void G4VUserPhysicsList::SetDefaultCutValue(G4double value)
350 {                                                 401 {
351   if (value < 0.0) {                           << 402   if(value < 0.0)
                                                   >> 403   {
352 #ifdef G4VERBOSE                                  404 #ifdef G4VERBOSE
353     if (verboseLevel > 0) {                    << 405     if(verboseLevel > 0)
                                                   >> 406     {
354       G4cout << "G4VUserPhysicsList::SetDefaul    407       G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"
355              << "  :" << value / mm << "[mm]"     408              << "  :" << value / mm << "[mm]" << G4endl;
356     }                                             409     }
357 #endif                                            410 #endif
358     return;                                       411     return;
359   }                                               412   }
360                                                   413 
361   defaultCutValue = value;                     << 414   defaultCutValue      = value;
362   isSetDefaultCutValue = true;                    415   isSetDefaultCutValue = true;
363                                                   416 
364   // set cut values for gamma at first and for    417   // set cut values for gamma at first and for e- and e+
365   SetCutValue(defaultCutValue, "gamma");          418   SetCutValue(defaultCutValue, "gamma");
366   SetCutValue(defaultCutValue, "e-");             419   SetCutValue(defaultCutValue, "e-");
367   SetCutValue(defaultCutValue, "e+");             420   SetCutValue(defaultCutValue, "e+");
368   SetCutValue(defaultCutValue, "proton");         421   SetCutValue(defaultCutValue, "proton");
369                                                   422 
370 #ifdef G4VERBOSE                                  423 #ifdef G4VERBOSE
371   if (verboseLevel > 1) {                      << 424   if(verboseLevel > 1)
                                                   >> 425   {
372     G4cout << "G4VUserPhysicsList::SetDefaultC    426     G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"
373            << "default cut value is changed to << 427            << "default cut value is changed to   :" << defaultCutValue / mm
                                                   >> 428            << "[mm]" << G4endl;
374   }                                               429   }
375 #endif                                            430 #endif
376 }                                                 431 }
377                                                   432 
378 // ------------------------------------------- << 433 ////////////////////////////////////////////////////////
379 G4double G4VUserPhysicsList::GetCutValue(const    434 G4double G4VUserPhysicsList::GetCutValue(const G4String& name) const
380 {                                                 435 {
381   std::size_t nReg = (G4RegionStore::GetInstan << 436   size_t nReg = (G4RegionStore::GetInstance())->size();
382   if (nReg == 0) {                             << 437   if(nReg == 0)
                                                   >> 438   {
383 #ifdef G4VERBOSE                                  439 #ifdef G4VERBOSE
384     if (verboseLevel > 0) {                    << 440     if(verboseLevel > 0)
                                                   >> 441     {
385       G4cout << "G4VUserPhysicsList::GetCutVal    442       G4cout << "G4VUserPhysicsList::GetCutValue "
386              << " : No Default Region " << G4e    443              << " : No Default Region " << G4endl;
387     }                                             444     }
388 #endif                                            445 #endif
389     G4Exception("G4VUserPhysicsList::GetCutVal << 446     G4Exception("G4VUserPhysicsList::GetCutValue", "Run0253", FatalException,
                                                   >> 447                 "No Default Region");
390     return -1. * mm;                              448     return -1. * mm;
391   }                                               449   }
392   G4Region* region = G4RegionStore::GetInstanc << 450   G4Region* region =
                                                   >> 451     G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
393   return region->GetProductionCuts()->GetProdu    452   return region->GetProductionCuts()->GetProductionCut(name);
394 }                                                 453 }
395                                                   454 
396 // ------------------------------------------- << 455 ////////////////////////////////////////////////////////
397 void G4VUserPhysicsList::SetCutValue(G4double     456 void G4VUserPhysicsList::SetCutValue(G4double aCut, const G4String& name)
398 {                                                 457 {
399   SetParticleCuts(aCut, name);                    458   SetParticleCuts(aCut, name);
400 }                                                 459 }
401                                                   460 
402 // ------------------------------------------- << 461 ////////////////////////////////////////////////////////
403 void G4VUserPhysicsList::SetCutValue(G4double  << 462 void G4VUserPhysicsList::SetCutValue(G4double aCut, const G4String& pname,
                                                   >> 463                                      const G4String& rname)
404 {                                                 464 {
405   G4Region* region = G4RegionStore::GetInstanc    465   G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
406   if (region != nullptr) {                     << 466   if(region != 0)
                                                   >> 467   {
407     // set cut value                              468     // set cut value
408     SetParticleCuts(aCut, pname, region);         469     SetParticleCuts(aCut, pname, region);
409   }                                               470   }
410   else {                                       << 471   else
                                                   >> 472   {
411 #ifdef G4VERBOSE                                  473 #ifdef G4VERBOSE
412     if (verboseLevel > 0) {                    << 474     if(verboseLevel > 0)
                                                   >> 475     {
413       G4cout << "G4VUserPhysicsList::SetCutVal    476       G4cout << "G4VUserPhysicsList::SetCutValue "
414              << " : No Region of " << rname <<    477              << " : No Region of " << rname << G4endl;
415     }                                             478     }
416 #endif                                            479 #endif
417   }                                               480   }
418 }                                                 481 }
419                                                   482 
420 // ------------------------------------------- << 483 ////////////////////////////////////////////////////////
421 void G4VUserPhysicsList::SetCutsWithDefault()     484 void G4VUserPhysicsList::SetCutsWithDefault()
422 {                                                 485 {
423   SetDefaultCutValue(defaultCutValue);            486   SetDefaultCutValue(defaultCutValue);
424   G4VUserPhysicsList::SetCuts();                  487   G4VUserPhysicsList::SetCuts();
425 }                                                 488 }
426                                                   489 
427 // ------------------------------------------- << 490 ////////////////////////////////////////////////////////
428 void G4VUserPhysicsList::SetCutsForRegion(G4do    491 void G4VUserPhysicsList::SetCutsForRegion(G4double aCut, const G4String& rname)
429 {                                                 492 {
430   // set cut values for gamma at first and for    493   // set cut values for gamma at first and for e- and e+
431   SetCutValue(aCut, "gamma", rname);              494   SetCutValue(aCut, "gamma", rname);
432   SetCutValue(aCut, "e-", rname);                 495   SetCutValue(aCut, "e-", rname);
433   SetCutValue(aCut, "e+", rname);                 496   SetCutValue(aCut, "e+", rname);
434   SetCutValue(aCut, "proton", rname);             497   SetCutValue(aCut, "proton", rname);
435 }                                                 498 }
436                                                   499 
437 // ------------------------------------------- << 500 ////////////////////////////////////////////////////////
438 void G4VUserPhysicsList::SetParticleCuts(G4dou << 501 void G4VUserPhysicsList::SetParticleCuts(G4double cut,
                                                   >> 502                                          G4ParticleDefinition* particle,
439                                          G4Reg    503                                          G4Region* region)
440 {                                                 504 {
441   SetParticleCuts(cut, particle->GetParticleNa    505   SetParticleCuts(cut, particle->GetParticleName(), region);
442 }                                                 506 }
443                                                   507 
444 // ------------------------------------------- << 508 ////////////////////////////////////////////////////////
445 void G4VUserPhysicsList::SetParticleCuts(G4dou << 509 void G4VUserPhysicsList::SetParticleCuts(G4double cut,
                                                   >> 510                                          const G4String& particleName,
446                                          G4Reg    511                                          G4Region* region)
447 {                                                 512 {
448   if (cut < 0.0) {                             << 513   if(cut < 0.0)
                                                   >> 514   {
449 #ifdef G4VERBOSE                                  515 #ifdef G4VERBOSE
450     if (verboseLevel > 0) {                    << 516     if(verboseLevel > 0)
                                                   >> 517     {
451       G4cout << "G4VUserPhysicsList::SetPartic    518       G4cout << "G4VUserPhysicsList::SetParticleCuts: negative cut values"
452              << "  :" << cut / mm << "[mm]"       519              << "  :" << cut / mm << "[mm]"
453              << " for " << particleName << G4e    520              << " for " << particleName << G4endl;
454     }                                             521     }
455 #endif                                            522 #endif
456     return;                                       523     return;
457   }                                               524   }
458                                                   525 
459   G4Region* world_region =                        526   G4Region* world_region =
460     G4RegionStore::GetInstance()->GetRegion("D    527     G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", false);
461   if (region == nullptr) {                     << 528   if(!region)
462     std::size_t nReg = G4RegionStore::GetInsta << 529   {
463     if (nReg == 0) {                           << 530     size_t nReg = (G4RegionStore::GetInstance())->size();
                                                   >> 531     if(nReg == 0)
                                                   >> 532     {
464 #ifdef G4VERBOSE                                  533 #ifdef G4VERBOSE
465       if (verboseLevel > 0) {                  << 534       if(verboseLevel > 0)
                                                   >> 535       {
466         G4cout << "G4VUserPhysicsList::SetPart    536         G4cout << "G4VUserPhysicsList::SetParticleCuts "
467                << " : No Default Region " << G    537                << " : No Default Region " << G4endl;
468       }                                           538       }
469 #endif                                            539 #endif
470       G4Exception("G4VUserPhysicsList::SetPart << 540       G4Exception("G4VUserPhysicsList::SetParticleCuts ", "Run0254",
471                   "No Default Region");        << 541                   FatalException, "No Default Region");
472       return;                                     542       return;
473     }                                             543     }
474     region = world_region;                        544     region = world_region;
475   }                                               545   }
476                                                   546 
477   if (!isSetDefaultCutValue) {                 << 547   if(!isSetDefaultCutValue)
                                                   >> 548   {
478     SetDefaultCutValue(defaultCutValue);          549     SetDefaultCutValue(defaultCutValue);
479   }                                               550   }
480                                                   551 
481   G4ProductionCuts* pcuts = region->GetProduct    552   G4ProductionCuts* pcuts = region->GetProductionCuts();
482   if (region != world_region                   << 553   if(region != world_region &&
483       && pcuts == G4ProductionCutsTable::GetPr << 554      pcuts == G4ProductionCutsTable::GetProductionCutsTable()
                                                   >> 555                 ->GetDefaultProductionCuts())
484   {  // This region had no unique cuts yet but    556   {  // This region had no unique cuts yet but shares the default cuts.
485      // Need to create a new object before set << 557     // Need to create a new object before setting the value.
486     pcuts = new G4ProductionCuts(              << 558     pcuts =
487       *(G4ProductionCutsTable::GetProductionCu << 559       new G4ProductionCuts(*(G4ProductionCutsTable::GetProductionCutsTable()
                                                   >> 560                                ->GetDefaultProductionCuts()));
488     region->SetProductionCuts(pcuts);             561     region->SetProductionCuts(pcuts);
489   }                                               562   }
490   pcuts->SetProductionCut(cut, particleName);     563   pcuts->SetProductionCut(cut, particleName);
491 #ifdef G4VERBOSE                                  564 #ifdef G4VERBOSE
492   if (verboseLevel > 2) {                      << 565   if(verboseLevel > 2)
                                                   >> 566   {
493     G4cout << "G4VUserPhysicsList::SetParticle    567     G4cout << "G4VUserPhysicsList::SetParticleCuts: "
494            << "  :" << cut / mm << "[mm]"         568            << "  :" << cut / mm << "[mm]"
495            << " for " << particleName << G4end    569            << " for " << particleName << G4endl;
496   }                                               570   }
497 #endif                                            571 #endif
498 }                                                 572 }
499                                                   573 
500 // ------------------------------------------- << 574 ///////////////////////////////////////////////////////////////
501 void G4VUserPhysicsList::BuildPhysicsTable()      575 void G4VUserPhysicsList::BuildPhysicsTable()
502 {                                                 576 {
503   // Prepare Physics table for all particles      577   // Prepare Physics table for all particles
504   theParticleIterator->reset();                   578   theParticleIterator->reset();
505   while ((*theParticleIterator)()) {           << 579   while((*theParticleIterator)())
                                                   >> 580   {
506     G4ParticleDefinition* particle = thePartic    581     G4ParticleDefinition* particle = theParticleIterator->value();
507     PreparePhysicsTable(particle);                582     PreparePhysicsTable(particle);
508   }                                               583   }
509                                                   584 
510   // ask processes to prepare physics table       585   // ask processes to prepare physics table
511   if (fRetrievePhysicsTable) {                 << 586   if(fRetrievePhysicsTable)
512     fIsRestoredCutValues = fCutsTable->Retriev << 587   {
                                                   >> 588     fIsRestoredCutValues =
                                                   >> 589       fCutsTable->RetrieveCutsTable(directoryPhysicsTable, fStoredInAscii);
513     // check if retrieve Cut Table successfull    590     // check if retrieve Cut Table successfully
514     if (!fIsRestoredCutValues) {               << 591     if(!fIsRestoredCutValues)
                                                   >> 592     {
515 #ifdef G4VERBOSE                                  593 #ifdef G4VERBOSE
516       if (verboseLevel > 0) {                  << 594       if(verboseLevel > 0)
                                                   >> 595       {
517         G4cout << "G4VUserPhysicsList::BuildPh    596         G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
518                << " Retrieve Cut Table failed     597                << " Retrieve Cut Table failed !!" << G4endl;
519       }                                           598       }
520 #endif                                            599 #endif
521       G4Exception("G4VUserPhysicsList::BuildPh << 600       G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0255",
522                   "Fail to retrieve Production << 601                   RunMustBeAborted, "Fail to retrieve Production Cut Table");
523     }                                             602     }
524     else {                                     << 603     else
                                                   >> 604     {
525 #ifdef G4VERBOSE                                  605 #ifdef G4VERBOSE
526       if (verboseLevel > 2) {                  << 606       if(verboseLevel > 2)
                                                   >> 607       {
527         G4cout << "G4VUserPhysicsList::BuildPh    608         G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
528                << "  Retrieve Cut Table succes    609                << "  Retrieve Cut Table successfully " << G4endl;
529       }                                           610       }
530 #endif                                            611 #endif
531     }                                             612     }
532   }                                               613   }
533   else {                                       << 614   else
                                                   >> 615   {
534 #ifdef G4VERBOSE                                  616 #ifdef G4VERBOSE
535     if (verboseLevel > 2) {                    << 617     if(verboseLevel > 2)
                                                   >> 618     {
536       G4cout << "G4VUserPhysicsList::BuildPhys    619       G4cout << "G4VUserPhysicsList::BuildPhysicsTable"
537              << " does not retrieve Cut Table     620              << " does not retrieve Cut Table but calculate " << G4endl;
538     }                                             621     }
539 #endif                                            622 #endif
540   }                                               623   }
541                                                   624 
542   // Sets a value to particle                     625   // Sets a value to particle
543   // set cut values for gamma at first and for    626   // set cut values for gamma at first and for e- and e+
544   G4String particleName;                          627   G4String particleName;
545   G4ParticleDefinition* GammaP = theParticleTa    628   G4ParticleDefinition* GammaP = theParticleTable->FindParticle("gamma");
546   if (GammaP != nullptr) BuildPhysicsTable(Gam << 629   if(GammaP)
                                                   >> 630     BuildPhysicsTable(GammaP);
547   G4ParticleDefinition* EMinusP = theParticleT    631   G4ParticleDefinition* EMinusP = theParticleTable->FindParticle("e-");
548   if (EMinusP != nullptr) BuildPhysicsTable(EM << 632   if(EMinusP)
                                                   >> 633     BuildPhysicsTable(EMinusP);
549   G4ParticleDefinition* EPlusP = theParticleTa    634   G4ParticleDefinition* EPlusP = theParticleTable->FindParticle("e+");
550   if (EPlusP != nullptr) BuildPhysicsTable(EPl << 635   if(EPlusP)
                                                   >> 636     BuildPhysicsTable(EPlusP);
551   G4ParticleDefinition* ProtonP = theParticleT    637   G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton");
552   if (ProtonP != nullptr) BuildPhysicsTable(Pr << 638   if(ProtonP)
                                                   >> 639     BuildPhysicsTable(ProtonP);
553                                                   640 
554   theParticleIterator->reset();                   641   theParticleIterator->reset();
555   while ((*theParticleIterator)()) {           << 642   while((*theParticleIterator)())
                                                   >> 643   {
556     G4ParticleDefinition* particle = thePartic    644     G4ParticleDefinition* particle = theParticleIterator->value();
557     if (particle != GammaP && particle != EMin << 645     if(particle != GammaP && particle != EMinusP && particle != EPlusP &&
                                                   >> 646        particle != ProtonP)
                                                   >> 647     {
558       BuildPhysicsTable(particle);                648       BuildPhysicsTable(particle);
559     }                                             649     }
560   }                                               650   }
561                                                   651 
562   // Set flag                                     652   // Set flag
563   fIsPhysicsTableBuilt = true;                    653   fIsPhysicsTableBuilt = true;
564 }                                                 654 }
565                                                << 655 ///////////////////////////////////////////////////////////////
566 // ------------------------------------------- << 656 // Change in order to share physics tables for two kind of process.
567 void G4VUserPhysicsList::BuildPhysicsTable(G4P    657 void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle)
568 {                                                 658 {
569   if (auto* trackingManager = particle->GetTra << 659   if(!(particle->GetMasterProcessManager()))
570 #ifdef G4VERBOSE                               << 660   {
571     if (verboseLevel > 2) {                    << 661     G4cout
572       G4cout << "G4VUserPhysicsList::BuildPhys << 662       << "#### G4VUserPhysicsList::BuildPhysicsTable() - BuildPhysicsTable("
573              << "Calculate Physics Table for " << 663       << particle->GetParticleName() << ") skipped..." << G4endl;
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;                                       664     return;
591   }                                               665   }
592   if (fRetrievePhysicsTable) {                 << 666   if(fRetrievePhysicsTable)
593     if (!fIsRestoredCutValues) {               << 667   {
                                                   >> 668     if(!fIsRestoredCutValues)
                                                   >> 669     {
594       // fail to retrieve cut tables              670       // fail to retrieve cut tables
595 #ifdef G4VERBOSE                                  671 #ifdef G4VERBOSE
596       if (verboseLevel > 0) {                  << 672       if(verboseLevel > 0)
                                                   >> 673       {
597         G4cout << "G4VUserPhysicsList::BuildPh    674         G4cout << "G4VUserPhysicsList::BuildPhysicsTable  "
598                << "Physics table can not be re << 675                << "Physics table can not be retrieved and will be calculated "
                                                   >> 676                << G4endl;
599       }                                           677       }
600 #endif                                            678 #endif
601       fRetrievePhysicsTable = false;              679       fRetrievePhysicsTable = false;
602     }                                             680     }
603     else {                                     << 681     else
                                                   >> 682     {
604 #ifdef G4VERBOSE                                  683 #ifdef G4VERBOSE
605       if (verboseLevel > 2) {                  << 684       if(verboseLevel > 2)
                                                   >> 685       {
606         G4cout << "G4VUserPhysicsList::BuildPh    686         G4cout << "G4VUserPhysicsList::BuildPhysicsTable  "
607                << " Retrieve Physics Table for << 687                << " Retrieve Physics Table for " << particle->GetParticleName()
                                                   >> 688                << G4endl;
608       }                                           689       }
609 #endif                                            690 #endif
610       //  Retrieve PhysicsTable from files for    691       //  Retrieve PhysicsTable from files for proccesses
611       RetrievePhysicsTable(particle, directory    692       RetrievePhysicsTable(particle, directoryPhysicsTable, fStoredInAscii);
612     }                                             693     }
613   }                                               694   }
614                                                   695 
615 #ifdef G4VERBOSE                                  696 #ifdef G4VERBOSE
616   if (verboseLevel > 2) {                      << 697   if(verboseLevel > 2)
                                                   >> 698   {
617     G4cout << "G4VUserPhysicsList::BuildPhysic    699     G4cout << "G4VUserPhysicsList::BuildPhysicsTable  "
618            << "Calculate Physics Table for " < << 700            << "Calculate Physics Table for " << particle->GetParticleName()
                                                   >> 701            << G4endl;
619   }                                               702   }
620 #endif                                            703 #endif
621   // Rebuild the physics tables for every proc    704   // Rebuild the physics tables for every process for this particle type
622   // if particle is not ShortLived                705   // if particle is not ShortLived
623   if (!particle->IsShortLived()) {             << 706   if(!particle->IsShortLived())
                                                   >> 707   {
624     G4ProcessManager* pManager = particle->Get    708     G4ProcessManager* pManager = particle->GetProcessManager();
625     if (pManager == nullptr) {                 << 709     if(!pManager)
                                                   >> 710     {
626 #ifdef G4VERBOSE                                  711 #ifdef G4VERBOSE
627       if (verboseLevel > 0) {                  << 712       if(verboseLevel > 0)
                                                   >> 713       {
628         G4cout << "G4VUserPhysicsList::BuildPh    714         G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
629                << " : No Process Manager for " << 715                << " : No Process Manager for " << particle->GetParticleName()
630         G4cout << particle->GetParticleName()  << 716                << G4endl;
                                                   >> 717         G4cout << particle->GetParticleName()
                                                   >> 718                << " should be created in your PhysicsList" << G4endl;
631       }                                           719       }
632 #endif                                            720 #endif
633       G4Exception("G4VUserPhysicsList::BuildPh << 721       G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0271",
634                   "No process manager");       << 722                   FatalException, "No process manager");
635       return;                                     723       return;
636     }                                             724     }
637                                                   725 
638     // Get processes from master thread;          726     // Get processes from master thread;
639     G4ProcessManager* pManagerShadow = particl    727     G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
640                                                   728 
641     G4ProcessVector* pVector = pManager->GetPr    729     G4ProcessVector* pVector = pManager->GetProcessList();
642     if (pVector == nullptr) {                  << 730     if(!pVector)
                                                   >> 731     {
643 #ifdef G4VERBOSE                                  732 #ifdef G4VERBOSE
644       if (verboseLevel > 0) {                  << 733       if(verboseLevel > 0)
                                                   >> 734       {
645         G4cout << "G4VUserPhysicsList::BuildPh    735         G4cout << "G4VUserPhysicsList::BuildPhysicsTable  "
646                << " : No Process Vector for "  << 736                << " : No Process Vector for " << particle->GetParticleName()
                                                   >> 737                << G4endl;
647       }                                           738       }
648 #endif                                            739 #endif
649       G4Exception("G4VUserPhysicsList::BuildPh << 740       G4Exception("G4VUserPhysicsList::BuildPhysicsTable", "Run0272",
650                   "No process Vector");        << 741                   FatalException, "No process Vector");
651       return;                                     742       return;
652     }                                             743     }
653 #ifdef G4VERBOSE                                  744 #ifdef G4VERBOSE
654     if (verboseLevel > 2) {                    << 745     if(verboseLevel > 2)
655       G4cout << "G4VUserPhysicsList::BuildPhys << 746     {
656              << G4endl;                        << 747       G4cout << "G4VUserPhysicsList::BuildPhysicsTable %%%%%% "
657       G4cout << " ProcessManager : " << pManag << 748              << particle->GetParticleName() << G4endl;
658              << G4endl;                        << 749       G4cout << " ProcessManager : " << pManager
659       for (G4int iv1 = 0; iv1 < (G4int)pVector << 750              << " ProcessManagerShadow : " << pManagerShadow << G4endl;
660         G4cout << "  " << iv1 << " - " << (*pV << 751       for(std::size_t iv1 = 0; iv1 < pVector->size(); ++iv1)
                                                   >> 752       {
                                                   >> 753         G4cout << "  " << iv1 << " - " << (*pVector)[iv1]->GetProcessName()
                                                   >> 754                << G4endl;
661       }                                           755       }
662       G4cout << "----------------------------- << 756       G4cout << "--------------------------------------------------------------"
                                                   >> 757              << G4endl;
663       G4ProcessVector* pVectorShadow = pManage    758       G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
664                                                   759 
665       for (G4int iv2 = 0; iv2 < (G4int)pVector << 760       for(std::size_t iv2 = 0; iv2 < pVectorShadow->size(); ++iv2)
666         G4cout << "  " << iv2 << " - " << (*pV << 761       {
                                                   >> 762         G4cout << "  " << iv2 << " - "
                                                   >> 763                << (*pVectorShadow)[iv2]->GetProcessName() << G4endl;
667       }                                           764       }
668     }                                             765     }
669 #endif                                            766 #endif
670     for (G4int j = 0; j < (G4int)pVector->size << 767     for(std::size_t j = 0; j < pVector->size(); ++j)
                                                   >> 768     {
671       // Andrea July 16th 2013 : migration to     769       // Andrea July 16th 2013 : migration to new interface...
672       // Infer if we are in a worker thread or    770       // Infer if we are in a worker thread or master thread
673       // Master thread is the one in which the    771       // Master thread is the one in which the process manager
674       // and process manager shadow pointers a    772       // and process manager shadow pointers are the same
675       if (pManagerShadow == pManager) {        << 773       if(pManagerShadow == pManager)
                                                   >> 774       {
676         (*pVector)[j]->BuildPhysicsTable(*part    775         (*pVector)[j]->BuildPhysicsTable(*particle);
677       }                                           776       }
678       else {                                   << 777       else
                                                   >> 778       {
679         (*pVector)[j]->BuildWorkerPhysicsTable    779         (*pVector)[j]->BuildWorkerPhysicsTable(*particle);
680       }                                           780       }
681                                                   781 
682     }  // End loop on processes vector            782     }  // End loop on processes vector
683   }  // End if short-lived                     << 783   }    // End if short-lived
684 }                                                 784 }
685                                                   785 
686 // ------------------------------------------- << 786 ///////////////////////////////////////////////////////////////
687 void G4VUserPhysicsList::PreparePhysicsTable(G    787 void G4VUserPhysicsList::PreparePhysicsTable(G4ParticleDefinition* particle)
688 {                                                 788 {
689   if (auto* trackingManager = particle->GetTra << 789   if(!(particle->GetMasterProcessManager()))
690     trackingManager->PreparePhysicsTable(*part << 790   {
691     return;                                    << 791     ////    G4cout << "#### G4VUserPhysicsList::BuildPhysicsTable() -
692   }                                            << 792     /// BuildPhysicsTable(" /           << particle->GetParticleName() << ")
693                                                << 793     /// skipped..." << G4endl;
694   if ((particle->GetMasterProcessManager()) == << 
695     return;                                       794     return;
696   }                                               795   }
697   // Prepare the physics tables for every proc    796   // Prepare the physics tables for every process for this particle type
698   // if particle is not ShortLived                797   // if particle is not ShortLived
699   if (!particle->IsShortLived()) {             << 798   if(!particle->IsShortLived())
                                                   >> 799   {
700     G4ProcessManager* pManager = particle->Get    800     G4ProcessManager* pManager = particle->GetProcessManager();
701     if (pManager == nullptr) {                 << 801     if(!pManager)
                                                   >> 802     {
702 #ifdef G4VERBOSE                                  803 #ifdef G4VERBOSE
703       if (verboseLevel > 0) {                  << 804       if(verboseLevel > 0)
                                                   >> 805       {
704         G4cout << "G4VUserPhysicsList::Prepare    806         G4cout << "G4VUserPhysicsList::PreparePhysicsTable  "
705                << ": No Process Manager for "  << 807                << ": No Process Manager for " << particle->GetParticleName()
706         G4cout << particle->GetParticleName()  << 808                << G4endl;
                                                   >> 809         G4cout << particle->GetParticleName()
                                                   >> 810                << " should be created in your PhysicsList" << G4endl;
707       }                                           811       }
708 #endif                                            812 #endif
709       G4Exception("G4VUserPhysicsList::Prepare << 813       G4Exception("G4VUserPhysicsList::PreparePhysicsTable", "Run0273",
710                   "No process manager");       << 814                   FatalException, "No process manager");
711       return;                                     815       return;
712     }                                             816     }
713                                                   817 
714     // Get processes from master thread           818     // Get processes from master thread
715     G4ProcessManager* pManagerShadow = particl    819     G4ProcessManager* pManagerShadow = particle->GetMasterProcessManager();
                                                   >> 820     // Andrea Dotti 15 Jan 2013: Change of interface of MSC
                                                   >> 821     // G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
716                                                   822 
717     G4ProcessVector* pVector = pManager->GetPr    823     G4ProcessVector* pVector = pManager->GetProcessList();
718     if (pVector == nullptr) {                  << 824     if(!pVector)
                                                   >> 825     {
719 #ifdef G4VERBOSE                                  826 #ifdef G4VERBOSE
720       if (verboseLevel > 0) {                  << 827       if(verboseLevel > 0)
                                                   >> 828       {
721         G4cout << "G4VUserPhysicsList::Prepare    829         G4cout << "G4VUserPhysicsList::PreparePhysicsTable  "
722                << ": No Process Vector for " < << 830                << ": No Process Vector for " << particle->GetParticleName()
                                                   >> 831                << G4endl;
723       }                                           832       }
724 #endif                                            833 #endif
725       G4Exception("G4VUserPhysicsList::Prepare << 834       G4Exception("G4VUserPhysicsList::PreparePhysicsTable", "Run0274",
726                   "No process Vector");        << 835                   FatalException, "No process Vector");
727       return;                                     836       return;
728     }                                             837     }
729     for (G4int j = 0; j < (G4int)pVector->size << 838     for(std::size_t j = 0; j < pVector->size(); ++j)
                                                   >> 839     {
730       // Andrea July 16th 2013 : migration to     840       // Andrea July 16th 2013 : migration to new interface...
731       // Infer if we are in a worker thread or    841       // Infer if we are in a worker thread or master thread
732       // Master thread is the one in which the    842       // Master thread is the one in which the process manager
733       // and process manager shadow pointers a    843       // and process manager shadow pointers are the same
734       if (pManagerShadow == pManager) {        << 844       if(pManagerShadow == pManager)
                                                   >> 845       {
735         (*pVector)[j]->PreparePhysicsTable(*pa    846         (*pVector)[j]->PreparePhysicsTable(*particle);
736       }                                           847       }
737       else {                                   << 848       else
                                                   >> 849       {
738         (*pVector)[j]->PrepareWorkerPhysicsTab    850         (*pVector)[j]->PrepareWorkerPhysicsTable(*particle);
739       }                                           851       }
740     }  // End loop on processes vector            852     }  // End loop on processes vector
741   }  // End if pn ShortLived                   << 853   }    // End if pn ShortLived
742 }                                                 854 }
743                                                   855 
744 // ------------------------------------------- << 856 // TODO Should we change this function?
745 void G4VUserPhysicsList::BuildIntegralPhysicsT << 857 ///////////////////////////////////////////////////////////////
746                                                << 858 void G4VUserPhysicsList::BuildIntegralPhysicsTable(
                                                   >> 859   G4VProcess* process, G4ParticleDefinition* particle)
747 {                                                 860 {
748   // TODO Should we change this function?      << 861   //*********************************************************************
749   //****************************************** << 862   // temporary addition to make the integral schema of electromagnetic
750   // Temporary addition to make the integral s << 
751   // processes work.                              863   // processes work.
                                                   >> 864   //
752                                                   865 
753   if ((process->GetProcessName() == "Imsc") || << 866   if((process->GetProcessName() == "Imsc") ||
754       || (process->GetProcessName() == "IeBrem << 867      (process->GetProcessName() == "IeIoni") ||
755       || (process->GetProcessName() == "IhIoni << 868      (process->GetProcessName() == "IeBrems") ||
756       || (process->GetProcessName() == "IMuBre << 869      (process->GetProcessName() == "Iannihil") ||
                                                   >> 870      (process->GetProcessName() == "IhIoni") ||
                                                   >> 871      (process->GetProcessName() == "IMuIoni") ||
                                                   >> 872      (process->GetProcessName() == "IMuBrems") ||
                                                   >> 873      (process->GetProcessName() == "IMuPairProd"))
757   {                                               874   {
758 #ifdef G4VERBOSE                                  875 #ifdef G4VERBOSE
759     if (verboseLevel > 2) {                    << 876     if(verboseLevel > 2)
                                                   >> 877     {
760       G4cout << "G4VUserPhysicsList::BuildInte    878       G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable  "
761              << " BuildPhysicsTable is invoked << 879              << " BuildPhysicsTable is invoked for "
762              << particle->GetParticleName() << << 880              << process->GetProcessName() << "(" << particle->GetParticleName()
                                                   >> 881              << ")" << G4endl;
763     }                                             882     }
764 #endif                                            883 #endif
765     process->BuildPhysicsTable(*particle);        884     process->BuildPhysicsTable(*particle);
766   }                                               885   }
767 }                                                 886 }
768                                                   887 
769 // ------------------------------------------- << 888 ///////////////////////////////////////////////////////////////
770 void G4VUserPhysicsList::DumpList() const         889 void G4VUserPhysicsList::DumpList() const
771 {                                                 890 {
772   theParticleIterator->reset();                   891   theParticleIterator->reset();
773   G4int idx = 0;                                  892   G4int idx = 0;
774   while ((*theParticleIterator)()) {           << 893   while((*theParticleIterator)())
                                                   >> 894   {
775     G4ParticleDefinition* particle = thePartic    895     G4ParticleDefinition* particle = theParticleIterator->value();
776     G4cout << particle->GetParticleName();        896     G4cout << particle->GetParticleName();
777     if ((idx++ % 4) == 3) {                    << 897     if((idx++ % 4) == 3)
                                                   >> 898     {
778       G4cout << G4endl;                           899       G4cout << G4endl;
779     }                                             900     }
780     else {                                     << 901     else
                                                   >> 902     {
781       G4cout << ", ";                             903       G4cout << ", ";
782     }                                             904     }
783   }                                               905   }
784   G4cout << G4endl;                               906   G4cout << G4endl;
785 }                                                 907 }
786                                                   908 
787 // ------------------------------------------- << 909 ///////////////////////////////////////////////////////////////
788 void G4VUserPhysicsList::DumpCutValuesTable(G4    910 void G4VUserPhysicsList::DumpCutValuesTable(G4int flag)
789 {                                                 911 {
790   fDisplayThreshold = flag;                       912   fDisplayThreshold = flag;
791 }                                                 913 }
792                                                   914 
793 // ------------------------------------------- << 915 ///////////////////////////////////////////////////////////////
794 void G4VUserPhysicsList::DumpCutValuesTableIfR    916 void G4VUserPhysicsList::DumpCutValuesTableIfRequested()
795 {                                                 917 {
796   if (fDisplayThreshold == 0) return;          << 918   if(fDisplayThreshold == 0)
                                                   >> 919     return;
797   G4ProductionCutsTable::GetProductionCutsTabl    920   G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples();
798   fDisplayThreshold = 0;                          921   fDisplayThreshold = 0;
799 }                                                 922 }
800                                                   923 
801 // ------------------------------------------- << 924 ///////////////////////////////////////////////////////////////
802 G4bool G4VUserPhysicsList::StorePhysicsTable(c    925 G4bool G4VUserPhysicsList::StorePhysicsTable(const G4String& directory)
803 {                                                 926 {
804   G4bool ascii = fStoredInAscii;                  927   G4bool ascii = fStoredInAscii;
805   G4String dir = directory;                       928   G4String dir = directory;
806   if (dir.empty())                             << 929   if(dir.isNull())
807     dir = directoryPhysicsTable;                  930     dir = directoryPhysicsTable;
808   else                                            931   else
809     directoryPhysicsTable = dir;                  932     directoryPhysicsTable = dir;
810                                                   933 
811   // store CutsTable info                         934   // store CutsTable info
812   if (!fCutsTable->StoreCutsTable(dir, ascii)) << 935   if(!fCutsTable->StoreCutsTable(dir, ascii))
                                                   >> 936   {
813     G4Exception("G4VUserPhysicsList::StorePhys    937     G4Exception("G4VUserPhysicsList::StorePhysicsTable", "Run0281", JustWarning,
814                 "Fail to store Cut Table");       938                 "Fail to store Cut Table");
815     return false;                                 939     return false;
816   }                                               940   }
817 #ifdef G4VERBOSE                                  941 #ifdef G4VERBOSE
818   if (verboseLevel > 2) {                      << 942   if(verboseLevel > 2)
                                                   >> 943   {
819     G4cout << "G4VUserPhysicsList::StorePhysic    944     G4cout << "G4VUserPhysicsList::StorePhysicsTable   "
820            << " Store material and cut values     945            << " Store material and cut values successfully" << G4endl;
821   }                                               946   }
822 #endif                                            947 #endif
823                                                   948 
824   G4bool success = true;                          949   G4bool success = true;
825                                                   950 
826   // loop over all particles in G4ParticleTabl    951   // loop over all particles in G4ParticleTable
827   theParticleIterator->reset();                   952   theParticleIterator->reset();
828   while ((*theParticleIterator)()) {           << 953   while((*theParticleIterator)())
                                                   >> 954   {
829     G4ParticleDefinition* particle = thePartic    955     G4ParticleDefinition* particle = theParticleIterator->value();
830     // Store physics tables for every process     956     // Store physics tables for every process for this particle type
831     G4ProcessVector* pVector = (particle->GetP << 957     G4ProcessVector* pVector =
832     for (G4int j = 0; j < (G4int)pVector->size << 958       (particle->GetProcessManager())->GetProcessList();
833       if (!(*pVector)[j]->StorePhysicsTable(pa << 959     for(std::size_t j = 0; j < pVector->size(); ++j)
                                                   >> 960     {
                                                   >> 961       if(!(*pVector)[j]->StorePhysicsTable(particle, dir, ascii))
                                                   >> 962       {
834         G4String comment = "Fail to store phys    963         G4String comment = "Fail to store physics table for ";
835         comment += (*pVector)[j]->GetProcessNa    964         comment += (*pVector)[j]->GetProcessName();
836         comment += "(" + particle->GetParticle    965         comment += "(" + particle->GetParticleName() + ")";
837         G4Exception("G4VUserPhysicsList::Store << 966         G4Exception("G4VUserPhysicsList::StorePhysicsTable", "Run0282",
                                                   >> 967                     JustWarning, comment);
838         success = false;                          968         success = false;
839       }                                           969       }
840     }                                             970     }
841     // end loop over processes                    971     // end loop over processes
842   }                                               972   }
843   // end loop over particles                      973   // end loop over particles
844   return success;                                 974   return success;
845 }                                                 975 }
846                                                   976 
847 // ------------------------------------------- << 977 ///////////////////////////////////////////////////////////////
848 void G4VUserPhysicsList::SetPhysicsTableRetrie    978 void G4VUserPhysicsList::SetPhysicsTableRetrieved(const G4String& directory)
849 {                                                 979 {
850   fRetrievePhysicsTable = true;                   980   fRetrievePhysicsTable = true;
851   if (!directory.empty()) {                    << 981   if(!directory.isNull())
                                                   >> 982   {
852     directoryPhysicsTable = directory;            983     directoryPhysicsTable = directory;
853   }                                               984   }
854   fIsCheckedForRetrievePhysicsTable = false;      985   fIsCheckedForRetrievePhysicsTable = false;
855   fIsRestoredCutValues = false;                << 986   fIsRestoredCutValues              = false;
856 }                                                 987 }
857                                                   988 
858 // ------------------------------------------- << 989 ///////////////////////////////////////////////////////////////
859 void G4VUserPhysicsList::RetrievePhysicsTable(    990 void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle,
860                                                << 991                                               const G4String& directory,
                                                   >> 992                                               G4bool ascii)
861 {                                                 993 {
862   G4bool success[100];                            994   G4bool success[100];
863   // Retrieve physics tables for every process    995   // Retrieve physics tables for every process for this particle type
864   G4ProcessVector* pVector = (particle->GetPro    996   G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
865   for (G4int j = 0; j < (G4int)pVector->size() << 997   for(std::size_t j = 0; j < pVector->size(); ++j)
866     success[j] = (*pVector)[j]->RetrievePhysic << 998   {
                                                   >> 999     success[j] =
                                                   >> 1000       (*pVector)[j]->RetrievePhysicsTable(particle, directory, ascii);
867                                                   1001 
868     if (!success[j]) {                         << 1002     if(!success[j])
                                                   >> 1003     {
869 #ifdef G4VERBOSE                                  1004 #ifdef G4VERBOSE
870       if (verboseLevel > 2) {                  << 1005       if(verboseLevel > 2)
                                                   >> 1006       {
871         G4cout << "G4VUserPhysicsList::Retriev    1007         G4cout << "G4VUserPhysicsList::RetrievePhysicsTable   "
872                << " Fail to retrieve Physics T << 1008                << " Fail to retrieve Physics Table for "
                                                   >> 1009                << (*pVector)[j]->GetProcessName() << G4endl;
                                                   >> 1010         G4cout << "Calculate Physics Table for " << particle->GetParticleName()
873                << G4endl;                         1011                << G4endl;
874         G4cout << "Calculate Physics Table for << 
875       }                                           1012       }
876 #endif                                            1013 #endif
877       (*pVector)[j]->BuildPhysicsTable(*partic    1014       (*pVector)[j]->BuildPhysicsTable(*particle);
878     }                                             1015     }
879   }                                               1016   }
880   for (G4int j = 0; j < (G4int)pVector->size() << 1017   for(std::size_t j = 0; j < pVector->size(); ++j)
                                                   >> 1018   {
881     // temporary addition to make the integral    1019     // temporary addition to make the integral schema
882     if (!success[j]) BuildIntegralPhysicsTable << 1020     if(!success[j])
                                                   >> 1021       BuildIntegralPhysicsTable((*pVector)[j], particle);
883   }                                               1022   }
884 }                                                 1023 }
885                                                   1024 
886 // ------------------------------------------- << 1025 ///////////////////////////////////////////////////////////////
887 void G4VUserPhysicsList::SetApplyCuts(G4bool v    1026 void G4VUserPhysicsList::SetApplyCuts(G4bool value, const G4String& name)
888 {                                                 1027 {
889 #ifdef G4VERBOSE                                  1028 #ifdef G4VERBOSE
890   if (verboseLevel > 2) {                      << 1029   if(verboseLevel > 2)
                                                   >> 1030   {
891     G4cout << "G4VUserPhysicsList::SetApplyCut    1031     G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl;
892   }                                               1032   }
893 #endif                                            1033 #endif
894   if (name == "all") {                         << 1034   if(name == "all")
                                                   >> 1035   {
895     theParticleTable->FindParticle("gamma")->S    1036     theParticleTable->FindParticle("gamma")->SetApplyCutsFlag(value);
896     theParticleTable->FindParticle("e-")->SetA    1037     theParticleTable->FindParticle("e-")->SetApplyCutsFlag(value);
897     theParticleTable->FindParticle("e+")->SetA    1038     theParticleTable->FindParticle("e+")->SetApplyCutsFlag(value);
898     theParticleTable->FindParticle("proton")->    1039     theParticleTable->FindParticle("proton")->SetApplyCutsFlag(value);
899   }                                               1040   }
900   else {                                       << 1041   else
                                                   >> 1042   {
901     theParticleTable->FindParticle(name)->SetA    1043     theParticleTable->FindParticle(name)->SetApplyCutsFlag(value);
902   }                                               1044   }
903 }                                                 1045 }
904                                                   1046 
905 // ------------------------------------------- << 1047 ///////////////////////////////////////////////////////////////
906 G4bool G4VUserPhysicsList::GetApplyCuts(const     1048 G4bool G4VUserPhysicsList::GetApplyCuts(const G4String& name) const
907 {                                                 1049 {
908   return theParticleTable->FindParticle(name)-    1050   return theParticleTable->FindParticle(name)->GetApplyCutsFlag();
909 }                                                 1051 }
910                                                   1052 
911 // ------------------------------------------- << 1053 ////////////////////////////////////////////////////////
912 void G4VUserPhysicsList::CheckParticleList()      1054 void G4VUserPhysicsList::CheckParticleList()
913 {                                                 1055 {
914   if (!fDisableCheckParticleList) {            << 1056   if(!fDisableCheckParticleList)
                                                   >> 1057   {
915     G4MT_thePLHelper->CheckParticleList();        1058     G4MT_thePLHelper->CheckParticleList();
916   }                                               1059   }
917 }                                                 1060 }
918                                                   1061 
919 // ------------------------------------------- << 1062 ////////////////////////////////////////////////////////
920 void G4VUserPhysicsList::AddTransportation()      1063 void G4VUserPhysicsList::AddTransportation()
921 {                                                 1064 {
922   G4MT_thePLHelper->AddTransportation();          1065   G4MT_thePLHelper->AddTransportation();
923 }                                                 1066 }
924                                                   1067 
925 // ------------------------------------------- << 1068 ////////////////////////////////////////////////////////
926 void G4VUserPhysicsList::UseCoupledTransportat    1069 void G4VUserPhysicsList::UseCoupledTransportation(G4bool vl)
927 {                                                 1070 {
928   G4MT_thePLHelper->UseCoupledTransportation(v    1071   G4MT_thePLHelper->UseCoupledTransportation(vl);
929 }                                                 1072 }
930                                                   1073 
931 // ------------------------------------------- << 1074 ////////////////////////////////////////////////////////
932 G4bool G4VUserPhysicsList::RegisterProcess(G4V << 1075 G4bool G4VUserPhysicsList::RegisterProcess(G4VProcess* process,
                                                   >> 1076                                            G4ParticleDefinition* particle)
933 {                                                 1077 {
934   return G4MT_thePLHelper->RegisterProcess(pro    1078   return G4MT_thePLHelper->RegisterProcess(process, particle);
935 }                                                 1079 }
936                                                   1080 
937 // ------------------------------------------- << 1081 ////////////////////////////////////////////////////////
938 G4ParticleTable::G4PTblDicIterator* G4VUserPhy << 1082 G4ParticleTable::G4PTblDicIterator* G4VUserPhysicsList::GetParticleIterator()
                                                   >> 1083   const
939 {                                                 1084 {
940   return (subInstanceManager.offset[g4vuplInst    1085   return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
941 }                                                 1086 }
942                                                   1087 
943 // ------------------------------------------- << 1088 ////////////////////////////////////////////////////////
944 void G4VUserPhysicsList::SetVerboseLevel(G4int    1089 void G4VUserPhysicsList::SetVerboseLevel(G4int value)
945 {                                                 1090 {
946   verboseLevel = value;                           1091   verboseLevel = value;
947   // set verboseLevel for G4ProductionCutsTabl    1092   // set verboseLevel for G4ProductionCutsTable same as one for
948   // G4VUserPhysicsList:                          1093   // G4VUserPhysicsList:
949   fCutsTable->SetVerboseLevel(verboseLevel);      1094   fCutsTable->SetVerboseLevel(verboseLevel);
950                                                   1095 
951   G4MT_thePLHelper->SetVerboseLevel(verboseLev    1096   G4MT_thePLHelper->SetVerboseLevel(verboseLevel);
952                                                   1097 
953 #ifdef G4VERBOSE                                  1098 #ifdef G4VERBOSE
954   if (verboseLevel > 1) {                      << 1099   if(verboseLevel > 1)
                                                   >> 1100   {
955     G4cout << "G4VUserPhysicsList::SetVerboseL    1101     G4cout << "G4VUserPhysicsList::SetVerboseLevel  :"
956            << " Verbose level is set to " << v    1102            << " Verbose level is set to " << verboseLevel << G4endl;
                                                   >> 1103   }
                                                   >> 1104 #endif
                                                   >> 1105 }
                                                   >> 1106 
                                                   >> 1107 ///////////////////////////////////////////////////////////////
                                                   >> 1108 /// obsolete methods
                                                   >> 1109 
                                                   >> 1110 ///////////////////////////////////////////////////////////////
                                                   >> 1111 void G4VUserPhysicsList::ResetCuts()
                                                   >> 1112 {
                                                   >> 1113 #ifdef G4VERBOSE
                                                   >> 1114   if(verboseLevel > 0)
                                                   >> 1115   {
                                                   >> 1116     G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."
                                                   >> 1117            << " This method gives no effect and you can remove it. " << G4endl;
957   }                                               1118   }
958 #endif                                            1119 #endif
959 }                                                 1120 }
960                                                   1121