79 if (pVVis !=
nullptr) {
118 if (fSDM !=
nullptr) {
128 std::ostringstream oss;
129 G4Random::saveFullState(oss);
137 G4cout <<
"### Run " <<
currentRun->GetRunID() <<
" starts on worker thread "
150 std::ostringstream os;
167 "G4VUserPrimaryGeneratorAction is not defined!");
187 for (
G4int evt = 0; evt < n_event; ++evt) {
207 G4cout <<
"Applying command \"" <<
msgText <<
"\" @ " << __FUNCTION__ <<
":" << __LINE__
218 auto anEvent =
new G4Event(i_event);
222 G4bool eventHasToBeSeeded =
true;
257 anEvent->ScoresRecorded();
262 else if (eventHasToBeSeeded) {
265 s1 = helper->
GetSeed(i_event * 2);
266 s2 = helper->
GetSeed(i_event * 2 + 1);
269 if (eventHasToBeSeeded) {
270 G4long seeds[3] = {s1, s2, 0};
271 G4Random::setTheSeeds(seeds, -1);
282 const auto filename = [&] {
283 std::ostringstream os;
284 os <<
"run" <<
currentRun->GetRunID() <<
"evt" << anEvent->GetEventID();
288 G4bool RNGstatusReadFromFile =
false;
291 std::ostringstream os;
292 os << filename() <<
".rndm";
293 const G4String& randomStatusFile = os.str();
294 std::ifstream ifile(randomStatusFile.c_str());
297 RNGstatusReadFromFile =
true;
298 G4Random::restoreEngineStatus(randomStatusFile.c_str());
303 std::ostringstream oss;
304 G4Random::saveFullState(oss);
317 G4cout <<
"--> Event " << anEvent->GetEventID() <<
" starts";
318 if (eventHasToBeSeeded)
G4cout <<
" with initial seeds (" << s1 <<
"," << s2 <<
")";
383 std::ostringstream os;
385 G4Random::saveEngineStatus(os.str().c_str());
393 if (mrm ==
nullptr)
return;
400 for (uintmax_t i = 0; i < command_stack.size(); ++i)
410 for (
const auto& itr : command_stack)
434 if ((run !=
nullptr) && run->
GetRunID() != runId) {
448 G4bool empty_macro = (macroFile.empty() || macroFile ==
" ");
450 const char* macro = (empty_macro) ?
nullptr : macroFile.c_str();
451 numSelect = (empty_macro) ? -1 : numSelect;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4TemplateRNGHelper< G4long > G4RNGHelper
G4GLOB_DLL std::ostream G4cout
static G4int SeedOncePerCommunication()
virtual G4int SetUpNEvents(G4Event *, G4SeedsQueue *seedsQueue, G4bool reseedRequired=true)
const CLHEP::HepRandomEngine * getMasterRandomEngine() const
virtual void ThisWorkerReady()
G4int GetEventModulo() const
static G4MTRunManager * GetMasterRunManager()
std::vector< G4String > GetCommandStack()
virtual G4bool SetUpAnEvent(G4Event *, G4long &s1, G4long &s2, G4long &s3, G4bool reseedRequired=true)
virtual void ThisWorkerEndEventLoop()
static G4ParallelWorldProcessStore * GetInstance()
G4bool isScoreNtupleWriter
virtual void CleanUpPreviousEvents()
G4int storeRandomNumberStatusToG4Event
const G4UserWorkerInitialization * GetUserWorkerInitialization() const
std::list< G4Event * > * previousEvents
G4int numberOfEventProcessed
G4int GetNumberOfEventsToBeProcessed() const
virtual void InitializeEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
G4RunManagerKernel * kernel
virtual G4bool ConfirmBeamOnCondition()
static G4RunManager * GetRunManager()
G4String randomNumberStatusForThisRun
static G4bool IfGeometryHasBeenDestroyed()
G4UserRunAction * userRunAction
G4bool rngStatusEventsFlag
virtual void RunTermination()
const G4String & GetSelectMacro() const
G4VUserPrimaryGeneratorAction * userPrimaryGeneratorAction
void UpdateScoring(const G4Event *evt=nullptr)
const G4Run * GetCurrentRun() const
G4int numberOfEventToBeProcessed
G4String randomNumberStatusDir
G4String randomNumberStatusForThisEvent
const G4UserWorkerThreadInitialization * GetUserWorkerThreadInitialization() const
G4int n_perviousEventsToBeStored
G4bool storeRandomNumberStatus
G4EventManager * eventManager
virtual void TerminateOneEvent()
G4int GetNumberOfSelectEvents() const
virtual void AnalyzeEvent(G4Event *anEvent)
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
static G4TaskRunManager * GetMasterRunManager()
G4int GetNumberOfEventsPerTask() const
static G4TemplateRNGHelper< G4long > * GetInstance()
virtual const T GetSeed(const G4int &sdId)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
virtual void WorkerRunEnd() const
virtual void WorkerRunStart() const
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine *aRNGEngine) const
virtual G4bool Book(G4HCofThisEvent *hce)=0
static G4VScoreNtupleWriter * Instance()
virtual void OpenFile()=0
static G4VVisManager * GetConcreteInstance()
virtual void SetUpForAThread()
virtual void MergePartialResults(G4bool mergeEvents=true)
G4bool readStatusFromFile
G4WorkerThread * workerContext
void ConstructScoringWorlds() override
void DoEventLoop(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1) override
G4Event * GenerateEvent(G4int i_event) override
void StoreRNGStatus(const G4String &filenamePrefix) override
void RunTermination() override
void TerminateEventLoop() override
void SetupDefaultRNGEngine() override
G4WorkerTaskRunManager()=default
void ProcessOneEvent(G4int i_event) override
static G4WorkerTaskRunManagerKernel * GetWorkerRunManagerKernel()
G4StrVector processedCommandStack
void RunInitialization() override
static G4WorkerTaskRunManager * GetWorkerRunManager()
#define G4ThreadLocalStatic