Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4WorkerRunManager.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4WorkerRunManager implementation
27//
28// Original authors: X.Dong, A.Dotti - 2013
29// --------------------------------------------------------------------
30
31#include <fstream>
32#include <sstream>
33
34#include "G4WorkerRunManager.hh"
35#include "G4MTRunManager.hh"
37#include "G4RNGHelper.hh"
38#include "G4Run.hh"
39#include "G4SDManager.hh"
40#include "G4ScoringManager.hh"
41#include "G4TiMemory.hh"
42#include "G4Timer.hh"
44#include "G4UImanager.hh"
45#include "G4UserRunAction.hh"
49#include "G4VScoringMesh.hh"
52#include "G4VUserPhysicsList.hh"
54#include "G4VVisManager.hh"
56#include "G4WorkerThread.hh"
57#include "G4MTRunManager.hh"
59#include "G4AutoLock.hh"
60
61// --------------------------------------------------------------------
63{
64 return static_cast<G4WorkerRunManager*>(G4RunManager::GetRunManager());
65}
66
67// --------------------------------------------------------------------
69{
71}
72
73// --------------------------------------------------------------------
75 : G4RunManager(workerRM)
76{
77 // This constructor should never be called in non-multithreaded mode
78
79#ifndef G4MULTITHREADED
81 msg << "Geant4 code is compiled without multi-threading support "
82 "(-DG4MULTITHREADED "
83 "is set to off).";
84 msg << " This type of RunManager can only be used in mult-threaded "
85 "applications.";
86 G4Exception("G4WorkerRunManager::G4WorkerRunManager()", "Run0103",
87 FatalException, msg);
88#endif
91 if(masterScM != nullptr)
92 G4ScoringManager::GetScoringManager(); // TLS instance for a worker
93
94 // Properly initialise luxury level for Ranlux* engines...
95 //
96 if(dynamic_cast<const CLHEP::Ranlux64Engine*>(G4Random::getTheEngine()))
97 {
99 dynamic_cast<const CLHEP::Ranlux64Engine*>(G4Random::getTheEngine());
100 luxury = theEngine->getLuxury();
101 }
102 else if(dynamic_cast<const CLHEP::RanluxEngine*>(G4Random::getTheEngine()))
103 {
105 dynamic_cast<const CLHEP::RanluxEngine*>(G4Random::getTheEngine());
106 luxury = theEngine->getLuxury();
107 }
108
110
111#ifdef G4MULTITHREADED
113 if(pVVis != nullptr)
114 {
115 pVVis->SetUpForAThread();
116 visIsSetUp = true;
117 }
118#endif
119}
120
121// --------------------------------------------------------------------
123{
124 // Delete thread-local data process manager objects
125 if(physicsList)
126 {
127 // physicsList->TerminateWorker();
128 // physicsList->RemoveProcessManager();
129 }
130
131 // Put these pointers to zero: owned by master thread
132 // If not to zero, the base class destructor will attempt to
133 // delete them
134 userDetector = nullptr;
135 userWorkerInitialization = nullptr;
137 userActionInitialization = nullptr;
138 physicsList = nullptr;
139 if(verboseLevel > 1)
140 G4cout << "Destroying WorkerRunManager (" << this << ")" << G4endl;
141}
142
143// --------------------------------------------------------------------
145{
146 if(userDetector == nullptr)
147 {
148 G4Exception("G4RunManager::InitializeGeometry", "Run0033", FatalException,
149 "G4VUserDetectorConstruction is not defined!");
150 return;
151 }
153 {
155 }
156
157 // Step1: Get pointer to the physiWorld (note: needs to get the "super
158 // pointer, i.e. the one shared by all threads"
159 G4RunManagerKernel* masterKernel =
161 G4VPhysicalVolume* worldVol = masterKernel->GetCurrentWorld();
162 // Step2:, Call a new "WorkerDefineWorldVolume( pointer from 2-, false);
163 kernel->WorkerDefineWorldVolume(worldVol, false);
165 // Step3: Call user's ConstructSDandField()
168 geometryInitialized = true;
169}
170
171// --------------------------------------------------------------------
173{
174#ifdef G4MULTITHREADED
175 if(!visIsSetUp)
176 {
178 if(pVVis != nullptr)
179 {
180 pVVis->SetUpForAThread();
181 visIsSetUp = true;
182 }
183 }
184#endif
185
187 return;
188
189 // Signal this thread can start event loop.
190 // Note this will return only when all threads reach this point
192 if(fakeRun)
193 return;
194
195 const G4UserWorkerInitialization* uwi =
198 delete currentRun;
199 currentRun = nullptr;
200
203 // Call a user hook: this is guaranteed all threads are "synchronized"
204 if(uwi)
205 uwi->WorkerRunStart();
206
207 if(userRunAction)
209 if(currentRun == nullptr)
210 currentRun = new G4Run();
211
214
217 if(fSDM != nullptr)
218 {
220 }
221
223 {
224 auto hce = (fSDM != nullptr) ? fSDM->PrepareNewEvent() : nullptr;
226 delete hce;
227 }
228
229 std::ostringstream oss;
230 G4Random::saveFullState(oss);
233
234 for(G4int i_prev = 0; i_prev < n_perviousEventsToBeStored; ++i_prev)
235 {
236 previousEvents->push_back(nullptr);
237 }
238
239 if(printModulo > 0 || verboseLevel > 0)
240 {
241 G4cout << "### Run " << currentRun->GetRunID()
242 << " starts on worker thread "
244 << G4endl;
245 }
246 if(userRunAction != nullptr)
248
249#if defined(GEANT4_USE_TIMEMORY)
250 workerRunProfiler.reset(new ProfilerConfig(currentRun));
251#endif
252
254 {
256 }
257
259 {
260 G4String fileN = "currentRun";
262 {
263 std::ostringstream os;
264 os << "run" << currentRun->GetRunID();
265 fileN = os.str();
266 }
267 StoreRNGStatus(fileN);
268 }
269
270 runAborted = false;
272}
273
274// --------------------------------------------------------------------
275void G4WorkerRunManager::DoEventLoop(G4int n_event, const char* macroFile,
276 G4int n_select)
277{
278 if(userPrimaryGeneratorAction == nullptr)
279 {
280 G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
281 "G4VUserPrimaryGeneratorAction is not defined!");
282 }
283
284 // This is the same as in the sequential case, just the for-loop indexes are
285 // different
286 InitializeEventLoop(n_event, macroFile, n_select);
287
288 // Reset random number seeds queue
289 while(seedsQueue.size() > 0)
290 {
291 seedsQueue.pop();
292 }
293 // for each run, worker should receive at least one set of random number
294 // seeds.
295 runIsSeeded = false;
296
297 // Event loop
298 eventLoopOnGoing = true;
299 /////// G4int i_event = workerContext->GetThreadId();
300 G4int i_event = -1;
301 nevModulo = -1;
302 currEvID = -1;
303
304 while(eventLoopOnGoing)
305 {
306 ProcessOneEvent(i_event);
308 {
310 if(runAborted)
311 {
312 eventLoopOnGoing = false;
313 }
314 ////// else
315 ////// {
316 ////// i_event += workerContext->GetNumberThreads();
317 ////// eventLoopOnGoing = i_event<n_event;
318 ////// }
319 }
320 }
321
323}
324
325// --------------------------------------------------------------------
327{
328 currentEvent = GenerateEvent(i_event);
330 {
336 }
337}
338
339// --------------------------------------------------------------------
341{
342 G4Event* anEvent = new G4Event(i_event);
343 G4long s1 = 0;
344 G4long s2 = 0;
345 G4long s3 = 0;
346 G4bool eventHasToBeSeeded = true;
348 {
349 eventHasToBeSeeded = false;
350 }
351
352 if(i_event < 0)
353 {
355 if(nevM == 1)
356 {
358 anEvent, s1, s2, s3, eventHasToBeSeeded);
359 runIsSeeded = true;
360 }
361 else
362 {
363 if(nevModulo <= 0)
364 {
366 anEvent, &seedsQueue, eventHasToBeSeeded);
367 if(nevToDo == 0)
368 {
369 eventLoopOnGoing = false;
370 }
371 else
372 {
373 currEvID = anEvent->GetEventID();
374 nevModulo = nevToDo - 1;
375 }
376 }
377 else
378 {
380 eventHasToBeSeeded = false;
381 anEvent->SetEventID(++currEvID);
382 --nevModulo;
383 }
384 if(eventLoopOnGoing && eventHasToBeSeeded)
385 {
386 s1 = seedsQueue.front();
387 seedsQueue.pop();
388 s2 = seedsQueue.front();
389 seedsQueue.pop();
390 }
391 }
392
394 {
395 delete anEvent;
396 return nullptr;
397 }
398 }
399 else if(eventHasToBeSeeded)
400 {
401 // Need to reseed random number generator
403 s1 = helper->GetSeed(i_event * 2);
404 s2 = helper->GetSeed(i_event * 2 + 1);
405 }
406
407 if(eventHasToBeSeeded)
408 {
409 G4long seeds[3] = { s1, s2, 0 };
410 G4Random::setTheSeeds(seeds, luxury);
411 runIsSeeded = true;
412 }
413
414 // Read from file seed.
415 // Andrea Dotti 4 November 2015
416 // This is required for strong-reproducibility, in MT mode we have that each
417 // thread produces, for each event a status file, we want to do that.
418 // Search a random file with the format run{%d}evt{%d}.rndm
419
420 // This is the filename base constructed from run and event
421 const auto filename = [&] {
422 std::ostringstream os;
423 os << "run" << currentRun->GetRunID() << "evt" << anEvent->GetEventID();
424 return os.str();
425 };
426
427 G4bool RNGstatusReadFromFile = false;
429 {
430 // Build full path of RNG status file for this event
431 std::ostringstream os;
432 os << filename() << ".rndm";
433 const G4String& randomStatusFile = os.str();
434 std::ifstream ifile(randomStatusFile.c_str());
435 if(ifile)
436 { // File valid and readable
437 RNGstatusReadFromFile = true;
438 G4Random::restoreEngineStatus(randomStatusFile.c_str());
439 }
440 }
441
444 {
445 std::ostringstream oss;
446 G4Random::saveFullState(oss);
449 }
450
451 if(storeRandomNumberStatus && !RNGstatusReadFromFile)
452 { // If reading from file, avoid to rewrite the same
453 G4String fileN = "currentEvent";
455 {
456 fileN = filename();
457 }
458 StoreRNGStatus(fileN);
459 }
460
461 if(printModulo > 0 && anEvent->GetEventID() % printModulo == 0)
462 {
463 G4cout << "--> Event " << anEvent->GetEventID() << " starts";
464 if(eventHasToBeSeeded)
465 {
466 G4cout << " with initial seeds (" << s1 << "," << s2 << ")";
467 }
468 G4cout << "." << G4endl;
469 }
471 return anEvent;
472}
473
474// --------------------------------------------------------------------
476{
477 // Merge partial results into global run
480 if(ScM != nullptr)
481 mtRM->MergeScores(ScM);
482 mtRM->MergeRun(currentRun);
483}
484
485// --------------------------------------------------------------------
487{
488 if(!fakeRun)
489 {
490#if defined(GEANT4_USE_TIMEMORY)
491 workerRunProfiler.reset();
492#endif
494
495 // Call a user hook: note this is before the next barrier
496 // so threads execute this method asyncrhonouzly
497 //(TerminateRun allows for synch via G4RunAction::EndOfRun)
498 const G4UserWorkerInitialization* uwi =
500 if(uwi != nullptr)
501 uwi->WorkerRunEnd();
502 }
503
505 // Signal this thread has finished envent-loop.
506 // Note this will return only whan all threads reach this point
508}
509
510// --------------------------------------------------------------------
512{
513 if(verboseLevel > 0 && !fakeRun)
514 {
515 timer->Stop();
516 G4cout << "Thread-local run terminated." << G4endl;
517 G4cout << "Run Summary" << G4endl;
518 if(runAborted)
519 {
520 G4cout << " Run Aborted after " << numberOfEventProcessed
521 << " events processed." << G4endl;
522 }
523 else
524 {
525 G4cout << " Number of events processed : " << numberOfEventProcessed
526 << G4endl;
527 }
528 G4cout << " " << *timer << G4endl;
529 }
530}
531
532// --------------------------------------------------------------------
533namespace
534{
535 G4Mutex ConstructScoringWorldsMutex = G4MUTEX_INITIALIZER;
536}
537
538// --------------------------------------------------------------------
540{
541 using MeshShape = G4VScoringMesh::MeshShape;
542
543 // Return if unnecessary
545 if(ScM == nullptr)
546 return;
547 G4int nPar = (G4int)ScM->GetNumberOfMesh();
548 if(nPar < 1)
549 return;
550
551 // Update thread-local G4TransportationManager of all the world volumes
553
555
557
558 for(G4int iw = 0; iw < nPar; ++iw)
559 {
560 G4VScoringMesh* mesh = ScM->GetMesh(iw);
563 G4VPhysicalVolume* pWorld = nullptr;
564 if(mesh->GetShape() != MeshShape::realWorldLogVol)
565 {
567 ->IsWorldExisting(ScM->GetWorldName(iw));
568 if(pWorld == nullptr)
569 {
571 ed << "Mesh name <" << ScM->GetWorldName(iw)
572 << "> is not found in the master thread.";
573 G4Exception("G4WorkerRunManager::ConstructScoringWorlds()", "RUN79001",
574 FatalException, ed);
575 }
576 }
577 if(!(mesh->GetMeshElementLogical()))
578 {
579 G4AutoLock l(&ConstructScoringWorldsMutex);
580 G4VScoringMesh* masterMesh = masterScM->GetMesh(iw);
581 mesh->SetMeshElementLogical(masterMesh->GetMeshElementLogical());
582 l.unlock();
583
584 if(mesh->GetShape() != MeshShape::realWorldLogVol)
585 {
586 G4ParallelWorldProcess* theParallelWorldProcess =
588 if(theParallelWorldProcess != nullptr)
589 {
590 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
591 }
592 else
593 {
594 theParallelWorldProcess =
596 mesh->SetParallelWorldProcess(theParallelWorldProcess);
597 theParallelWorldProcess->SetParallelWorld(ScM->GetWorldName(iw));
598
599 particleIterator->reset();
600 while((*particleIterator)())
601 {
602 G4ParticleDefinition* particle = particleIterator->value();
603 G4ProcessManager* pmanager = particle->GetProcessManager();
604 if(pmanager != nullptr)
605 {
606 pmanager->AddProcess(theParallelWorldProcess);
607 if(theParallelWorldProcess->IsAtRestRequired(particle))
608 {
609 pmanager->SetProcessOrdering(theParallelWorldProcess, idxAtRest,
610 9900);
611 }
612 pmanager->SetProcessOrderingToSecond(theParallelWorldProcess,
614 pmanager->SetProcessOrdering(theParallelWorldProcess, idxPostStep,
615 9900);
616 } // if(pmanager)
617 } // while
618 }
619 theParallelWorldProcess->SetLayeredMaterialFlag(mesh->LayeredMassFlg());
620 }
621 }
622 mesh->WorkerConstruct(pWorld);
623 }
624}
625
626// --------------------------------------------------------------------
628{
630 "G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)",
631 "Run0118", FatalException,
632 "This method should be used only with an instance of G4MTRunManager");
633}
634
635// --------------------------------------------------------------------
638{
640 "G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)",
641 "Run0119", FatalException,
642 "This method should be used only with an instance of G4MTRunManager");
643}
644
645// --------------------------------------------------------------------
647{
649 "G4RunManager::SetUserInitialization(G4VUserActionInitialization*)",
650 "Run0120", FatalException,
651 "This method should be used only with an instance of G4MTRunManager");
652}
653
654// --------------------------------------------------------------------
656{
658 "G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)",
659 "Run0121", FatalException,
660 "This method should be used only with an instance of G4MTRunManager");
661}
662
663// --------------------------------------------------------------------
665{
666 pl->InitializeWorker();
668}
669
670// --------------------------------------------------------------------
672{
673 G4RunManager::SetUserAction(userAction);
674 if(userAction != nullptr)
675 userAction->SetMaster(false);
676}
677
678// --------------------------------------------------------------------
679void G4WorkerRunManager::SetupDefaultRNGEngine()
680{
681 const CLHEP::HepRandomEngine* mrnge =
685 uwti->SetupRNGEngine(mrnge);
686}
687
688// Forward calls (avoid GCC compilation warnings)
689
690// --------------------------------------------------------------------
692{
694}
695
696// --------------------------------------------------------------------
698{
700}
701
702// --------------------------------------------------------------------
704{
706}
707
708// --------------------------------------------------------------------
710{
712}
713
714// --------------------------------------------------------------------
716{
718}
719
720// --------------------------------------------------------------------
722{
723 std::ostringstream os;
724 os << randomNumberStatusDir << "G4Worker" << workerContext->GetThreadId()
725 << "_" << fn << ".rndm";
726 G4Random::saveEngineStatus(os.str().c_str());
727}
728
729// --------------------------------------------------------------------
731{
732 G4int runNumber = 0;
733 if(currentRun != nullptr)
734 runNumber = currentRun->GetRunID();
736 {
737 G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
738 << " Random number status was not stored prior to this run."
739 << G4endl << "/random/setSavingFlag command must be issued. "
740 << "Command ignored." << G4endl;
741 return;
742 }
743
744 std::ostringstream oos;
745 oos << "G4Worker" << workerContext->GetThreadId() << "_"
746 << "currentRun.rndm"
747 << "\0";
748 G4String fileIn = randomNumberStatusDir + oos.str();
749
750 std::ostringstream os;
751 os << "run" << runNumber << ".rndm" << '\0';
752 G4String fileOut = randomNumberStatusDir + os.str();
753
754#ifdef WIN32
755 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
756#else
757 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
758#endif
760 if(verboseLevel > 0)
761 {
762 G4cout << fileIn << " is copied to " << fileOut << G4endl;
763 }
764}
765
766// --------------------------------------------------------------------
768{
769 if(currentEvent == nullptr)
770 {
771 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
772 << " there is no currentEvent available." << G4endl
773 << "Command ignored." << G4endl;
774 return;
775 }
776
778 {
779 G4cerr << "Warning from G4RunManager::rndmSaveThisEvent():"
780 << " Random number engine status is not available." << G4endl
781 << "/random/setSavingFlag command must be issued "
782 << "prior to the start of the run. Command ignored." << G4endl;
783 return;
784 }
785
786 std::ostringstream oos;
787 oos << "G4Worker" << workerContext->GetThreadId() << "_"
788 << "currentEvent.rndm"
789 << "\0";
790 G4String fileIn = randomNumberStatusDir + oos.str();
791
792 std::ostringstream os;
793 os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
794 << ".rndm" << '\0';
795 G4String fileOut = randomNumberStatusDir + os.str();
796
797#ifdef WIN32
798 G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
799#else
800 G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
801#endif
803 if(verboseLevel > 0)
804 {
805 G4cout << fileIn << " is copied to " << fileOut << G4endl;
806 }
807}
808
809// --------------------------------------------------------------------
811{
816 {
817 if(nextAction ==
819 // run
820 {
821 // The following code deals with changing materials between runs
822 static G4ThreadLocal G4bool skipInitialization = true;
823 if(skipInitialization)
824 {
825 // re-initialization is not necessary for the first run
826 skipInitialization = false;
827 }
828 else
829 {
830 // ReinitializeGeometry();
832 }
833
834 // Execute UI commands stored in the master UI manager
835 std::vector<G4String> cmds = mrm->GetCommandStack();
836 G4UImanager* uimgr = G4UImanager::GetUIpointer(); // TLS instance
837 for(auto it = cmds.cbegin(); it != cmds.cend(); ++it)
838 {
839 uimgr->ApplyCommand(*it);
840 }
841 // Start this run
842 G4int numevents = mrm->GetNumberOfEventsToBeProcessed();
843 G4String macroFile = mrm->GetSelectMacro();
844 G4int numSelect = mrm->GetNumberOfSelectEvents();
845 if(macroFile == "" || macroFile == " ")
846 {
847 this->BeamOn(numevents);
848 }
849 else
850 {
851 this->BeamOn(numevents, macroFile, numSelect);
852 }
853 }
855 {
856 std::vector<G4String> cmds = mrm->GetCommandStack();
857 G4UImanager* uimgr = G4UImanager::GetUIpointer(); // TLS instance
858 for(auto it = cmds.cbegin(); it != cmds.cend(); ++it)
859 {
860 uimgr->ApplyCommand(*it);
861 }
863 }
864 else
865 {
867 d << "Cannot continue, this worker has been requested an unknown action: "
868 << static_cast<
869 std::underlying_type<G4MTRunManager::WorkerActionRequest>::type>(
870 nextAction);
871 G4Exception("G4WorkerRunManager::DoWork", "Run0104", FatalException, d);
872 }
873
874 // Now wait for master thread to signal new action to be performed
875 nextAction = mrm->ThisWorkerWaitForNextAction();
876 } // No more actions to perform
877
878 return;
879}
std::vector< G4InuclElementaryParticle >::iterator particleIterator
Definition: G4BigBanger.cc:64
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
@ idxPostStep
@ idxAtRest
@ idxAlongStep
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
long G4long
Definition: G4Types.hh:87
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
std::shared_ptr< HepRandomEngine > theEngine
Definition: Random.cc:76
void ProcessOneEvent(G4Event *anEvent)
void SetRandomNumberStatus(G4String &st)
Definition: G4Event.hh:90
G4int GetEventID() const
Definition: G4Event.hh:118
void SetEventID(G4int i)
Definition: G4Event.hh:80
static G4int SeedOncePerCommunication()
virtual WorkerActionRequest ThisWorkerWaitForNextAction()
virtual void ThisWorkerProcessCommandsStackDone()
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
virtual G4bool SetUpAnEvent(G4Event *, long &s1, long &s2, long &s3, G4bool reseedRequired=true)
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
static G4ScoringManager * GetMasterScoringManager()
virtual void ThisWorkerReady()
G4int GetEventModulo() const
static G4MTRunManager * GetMasterRunManager()
void MergeRun(const G4Run *localRun)
static G4RunManagerKernel * GetMasterRunManagerKernel()
void MergeScores(const G4ScoringManager *localScoringManager)
std::vector< G4String > GetCommandStack()
virtual void ThisWorkerEndEventLoop()
static G4ParallelWorldProcessStore * GetInstance()
void SetLayeredMaterialFlag(G4bool flg=true)
void SetParallelWorld(G4String parallelWorldName)
G4bool IsAtRestRequired(G4ParticleDefinition *)
G4ProcessManager * GetProcessManager() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void WorkerG4ParticleTable()
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4VPhysicalVolume * GetCurrentWorld() const
void SetNumberOfParallelWorld(G4int i)
G4bool RunInitialization(G4bool fakeRun=false)
void WorkerDefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4int GetNumberOfParallelWorld() const
G4bool isScoreNtupleWriter
G4bool geometryInitialized
void CleanUpPreviousEvents()
G4int storeRandomNumberStatusToG4Event
G4UserWorkerInitialization * userWorkerInitialization
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
std::list< G4Event * > * previousEvents
G4Timer * timer
G4UserWorkerThreadInitialization * userWorkerThreadInitialization
G4int n_select_msg
G4int numberOfEventProcessed
G4int GetNumberOfEventsToBeProcessed() const
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
G4int runIDCounter
G4RunManagerKernel * kernel
G4int verboseLevel
G4Run * currentRun
static G4RunManager * GetRunManager()
G4DCtable * DCtable
G4String randomNumberStatusForThisRun
G4bool runAborted
G4String msgText
virtual void BeamOn(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
G4UserRunAction * userRunAction
G4bool rngStatusEventsFlag
virtual void RunTermination()
const G4String & GetSelectMacro() const
G4VUserActionInitialization * userActionInitialization
static G4RUN_DLL G4bool fGeometryHasBeenDestroyed
G4VUserDetectorConstruction * userDetector
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
G4int numberOfEventToBeProcessed
G4String randomNumberStatusDir
virtual void SetUserAction(G4UserRunAction *userAction)
G4String randomNumberStatusForThisEvent
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
G4int n_perviousEventsToBeStored
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4bool storeRandomNumberStatus
G4EventManager * eventManager
virtual void TerminateOneEvent()
G4int GetNumberOfSelectEvents() const
G4VUserPhysicsList * physicsList
virtual void AnalyzeEvent(G4Event *anEvent)
void UpdateScoring()
G4Event * currentEvent
Definition: G4Run.hh:49
void SetHCtable(G4HCtable *HCtbl)
Definition: G4Run.hh:107
G4int GetRunID() const
Definition: G4Run.hh:78
void SetNumberOfEventToBeProcessed(G4int n_ev)
Definition: G4Run.hh:103
void SetRunID(G4int id)
Definition: G4Run.hh:102
void SetDCtable(G4DCtable *DCtbl)
Definition: G4Run.hh:108
void SetRandomNumberStatus(G4String &st)
Definition: G4Run.hh:109
G4HCofThisEvent * PrepareNewEvent()
Definition: G4SDManager.cc:113
static G4SDManager * GetSDMpointerIfExist()
Definition: G4SDManager.cc:47
G4HCtable * GetHCtable() const
Definition: G4SDManager.hh:101
G4VScoringMesh * GetMesh(G4int i) const
size_t GetNumberOfMesh() const
static G4ScoringManager * GetScoringManager()
G4String GetWorldName(G4int i) const
static G4ScoringManager * GetScoringManagerIfExist()
static G4TemplateRNGHelper< T > * GetInstance()
Definition: G4RNGHelper.cc:42
virtual const T GetSeed(const G4int &sdId)
Definition: G4RNGHelper.hh:64
void Stop()
static G4TransportationManager * GetTransportationManager()
G4VPhysicalVolume * IsWorldExisting(const G4String &worldName)
void SetIgnoreCmdNotFound(G4bool val)
Definition: G4UImanager.hh:229
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
virtual void BeginOfRunAction(const G4Run *aRun)
virtual G4Run * GenerateRun()
virtual void SetMaster(G4bool val=true)
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
MeshShape GetShape() const
G4LogicalVolume * GetMeshElementLogical() const
virtual void WorkerConstruct(G4VPhysicalVolume *fWorldPhys)
void GeometryHasBeenDestroyed()
G4ParallelWorldProcess * GetParallelWorldProcess() const
void SetParallelWorldProcess(G4ParallelWorldProcess *proc)
void SetMeshElementLogical(G4LogicalVolume *val)
G4bool LayeredMassFlg()
virtual void InitializeWorker()
virtual void GeneratePrimaries(G4Event *anEvent)=0
static G4VVisManager * GetConcreteInstance()
virtual void ConstructScoringWorlds()
static G4WorkerRunManagerKernel * GetWorkerRunManagerKernel()
virtual void RunTermination()
virtual void rndmSaveThisEvent()
virtual void MergePartialResults()
G4WorkerThread * workerContext
virtual void SetUserAction(G4UserRunAction *userAction)
virtual void SetUserInitialization(G4VUserPhysicsList *userInit)
virtual void rndmSaveThisRun()
static G4WorkerRunManager * GetWorkerRunManager()
virtual void ProcessOneEvent(G4int i_event)
virtual void TerminateEventLoop()
virtual void RunInitialization()
virtual void DoEventLoop(G4int n_event, const char *macroFile=0, G4int n_select=-1)
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
virtual void InitializeGeometry()
virtual G4Event * GenerateEvent(G4int i_event)
virtual void StoreRNGStatus(const G4String &filenamePrefix)
G4int GetThreadId() const
static void UpdateGeometryAndPhysicsVectorFromMaster()
G4int G4GetThreadId()
Definition: G4Threading.cc:122
#define G4ThreadLocal
Definition: tls.hh:77