Geant4 Cross Reference |
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 // G4MTRunManagerKernel implementation << 27 // << 28 // Author: M.Asai - July 2013 << 29 // ------------------------------------------- << 30 #include "G4MTRunManagerKernel.hh" << 31 26 32 #include "G4AutoLock.hh" << 27 #include "G4MTRunManagerKernel.hh" 33 #include "G4DecayTable.hh" << 34 #include "G4LogicalVolume.hh" << 35 #include "G4Material.hh" << 36 #include "G4MaterialTable.hh" << 37 #include "G4PVParameterised.hh" << 38 #include "G4PVReplica.hh" << 39 #include "G4ParticleDefinition.hh" << 40 #include "G4ParticleTable.hh" << 41 #include "G4ParticleTableIterator.hh" << 42 #include "G4PhysicalVolumeStore.hh" << 43 #include "G4PhysicsVector.hh" << 44 #include "G4PolyconeSide.hh" << 45 #include "G4PolyhedraSide.hh" << 46 #include "G4Region.hh" << 47 #include "G4RegionStore.hh" 28 #include "G4RegionStore.hh" 48 #include "G4StateManager.hh" 29 #include "G4StateManager.hh" 49 #include "G4UImanager.hh" << 30 #include "G4AutoLock.hh" 50 #include "G4UserWorkerInitialization.hh" << 51 #include "G4UserWorkerThreadInitialization.hh" << 52 #include "G4VDecayChannel.hh" << 53 #include "G4VModularPhysicsList.hh" << 54 #include "G4VPhysicalVolume.hh" << 55 #include "G4VPhysicsConstructor.hh" << 56 #include "G4VUserActionInitialization.hh" << 57 #include "G4VUserPhysicsList.hh" << 58 #include "G4WorkerRunManager.hh" << 59 #include "G4WorkerThread.hh" << 60 << 61 std::vector<G4WorkerRunManager*>* G4MTRunManag << 62 31 63 G4ThreadLocal G4WorkerThread* G4MTRunManagerKe << 32 std::vector<G4WorkerRunManager*>* G4MTRunManagerKernel::workerRMvector = 0; 64 33 65 // ------------------------------------------- << 34 namespace { 66 namespace << 35 G4Mutex workerRMMutex = G4MUTEX_INITIALIZER; 67 { << 68 G4Mutex workerRMMutex = G4MUTEX_INITIALIZER; << 69 } 36 } 70 37 71 // ------------------------------------------- << 72 G4MTRunManagerKernel::G4MTRunManagerKernel() : 38 G4MTRunManagerKernel::G4MTRunManagerKernel() : G4RunManagerKernel(masterRMK) 73 { 39 { 74 // This version of the constructor should ne << 40 //This version of the constructor should never be called in sequential mode! 75 #ifndef G4MULTITHREADED 41 #ifndef G4MULTITHREADED 76 G4ExceptionDescription msg; << 42 G4ExceptionDescription msg; 77 msg << "Geant4 code is compiled without mult << 43 msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off)."; 78 "(-DG4MULTITHREADED " << 44 msg<<" This type of RunManager can only be used in mult-threaded applications."; 79 "is set to off)."; << 45 G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0035",FatalException,msg); 80 msg << " This type of RunManager can only be << 81 "applications."; << 82 G4Exception("G4RunManagerKernel::G4RunManage << 83 #endif 46 #endif 84 G4AutoLock l(&workerRMMutex); << 47 if(!workerRMvector) workerRMvector = new std::vector<G4WorkerRunManager*>; 85 if (workerRMvector == nullptr) workerRMvecto << 48 //Set flag that a MT-type kernel has been instantiated 86 l.unlock(); << 49 G4Threading::SetMultithreadedApplication(true); 87 // Set flag that a MT-type kernel has been i << 88 G4Threading::SetMultithreadedApplication(tru << 89 } 50 } 90 51 91 // ------------------------------------------- << 92 G4MTRunManagerKernel::~G4MTRunManagerKernel() 52 G4MTRunManagerKernel::~G4MTRunManagerKernel() 93 { 53 { 94 G4AutoLock l(&workerRMMutex); << 54 if(!workerRMvector) 95 if (workerRMvector != nullptr) { << 55 { 96 if (!workerRMvector->empty()) { << 56 if(workerRMvector->size()>0) 97 G4ExceptionDescription msg; << 57 { 98 msg << "G4MTRunManagerKernel is to be de << 58 G4ExceptionDescription msg; 99 << " G4WorkerRunManager are still al << 59 msg<<"G4MTRunManagerKernel is to be deleted while " 100 G4Exception("G4RunManagerKernel::~G4RunM << 60 <<workerRMvector->size()<<" G4WorkerRunManager are still alive."; 101 } << 61 G4Exception("G4RunManagerKernel::~G4RunManagerKernel()", 102 delete workerRMvector; << 62 "Run10035",FatalException,msg); 103 workerRMvector = nullptr; << 63 } 104 } << 64 delete workerRMvector; >> 65 workerRMvector = 0; >> 66 } 105 } 67 } 106 68 107 // ------------------------------------------- << 108 void G4MTRunManagerKernel::SetupShadowProcess( 69 void G4MTRunManagerKernel::SetupShadowProcess() const 109 { 70 { 110 // Behavior is the same as base class (seque << 71 //Behavior is the same as base class (sequential mode) 111 // ShadowProcess pointer == process poitner << 72 //ShadowProcess pointer == process poitner 112 G4RunManagerKernel::SetupShadowProcess(); << 73 G4RunManagerKernel::SetupShadowProcess(); 113 } 74 } 114 75 115 // ------------------------------------------- << 76 #include "G4WorkerRunManager.hh" 116 G4WorkerThread* G4MTRunManagerKernel::GetWorke << 77 #include "G4UserWorkerInitialization.hh" 117 { << 78 #include "G4UserWorkerThreadInitialization.hh" 118 return wThreadContext; << 79 #include "G4VUserActionInitialization.hh" 119 } << 80 #include "G4WorkerThread.hh" >> 81 #include "G4UImanager.hh" >> 82 #include "G4LogicalVolume.hh" >> 83 #include "G4VPhysicalVolume.hh" >> 84 #include "G4PVReplica.hh" >> 85 #include "G4Region.hh" >> 86 #include "G4Material.hh" >> 87 #include "G4PhysicsVector.hh" >> 88 #include "G4VDecayChannel.hh" >> 89 #include "G4PhysicalVolumeStore.hh" >> 90 #include "G4MaterialTable.hh" >> 91 #include "G4PolyconeSide.hh" >> 92 #include "G4PolyhedraSide.hh" >> 93 #include "G4PVParameterised.hh" >> 94 #include "G4VUserPhysicsList.hh" >> 95 #include "G4VPhysicsConstructor.hh" >> 96 #include "G4VModularPhysicsList.hh" >> 97 >> 98 G4ThreadLocal G4WorkerThread* G4MTRunManagerKernel::wThreadContext = 0; >> 99 G4WorkerThread* G4MTRunManagerKernel::GetWorkerThread() >> 100 { return wThreadContext; } 120 101 121 // ------------------------------------------- << 102 void* G4MTRunManagerKernel::StartThread(void* context) 122 void G4MTRunManagerKernel::StartThread(G4Worke << 123 { 103 { 124 //!!!!!!!!!!!!!!!!!!!!!!!!!! 104 //!!!!!!!!!!!!!!!!!!!!!!!!!! 125 //!!!!!! IMPORTANT !!!!!!!!! 105 //!!!!!! IMPORTANT !!!!!!!!! 126 //!!!!!!!!!!!!!!!!!!!!!!!!!! 106 //!!!!!!!!!!!!!!!!!!!!!!!!!! 127 // Here is not sequential anymore and G4User 107 // Here is not sequential anymore and G4UserWorkerThreadInitialization is 128 // a shared user initialization class. << 108 // a shared user initialization class 129 // This means this method cannot use data me << 109 // This means this method cannot use data memebers of G4RunManagerKernel 130 // unless they are invariant ("read-only") a 110 // unless they are invariant ("read-only") and can be safely shared. 131 // All the rest that is not invariant should << 111 // All the rest that is not invariant should be incapsualted into 132 // the context (or, as for wThreadContext be << 112 // the context (or, as for wThreadContext be G4ThreadLocal) 133 //!!!!!!!!!!!!!!!!!!!!!!!!!! 113 //!!!!!!!!!!!!!!!!!!!!!!!!!! 134 // #ifdef G4MULTITHREADED << 114 //#ifdef G4MULTITHREADED 135 // turnontpmalloc(); << 115 // turnontpmalloc(); 136 // #endif << 116 //#endif 137 G4Threading::WorkerThreadJoinsPool(); << 117 138 wThreadContext = context; << 118 wThreadContext = static_cast<G4WorkerThread*>(context); 139 G4MTRunManager* masterRM = G4MTRunManager::G 119 G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager(); 140 120 >> 121 141 //============================ 122 //============================ 142 // Step-0: Thread ID << 123 //Step-0: Thread ID 143 //============================ 124 //============================ 144 // Initialise per-thread stream-output << 125 //Initliazie per-thread stream-output 145 // The following line is needed before we ac << 126 //The following line is needed before we actually do IO initialization 146 // because the constructor of UI manager res << 127 //becasue the constructor of UI manager resets the IO destination. 147 G4int thisID = wThreadContext->GetThreadId() 128 G4int thisID = wThreadContext->GetThreadId(); 148 G4Threading::G4SetThreadId(thisID); 129 G4Threading::G4SetThreadId(thisID); 149 G4UImanager::GetUIpointer()->SetUpForAThread 130 G4UImanager::GetUIpointer()->SetUpForAThread(thisID); 150 131 151 //============================ 132 //============================ 152 // Optimization: optional << 133 //Optimization Step 153 //============================ 134 //============================ 154 // Enforce thread affinity if requested << 135 //Enforce thread affinity if requested 155 wThreadContext->SetPinAffinity(masterRM->Get << 136 #if !defined(WIN32) 156 << 137 if ( masterRM->GetPinAffinity() != 0 ) { >> 138 G4cout<<"AFFINITY SET"<<G4endl; >> 139 //Assign this thread to cpus in a round robin way >> 140 G4int offset = masterRM->GetPinAffinity(); >> 141 G4int cpuindex = 0; >> 142 if ( std::abs(offset)>G4Threading::G4GetNumberOfCores() ) { >> 143 G4Exception("G4MTRunManagerKernel::StarThread","Run0035",JustWarning,"Cannot set thread affinity, affinity parameter larger than number of cores"); >> 144 } >> 145 if ( offset == 0 ) { >> 146 offset = 1; >> 147 G4Exception("G4MTRunManagerKernel::StarThread","Run0035",JustWarning,"Affinity parameter==0, using 1 instead."); >> 148 } >> 149 if (offset>0) { //Start assigning affinity to given CPU >> 150 --offset; >> 151 cpuindex = (thisID+offset) % G4Threading::G4GetNumberOfCores(); //Round robin >> 152 } else {//Exclude the given CPU >> 153 offset *= -1; >> 154 --offset; >> 155 G4int myidx = thisID%(G4Threading::G4GetNumberOfCores()-1); >> 156 cpuindex = myidx + (myidx>=offset); >> 157 } >> 158 G4cout<<"AFFINITY:"<<cpuindex<<G4endl; >> 159 //Avoid compilation warning in C90 standard w/o MT >> 160 #if defined(G4MULTITHREADED) >> 161 G4Thread t = G4THREADSELF(); >> 162 #else >> 163 G4Thread t; >> 164 #endif >> 165 G4bool success = G4Threading::G4SetPinAffinity(cpuindex,t); >> 166 if ( ! success ) { >> 167 G4Exception("G4MTRunManagerKernel::StarThread","Run0035",JustWarning,"Cannot set thread affinity."); >> 168 } >> 169 } >> 170 #endif >> 171 157 //============================ 172 //============================ 158 // Step-1: Random number engine << 173 //Step-1: Random number engine 159 //============================ 174 //============================ 160 // RNG Engine needs to be initialised by "cl << 175 //RNG Engine needs to be initialized by "cloning" the master one. 161 const CLHEP::HepRandomEngine* masterEngine = 176 const CLHEP::HepRandomEngine* masterEngine = masterRM->getMasterRandomEngine(); 162 masterRM->GetUserWorkerThreadInitialization( 177 masterRM->GetUserWorkerThreadInitialization()->SetupRNGEngine(masterEngine); 163 178 164 //============================ 179 //============================ 165 // Step-2: Initialise worker thread << 180 //Step-2: Initialize worker thread 166 //============================ 181 //============================ 167 if (masterRM->GetUserWorkerInitialization() << 182 if(masterRM->GetUserWorkerInitialization()) 168 masterRM->GetUserWorkerInitialization()->W << 183 { masterRM->GetUserWorkerInitialization()->WorkerInitialize(); } 169 } << 184 if(masterRM->GetUserActionInitialization()) 170 if (masterRM->GetUserActionInitialization() << 185 { 171 G4VSteppingVerbose* sv = masterRM->GetUser << 186 G4VSteppingVerbose* sv = masterRM->GetUserActionInitialization()->InitializeSteppingVerbose(); 172 if (sv != nullptr) { << 187 if ( sv ) { G4VSteppingVerbose::SetInstance(sv); } 173 G4VSteppingVerbose::SetInstance(sv); << 174 } << 175 } 188 } 176 // Now initialise worker part of shared obje << 189 //Now initialize worker part of shared objects (geometry/physics) 177 G4WorkerThread::BuildGeometryAndPhysicsVecto << 190 wThreadContext->BuildGeometryAndPhysicsVector(); 178 G4WorkerRunManager* wrm = masterRM->GetUserW << 191 G4WorkerRunManager* wrm >> 192 = masterRM->GetUserWorkerThreadInitialization()->CreateWorkerRunManager(); 179 wrm->SetWorkerThread(wThreadContext); 193 wrm->SetWorkerThread(wThreadContext); 180 G4AutoLock wrmm(&workerRMMutex); 194 G4AutoLock wrmm(&workerRMMutex); 181 workerRMvector->push_back(wrm); 195 workerRMvector->push_back(wrm); 182 wrmm.unlock(); 196 wrmm.unlock(); 183 197 184 //================================ 198 //================================ 185 // Step-3: Setup worker run manager << 199 //Step-3: Setup worker run manager 186 //================================ 200 //================================ 187 // Set the detector and physics list to the 201 // Set the detector and physics list to the worker thread. Share with master 188 const G4VUserDetectorConstruction* detector 202 const G4VUserDetectorConstruction* detector = masterRM->GetUserDetectorConstruction(); 189 wrm->G4RunManager::SetUserInitialization(con 203 wrm->G4RunManager::SetUserInitialization(const_cast<G4VUserDetectorConstruction*>(detector)); 190 const G4VUserPhysicsList* physicslist = mast 204 const G4VUserPhysicsList* physicslist = masterRM->GetUserPhysicsList(); 191 wrm->SetUserInitialization(const_cast<G4VUse 205 wrm->SetUserInitialization(const_cast<G4VUserPhysicsList*>(physicslist)); 192 206 193 //================================ 207 //================================ 194 // Step-4: Initialise worker run manager << 208 //Step-4: Initialize worker run manager 195 //================================ 209 //================================ 196 if (masterRM->GetUserActionInitialization() << 210 if(masterRM->GetUserActionInitialization()) 197 masterRM->GetNonConstUserActionInitializat << 211 { masterRM->GetNonConstUserActionInitialization()->Build(); } 198 } << 212 if(masterRM->GetUserWorkerInitialization()) 199 if (masterRM->GetUserWorkerInitialization() << 213 { masterRM->GetUserWorkerInitialization()->WorkerStart(); } 200 masterRM->GetUserWorkerInitialization()->W << 201 } << 202 wrm->Initialize(); 214 wrm->Initialize(); 203 215 204 //================================ 216 //================================ 205 // Step5: Loop over requests from the master << 217 //Step5: Loop over requests from the master thread 206 //================================ 218 //================================ 207 // This function should enter a loop process << 219 G4MTRunManager::WorkerActionRequest nextAction = masterRM->ThisWorkerWaitForNextAction(); 208 // requests from master. It should block unt << 220 while( nextAction != G4MTRunManager::ENDWORKER ) 209 // to terminate << 221 { 210 wrm->DoWork(); << 222 if( nextAction == G4MTRunManager::NEXTITERATION ) // start the next run >> 223 { >> 224 //The following code deals with changing materials between runs >> 225 static G4ThreadLocal G4bool skipInitialization = true; >> 226 if(skipInitialization) >> 227 { >> 228 // re-initialization is not necessary for the first run >> 229 skipInitialization = false; >> 230 } >> 231 else >> 232 { >> 233 // ReinitializeGeometry(); >> 234 wThreadContext->UpdateGeometryAndPhysicsVectorFromMaster(); >> 235 } >> 236 >> 237 // Execute UI commands stored in the masther UI manager >> 238 std::vector<G4String> cmds = masterRM->GetCommandStack(); >> 239 G4UImanager* uimgr = G4UImanager::GetUIpointer(); //TLS instance >> 240 std::vector<G4String>::const_iterator it = cmds.begin(); >> 241 for(;it!=cmds.end();it++) >> 242 { uimgr->ApplyCommand(*it); } >> 243 //Start this run >> 244 G4int numevents = masterRM->GetNumberOfEventsToBeProcessed(); >> 245 G4String macroFile = masterRM->GetSelectMacro(); >> 246 G4int numSelect = masterRM->GetNumberOfSelectEvents(); >> 247 if ( macroFile == "" || macroFile == " " ) >> 248 { >> 249 wrm->BeamOn(numevents); >> 250 } >> 251 else >> 252 { >> 253 wrm->BeamOn(numevents,macroFile,numSelect); >> 254 } >> 255 } >> 256 else >> 257 { >> 258 G4ExceptionDescription d; >> 259 d<<"Cannot continue, this worker has been requested an unknwon action: " >> 260 <<nextAction<<" expecting: ENDWORKER(=" <<G4MTRunManager::ENDWORKER >> 261 <<") or NEXTITERATION(="<<G4MTRunManager::NEXTITERATION<<")"; >> 262 G4Exception("G4MTRunManagerKernel::StartThread","Run0035",FatalException,d); >> 263 } >> 264 >> 265 //Now wait for master thread to signal new action to be performed >> 266 nextAction = masterRM->ThisWorkerWaitForNextAction(); >> 267 } //No more actions to perform 211 268 212 //=============================== 269 //=============================== 213 // Step-6: Terminate worker thread << 270 //Step-6: Terminate worker thread 214 //=============================== 271 //=============================== 215 if (masterRM->GetUserWorkerInitialization() << 272 if(masterRM->GetUserWorkerInitialization()) 216 masterRM->GetUserWorkerInitialization()->W << 273 { masterRM->GetUserWorkerInitialization()->WorkerStop(); } 217 } << 218 274 219 wrmm.lock(); 275 wrmm.lock(); 220 for (auto itrWrm = workerRMvector->cbegin(); << 276 std::vector<G4WorkerRunManager*>::iterator itrWrm = workerRMvector->begin(); 221 if ((*itrWrm) == wrm) { << 277 for(;itrWrm!=workerRMvector->end();itrWrm++) >> 278 { >> 279 if((*itrWrm)==wrm) >> 280 { 222 workerRMvector->erase(itrWrm); 281 workerRMvector->erase(itrWrm); 223 break; 282 break; 224 } 283 } 225 } 284 } 226 wrmm.unlock(); 285 wrmm.unlock(); 227 delete wrm; 286 delete wrm; >> 287 wThreadContext->DestroyGeometryAndPhysicsVector(); >> 288 wThreadContext = 0; 228 289 229 //=============================== << 290 return static_cast<void*>(0); 230 // Step-7: Cleanup split classes << 231 //=============================== << 232 G4WorkerThread::DestroyGeometryAndPhysicsVec << 233 wThreadContext = nullptr; << 234 << 235 G4Threading::WorkerThreadLeavesPool(); << 236 } 291 } 237 292 238 // ------------------------------------------- << 293 //Now moved to G4WorkerThread >> 294 //void G4MTRunManagerKernel::ReinitializeGeometry() >> 295 //{ >> 296 // G4AutoLock wrmm(&workerRMMutex); >> 297 // //================================================= >> 298 // //Step-0: keep sensitive detector and field manager >> 299 // //================================================= >> 300 // typedef std::map<G4LogicalVolume*,std::pair<G4VSensitiveDetector*,G4FieldManager*> > LV2SDFM; >> 301 // LV2SDFM lvmap; >> 302 // G4PhysicalVolumeStore* mphysVolStore = G4PhysicalVolumeStore::GetInstance(); >> 303 // for(size_t ip=0;ip<mphysVolStore->size();ip++) >> 304 // { >> 305 // G4VPhysicalVolume* pv = (*mphysVolStore)[ip]; >> 306 // G4LogicalVolume *lv = pv->GetLogicalVolume(); >> 307 // G4VSensitiveDetector* sd = lv->GetSensitiveDetector(); >> 308 // G4FieldManager* fm = lv->GetFieldManager(); >> 309 // if(sd||fm) lvmap[lv] = std::make_pair(sd,fm); >> 310 // } >> 311 // >> 312 // //=========================== >> 313 // //Step-1: Clean the instances >> 314 // //=========================== >> 315 // const_cast<G4LVManager&>(G4LogicalVolume::GetSubInstanceManager()).FreeSlave(); >> 316 // const_cast<G4PVManager&>(G4VPhysicalVolume::GetSubInstanceManager()).FreeSlave(); >> 317 // const_cast<G4PVRManager&>(G4PVReplica::GetSubInstanceManager()).FreeSlave(); >> 318 // const_cast<G4RegionManager&>(G4Region::GetSubInstanceManager()).FreeSlave(); >> 319 // const_cast<G4PlSideManager&>(G4PolyconeSide::GetSubInstanceManager()).FreeSlave(); >> 320 // const_cast<G4PhSideManager&>(G4PolyhedraSide::GetSubInstanceManager()).FreeSlave(); >> 321 // >> 322 // //=========================== >> 323 // //Step-2: Re-create instances >> 324 // //=========================== >> 325 // const_cast<G4LVManager&>(G4LogicalVolume::GetSubInstanceManager()).SlaveCopySubInstanceArray(); >> 326 // const_cast<G4PVManager&>(G4VPhysicalVolume::GetSubInstanceManager()).SlaveCopySubInstanceArray(); >> 327 // const_cast<G4PVRManager&>(G4PVReplica::GetSubInstanceManager()).SlaveCopySubInstanceArray(); >> 328 // const_cast<G4RegionManager&>(G4Region::GetSubInstanceManager()).SlaveInitializeSubInstance(); >> 329 // const_cast<G4PlSideManager&>(G4PolyconeSide::GetSubInstanceManager()).SlaveInitializeSubInstance(); >> 330 // const_cast<G4PhSideManager&>(G4PolyhedraSide::GetSubInstanceManager()).SlaveInitializeSubInstance(); >> 331 // >> 332 // //=============================== >> 333 // //Step-3: Re-initialize instances >> 334 // //=============================== >> 335 // for(size_t ip=0;ip<mphysVolStore->size();ip++) >> 336 // { >> 337 // G4VPhysicalVolume* physVol = (*mphysVolStore)[ip]; >> 338 // G4LogicalVolume* g4LogicalVolume = physVol->GetLogicalVolume(); >> 339 // G4VSolid* g4VSolid = g4LogicalVolume->GetMasterSolid(); // shadow pointer >> 340 // G4PVReplica* g4PVReplica = 0; >> 341 // g4PVReplica = dynamic_cast<G4PVReplica*>(physVol); >> 342 // if(g4PVReplica) // if the volume is a replica >> 343 // { >> 344 // G4VSolid *slaveg4VSolid = g4VSolid->Clone(); >> 345 // g4LogicalVolume->InitialiseWorker(g4LogicalVolume,slaveg4VSolid,0); >> 346 // } >> 347 // else >> 348 // { g4LogicalVolume->InitialiseWorker(g4LogicalVolume,g4VSolid,0); } >> 349 // } >> 350 // >> 351 // //=================================================== >> 352 // //Step-4: Restore sensitive detector and field manaer >> 353 // //=================================================== >> 354 // LV2SDFM::const_iterator it = lvmap.begin(); >> 355 // for(; it!=lvmap.end() ; ++it ) >> 356 // { >> 357 // G4LogicalVolume* lv = it->first; >> 358 // G4VSensitiveDetector* sd = (it->second).first; >> 359 // G4FieldManager* fm = (it->second).second; >> 360 // lv->SetFieldManager(fm, false); >> 361 // lv->SetSensitiveDetector(sd); >> 362 // } >> 363 // wrmm.unlock(); >> 364 //} >> 365 >> 366 #include "G4ParticleDefinition.hh" >> 367 #include "G4ParticleTable.hh" >> 368 #include "G4ParticleTableIterator.hh" >> 369 #include "G4DecayTable.hh" >> 370 #include "G4VDecayChannel.hh" >> 371 239 void G4MTRunManagerKernel::SetUpDecayChannels( 372 void G4MTRunManagerKernel::SetUpDecayChannels() 240 { 373 { 241 auto pItr = G4ParticleTable::GetParticleTabl << 374 G4ParticleTable::G4PTblDicIterator* pItr >> 375 = G4ParticleTable::GetParticleTable()->GetIterator(); 242 pItr->reset(); 376 pItr->reset(); 243 while ((*pItr)()) { << 377 while((*pItr)()) >> 378 { 244 G4DecayTable* dt = pItr->value()->GetDecay 379 G4DecayTable* dt = pItr->value()->GetDecayTable(); 245 if (dt != nullptr) { << 380 if(dt) >> 381 { 246 G4int nCh = dt->entries(); 382 G4int nCh = dt->entries(); 247 for (G4int i = 0; i < nCh; ++i) { << 383 for(G4int i=0;i<nCh;i++) 248 dt->GetDecayChannel(i)->GetDaughter(0) << 384 { dt->GetDecayChannel(i)->GetDaughter(0); } 249 } << 250 } 385 } 251 } 386 } 252 } 387 } 253 388 254 // ------------------------------------------- << 255 void G4MTRunManagerKernel::BroadcastAbortRun(G 389 void G4MTRunManagerKernel::BroadcastAbortRun(G4bool softAbort) 256 { 390 { 257 G4AutoLock wrmm(&workerRMMutex); 391 G4AutoLock wrmm(&workerRMMutex); 258 << 392 std::vector<G4WorkerRunManager*>::iterator itr = workerRMvector->begin(); 259 for (const auto& itr : *workerRMvector) { << 393 for(;itr!=workerRMvector->end();itr++) 260 itr->AbortRun(softAbort); << 394 { (*itr)->AbortRun(softAbort); } 261 } << 262 } 395 } >> 396 263 397