64 #ifndef G4MULTITHREADED
66 msg<<
"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
67 msg<<
" This type of RunManager can only be used in mult-threaded applications.";
83 if ( dynamic_cast<const CLHEP::Ranlux64Engine*>(G4Random::getTheEngine()) )
88 else if ( dynamic_cast<const CLHEP::RanluxEngine*>(G4Random::getTheEngine()) )
100 #ifdef G4MULTITHREADED
104 pVVis->SetUpForAThread();
108 { visIsSetUp =
false; }
135 G4Exception(
"G4RunManager::InitializeGeometry",
"Run0033",
159 #ifdef G4MULTITHREADED
165 pVVis->SetUpForAThread();
206 std::ostringstream oss;
207 G4Random::saveFullState(oss);
228 std::ostringstream os;
245 "G4VUserPrimaryGeneratorAction is not defined!");
304 G4bool eventHasToBeSeeded =
true;
306 { eventHasToBeSeeded =
false; }
350 else if(eventHasToBeSeeded)
354 s1 = helper->
GetSeed(i_event*2);
355 s2 = helper->
GetSeed(i_event*2+1);
358 if(eventHasToBeSeeded)
360 long seeds[3] = {
s1, s2, 0 };
361 G4Random::setTheSeeds(seeds,
luxury);
374 std::ostringstream os;
379 G4bool RNGstatusReadFromFile =
false;
382 std::ostringstream os;
384 const G4String& randomStatusFile = os.str();
385 std::ifstream ifile(randomStatusFile.c_str());
387 RNGstatusReadFromFile =
true;
388 G4Random::restoreEngineStatus(randomStatusFile.c_str());
395 std::ostringstream oss;
396 G4Random::saveFullState(oss);
412 if(eventHasToBeSeeded)
413 {
G4cout <<
" with initial seeds (" << s1 <<
"," << s2 <<
")"; }
495 assert( masterScM != NULL );
500 for(
G4int iw=0;iw<nPar;iw++)
505 if(mesh->
GetShape()!=MeshShape::realWorldLogVol)
511 ed<<
"Mesh name <"<<ScM->
GetWorldName(iw)<<
"> is not found in the master thread.";
522 if(mesh->
GetShape()!=MeshShape::realWorldLogVol)
525 if(theParallelWorldProcess)
533 particleIterator->
reset();
534 while( (*particleIterator)() ){
539 pmanager->
AddProcess(theParallelWorldProcess);
555 G4Exception(
"G4RunManager::SetUserInitialization(G4UserWorkerInitialization*)",
"Run0118",
556 FatalException,
"This method should be used only with an instance of G4MTRunManager");
561 G4Exception(
"G4RunManager::SetUserInitialization(G4UserWorkerThreadInitialization*)",
"Run0119",
562 FatalException,
"This method should be used only with an instance of G4MTRunManager");
567 G4Exception(
"G4RunManager::SetUserInitialization(G4VUserActionInitialization*)",
"Run0120",
568 FatalException,
"This method should be used only with an instance of G4MTRunManager");
573 G4Exception(
"G4RunManager::SetUserInitialization(G4VUserDetectorConstruction*)",
"Run0121",
574 FatalException,
"This method should be used only with an instance of G4MTRunManager");
586 if(userAction) userAction->
SetMaster(
false);
627 std::ostringstream os;
629 G4Random::saveEngineStatus(os.str().c_str());
638 G4cerr <<
"Warning from G4RunManager::rndmSaveThisRun():"
639 <<
" Random number status was not stored prior to this run."
640 <<
G4endl <<
"/random/setSavingFlag command must be issued. "
641 <<
"Command ignored." <<
G4endl;
645 std::ostringstream oos;
647 <<
"_" <<
"currentRun.rndm" <<
"\0";
650 std::ostringstream os;
651 os <<
"run" << runNumber <<
".rndm" <<
'\0';
655 G4String copCmd =
"/control/shell copy " + fileIn +
" " + fileOut;
657 G4String copCmd =
"/control/shell cp " + fileIn +
" " + fileOut;
661 {
G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl; }
669 <<
"Warning from G4RunManager::rndmSaveThisEvent():"
670 <<
" there is no currentEvent available."
678 <<
"Warning from G4RunManager::rndmSaveThisEvent():"
679 <<
" Random number engine status is not available."
680 <<
G4endl <<
"/random/setSavingFlag command must be issued "
681 <<
"prior to the start of the run. Command ignored." <<
G4endl;
685 std::ostringstream oos;
687 <<
"_" <<
"currentEvent.rndm" <<
"\0";
690 std::ostringstream os;
695 G4String copCmd =
"/control/shell copy " + fileIn +
" " + fileOut;
697 G4String copCmd =
"/control/shell cp " + fileIn +
" " + fileOut;
701 {
G4cout << fileIn <<
" is copied to " << fileOut <<
G4endl; }
709 while( nextAction != G4MTRunManager::WorkerActionRequest::ENDWORKER )
711 if( nextAction == G4MTRunManager::WorkerActionRequest::NEXTITERATION )
715 if(skipInitialization)
718 skipInitialization =
false;
729 std::vector<G4String>::const_iterator
it = cmds.begin();
730 for(;it!=cmds.end();it++)
736 if ( macroFile ==
"" || macroFile ==
" " )
742 this->
BeamOn(numevents,macroFile,numSelect);
745 else if (nextAction == G4MTRunManager::WorkerActionRequest::PROCESSUI ) {
748 std::vector<G4String>::const_iterator
it = cmds.begin();
749 for(;it!=cmds.end();it++)
756 d<<
"Cannot continue, this worker has been requested an unknown action: "
757 <<
static_cast<std::underlying_type<G4MTRunManager::WorkerActionRequest>::type
>(nextAction);