Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/run/src/G4RunManagerKernel.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/G4RunManagerKernel.cc (Version 11.3.0) and /run/src/G4RunManagerKernel.cc (Version 10.2.p2)


  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 // G4RunManagerKernel implementation           << 
 27 //                                                 26 //
 28 // Author: M.Asai, 1 August 2003               <<  27 // $Id: G4RunManagerKernel.cc 90233 2015-05-21 08:56:28Z gcosmo $
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 //
 30                                                    30 
 31 #include "G4RunManagerKernel.hh"                   31 #include "G4RunManagerKernel.hh"
 32                                                    32 
 33 #include "G4AllocatorList.hh"                  <<  33 #include <vector>
                                                   >>  34 
                                                   >>  35 #include "G4StateManager.hh"
 34 #include "G4ApplicationState.hh"                   36 #include "G4ApplicationState.hh"
 35 #include "G4AutoLock.hh"                       << 
 36 #include "G4ExceptionHandler.hh"                   37 #include "G4ExceptionHandler.hh"
 37 #include "G4FieldManagerStore.hh"              <<  38 #include "G4PrimaryTransformer.hh"
 38 #include "G4Geantino.hh"                       << 
 39 #include "G4GeometryManager.hh"                    39 #include "G4GeometryManager.hh"
 40 #include "G4IonConstructor.hh"                 << 
 41 #include "G4IonTable.hh"                       << 
 42 #include "G4LogicalVolume.hh"                  << 
 43 #include "G4LogicalVolumeStore.hh"             << 
 44 #include "G4MTRunManager.hh"                   << 
 45 #include "G4NavigationHistoryPool.hh"              40 #include "G4NavigationHistoryPool.hh"
 46 #include "G4ParallelWorldProcessStore.hh"      <<  41 #include "G4TransportationManager.hh"
 47 #include "G4ParticleDefinition.hh"             <<  42 #include "G4VPhysicalVolume.hh"
                                                   >>  43 #include "G4LogicalVolume.hh"
                                                   >>  44 #include "G4VUserPhysicsList.hh"
                                                   >>  45 
 48 #include "G4ParticleTable.hh"                      46 #include "G4ParticleTable.hh"
 49 #include "G4ParticleTableIterator.hh"          << 
 50 #include "G4PathFinder.hh"                     << 
 51 #include "G4PrimaryTransformer.hh"             << 
 52 #include "G4ProcessManager.hh"                 << 
 53 #include "G4ProcessVector.hh"                  << 
 54 #include "G4ProductionCuts.hh"                 << 
 55 #include "G4ProductionCutsTable.hh"            << 
 56 #include "G4RNGHelper.hh"                      << 
 57 #include "G4Region.hh"                             47 #include "G4Region.hh"
 58 #include "G4RegionStore.hh"                        48 #include "G4RegionStore.hh"
                                                   >>  49 #include "G4ProductionCuts.hh"
                                                   >>  50 #include "G4ProductionCutsTable.hh"
 59 #include "G4SDManager.hh"                          51 #include "G4SDManager.hh"
 60 #include "G4ScoreSplittingProcess.hh"          <<  52 #include "G4ParallelWorldProcessStore.hh"
 61 #include "G4StateManager.hh"                   << 
 62 #include "G4TransportationManager.hh"          << 
 63 #include "G4UImanager.hh"                          53 #include "G4UImanager.hh"
 64 #include "G4UnitsTable.hh"                     << 
 65 #include "G4VPhysicalVolume.hh"                << 
 66 #include "G4VProcess.hh"                       << 
 67 #include "G4VUserPhysicsList.hh"               << 
 68 #include "G4VVisManager.hh"                        54 #include "G4VVisManager.hh"
                                                   >>  55 #include "G4UnitsTable.hh"
 69 #include "G4Version.hh"                            56 #include "G4Version.hh"
 70 #include "G4ios.hh"                                57 #include "G4ios.hh"
 71                                                    58 
 72 #include <vector>                              <<  59 #include "G4MTRunManager.hh"
                                                   >>  60 #include "G4AllocatorList.hh"
 73                                                    61 
 74 #ifdef G4BT_DEBUG                              <<  62 #include "G4AutoLock.hh"
 75 #  include "G4Backtrace.hh"                    << 
 76 #endif                                         << 
 77                                                    63 
 78 #ifdef G4FPE_DEBUG                                 64 #ifdef G4FPE_DEBUG
 79 #  include "G4FPEDetection.hh"                 <<  65   #include "G4FPEDetection.hh"
 80 #endif                                             66 #endif
 81                                                    67 
 82 // The following lines are needed since G4VUse <<  68 //The following lines are needed since G4VUserPhysicsList uses a #define theParticleIterator
 83 // uses a #define theParticleIterator          << 
 84 #ifdef theParticleIterator                         69 #ifdef theParticleIterator
 85 #  undef theParticleIterator                   <<  70 #undef theParticleIterator
 86 #endif                                             71 #endif
 87                                                    72 
 88 G4ThreadLocal G4RunManagerKernel* G4RunManager <<  73 G4ThreadLocal G4RunManagerKernel* G4RunManagerKernel::fRunManagerKernel = 0;
 89                                                    74 
 90 // ------------------------------------------- << 
 91 G4RunManagerKernel* G4RunManagerKernel::GetRun     75 G4RunManagerKernel* G4RunManagerKernel::GetRunManagerKernel()
 92 {                                              <<  76 { return fRunManagerKernel; }
 93   return fRunManagerKernel;                    << 
 94 }                                              << 
 95                                                    77 
 96 // ------------------------------------------- << 
 97 G4RunManagerKernel::G4RunManagerKernel()           78 G4RunManagerKernel::G4RunManagerKernel()
                                                   >>  79 : physicsList(0),currentWorld(0),
                                                   >>  80  geometryInitialized(false),physicsInitialized(false),
                                                   >>  81  geometryToBeOptimized(true),
                                                   >>  82  physicsNeedsToBeReBuilt(true),verboseLevel(0),
                                                   >>  83  numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
                                                   >>  84  numberOfStaticAllocators(0)
 98 {                                                  85 {
 99 #ifdef G4FPE_DEBUG                                 86 #ifdef G4FPE_DEBUG
100   InvalidOperationDetection();                     87   InvalidOperationDetection();
101 #endif                                             88 #endif
102                                                << 
103 #ifdef G4BT_DEBUG                              << 
104   auto _signals = G4GetEnv<std::string>("G4BAC << 
105   if (_signals.empty()) {                      << 
106     G4Backtrace::Enable();                     << 
107   }                                            << 
108   else {                                       << 
109     G4Backtrace::Enable(_signals);             << 
110   }                                            << 
111 #endif                                         << 
112                                                << 
113   G4AllocatorList* allocList = G4AllocatorList     89   G4AllocatorList* allocList = G4AllocatorList::GetAllocatorListIfExist();
114   if (allocList != nullptr) numberOfStaticAllo <<  90   if(allocList) numberOfStaticAllocators = allocList->Size();
115                                                <<  91   defaultExceptionHandler = new G4ExceptionHandler();
116   if (G4StateManager::GetStateManager()->GetEx <<  92   if(fRunManagerKernel)
117     defaultExceptionHandler = new G4ExceptionH <<  93   {
118   }                                            <<  94     G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
119   if (fRunManagerKernel != nullptr) {          <<  95                 FatalException,"More than one G4RunManagerKernel is constructed.");
120     G4Exception("G4RunManagerKernel::G4RunMana << 
121                 "More than one G4RunManagerKer << 
122   }                                                96   }
123   fRunManagerKernel = this;                        97   fRunManagerKernel = this;
124                                                    98 
125   G4ParticleTable* particleTable = G4ParticleT     99   G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
126   if (particleTable->entries() > 0) {          << 100   if(particleTable->entries()>0)
                                                   >> 101   {
127     // No particle should be registered before    102     // No particle should be registered beforehand
128     G4ExceptionDescription ED;                    103     G4ExceptionDescription ED;
129     ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! << 104     ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
130     ED << " G4RunManagerKernel fatal exception << 105     ED<<" G4RunManagerKernel fatal exception"<<G4endl;
131     ED << "  -- Following particles have alrea << 106     ED<<"  -- Following particles have already been registered"<<G4endl;
132     ED << "     before G4RunManagerKernel is i << 107     ED<<"     before G4RunManagerKernel is instantiated."<<G4endl;
133     for (G4int i = 0; i < particleTable->entri << 108     for(int i=0;i<particleTable->entries();i++)
134       ED << "     " << particleTable->GetParti << 109     { ED<<"     "<<particleTable->GetParticle(i)->GetParticleName()<<G4endl; }
135     }                                          << 110     ED<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<G4endl;
136     ED << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! << 111     G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0002",
137     G4Exception("G4RunManagerKernel::G4RunMana << 112        FatalException,ED);
138   }                                               113   }
139                                                << 114   
140   // construction of Geant4 kernel classes        115   // construction of Geant4 kernel classes
141   eventManager = new G4EventManager();            116   eventManager = new G4EventManager();
142                                                   117 
143   defaultRegion = new G4Region("DefaultRegionF << 118   defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
144   defaultRegionForParallelWorld =              << 119   defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
145     new G4Region("DefaultRegionForParallelWorl << 
146   defaultRegion->SetProductionCuts(               120   defaultRegion->SetProductionCuts(
147     G4ProductionCutsTable::GetProductionCutsTa << 121        G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
148   defaultRegionForParallelWorld->SetProduction    122   defaultRegionForParallelWorld->SetProductionCuts(
149     G4ProductionCutsTable::GetProductionCutsTa << 123        G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
150                                                   124 
151   runManagerKernelType = sequentialRMK;           125   runManagerKernelType = sequentialRMK;
152   // set the initial application state            126   // set the initial application state
153   G4StateManager::GetStateManager()->SetNewSta    127   G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
154                                                   128 
155   // version banner                               129   // version banner
156   G4String vs = G4Version;                        130   G4String vs = G4Version;
157   vs = vs.substr(1, vs.size() - 2);            << 131   vs = vs.substr(1,vs.size()-2);
158   versionString = " Geant4 version ";             132   versionString = " Geant4 version ";
159   versionString += vs;                            133   versionString += vs;
160   versionString += "   ";                         134   versionString += "   ";
161   versionString += G4Date;                        135   versionString += G4Date;
162   G4cout << G4endl << "*********************** << 136   G4cout << G4endl
163          << versionString << G4endl << "       << 137     << "*************************************************************" << G4endl
164          << G4endl << "                      R << 138     << versionString << G4endl
165          << "                                  << 139     << "                      Copyright : Geant4 Collaboration" << G4endl
166          << "                                  << 140     << "                      Reference : NIM A 506 (2003), 250-303" << G4endl
167          << "                             WWW  << 141     << "                            WWW : http://cern.ch/geant4" << G4endl
168          << "********************************* << 142     << "*************************************************************" << G4endl
                                                   >> 143     << G4endl;
169 }                                                 144 }
170                                                   145 
171 // ------------------------------------------- << 
172 G4RunManagerKernel::G4RunManagerKernel(RMKType    146 G4RunManagerKernel::G4RunManagerKernel(RMKType rmkType)
                                                   >> 147 : physicsList(0),currentWorld(0),
                                                   >> 148 geometryInitialized(false),physicsInitialized(false),
                                                   >> 149 geometryToBeOptimized(true),
                                                   >> 150 physicsNeedsToBeReBuilt(true),verboseLevel(0),
                                                   >> 151 numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
                                                   >> 152  numberOfStaticAllocators(0)
173 {                                                 153 {
174 // This version of the constructor should neve << 154 //This version of the constructor should never be called in sequential mode!
175 #ifndef G4MULTITHREADED                           155 #ifndef G4MULTITHREADED
176   G4ExceptionDescription msg;                  << 156     G4ExceptionDescription msg;
177   msg << "Geant4 code is compiled without mult << 157     msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
178          "(-DG4MULTITHREADED is set to off)."; << 158     msg<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
179   msg << " This type of RunManagerKernel can o << 159     G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msg);
180          "applications.";                      << 
181   G4Exception("G4RunManagerKernel::G4RunManage << 
182 #endif                                            160 #endif
183                                                   161 
184 #ifdef G4FPE_DEBUG                                162 #ifdef G4FPE_DEBUG
185   if (G4Threading::IsMasterThread()) {         << 163    if ( G4Threading::IsMasterThread() ) {
186     InvalidOperationDetection();               << 164      InvalidOperationDetection();
187   }                                            << 165    }
188 #endif                                            166 #endif
189                                                << 167     
190 #ifdef G4BT_DEBUG                              << 
191   auto _signals = G4GetEnv<std::string>("G4BAC << 
192   if (_signals.empty()) {                      << 
193     G4Backtrace::Enable();                     << 
194   }                                            << 
195   else {                                       << 
196     G4Backtrace::Enable(_signals);             << 
197   }                                            << 
198 #endif                                         << 
199                                                << 
200   if (G4StateManager::GetStateManager()->GetEx << 
201     defaultExceptionHandler = new G4ExceptionH    168     defaultExceptionHandler = new G4ExceptionHandler();
202   }                                            << 169     if(fRunManagerKernel)
203                                                << 170     {
204   if (fRunManagerKernel != nullptr) {          << 171         G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0001",
205     G4Exception("G4RunManagerKernel::G4RunMana << 172                     FatalException,"More than one G4RunManagerKernel is constructed.");
206                 "More than one G4RunManagerKer << 173     }
207   }                                            << 174     fRunManagerKernel = this;
208   fRunManagerKernel = this;                    << 175     // construction of Geant4 kernel classes
209   // construction of Geant4 kernel classes     << 176     eventManager = new G4EventManager();
210   eventManager = new G4EventManager();         << 177     
211                                                << 178     switch(rmkType)
212   switch (rmkType) {                           << 179     {
213     case masterRMK:                            << 180      case masterRMK:
214       // Master thread behvior                 << 181         //Master thread behvior
215       defaultRegion = new G4Region("DefaultReg << 182         defaultRegion = new G4Region("DefaultRegionForTheWorld"); // deleted by store
216       defaultRegionForParallelWorld =          << 183         defaultRegionForParallelWorld = new G4Region("DefaultRegionForParallelWorld"); // deleted by store
217         new G4Region("DefaultRegionForParallel << 184         defaultRegion->SetProductionCuts(
218       defaultRegion->SetProductionCuts(        << 185                G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
219         G4ProductionCutsTable::GetProductionCu << 186         defaultRegionForParallelWorld->SetProductionCuts(
220       defaultRegionForParallelWorld->SetProduc << 187                G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
221         G4ProductionCutsTable::GetProductionCu << 188         break;
222       break;                                   << 189      case workerRMK:
223     case workerRMK:                            << 190         //Worker thread behavior
224       // Worker thread behavior                << 191         defaultRegion = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld", true);
225       defaultRegion = G4RegionStore::GetInstan << 192         defaultRegionForParallelWorld
226       defaultRegionForParallelWorld =          << 193             = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForParallelWorld", true);
227         G4RegionStore::GetInstance()->GetRegio << 194         break;
228       break;                                   << 195      default:   
229     default:                                   << 196         defaultRegion = 0;
230       defaultRegion = nullptr;                 << 197         defaultRegionForParallelWorld = 0;
231       defaultRegionForParallelWorld = nullptr; << 198         G4ExceptionDescription msgx;
232       G4ExceptionDescription msgx;             << 199         msgx<<" This type of RunManagerKernel can only be used in mult-threaded applications.";
233       msgx << " This type of RunManagerKernel  << 200         G4Exception("G4RunManagerKernel::G4RunManagerKernel(G4bool)","Run0035",FatalException,msgx);
234               "applications.";                 << 201     }
235       G4Exception("G4RunManagerKernel::G4RunMa << 202     runManagerKernelType = rmkType;
236                   msgx);                       << 203     
237   }                                            << 204     // set the initial application state
238   runManagerKernelType = rmkType;              << 205     G4StateManager::GetStateManager()->SetNewState(G4State_PreInit);
239                                                << 206     
240   // set the initial application state         << 207     // version banner
241   G4StateManager::GetStateManager()->SetNewSta << 208     G4String vs = G4Version;
242                                                << 209     vs = vs.substr(1,vs.size()-2);
243   // version banner                            << 210     switch(rmkType)
244   G4String vs = G4Version;                     << 211     {
245   vs = vs.substr(1, vs.size() - 2);            << 212      case masterRMK:
246   switch (rmkType) {                           << 
247     case masterRMK:                            << 
248       versionString = " Geant4 version ";         213       versionString = " Geant4 version ";
249       versionString += vs;                        214       versionString += vs;
250       versionString += "   ";                     215       versionString += "   ";
251       versionString += G4Date;                    216       versionString += G4Date;
252       G4cout << G4endl << "******************* << 217       G4cout << G4endl
253              << versionString << G4endl << "   << 218        << "*************************************************************" << G4endl
254              << "                       Copyri << 219        << versionString << G4endl
255              << "                      Referen << 220        << "  << in Multi-threaded mode >> " << G4endl
256              << "                              << 221        << "                      Copyright : Geant4 Collaboration" << G4endl
257              << "                              << 222        << "                      Reference : NIM A 506 (2003), 250-303" << G4endl
258              << "                              << 223        << "                            WWW : http://cern.ch/geant4" << G4endl
259              << "***************************** << 224        << "*************************************************************" << G4endl
260              << G4endl;                        << 225        << G4endl;
261       break;                                   << 226        break;
262     default:                                   << 227      default:
263       if (verboseLevel != 0) {                 << 228       versionString = " Local thread RunManagerKernel version ";
264         versionString = " Local thread RunMana << 229       versionString += vs;
265         versionString += vs;                   << 230       G4cout << G4endl
266         G4cout << G4endl                       << 231        << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
267                << "^^^^^^^^^^^^^^^^^^^^^^^^^^^ << 232        << versionString << G4endl
268                   "^^^^^^^^^"                  << 233        << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
269                << G4endl << versionString << G << 234        << G4endl;
270                << "^^^^^^^^^^^^^^^^^^^^^^^^^^^ << 235     }
271                   "^^^^^^^^^"                  << 
272                << G4endl << G4endl;            << 
273       }                                        << 
274   }                                            << 
275                                                << 
276 #ifdef G4MULTITHREADED                         << 
277   G4UnitDefinition::GetUnitsTable().Synchroniz << 
278 #endif                                         << 
279 }                                                 236 }
280                                                   237 
281 // ------------------------------------------- << 
282 void G4RunManagerKernel::SetupDefaultRegion()     238 void G4RunManagerKernel::SetupDefaultRegion()
283 {                                                 239 {
284   if (runManagerKernelType == workerRMK) retur << 240     if(runManagerKernelType==workerRMK) return;
285                                                   241 
286   // Remove old world logical volume from the  << 242     // Remove old world logical volume from the default region, if exist
287   if (defaultRegion->GetNumberOfRootVolumes()  << 243     if(defaultRegion->GetNumberOfRootVolumes())
288     if (defaultRegion->GetNumberOfRootVolumes( << 244     {
289       G4Exception("G4RunManager::SetupDefaultR << 245         if(defaultRegion->GetNumberOfRootVolumes()>size_t(1))
290                   "Default world region should << 246         {
                                                   >> 247             G4Exception("G4RunManager::SetupDefaultRegion",
                                                   >> 248                         "Run0005",
                                                   >> 249                         FatalException,
                                                   >> 250                         "Default world region should have a unique logical volume.");
                                                   >> 251         }
                                                   >> 252         std::vector<G4LogicalVolume*>::iterator lvItr
                                                   >> 253         = defaultRegion->GetRootLogicalVolumeIterator();
                                                   >> 254         defaultRegion->RemoveRootLogicalVolume(*lvItr,false);
                                                   >> 255         if(verboseLevel>1) G4cout
                                                   >> 256             << "Obsolete world logical volume is removed from the default region." << G4endl;
291     }                                             257     }
292     auto lvItr = defaultRegion->GetRootLogical << 258 
293     defaultRegion->RemoveRootLogicalVolume(*lv << 
294     if (verboseLevel > 1)                      << 
295       G4cout << "Obsolete world logical volume << 
296   }                                            << 
297 }                                                 259 }
298                                                   260 
299 // ------------------------------------------- << 
300 G4RunManagerKernel::~G4RunManagerKernel()         261 G4RunManagerKernel::~G4RunManagerKernel()
301 {                                                 262 {
302   G4StateManager* pStateManager = G4StateManag    263   G4StateManager* pStateManager = G4StateManager::GetStateManager();
303   // set the application state to the quite st    264   // set the application state to the quite state
304   if (pStateManager->GetCurrentState() != G4St << 265   if(pStateManager->GetCurrentState()!=G4State_Quit)
305     if (verboseLevel > 1) G4cout << "G4 kernel << 266   {
                                                   >> 267     if(verboseLevel>0) G4cout << "G4 kernel has come to Quit state." << G4endl;
306     pStateManager->SetNewState(G4State_Quit);     268     pStateManager->SetNewState(G4State_Quit);
307   }                                               269   }
308                                                   270 
309   // open geometry for deletion                   271   // open geometry for deletion
310   G4GeometryManager::GetInstance()->OpenGeomet    272   G4GeometryManager::GetInstance()->OpenGeometry();
311                                                   273 
312   // deletion of Geant4 kernel classes            274   // deletion of Geant4 kernel classes
313   delete G4ParallelWorldProcessStore::GetInsta << 275   G4ParallelWorldProcessStore* pwps = G4ParallelWorldProcessStore::GetInstanceIfExist();
314   delete G4SDManager::GetSDMpointerIfExist();  << 276   if(pwps) delete pwps;
315   if (verboseLevel > 1) G4cout << "G4SDManager << 277   G4SDManager* fSDM = G4SDManager::GetSDMpointerIfExist();
                                                   >> 278   if(fSDM)
                                                   >> 279   {
                                                   >> 280     delete fSDM;
                                                   >> 281     if(verboseLevel>1) G4cout << "G4SDManager deleted." << G4endl;
                                                   >> 282   }
316   delete eventManager;                            283   delete eventManager;
317   if (verboseLevel > 1) G4cout << "EventManage << 284   if(verboseLevel>1) G4cout << "EventManager deleted." << G4endl;
318                                                   285 
319   G4UnitDefinition::ClearUnitsTable();            286   G4UnitDefinition::ClearUnitsTable();
320   if (verboseLevel > 1) G4cout << "Units table << 287   if(verboseLevel>1) G4cout << "Units table cleared." << G4endl;
321                                                << 
322   // deletion of path-finder field-manager sto << 
323   // manager                                   << 
324   delete G4PathFinder::GetInstanceIfExist();   << 
325   delete G4FieldManagerStore::GetInstanceIfExi << 
326   delete G4GeometryManager::GetInstanceIfExist << 
327   delete G4TransportationManager::GetInstanceI << 
328   if (verboseLevel > 1) G4cout << "Transportat << 
329                                                   288 
330   // deletion of navigation levels                289   // deletion of navigation levels
331   if (verboseLevel > 1) G4NavigationHistoryPoo << 290   if(verboseLevel>1) G4NavigationHistoryPool::GetInstance()->Print();
332   delete G4NavigationHistoryPool::GetInstance(    291   delete G4NavigationHistoryPool::GetInstance();
333                                                   292 
334   // deletion of G4RNGHelper singleton         << 
335   if (runManagerKernelType != workerRMK) {     << 
336     delete G4RNGHelper::GetInstanceIfExist();  << 
337     if (verboseLevel > 1) G4cout << "G4RNGHelp << 
338   }                                            << 
339                                                << 
340   // deletion of allocators                       293   // deletion of allocators
341   G4AllocatorList* allocList = G4AllocatorList    294   G4AllocatorList* allocList = G4AllocatorList::GetAllocatorListIfExist();
342   if (allocList != nullptr) {                  << 295   if(allocList)
343     allocList->Destroy(numberOfStaticAllocator << 296   {
344     delete allocList;                          << 297     allocList->Destroy(numberOfStaticAllocators,verboseLevel);
345     if (verboseLevel > 1) G4cout << "G4Allocat << 298     delete allocList; 
                                                   >> 299     if(verboseLevel>1) G4cout << "G4Allocator objects are deleted." << G4endl;
346   }                                               300   }
347                                                   301 
348   G4UImanager* pUImanager = G4UImanager::GetUI    302   G4UImanager* pUImanager = G4UImanager::GetUIpointer();
349   if ((runManagerKernelType == workerRMK) && ( << 303   if((runManagerKernelType==workerRMK) && (verboseLevel>0))
350     G4cout << "Thread-local UImanager is to be << 304   {
351            << "There should not be any thread- << 305     G4cout << "Thread-local UImanager is to be deleted." << G4endl 
                                                   >> 306            << "There should not be any thread-local G4cout/G4cerr hereafter."
                                                   >> 307            << G4endl;
                                                   >> 308     verboseLevel = 0;
352   }                                               309   }
353   delete pUImanager;                           << 310   if(pUImanager) delete pUImanager;
354   if (verboseLevel > 1) G4cout << "UImanager d << 311   if(verboseLevel>1) G4cout << "UImanager deleted." << G4endl;
355                                                << 312   
356   delete pStateManager;                        << 313   delete pStateManager; 
357   if (verboseLevel > 1) G4cout << "StateManage << 314   if(verboseLevel>1) G4cout << "StateManager deleted." << G4endl;
358   delete defaultExceptionHandler;                 315   delete defaultExceptionHandler;
359   if (verboseLevel > 1) G4cout << "RunManagerK << 316   if(verboseLevel>0) G4cout << "RunManagerKernel is deleted. Good bye :)" << G4endl;
360   fRunManagerKernel = nullptr;                 << 317   fRunManagerKernel = 0;
361 }                                                 318 }
362                                                   319 
363 // ------------------------------------------- << 
364 void G4RunManagerKernel::WorkerUpdateWorldVolu    320 void G4RunManagerKernel::WorkerUpdateWorldVolume()
365 {                                                 321 {
366   G4MTRunManager* masterRM = G4MTRunManager::G    322   G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
367   G4TransportationManager* transM = G4Transpor    323   G4TransportationManager* transM = G4TransportationManager::GetTransportationManager();
368   G4MTRunManager::masterWorlds_t masterWorlds  << 324   G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
369   for (const auto& masterWorld : masterWorlds) << 325   G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
370     G4VPhysicalVolume* wv = masterWorld.second << 326   for(;itrMW!=masterWorlds.end();itrMW++)
371     G4VPhysicalVolume* pWorld =                << 327   {
372       G4TransportationManager::GetTransportati << 328     G4VPhysicalVolume* wv = (*itrMW).second;
373     if (pWorld == nullptr) {                   << 329     G4VPhysicalVolume* pWorld
374       transM->RegisterWorld(wv);               << 330        = G4TransportationManager::GetTransportationManager()
375     }                                          << 331          ->IsWorldExisting(wv->GetName());
                                                   >> 332     if(!pWorld)
                                                   >> 333     { transM->RegisterWorld(wv); }
376   }                                               334   }
377 }                                                 335 }
378                                                   336 
379 // ------------------------------------------- << 
380 void G4RunManagerKernel::WorkerDefineWorldVolu    337 void G4RunManagerKernel::WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol,
381                                                << 338                                      G4bool topologyIsChanged)
382 {                                                 339 {
383   G4StateManager* stateManager = G4StateManage << 340   G4StateManager*    stateManager = G4StateManager::GetStateManager();
384   G4ApplicationState currentState = stateManag    341   G4ApplicationState currentState = stateManager->GetCurrentState();
385   if (currentState != G4State_Init) {          << 342   if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
386     if (currentState != G4State_Idle && curren << 343   {
387       G4cout << "Current application state is  << 344     G4Exception("G4RunManagerKernel::DefineWorldVolume",
388              << G4endl;                        << 345     "DefineWorldVolumeAtIncorrectState",
389       G4Exception("G4RunManagerKernel::DefineW << 346     JustWarning,
390                   FatalException, "Geant4 kern << 347     "Geant4 kernel is not PreInit or Idle state : Method ignored.");
391       return;                                  << 348     if(verboseLevel>1) G4cerr << "Current application state is "
392     }                                          << 349       << stateManager->GetStateString(currentState) << G4endl;
393                                                << 350     return;
394     stateManager->SetNewState(G4State_Init);   << 
395   }                                               351   }
396                                                   352 
397   currentWorld = worldVol;                        353   currentWorld = worldVol;
398   G4MTRunManager* masterRM = G4MTRunManager::G    354   G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
399   G4TransportationManager* transM = G4Transpor    355   G4TransportationManager* transM = G4TransportationManager::GetTransportationManager();
400   G4MTRunManager::masterWorlds_t masterWorlds  << 356   G4MTRunManager::masterWorlds_t masterWorlds= masterRM->GetMasterWorlds();
401   for (const auto& masterWorld : masterWorlds) << 357   G4MTRunManager::masterWorlds_t::iterator itrMW = masterWorlds.begin();
402     if (masterWorld.first == 0) {              << 358   for(;itrMW!=masterWorlds.end();itrMW++)
403       if (masterWorld.second != currentWorld)  << 359   {
404         G4Exception("G4RunManagerKernel::Worke << 360     if((*itrMW).first == 0)
405                     "Mass world is inconsisten << 361     {
                                                   >> 362       if((*itrMW).second != currentWorld)
                                                   >> 363       {
                                                   >> 364         G4Exception("G4RunManagerKernel::WorkerDefineWorldVolume","RUN3091",
                                                   >> 365                     FatalException,"Mass world is inconsistent");
406       }                                           366       }
407       transM->SetWorldForTracking(masterWorld. << 367       transM->SetWorldForTracking((*itrMW).second);
408     }                                             368     }
409     else {                                     << 369     else
410       transM->RegisterWorld(masterWorld.second << 370     {
                                                   >> 371       transM->RegisterWorld((*itrMW).second);
411     }                                             372     }
412   }                                               373   }
413                                                   374 
414   if (topologyIsChanged) geometryNeedsToBeClos << 375   if(topologyIsChanged) geometryNeedsToBeClosed = true;
415                                                   376 
416   // Notify the VisManager as well             << 377   // Notify the VisManager as well                                                                                
417   if (G4Threading::IsMasterThread()) {         << 378   if(G4Threading::IsMasterThread())
                                                   >> 379   {
418     G4VVisManager* pVVisManager = G4VVisManage    380     G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
419     if (pVVisManager != nullptr) pVVisManager- << 381     if(pVVisManager) pVVisManager->GeometryHasChanged();
420   }                                               382   }
421                                                   383 
422   geometryInitialized = true;                     384   geometryInitialized = true;
423   stateManager->SetNewState(currentState);     << 385   if(physicsInitialized && currentState!=G4State_Idle)
424   if (physicsInitialized && currentState != G4 << 386   { stateManager->SetNewState(G4State_Idle); }
425     stateManager->SetNewState(G4State_Idle);   << 
426   }                                            << 
427 }                                                 387 }
428                                                   388 
429 // ------------------------------------------- << 389 void G4RunManagerKernel::DefineWorldVolume(G4VPhysicalVolume* worldVol,
430 void G4RunManagerKernel::DefineWorldVolume(G4V << 390                                      G4bool topologyIsChanged)
431 {                                                 391 {
432   G4StateManager* stateManager = G4StateManage << 392   G4StateManager*    stateManager = G4StateManager::GetStateManager();
433   G4ApplicationState currentState = stateManag    393   G4ApplicationState currentState = stateManager->GetCurrentState();
434                                                << 394   if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
435   if (currentState != G4State_Init) {          << 395   { 
436     if (currentState != G4State_Idle && curren << 396     G4Exception("G4RunManagerKernel::DefineWorldVolume",
437       G4cout << "Current application state is  << 397                 "Run00031",
438              << G4endl;                        << 398                 JustWarning,
439       G4Exception("G4RunManagerKernel::DefineW << 399                 "Geant4 kernel is not PreInit or Idle state : Method ignored.");
440                   FatalException, "Geant4 kern << 400     return;
441       return;                                  << 
442     }                                          << 
443                                                << 
444     stateManager->SetNewState(G4State_Init);   << 
445   }                                               401   }
446                                                   402 
447   // The world volume MUST NOT have a region d    403   // The world volume MUST NOT have a region defined by the user
448   if (worldVol->GetLogicalVolume()->GetRegion( << 404   if(worldVol->GetLogicalVolume()->GetRegion())
449     if (worldVol->GetLogicalVolume()->GetRegio << 405   {
                                                   >> 406     if(worldVol->GetLogicalVolume()->GetRegion()!=defaultRegion)
                                                   >> 407     {
450       G4ExceptionDescription ED;                  408       G4ExceptionDescription ED;
451       ED << "The world volume has a user-defin    409       ED << "The world volume has a user-defined region <"
452          << worldVol->GetLogicalVolume()->GetR << 410            << worldVol->GetLogicalVolume()->GetRegion()->GetName()
453       ED << "World would have a default region << 411            << ">." << G4endl;
454       G4Exception("G4RunManager::DefineWorldVo << 412       ED << "World would have a default region assigned by RunManagerKernel."
                                                   >> 413          << G4endl;
                                                   >> 414       G4Exception("G4RunManager::DefineWorldVolume",
                                                   >> 415                 "Run0004", FatalException, ED);
455     }                                             416     }
456   }                                               417   }
457                                                   418 
458   SetupDefaultRegion();                           419   SetupDefaultRegion();
459                                                << 420     
460   // Accept the world volume                      421   // Accept the world volume
461   currentWorld = worldVol;                     << 422   currentWorld = worldVol; 
462                                                   423 
463   // Set the default region to the world          424   // Set the default region to the world
464                                                   425 
465   G4LogicalVolume* worldLog = currentWorld->Ge    426   G4LogicalVolume* worldLog = currentWorld->GetLogicalVolume();
466   worldLog->SetRegion(defaultRegion);             427   worldLog->SetRegion(defaultRegion);
467   defaultRegion->AddRootLogicalVolume(worldLog    428   defaultRegion->AddRootLogicalVolume(worldLog);
468   if (verboseLevel > 1)                        << 429   if(verboseLevel>1) G4cout << worldLog->GetName()
469     G4cout << worldLog->GetName() << " is regi << 430    << " is registered to the default region." << G4endl;
470                                                   431 
471   // Set the world volume, notify the Navigato    432   // Set the world volume, notify the Navigator and reset its state
472   G4TransportationManager::GetTransportationMa << 433   G4TransportationManager::GetTransportationManager()
473   if (topologyIsChanged) geometryNeedsToBeClos << 434       ->SetWorldForTracking(currentWorld);
474                                                << 435   if(topologyIsChanged) geometryNeedsToBeClosed = true;
                                                   >> 436   
475   // Notify the VisManager as well                437   // Notify the VisManager as well
476   if (G4Threading::IsMasterThread()) {         << 438   if(G4Threading::IsMasterThread())
                                                   >> 439   {
477     G4VVisManager* pVVisManager = G4VVisManage    440     G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
478     if (pVVisManager != nullptr) pVVisManager- << 441     if(pVVisManager) pVVisManager->GeometryHasChanged();
479   }                                               442   }
480                                                   443 
481   geometryInitialized = true;                     444   geometryInitialized = true;
482   stateManager->SetNewState(currentState);     << 445   if(physicsInitialized && currentState!=G4State_Idle)
483   if (physicsInitialized && currentState != G4 << 446   { stateManager->SetNewState(G4State_Idle); }
484     stateManager->SetNewState(G4State_Idle);   << 447 } 
485   }                                            << 448   
486 }                                              << 
487                                                << 
488 // ------------------------------------------- << 
489 void G4RunManagerKernel::SetPhysics(G4VUserPhy    449 void G4RunManagerKernel::SetPhysics(G4VUserPhysicsList* uPhys)
490 {                                                 450 {
491   physicsList = uPhys;                            451   physicsList = uPhys;
492                                                   452 
493   if (runManagerKernelType == workerRMK) retur << 453   if(runManagerKernelType==workerRMK) return;
494                                                   454 
495   SetupPhysics();                                 455   SetupPhysics();
496   if (verboseLevel > 2) G4ParticleTable::GetPa << 456   if(verboseLevel>2) G4ParticleTable::GetParticleTable()->DumpTable();
497   if (verboseLevel > 1) {                      << 457   if(verboseLevel>1)
498     G4cout << "List of instantiated particles  << 458   {
499               "=============================== << 459     G4cout << "List of instantiated particles ============================================" << G4endl;
500            << G4endl;                          << 
501     G4int nPtcl = G4ParticleTable::GetParticle    460     G4int nPtcl = G4ParticleTable::GetParticleTable()->entries();
502     for (G4int i = 0; i < nPtcl; ++i) {        << 461     for(G4int i=0;i<nPtcl;i++)
                                                   >> 462     {
503       G4ParticleDefinition* pd = G4ParticleTab    463       G4ParticleDefinition* pd = G4ParticleTable::GetParticleTable()->GetParticle(i);
504       G4cout << pd->GetParticleName() << " ";     464       G4cout << pd->GetParticleName() << " ";
505       if (i % 10 == 9) G4cout << G4endl;       << 465       if(i%10==9) G4cout << G4endl;
506     }                                             466     }
507     G4cout << G4endl;                             467     G4cout << G4endl;
508   }                                               468   }
509 }                                                 469 }
510                                                   470 
511 // ------------------------------------------- << 471 #include "G4IonTable.hh"
                                                   >> 472 #include "G4ParticleTableIterator.hh"
                                                   >> 473 #include "G4IonConstructor.hh"
                                                   >> 474 #include "G4Geantino.hh"
                                                   >> 475 
512 void G4RunManagerKernel::SetupPhysics()           476 void G4RunManagerKernel::SetupPhysics()
513 {                                                 477 {
514   G4ParticleTable::GetParticleTable()->SetRead << 478   G4ParticleTable::GetParticleTable()->SetReadiness();
515                                                   479 
516   physicsList->ConstructParticle();            << 480     physicsList->ConstructParticle();
517                                                << 
518   // For sanity reason                         << 
519   G4Geantino::GeantinoDefinition();            << 
520   G4ParticleDefinition* gion = G4ParticleTable << 
521   if (gion != nullptr) {                       << 
522     G4IonConstructor::ConstructParticle();     << 
523   }                                            << 
524   G4ParticleTable::GetParticleTable()->GetIonT << 
525                                                   481 
526   auto pItr = G4ParticleTable::GetParticleTabl << 482     // For sanity reason
527   pItr->reset();                               << 483     G4Geantino::GeantinoDefinition();
528   while ((*pItr)()) {                          << 484     G4ParticleDefinition* gion = G4ParticleTable::GetParticleTable()->GetGenericIon();
529     G4ParticleDefinition* particle = pItr->val << 485     if(gion)
530     if (!(particle->IsGeneralIon())) particle- << 486     { G4IonConstructor::ConstructParticle(); }
531   }                                            << 487     G4ParticleTable::GetParticleTable()->GetIonTable()->InitializeLightIons();
532                                                << 488 
533   if (gion != nullptr) {                       << 489     G4ParticleTable::G4PTblDicIterator* pItr = G4ParticleTable::GetParticleTable()->GetIterator();
534     G4int gionId = gion->GetParticleDefinition << 490     pItr->reset();
535     pItr->reset(false);                        << 491     while( (*pItr)() )
536     while ((*pItr)()) {                        << 492     {
537       G4ParticleDefinition* particle = pItr->v    493       G4ParticleDefinition* particle = pItr->value();
538       if (particle->IsGeneralIon()) particle-> << 494       if(!(particle->IsGeneralIon())) particle->SetParticleDefinitionID();
                                                   >> 495     }
                                                   >> 496 
                                                   >> 497     if(gion)
                                                   >> 498     {
                                                   >> 499       G4int gionId = gion->GetParticleDefinitionID();
                                                   >> 500       pItr->reset(false);
                                                   >> 501       while( (*pItr)() )
                                                   >> 502       {
                                                   >> 503         G4ParticleDefinition* particle = pItr->value();
                                                   >> 504         if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
                                                   >> 505       }
539     }                                             506     }
540   }                                            << 
541 #ifdef G4MULTITHREADED                         << 
542   G4UnitDefinition::GetUnitsTable().Synchroniz << 
543 #endif                                         << 
544 }                                                 507 }
545                                                   508 
546 // ------------------------------------------- << 509 namespace {
547 namespace                                      << 510     G4Mutex initphysicsmutex = G4MUTEX_INITIALIZER;
548 {                                              << 
549 G4Mutex initphysicsmutex = G4MUTEX_INITIALIZER << 
550 }                                                 511 }
551                                                   512 
552 // ------------------------------------------- << 
553 void G4RunManagerKernel::InitializePhysics()      513 void G4RunManagerKernel::InitializePhysics()
554 {                                                 514 {
555   G4StateManager* stateManager = G4StateManage << 515   G4StateManager*    stateManager = G4StateManager::GetStateManager();
556   G4ApplicationState currentState = stateManag    516   G4ApplicationState currentState = stateManager->GetCurrentState();
557   if (currentState != G4State_Init) {          << 517   if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
558     G4cout << "Current application state is "  << 518   { 
559            << G4endl;                          << 519     G4Exception("G4RunManagerKernel::InitializePhysics",
560     if (currentState != G4State_Idle && curren << 520                 "Run0011", JustWarning,
561       G4Exception("G4RunManagerKernel::Initial << 521                 "Geant4 kernel is not PreInit or Idle state : Method ignored.");
562                   FatalException, "Geant4 kern << 522     return;
563       return;                                  << 
564     }                                          << 
565                                                << 
566     G4cout << "Warning : Geant4 kernel is not  << 
567     stateManager->SetNewState(G4State_Init);   << 
568   }                                               523   }
569                                                   524 
570   if (physicsList == nullptr) {                << 525   if(!physicsList)
571     G4Exception("G4RunManagerKernel::Initializ << 526   {
                                                   >> 527     G4Exception("G4RunManagerKernel::InitializePhysics",
                                                   >> 528                 "Run0012", FatalException,
572                 "G4VUserPhysicsList is not def    529                 "G4VUserPhysicsList is not defined");
573     return;                                       530     return;
574   }                                               531   }
575                                                   532 
576   if (verboseLevel > 1) G4cout << "physicsList << 533   if(verboseLevel>1) G4cout << "physicsList->Construct() start." << G4endl;
577   if (numberOfParallelWorld > 0) physicsList-> << 534   if(numberOfParallelWorld>0) physicsList->UseCoupledTransportation();
578   physicsList->Construct();                       535   physicsList->Construct();
579                                                << 536     
580   if (verboseLevel > 1) G4cout << "physicsList << 537   if(verboseLevel>1) G4cout << "physicsList->CheckParticleList() start." << G4endl;
581   physicsList->CheckParticleList();               538   physicsList->CheckParticleList();
582                                                << 539     //Cannot assume that SetCuts and CheckRegions are thread safe. We need to mutex
583   // Cannot assume that SetCuts() and CheckReg << 540     //Report from valgrind --tool=drd
584   // We need to mutex (report from valgrind -- << 
585   G4AutoLock l(&initphysicsmutex);                541   G4AutoLock l(&initphysicsmutex);
586   if (G4Threading::IsMasterThread()) {         << 542   if ( G4Threading::IsMasterThread() ) {
587     if (verboseLevel > 1) G4cout << "physicsLi << 543     if(verboseLevel>1) G4cout << "physicsList->setCut() start." << G4endl;
588     physicsList->SetCuts();                    << 544     physicsList->SetCuts();
                                                   >> 545 
589   }                                               546   }
590   CheckRegions();                                 547   CheckRegions();
591   l.unlock();                                     548   l.unlock();
592                                                   549 
593   physicsInitialized = true;                   << 550 /*******************
                                                   >> 551 //  static G4bool createIsomerOnlyOnce = false;
                                                   >> 552 //  if(G4Threading::IsMultithreadedApplication() && G4Threading::IsMasterThread())
                                                   >> 553 //  {
                                                   >> 554 //    if(!createIsomerOnlyOnce)
                                                   >> 555 //    {
                                                   >> 556 //      createIsomerOnlyOnce = true;
                                                   >> 557 //      G4ParticleDefinition* gion = G4ParticleTable::GetParticleTable()->GetGenericIon();
                                                   >> 558 //      if(gion)
                                                   >> 559 //      {
                                                   >> 560 //        G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
                                                   >> 561 //        PropagateGenericIonID();
                                                   >> 562 //      }
                                                   >> 563 //    }
                                                   >> 564 //  }
                                                   >> 565 *********************/
594                                                   566 
595 #ifdef G4MULTITHREADED                         << 567   physicsInitialized = true;
596   G4UnitDefinition::GetUnitsTable().Synchroniz << 568   if(geometryInitialized && currentState!=G4State_Idle)
597 #endif                                         << 569   { stateManager->SetNewState(G4State_Idle); }
598                                                << 
599   stateManager->SetNewState(currentState);     << 
600   if (geometryInitialized && currentState != G << 
601     stateManager->SetNewState(G4State_Idle);   << 
602   }                                            << 
603 }                                                 570 }
604                                                   571 
605 // ------------------------------------------- << 
606 G4bool G4RunManagerKernel::RunInitialization(G    572 G4bool G4RunManagerKernel::RunInitialization(G4bool fakeRun)
607 {                                                 573 {
608   G4StateManager* stateManager = G4StateManage << 574   G4StateManager*    stateManager = G4StateManager::GetStateManager();
609   G4ApplicationState currentState = stateManag    575   G4ApplicationState currentState = stateManager->GetCurrentState();
610                                                   576 
611   if (!geometryInitialized) {                  << 577   if(!geometryInitialized) 
612     G4Exception("G4RunManagerKernel::RunInitia << 578   { 
                                                   >> 579     G4Exception("G4RunManagerKernel::RunInitialization",
                                                   >> 580                 "Run0021",
                                                   >> 581                 JustWarning,
613                 "Geometry has not yet initiali    582                 "Geometry has not yet initialized : method ignored.");
614     return false;                                 583     return false;
615   }                                               584   }
616                                                << 585   
617   if (!physicsInitialized) {                   << 586   if(!physicsInitialized) 
618     G4Exception("G4RunManagerKernel::RunInitia << 587   { 
                                                   >> 588     G4Exception("G4RunManagerKernel::RunInitialization",
                                                   >> 589                 "Run0022",
                                                   >> 590                 JustWarning,
619                 "Physics has not yet initializ    591                 "Physics has not yet initialized : method ignored.");
620     return false;                                 592     return false;
621   }                                               593   }
622                                                   594 
623   if (currentState != G4State_Idle) {          << 595   if( currentState != G4State_Idle )
624     G4Exception("G4RunManagerKernel::RunInitia << 596   { 
                                                   >> 597     G4Exception("G4RunManagerKernel::RunInitialization",
                                                   >> 598                 "Run0023",
                                                   >> 599                 JustWarning,
625                 "Geant4 kernel not in Idle sta    600                 "Geant4 kernel not in Idle state : method ignored.");
626     return false;                                 601     return false;
627   }                                               602   }
628                                                   603 
629   if (geometryNeedsToBeClosed) CheckRegularGeo << 604   if(geometryNeedsToBeClosed) CheckRegularGeometry();
630                                                   605 
631   stateManager->SetNewState(G4State_Init);     << 
632   PropagateGenericIonID();                        606   PropagateGenericIonID();
633   SetupShadowProcess();                           607   SetupShadowProcess();
634   UpdateRegion();                                 608   UpdateRegion();
635   BuildPhysicsTables(fakeRun);                    609   BuildPhysicsTables(fakeRun);
636                                                   610 
637   if (geometryNeedsToBeClosed) {               << 611   if(geometryNeedsToBeClosed)
638     if(!fakeRun || resetNavigatorAtInitializat << 612   {
                                                   >> 613     ResetNavigator();
639     // CheckRegularGeometry();                    614     // CheckRegularGeometry();
640     // Notify the VisManager as well              615     // Notify the VisManager as well
641     if (G4Threading::IsMasterThread()) {       << 616     if(G4Threading::IsMasterThread())
                                                   >> 617     {
642       G4VVisManager* pVVisManager = G4VVisMana    618       G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
643       if (pVVisManager != nullptr) pVVisManage << 619       if(pVVisManager) pVVisManager->GeometryHasChanged();
644     }                                             620     }
645   }                                               621   }
646                                                << 622  
647   GetPrimaryTransformer()->CheckUnknown();        623   GetPrimaryTransformer()->CheckUnknown();
648                                                   624 
649 #ifdef G4MULTITHREADED                         << 
650   G4UnitDefinition::GetUnitsTable().Synchroniz << 
651 #endif                                         << 
652                                                << 
653   stateManager->SetNewState(G4State_Idle);     << 
654   stateManager->SetNewState(G4State_GeomClosed    625   stateManager->SetNewState(G4State_GeomClosed);
655   return true;                                    626   return true;
656 }                                                 627 }
657                                                   628 
658 // ------------------------------------------- << 
659 void G4RunManagerKernel::PropagateGenericIonID    629 void G4RunManagerKernel::PropagateGenericIonID()
660 {                                                 630 {
661   G4ParticleDefinition* gion = G4ParticleTable    631   G4ParticleDefinition* gion = G4ParticleTable::GetParticleTable()->GetGenericIon();
662   if (gion != nullptr) {                       << 632   if(gion)
                                                   >> 633   {
                                                   >> 634     //G4ParticleTable::GetParticleTable()->GetIonTable()->CreateAllIsomer();
663     G4int gionId = gion->GetParticleDefinition    635     G4int gionId = gion->GetParticleDefinitionID();
664     auto pItr = G4ParticleTable::GetParticleTa << 636     G4ParticleTable::G4PTblDicIterator* pItr = G4ParticleTable::GetParticleTable()->GetIterator();
665     pItr->reset(false);                           637     pItr->reset(false);
666     while ((*pItr)()) {                        << 638     while( (*pItr)() )
                                                   >> 639     {
667       G4ParticleDefinition* particle = pItr->v    640       G4ParticleDefinition* particle = pItr->value();
668       if (particle->IsGeneralIon()) particle-> << 641       if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
669     }                                             642     }
670   }                                               643   }
671 }                                                 644 }
672                                                   645 
673 // ------------------------------------------- << 
674 void G4RunManagerKernel::RunTermination()         646 void G4RunManagerKernel::RunTermination()
675 {                                                 647 {
676   if (runManagerKernelType != workerRMK)       << 648   if ( runManagerKernelType != workerRMK )
677   { G4ProductionCutsTable::GetProductionCutsTa << 649       G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
678   G4StateManager::GetStateManager()->SetNewSta << 650   G4StateManager::GetStateManager()->SetNewState(G4State_Idle); 
679 }                                                 651 }
680                                                   652 
681 // ------------------------------------------- << 
682 void G4RunManagerKernel::ResetNavigator()         653 void G4RunManagerKernel::ResetNavigator()
683 {                                                 654 {
684   G4GeometryManager* geomManager = G4GeometryM << 655   if(runManagerKernelType==workerRMK)
685   if (runManagerKernelType == workerRMK) {     << 656   { geometryNeedsToBeClosed = false; return; }
686     // To ensure that it is called when using  << 
687     if( geomManager->IsParallelOptimisationCon << 
688        !geomManager->IsParallelOptimisationFin << 
689     {                                          << 
690       geomManager->UndertakeOptimisation();    << 
691     }                                          << 
692     geometryNeedsToBeClosed = false;           << 
693     return;                                    << 
694   }                                            << 
695                                                   657 
696   // We have to tweak the navigator's state in    658   // We have to tweak the navigator's state in case a geometry has been
697   // modified between runs. By the following c    659   // modified between runs. By the following calls we ensure that navigator's
698   // state is reset properly. It is required t    660   // state is reset properly. It is required the geometry to be closed
699   // and previous optimisations to be cleared.    661   // and previous optimisations to be cleared.
700                                                << 662   
701   if (verboseLevel > 1) G4cout << "Start closi << 663   G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
                                                   >> 664   if(verboseLevel>1) G4cout << "Start closing geometry." << G4endl;
702                                                   665 
703   geomManager->OpenGeometry();                    666   geomManager->OpenGeometry();
704   geomManager->CloseGeometry(geometryToBeOptim << 667   geomManager->CloseGeometry(geometryToBeOptimized, verboseLevel>1);
705                                                << 668  
706   geometryNeedsToBeClosed = false;                669   geometryNeedsToBeClosed = false;
707 }                                                 670 }
708                                                   671 
709 // ------------------------------------------- << 
710 void G4RunManagerKernel::UpdateRegion()           672 void G4RunManagerKernel::UpdateRegion()
711 {                                                 673 {
712   G4StateManager* stateManager = G4StateManage << 674   G4StateManager*    stateManager = G4StateManager::GetStateManager();
713   G4ApplicationState currentState = stateManag    675   G4ApplicationState currentState = stateManager->GetCurrentState();
714   if (currentState != G4State_Init) {          << 676   if( currentState != G4State_Idle )
715     G4Exception("G4RunManagerKernel::UpdateReg << 677   { 
716                 "Geant4 kernel not in Init sta << 678     G4Exception("G4RunManagerKernel::UpdateRegion",
                                                   >> 679                 "Run0024",
                                                   >> 680                 JustWarning,
                                                   >> 681                 "Geant4 kernel not in Idle state : method ignored.");
717     return;                                       682     return;
718   }                                               683   }
719                                                   684 
720   if (runManagerKernelType == workerRMK) retur << 685   if(runManagerKernelType==workerRMK) return;
721                                                   686 
722   CheckRegions();                                 687   CheckRegions();
723                                                   688 
724   G4RegionStore::GetInstance()->UpdateMaterial    689   G4RegionStore::GetInstance()->UpdateMaterialList(currentWorld);
725                                                   690 
726   G4ProductionCutsTable::GetProductionCutsTabl    691   G4ProductionCutsTable::GetProductionCutsTable()->UpdateCoupleTable(currentWorld);
727 }                                                 692 }
728                                                   693 
729 // ------------------------------------------- << 
730 void G4RunManagerKernel::BuildPhysicsTables(G4    694 void G4RunManagerKernel::BuildPhysicsTables(G4bool fakeRun)
731 {                                                 695 {
732   if (G4ProductionCutsTable::GetProductionCuts << 696   if( G4ProductionCutsTable::GetProductionCutsTable()->IsModified()
                                                   >> 697   || physicsNeedsToBeReBuilt)
                                                   >> 698   {
733 #ifdef G4MULTITHREADED                            699 #ifdef G4MULTITHREADED
734     if (runManagerKernelType == masterRMK) {   << 700     if(runManagerKernelType==masterRMK)
                                                   >> 701     {
735       // make sure workers also rebuild physic    702       // make sure workers also rebuild physics tables
736       G4UImanager* pUImanager = G4UImanager::G    703       G4UImanager* pUImanager = G4UImanager::GetUIpointer();
737       pUImanager->ApplyCommand("/run/physicsMo    704       pUImanager->ApplyCommand("/run/physicsModified");
738     }                                             705     }
739 #endif                                            706 #endif
740     physicsList->BuildPhysicsTable();             707     physicsList->BuildPhysicsTable();
                                                   >> 708     ////G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
741     physicsNeedsToBeReBuilt = false;              709     physicsNeedsToBeReBuilt = false;
742   }                                               710   }
743                                                   711 
744   if (!fakeRun && verboseLevel > 1) DumpRegion << 712   if(!fakeRun && verboseLevel>1) DumpRegion();
745   if (!fakeRun && verboseLevel > 0) physicsLis << 713   if(!fakeRun && verboseLevel>0) physicsList->DumpCutValuesTable();
746   if (!fakeRun) physicsList->DumpCutValuesTabl << 714   if(!fakeRun) physicsList->DumpCutValuesTableIfRequested();
747 }                                                 715 }
748                                                   716 
749 // ------------------------------------------- << 
750 void G4RunManagerKernel::CheckRegions()           717 void G4RunManagerKernel::CheckRegions()
751 {                                                 718 {
752   G4TransportationManager* transM = G4Transpor    719   G4TransportationManager* transM = G4TransportationManager::GetTransportationManager();
753   std::size_t nWorlds = transM->GetNoWorlds(); << 720   size_t nWorlds = transM->GetNoWorlds();
754   std::vector<G4VPhysicalVolume*>::iterator wI    721   std::vector<G4VPhysicalVolume*>::iterator wItr;
755   for (auto region : *G4RegionStore::GetInstan << 722   for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
756     // Let each region have a pointer to the w << 723   { 
757     // G4Region::SetWorld() checks if the regi << 724     G4Region* region = (*(G4RegionStore::GetInstance()))[i];
758     // set it only if it does. Thus, here we g << 725 
759     // volumes.                                << 726     //Let each region have a pointer to the world volume where it belongs to.
760     region->SetWorld(nullptr);  // reset       << 727     //G4Region::SetWorld() checks if the region belongs to the given world and set it
                                                   >> 728     //only if it does. Thus, here we go through all the registered world volumes.
                                                   >> 729     region->SetWorld(0); // reset
761     region->UsedInMassGeometry(false);            730     region->UsedInMassGeometry(false);
762     region->UsedInParallelGeometry(false);        731     region->UsedInParallelGeometry(false);
763     wItr = transM->GetWorldsIterator();           732     wItr = transM->GetWorldsIterator();
764     for (std::size_t iw = 0; iw < nWorlds; ++i << 733     for(size_t iw=0;iw<nWorlds;iw++)
765       if (region->BelongsTo(*wItr)) {          << 734     {
766         if (*wItr == currentWorld) {           << 735       if(region->BelongsTo(*wItr))
767           region->UsedInMassGeometry(true);    << 736       {
768         }                                      << 737         if(*wItr==currentWorld)
769         else {                                 << 738         { region->UsedInMassGeometry(true); }
770           region->UsedInParallelGeometry(true) << 739         else
771         }                                      << 740         { region->UsedInParallelGeometry(true); }
772       }                                           741       }
773       region->SetWorld(*wItr);                    742       region->SetWorld(*wItr);
774       ++wItr;                                  << 743       wItr++;
775     }                                             744     }
776                                                   745 
777     G4ProductionCuts* cuts = region->GetProduc    746     G4ProductionCuts* cuts = region->GetProductionCuts();
778     if (cuts == nullptr) {                     << 747     if(!cuts)
779       if (region->IsInMassGeometry() && verbos << 748     {
                                                   >> 749       if(region->IsInMassGeometry())
                                                   >> 750       {
780         G4cout << "Warning : Region <" << regi    751         G4cout << "Warning : Region <" << region->GetName()
781                << "> does not have specific pr << 752              << "> does not have specific production cuts," << G4endl
782                << "even though it appears in t << 753              << "even though it appears in the current tracking world." << G4endl;
783         G4cout << "Default cuts are used for t    754         G4cout << "Default cuts are used for this region." << G4endl;
784       }                                           755       }
785                                                   756 
786       if (region->IsInMassGeometry() || region << 757       if(region->IsInMassGeometry()||region->IsInParallelGeometry())
                                                   >> 758       {
787         region->SetProductionCuts(                759         region->SetProductionCuts(
788           G4ProductionCutsTable::GetProduction << 760           G4ProductionCutsTable::GetProductionCutsTable()
                                                   >> 761              ->GetDefaultProductionCuts());
789       }                                           762       }
790     }                                             763     }
791   }                                               764   }
792                                                   765 
793   //                                              766   //
794   // If a parallel world has no region, set de    767   // If a parallel world has no region, set default region for parallel world
795   //                                              768   //
796                                                   769 
797   wItr = transM->GetWorldsIterator();             770   wItr = transM->GetWorldsIterator();
798   for (std::size_t iw = 0; iw < nWorlds; ++iw) << 771   for(size_t iw=0;iw<nWorlds;iw++)
799     if (*wItr != currentWorld) {               << 772   {
                                                   >> 773     //G4cout << "+++ " << (*wItr)->GetName() << G4endl;
                                                   >> 774     if(*wItr!=currentWorld)
                                                   >> 775     {
800       G4LogicalVolume* pwLogical = (*wItr)->Ge    776       G4LogicalVolume* pwLogical = (*wItr)->GetLogicalVolume();
801       if (pwLogical->GetRegion() == nullptr) { << 777       if(!(pwLogical->GetRegion()))
                                                   >> 778       {
802         pwLogical->SetRegion(defaultRegionForP    779         pwLogical->SetRegion(defaultRegionForParallelWorld);
803         defaultRegionForParallelWorld->AddRoot    780         defaultRegionForParallelWorld->AddRootLogicalVolume(pwLogical);
                                                   >> 781         //G4cout << "+++++ defaultRegionForParallelWorld is set to "
                                                   >> 782         //       << (*wItr)->GetName() << " +++++" << G4endl;
804       }                                           783       }
805     }                                             784     }
806     ++wItr;                                    << 785     wItr++;
807   }                                               786   }
                                                   >> 787 
808 }                                                 788 }
809                                                   789 
810 // ------------------------------------------- << 
811 void G4RunManagerKernel::DumpRegion(const G4St    790 void G4RunManagerKernel::DumpRegion(const G4String& rname) const
812 {                                                 791 {
813   G4Region* region = G4RegionStore::GetInstanc    792   G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname);
814   if (region != nullptr) DumpRegion(region);   << 793   if(region) DumpRegion(region);
815 }                                                 794 }
816                                                   795 
817 // ------------------------------------------- << 
818 void G4RunManagerKernel::DumpRegion(G4Region*     796 void G4RunManagerKernel::DumpRegion(G4Region* region) const
819 {                                                 797 {
820   if (region == nullptr) {                     << 798   if(!region)
821     for (const auto& i : *G4RegionStore::GetIn << 799   {
822       DumpRegion(i);                           << 800     for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
823     }                                          << 801     { DumpRegion((*(G4RegionStore::GetInstance()))[i]); }
824   }                                            << 802   }
825   else {                                       << 803   else
826     if (G4Threading::IsWorkerThread()) return; << 804   {
                                                   >> 805     if(G4Threading::IsWorkerThread()) return;
827     G4cout << G4endl;                             806     G4cout << G4endl;
828     G4cout << "Region <" << region->GetName()     807     G4cout << "Region <" << region->GetName() << "> -- ";
829     if (region->GetWorldPhysical() != nullptr) << 808     if(region->GetWorldPhysical())
830       G4cout << " -- appears in <" << region-> << 809     {
831     }                                          << 810       G4cout << " -- appears in <" 
832     else {                                     << 811            << region->GetWorldPhysical()->GetName() << "> world volume";
833       G4cout << " -- is not associated to any  << 
834     }                                             812     }
                                                   >> 813     else
                                                   >> 814     { G4cout << " -- is not associated to any world."; }
835     G4cout << G4endl;                             815     G4cout << G4endl;
836     if (region->IsInMassGeometry()) {          << 816     if(region->IsInMassGeometry())
837       G4cout << " This region is in the mass w << 817     { G4cout << " This region is in the mass world." << G4endl; }
838     }                                          << 818     if(region->IsInParallelGeometry())
839     if (region->IsInParallelGeometry()) {      << 819     { G4cout << " This region is in the parallel world." << G4endl; }
840       G4cout << " This region is in the parall << 
841     }                                          << 
842                                                   820 
843     G4cout << " Root logical volume(s) : ";       821     G4cout << " Root logical volume(s) : ";
844     std::size_t nRootLV = region->GetNumberOfR << 822     size_t nRootLV = region->GetNumberOfRootVolumes();
845     auto lvItr = region->GetRootLogicalVolumeI << 823     std::vector<G4LogicalVolume*>::iterator lvItr = region->GetRootLogicalVolumeIterator();
846     for (std::size_t j = 0; j < nRootLV; ++j)  << 824     for(size_t j=0;j<nRootLV;j++)
847       G4cout << (*lvItr)->GetName() << " ";    << 825     { G4cout << (*lvItr)->GetName() << " "; lvItr++; }
848       ++lvItr;                                 << 
849     }                                          << 
850     G4cout << G4endl;                             826     G4cout << G4endl;
851                                                   827 
852     G4cout << " Pointers : G4VUserRegionInform << 828     G4cout << " Pointers : G4VUserRegionInformation[" << region->GetUserInformation() 
853            << "], G4UserLimits[" << region->Ge << 829            << "], G4UserLimits[" << region->GetUserLimits() 
854            << region->GetFastSimulationManager << 830            << "], G4FastSimulationManager[" << region->GetFastSimulationManager()
855            << region->GetRegionalSteppingActio << 831            << "], G4UserSteppingAction[" << region->GetRegionalSteppingAction() << "]" << G4endl;
856                                                << 832     
857     G4cout << " Materials : ";                    833     G4cout << " Materials : ";
858     auto mItr = region->GetMaterialIterator(); << 834     std::vector<G4Material*>::const_iterator mItr = region->GetMaterialIterator();
859     std::size_t nMaterial = region->GetNumberO << 835     size_t nMaterial = region->GetNumberOfMaterials();
860     for (std::size_t iMate = 0; iMate < nMater << 836     for(size_t iMate=0;iMate<nMaterial;iMate++)
                                                   >> 837     {
861       G4cout << (*mItr)->GetName() << " ";        838       G4cout << (*mItr)->GetName() << " ";
862       ++mItr;                                  << 839       mItr++;
863     }                                             840     }
864     G4cout << G4endl;                             841     G4cout << G4endl;
865     G4ProductionCuts* cuts = region->GetProduc    842     G4ProductionCuts* cuts = region->GetProductionCuts();
866     if ((cuts == nullptr) && region->IsInMassG << 843     if(!cuts && region->IsInMassGeometry())
                                                   >> 844     {
867       G4cerr << "Warning : Region <" << region    845       G4cerr << "Warning : Region <" << region->GetName()
868              << "> does not have specific prod    846              << "> does not have specific production cuts." << G4endl;
869       G4cerr << "Default cuts are used for thi    847       G4cerr << "Default cuts are used for this region." << G4endl;
870       region->SetProductionCuts(                  848       region->SetProductionCuts(
871         G4ProductionCutsTable::GetProductionCu << 849           G4ProductionCutsTable::GetProductionCutsTable()->GetDefaultProductionCuts());
872     }                                             850     }
873     else if (cuts != nullptr) {                << 851     else if(cuts)
                                                   >> 852     {
874       G4cout << " Production cuts : "             853       G4cout << " Production cuts : "
875              << "  gamma " << G4BestUnit(cuts- << 854              << "  gamma "
876              << G4BestUnit(cuts->GetProduction << 855              << G4BestUnit(cuts->GetProductionCut("gamma"),"Length")
877              << G4BestUnit(cuts->GetProduction << 856              << "     e- "
878              << G4BestUnit(cuts->GetProduction << 857              << G4BestUnit(cuts->GetProductionCut("e-"),"Length")
                                                   >> 858              << "     e+ "
                                                   >> 859              << G4BestUnit(cuts->GetProductionCut("e+"),"Length")
                                                   >> 860              << " proton "
                                                   >> 861              << G4BestUnit(cuts->GetProductionCut("proton"),"Length")
                                                   >> 862              << G4endl;
879     }                                             863     }
880   }                                               864   }
881 }                                                 865 }
882                                                   866 
883 // ------------------------------------------- << 867 #include "G4LogicalVolumeStore.hh"
884 void G4RunManagerKernel::CheckRegularGeometry(    868 void G4RunManagerKernel::CheckRegularGeometry()
885 {                                                 869 {
886   G4LogicalVolumeStore* store = G4LogicalVolum    870   G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
887   for (const auto& pos : *store) {             << 871   for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
888     if ((pos != nullptr) && (pos->GetNoDaughte << 872   {
889       if (pos->GetDaughter(0)->IsRegularStruct << 873     if((*pos)&&((*pos)->GetNoDaughters()==1))
                                                   >> 874     {
                                                   >> 875       if((*pos)->GetDaughter(0)->IsRegularStructure())
                                                   >> 876       {
890         SetScoreSplitter();                       877         SetScoreSplitter();
891         return;                                   878         return;
892       }                                           879       }
893     }                                             880     }
894   }                                               881   }
895 }                                                 882 }
896                                                << 883         
897 // ------------------------------------------- << 884 #include "G4ParticleTable.hh"
                                                   >> 885 #include "G4ParticleDefinition.hh"
                                                   >> 886 #include "G4ProcessManager.hh"
                                                   >> 887 #include "G4ProcessVector.hh"
                                                   >> 888 #include "G4VProcess.hh"
898 G4bool G4RunManagerKernel::ConfirmCoupledTrans    889 G4bool G4RunManagerKernel::ConfirmCoupledTransportation()
899 {                                                 890 {
900   G4ParticleTable* theParticleTable = G4Partic    891   G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
901   auto theParticleIterator = theParticleTable- << 892   G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable->GetIterator();
902   theParticleIterator->reset();                   893   theParticleIterator->reset();
903   while ((*theParticleIterator)()) {           << 894   while((*theParticleIterator)())
                                                   >> 895   {
904     G4ParticleDefinition* pd = theParticleIter    896     G4ParticleDefinition* pd = theParticleIterator->value();
905     G4ProcessManager* pm = pd->GetProcessManag    897     G4ProcessManager* pm = pd->GetProcessManager();
906     if (pm != nullptr) {                       << 898     if(pm)
                                                   >> 899     {
907       G4ProcessVector* pv = pm->GetAlongStepPr    900       G4ProcessVector* pv = pm->GetAlongStepProcessVector(typeDoIt);
908       G4VProcess* p = (*pv)[0];                   901       G4VProcess* p = (*pv)[0];
909       return ((p->GetProcessName()) == "Couple << 902       return ( (p->GetProcessName()) == "CoupledTransportation" );
910     }                                             903     }
911   }                                               904   }
912   return false;                                   905   return false;
913 }                                                 906 }
914                                                   907 
915 // ------------------------------------------- << 908 #include "G4ScoreSplittingProcess.hh"
916 void G4RunManagerKernel::SetScoreSplitter()       909 void G4RunManagerKernel::SetScoreSplitter()
917 {                                                 910 {
918   auto pSplitter = new G4ScoreSplittingProcess << 911   G4ScoreSplittingProcess* pSplitter = new G4ScoreSplittingProcess();
919   G4ParticleTable* theParticleTable = G4Partic    912   G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
920   auto theParticleIterator = theParticleTable- << 913   G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable->GetIterator();
921                                                   914 
922   // Ensure that Process is added only once to    915   // Ensure that Process is added only once to the particles' process managers
923   static G4ThreadLocal G4bool InitSplitter = f << 916   static G4ThreadLocal bool InitSplitter=false; 
924   if (!InitSplitter) {                         << 917   if( ! InitSplitter ) {
925     InitSplitter = true;                          918     InitSplitter = true;
926                                                   919 
927     theParticleIterator->reset();                 920     theParticleIterator->reset();
928     while ((*theParticleIterator)()) {         << 921     while( (*theParticleIterator)() )  
                                                   >> 922     {
929       G4ParticleDefinition* particle = thePart    923       G4ParticleDefinition* particle = theParticleIterator->value();
930       G4ProcessManager* pmanager = particle->G    924       G4ProcessManager* pmanager = particle->GetProcessManager();
931       if (pmanager != nullptr) {               << 925       if(pmanager)
932         pmanager->AddDiscreteProcess(pSplitter << 926   { pmanager->AddDiscreteProcess(pSplitter); }
933       }                                        << 
934     }                                             927     }
935                                                   928 
936     if (verboseLevel > 0) {                    << 929     if(verboseLevel>0) 
937       G4cout << "G4RunManagerKernel -- G4Score << 930     {
938                 "particles."                   << 931       G4cout << "G4RunManagerKernel -- G4ScoreSplittingProcess is appended to all particles." << G4endl;
939              << G4endl;                        << 
940     }                                             932     }
941   }                                               933   }
942 }                                                 934 }
943                                                   935 
944 // ------------------------------------------- << 
945 void G4RunManagerKernel::SetupShadowProcess()     936 void G4RunManagerKernel::SetupShadowProcess() const
946 {                                                 937 {
947   G4ParticleTable* theParticleTable = G4Partic << 938     G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
948   auto theParticleIterator = theParticleTable- << 939     G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable->GetIterator();
949   theParticleIterator->reset();                << 940     theParticleIterator->reset();
950   // loop on particles and get process manager << 941     //loop on particles and get process manager from there list of processes
951   while ((*theParticleIterator)()) {           << 942     while((*theParticleIterator)())
952     G4ParticleDefinition* pd = theParticleIter << 943     {
953     G4ProcessManager* pm = pd->GetProcessManag << 944         G4ParticleDefinition* pd = theParticleIterator->value();
954     if (pm != nullptr) {                       << 945         G4ProcessManager* pm = pd->GetProcessManager();
955       G4ProcessVector& procs = *(pm->GetProces << 946         if(pm)
956       for (G4int idx = 0; idx < (G4int)procs.s << 947         {
957         const G4VProcess* masterP = procs[idx] << 948             G4ProcessVector& procs = *(pm->GetProcessList());
958         if (masterP == nullptr) {              << 949             for ( G4int idx = 0 ; idx<procs.size() ; ++idx)
959           // Process does not have an associat << 950             {
960           // We are in master mode or sequenti << 951                 const G4VProcess* masterP = procs[idx]->GetMasterProcess();
961           procs[idx]->SetMasterProcess(const_c << 952                 if ( ! masterP )
                                                   >> 953                 {
                                                   >> 954                     //Process does not have an associated shadow master process
                                                   >> 955                     //We are in master mode or sequential
                                                   >> 956                     procs[idx]->SetMasterProcess(const_cast<G4VProcess*>(procs[idx]));
                                                   >> 957                 }
                                                   >> 958             }
962         }                                         959         }
963       }                                        << 
964     }                                             960     }
965   }                                            << 
966 }                                                 961 }
967                                                   962