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 7.0.p1)


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