80 if (pVVis !=
nullptr) {
81 pVVis->SetUpForAThread();
119 if (fSDM !=
nullptr) {
129 std::ostringstream oss;
130 G4Random::saveFullState(oss);
144#if defined(GEANT4_USE_TIMEMORY)
155 std::ostringstream os;
172 "G4VUserPrimaryGeneratorAction is not defined!");
192 for (
G4int evt = 0; evt < n_event; ++evt) {
212 G4cout <<
"Applying command \"" <<
msgText <<
"\" @ " << __FUNCTION__ <<
":" << __LINE__
223 auto anEvent =
new G4Event(i_event);
227 G4bool eventHasToBeSeeded =
true;
266 else if (eventHasToBeSeeded) {
269 s1 = helper->
GetSeed(i_event * 2);
270 s2 = helper->
GetSeed(i_event * 2 + 1);
273 if (eventHasToBeSeeded) {
274 G4long seeds[3] = {s1, s2, 0};
275 G4Random::setTheSeeds(seeds, -1);
286 const auto filename = [&] {
287 std::ostringstream os;
292 G4bool RNGstatusReadFromFile =
false;
295 std::ostringstream os;
296 os << filename() <<
".rndm";
297 const G4String& randomStatusFile = os.str();
298 std::ifstream ifile(randomStatusFile.c_str());
301 RNGstatusReadFromFile =
true;
302 G4Random::restoreEngineStatus(randomStatusFile.c_str());
307 std::ostringstream oss;
308 G4Random::saveFullState(oss);
321 G4cout <<
"--> Event " << anEvent->GetEventID() <<
" starts";
322 if (eventHasToBeSeeded)
G4cout <<
" with initial seeds (" << s1 <<
"," << s2 <<
")";
334#if defined(GEANT4_USE_TIMEMORY)
335 workerRunProfiler.reset();
376void G4WorkerTaskRunManager::SetupDefaultRNGEngine()
390 std::ostringstream os;
392 G4Random::saveEngineStatus(os.str().c_str());
400 if (mrm ==
nullptr)
return;
405 bool matching = (command_stack.size() == processedCommandStack.size());
407 for (uintmax_t i = 0; i < command_stack.size(); ++i)
408 if (processedCommandStack.at(i) != command_stack.at(i)) {
417 for (
const auto& itr : command_stack)
419 processedCommandStack = command_stack;
441 if ((run !=
nullptr) && run->
GetRunID() != runId) {
455 G4bool empty_macro = (macroFile.empty() || macroFile ==
" ");
457 const char* macro = (empty_macro) ?
nullptr : macroFile.c_str();
458 numSelect = (empty_macro) ? -1 : numSelect;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
void ProcessOneEvent(G4Event *anEvent)
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 RunInitialization(G4bool fakeRun=false)
G4bool isScoreNtupleWriter
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
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)
void SetHCtable(G4HCtable *HCtbl)
void SetNumberOfEventToBeProcessed(G4int n_ev)
void SetDCtable(G4DCtable *DCtbl)
void SetRandomNumberStatus(G4String &st)
G4HCofThisEvent * PrepareNewEvent()
static G4SDManager * GetSDMpointerIfExist()
G4HCtable * GetHCtable() const
static G4TaskRunManager * GetMasterRunManager()
static G4TemplateRNGHelper< T > * GetInstance()
virtual const T GetSeed(const G4int &sdId)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
virtual G4Run * GenerateRun()
virtual void BeginOfRunAction(const G4Run *)
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
virtual void GeneratePrimaries(G4Event *anEvent)=0
static G4VVisManager * GetConcreteInstance()
G4bool readStatusFromFile
virtual void MergePartialResults()
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
G4ProfilerConfig< G4ProfileType::Run > ProfilerConfig
void ProcessOneEvent(G4int i_event) override
static G4WorkerTaskRunManagerKernel * GetWorkerRunManagerKernel()
void RunInitialization() override
static G4WorkerTaskRunManager * GetWorkerRunManager()
G4int GetThreadId() const
static void UpdateGeometryAndPhysicsVectorFromMaster()
#define G4ThreadLocalStatic