Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
+54 -2
View File
@@ -137,7 +137,7 @@ G4MTRunManager::G4MTRunManager()
G4ExceptionDescription msg1;
msg1 << "There are " << numberOfStaticAllocators
<< " static G4Allocator objects detected.\n"
<< "In multi-threaded mode, all G4Allocator objects must be dynamicly "
<< "In multi-threaded mode, all G4Allocator objects must be dynamically "
"instantiated.";
G4Exception("G4MTRunManager::G4MTRunManager", "Run1035", FatalException,
msg1);
@@ -209,6 +209,41 @@ void G4MTRunManager::StoreRNGStatus(const G4String& fn)
G4Random::saveEngineStatus(os.str().c_str());
}
void G4MTRunManager::rndmSaveThisRun()
{
G4int runNumber = 0;
if(currentRun) runNumber = currentRun->GetRunID();
if(!storeRandomNumberStatus)
{
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
<< " Random number status was not stored prior to this run."
<< G4endl << "/random/setSavingFlag command must be issued. "
<< "Command ignored." << G4endl;
return;
}
G4String fileIn = randomNumberStatusDir + "G4Worker_currentRun.rndm";
std::ostringstream os;
os << "run" << runNumber << ".rndm" << '\0';
G4String fileOut = randomNumberStatusDir + os.str();
#ifdef WIN32
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
#else
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
#endif
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
if(verboseLevel > 0)
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
}
void G4MTRunManager::rndmSaveThisEvent()
{
G4Exception("G4MTRunManager::rndmSaveThisEvent","RUN_RNDM001",
FatalException,"This method shall not be invoked !!");
}
void G4MTRunManager::SetNumberOfThreads(G4int n)
{
if(threads.size() != 0)
@@ -284,6 +319,22 @@ void G4MTRunManager::CreateAndStartWorkers()
// number of threads: threads area created once
if(threads.size() == 0)
{
{
// for consistency with G4TaskRunManager
std::stringstream msg;
msg << "--> G4MTRunManager::CreateAndStartWorkers() --> "
<< "Initializing workers...";
std::stringstream ss;
ss.fill('=');
ss << std::setw(msg.str().length()) << "";
G4cout << "\n"
<< ss.str() << "\n"
<< msg.str() << "\n"
<< ss.str() << "\n"
<< G4endl;
}
for(G4int nw = 0; nw < nworkers; ++nw)
{
// Create a new worker and remember it
@@ -302,7 +353,6 @@ void G4MTRunManager::CreateAndStartWorkers()
void G4MTRunManager::InitializeEventLoop(G4int n_event, const char* macroFile,
G4int n_select)
{
TIMEMORY_AUTO_TIMER("");
MTkernel->SetUpDecayChannels();
numberOfEventToBeProcessed = n_event;
numberOfEventProcessed = 0;
@@ -617,6 +667,8 @@ void G4MTRunManager::TerminateWorkers()
RequestWorkersProcessCommandsStack();
// Ask workers to exit
NewActionRequest(WorkerActionRequest::ENDWORKER);
// finalize profiler before shutting down the threads
G4Profiler::Finalize();
// Now join threads.
#ifdef G4MULTITHREADED // protect here to prevent warning in compilation
while(!threads.empty())
+3 -3
View File
@@ -330,7 +330,7 @@ void G4PhysicsListHelper::ReadOrdingParameterTable()
}
#endif
G4Exception("G4PhysicsListHelper::ReadOrdingParameterTable", "Run0105",
JustWarning, "Fail to open ordering paramter table ");
JustWarning, "Fail to open ordering parameter table ");
}
else
{
@@ -540,7 +540,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
<< particle->GetParticleName() << " with type/subtype =" << pType
<< "/" << pSubType
<< " is not reigstered in OrdingParameterTable " << G4endl;
<< " is not registered in OrdingParameterTable " << G4endl;
}
#endif
G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0109",
@@ -629,7 +629,7 @@ G4bool G4PhysicsListHelper::RegisterProcess(G4VProcess* process,
G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
<< particle->GetParticleName() << " with type/subtype =" << pType
<< "/" << pSubType
<< " is sucessfully registered with ordering parameters " << ord[0]
<< " is successfully registered with ordering parameters " << ord[0]
<< ":" << ord[1] << ":" << ord[2] << G4endl;
}
#endif
+224 -25
View File
@@ -61,6 +61,8 @@
#include "G4VVisManager.hh"
#include "G4ios.hh"
#include "Randomize.hh"
#include "G4TiMemory.hh"
#include "G4Profiler.hh"
#include <sstream>
using namespace CLHEP;
@@ -230,10 +232,13 @@ G4RunManager::G4RunManager(RMType rmType)
G4Random::saveFullState(oss);
randomNumberStatusForThisRun = oss.str();
randomNumberStatusForThisEvent = oss.str();
ConfigureProfilers();
}
G4RunManager::~G4RunManager()
{
// finalize profiler before shutting down the threads
G4Profiler::Finalize();
G4StateManager* pStateManager = G4StateManager::GetStateManager();
// set the application state to the quite state
if(pStateManager->GetCurrentState() != G4State_Quit)
@@ -320,7 +325,6 @@ void G4RunManager::DeleteUserInitializations()
void G4RunManager::BeamOn(G4int n_event, const char* macroFile, G4int n_select)
{
TIMEMORY_AUTO_TIMER("");
if(n_event <= 0)
{
fakeRun = true;
@@ -381,7 +385,6 @@ void G4RunManager::RunInitialization()
if(!(kernel->RunInitialization(fakeRun)))
return;
TIMEMORY_AUTO_TIMER("");
runAborted = false;
numberOfEventProcessed = 0;
@@ -435,6 +438,10 @@ void G4RunManager::RunInitialization()
if(userRunAction)
userRunAction->BeginOfRunAction(currentRun);
#if defined(GEANT4_USE_TIMEMORY)
masterRunProfiler.reset(new ProfilerConfig(currentRun));
#endif
if(isScoreNtupleWriter)
{
G4VScoreNtupleWriter::Instance()->OpenFile();
@@ -456,7 +463,6 @@ void G4RunManager::RunInitialization()
void G4RunManager::DoEventLoop(G4int n_event, const char* macroFile,
G4int n_select)
{
TIMEMORY_AUTO_TIMER("");
InitializeEventLoop(n_event, macroFile, n_select);
// Event loop
@@ -500,7 +506,6 @@ void G4RunManager::InitializeEventLoop(G4int n_event, const char* macroFile,
void G4RunManager::ProcessOneEvent(G4int i_event)
{
TIMEMORY_AUTO_TIMER("");
currentEvent = GenerateEvent(i_event);
eventManager->ProcessOneEvent(currentEvent);
AnalyzeEvent(currentEvent);
@@ -511,7 +516,6 @@ void G4RunManager::ProcessOneEvent(G4int i_event)
void G4RunManager::TerminateOneEvent()
{
TIMEMORY_AUTO_TIMER("");
StackPreviousEvent(currentEvent);
currentEvent = 0;
numberOfEventProcessed++;
@@ -543,7 +547,6 @@ void G4RunManager::TerminateEventLoop()
G4Event* G4RunManager::GenerateEvent(G4int i_event)
{
TIMEMORY_AUTO_TIMER("");
if(!userPrimaryGeneratorAction)
{
G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
@@ -584,7 +587,6 @@ G4Event* G4RunManager::GenerateEvent(G4int i_event)
void G4RunManager::StoreRNGStatus(const G4String& fnpref)
{
TIMEMORY_AUTO_TIMER("");
G4String fileN = randomNumberStatusDir + fnpref + ".rndm";
G4Random::saveEngineStatus(fileN);
}
@@ -602,17 +604,25 @@ void G4RunManager::RunTermination()
{
if(!fakeRun)
{
#if defined(GEANT4_USE_TIMEMORY)
masterRunProfiler.reset();
#endif
CleanUpUnnecessaryEvents(0);
if(userRunAction)
userRunAction->EndOfRunAction(currentRun);
G4VPersistencyManager* fPersM =
G4VPersistencyManager::GetPersistencyManager();
if(fPersM)
fPersM->Store(currentRun);
// write & close analysis output
if(isScoreNtupleWriter)
// tasking occasionally will call this function even
// if there was not a current run
if(currentRun)
{
G4VScoreNtupleWriter::Instance()->Write();
if(userRunAction)
userRunAction->EndOfRunAction(currentRun);
G4VPersistencyManager* fPersM =
G4VPersistencyManager::GetPersistencyManager();
if(fPersM)
fPersM->Store(currentRun);
// write & close analysis output
if(isScoreNtupleWriter)
{
G4VScoreNtupleWriter::Instance()->Write();
}
}
runIDCounter++;
}
@@ -824,13 +834,13 @@ void G4RunManager::DefineWorldVolume(G4VPhysicalVolume* worldVol,
void G4RunManager::rndmSaveThisRun()
{
G4int runNumber = 0;
if(currentRun)
runNumber = currentRun->GetRunID();
if(currentRun) runNumber = currentRun->GetRunID();
if(!storeRandomNumberStatus)
{
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
<< " Random number status was not stored prior to this run."
<< G4endl << "Command ignored." << G4endl;
<< G4endl << "/random/setSavingFlag command must be issued. "
<< "Command ignored." << G4endl;
return;
}
@@ -840,23 +850,37 @@ void G4RunManager::rndmSaveThisRun()
os << "run" << runNumber << ".rndm" << '\0';
G4String fileOut = randomNumberStatusDir + os.str();
#ifdef WIN32
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
#else
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
#endif
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
if(verboseLevel > 0)
G4cout << "currentRun.rndm is copied to file: " << fileOut << G4endl;
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
}
void G4RunManager::rndmSaveThisEvent()
{
if(!storeRandomNumberStatus || currentEvent == 0)
if(currentEvent == 0)
{
G4cerr
<< "Warning from G4RunManager::rndmSaveThisEvent():"
<< " there is no currentEvent or its RandomEngineStatus is not available."
<< " there is no currentEvent available."
<< G4endl << "Command ignored." << G4endl;
return;
}
if(!storeRandomNumberStatus)
{
G4cerr
<< "Warning from G4RunManager::rndmSaveThisEvent():"
<< " Random number engine status is not available."
<< G4endl << "/random/setSavingFlag command must be issued "
<< "prior to the start of the run. Command ignored." << G4endl;
return;
}
G4String fileIn = randomNumberStatusDir + "currentEvent.rndm";
std::ostringstream os;
@@ -864,10 +888,14 @@ void G4RunManager::rndmSaveThisEvent()
<< ".rndm" << '\0';
G4String fileOut = randomNumberStatusDir + os.str();
#ifdef WIN32
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
#else
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
#endif
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
if(verboseLevel > 0)
G4cout << "currentEvent.rndm is copied to file: " << fileOut << G4endl;
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
}
void G4RunManager::RestoreRandomNumberStatus(const G4String& fileN)
@@ -924,7 +952,6 @@ void G4RunManager::ConstructScoringWorlds()
if(nPar < 1)
return;
TIMEMORY_AUTO_TIMER("");
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
G4ParticleTable::GetParticleTable()->GetIterator();
for(G4int iw = 0; iw < nPar; iw++)
@@ -1002,7 +1029,6 @@ void G4RunManager::UpdateScoring()
if(nPar < 1)
return;
TIMEMORY_AUTO_TIMER("");
G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
if(!HCE)
return;
@@ -1201,3 +1227,176 @@ void G4RunManager::ReinitializeGeometry(G4bool destroyFirst, G4bool prop)
}
}
}
//---------------------------------------------------------------------------//
void G4RunManager::ConfigureProfilers(int argc, char** argv)
{
std::vector<std::string> _args;
for(int i = 0; i < argc; ++i)
_args.push_back(argv[i]);
ConfigureProfilers(_args);
}
//---------------------------------------------------------------------------//
void G4RunManager::ConfigureProfilers(const std::vector<std::string>& args)
{
#ifdef GEANT4_USE_TIMEMORY
// parse command line if arguments were passed
G4Profiler::Configure(args);
#else
G4ConsumeParameters(args);
#endif
}
//---------------------------------------------------------------------------//
#if !defined(GEANT4_USE_TIMEMORY)
# define TIMEMORY_WEAK_PREFIX
# define TIMEMORY_WEAK_POSTFIX
#endif
//---------------------------------------------------------------------------//
extern "C"
{
// this allows the default setup to be overridden by linking
// in an custom extern C function into the application
TIMEMORY_WEAK_PREFIX
void G4RunProfilerInit(void) TIMEMORY_WEAK_POSTFIX;
extern void G4ProfilerInit(void);
// this gets executed when the library gets loaded
void G4RunProfilerInit(void)
{
#ifdef GEANT4_USE_TIMEMORY
G4ProfilerInit();
// guard against re-initialization
static bool _once = false;
if(_once)
return;
_once = true;
puts(">>> G4RunProfilerInit <<<");
using RunProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
using EventProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
using TrackProfilerConfig = G4ProfilerConfig<G4ProfileType::Track>;
using StepProfilerConfig = G4ProfilerConfig<G4ProfileType::Step>;
using UserProfilerConfig = G4ProfilerConfig<G4ProfileType::User>;
//
// these are the default functions for evaluating whether
// to start profiling
//
RunProfilerConfig::GetFallbackQueryFunctor() = [](const G4Run* _run) {
return G4Profiler::GetEnabled(G4ProfileType::Run) && _run;
};
EventProfilerConfig::GetFallbackQueryFunctor() = [](const G4Event* _event) {
return G4Profiler::GetEnabled(G4ProfileType::Event) && _event;
};
TrackProfilerConfig::GetFallbackQueryFunctor() = [](const G4Track* _track) {
return G4Profiler::GetEnabled(G4ProfileType::Track) && _track &&
_track->GetDynamicParticle();
};
StepProfilerConfig::GetFallbackQueryFunctor() = [](const G4Step* _step) {
return G4Profiler::GetEnabled(G4ProfileType::Step) && _step &&
_step->GetTrack();
};
UserProfilerConfig::GetFallbackQueryFunctor() =
[](const std::string& _user) {
return G4Profiler::GetEnabled(G4ProfileType::User) && !_user.empty();
};
//
// these are the default functions which encode the profiling label.
// Will not be called unless the query returned true
//
RunProfilerConfig::GetFallbackLabelFunctor() = [](const G4Run* _run) {
return TIMEMORY_JOIN('/', "G4Run", _run->GetRunID());
};
EventProfilerConfig::GetFallbackLabelFunctor() =
[](const G4Event* _event) -> std::string {
if(G4Profiler::GetPerEvent())
return TIMEMORY_JOIN('/', "G4Event", _event->GetEventID());
else
return "G4Event";
};
TrackProfilerConfig::GetFallbackLabelFunctor() = [](const G4Track* _track) {
auto pdef = _track->GetDynamicParticle()->GetParticleDefinition();
return TIMEMORY_JOIN('/', "G4Track", pdef->GetParticleName());
};
StepProfilerConfig::GetFallbackLabelFunctor() = [](const G4Step* _step) {
auto pdef = _step->GetTrack()->GetParticleDefinition();
return TIMEMORY_JOIN('/', "G4Step", pdef->GetParticleName());
};
UserProfilerConfig::GetFallbackLabelFunctor() =
[](const std::string& _user) { return _user; };
using RunTool = typename RunProfilerConfig::type;
using EventTool = typename EventProfilerConfig::type;
using TrackTool = typename TrackProfilerConfig::type;
using StepTool = typename StepProfilerConfig::type;
using UserTool = typename UserProfilerConfig::type;
RunProfilerConfig::GetFallbackToolFunctor() =
[](const std::string& _label) { return new RunTool{ _label }; };
EventProfilerConfig::GetFallbackToolFunctor() =
[](const std::string& _label) { return new EventTool{ _label }; };
TrackProfilerConfig::GetFallbackToolFunctor() =
[](const std::string& _label) {
return new TrackTool(_label, tim::scope::config(tim::scope::flat{}));
};
StepProfilerConfig::GetFallbackToolFunctor() =
[](const std::string& _label) {
return new StepTool(_label, tim::scope::config(tim::scope::flat{}));
};
UserProfilerConfig::GetFallbackToolFunctor() =
[](const std::string& _label) { return new UserTool(_label); };
auto comps = "wall_clock, cpu_clock, cpu_util, peak_rss";
auto run_env_comps =
tim::get_env<std::string>("G4PROFILE_RUN_COMPONENTS", comps);
auto event_env_comps =
tim::get_env<std::string>("G4PROFILE_EVENT_COMPONENTS", comps);
auto track_env_comps =
tim::get_env<std::string>("G4PROFILE_TRACK_COMPONENTS", comps);
auto step_env_comps =
tim::get_env<std::string>("G4PROFILE_STEP_COMPONENTS", comps);
auto user_env_comps =
tim::get_env<std::string>("G4PROFILE_USER_COMPONENTS", comps);
tim::configure<G4RunProfiler>(run_env_comps);
tim::configure<G4EventProfiler>(event_env_comps);
tim::configure<G4TrackProfiler>(track_env_comps);
tim::configure<G4StepProfiler>(step_env_comps);
tim::configure<G4UserProfiler>(user_env_comps);
#endif
}
} // extern "C"
//---------------------------------------------------------------------------//
#ifdef GEANT4_USE_TIMEMORY
namespace
{
static bool profiler_is_initialized = (G4RunProfilerInit(), true);
}
#endif
//---------------------------------------------------------------------------//
+29 -2
View File
@@ -64,6 +64,10 @@
#include "G4AutoLock.hh"
#include "G4RNGHelper.hh"
#ifdef G4BT_DEBUG
#include "G4Backtrace.hh"
#endif
#ifdef G4FPE_DEBUG
# include "G4FPEDetection.hh"
#endif
@@ -96,6 +100,19 @@ G4RunManagerKernel::G4RunManagerKernel()
#ifdef G4FPE_DEBUG
InvalidOperationDetection();
#endif
#ifdef G4BT_DEBUG
auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
if(_signals.empty())
{
G4Backtrace::Enable();
}
else
{
G4Backtrace::Enable(_signals);
}
#endif
G4AllocatorList* allocList = G4AllocatorList::GetAllocatorListIfExist();
if(allocList)
numberOfStaticAllocators = allocList->Size();
@@ -197,6 +214,18 @@ G4RunManagerKernel::G4RunManagerKernel(RMKType rmkType)
}
#endif
#ifdef G4BT_DEBUG
auto _signals = G4GetEnv<std::string>("G4BACKTRACE", "");
if(_signals.empty())
{
G4Backtrace::Enable();
}
else
{
G4Backtrace::Enable(_signals);
}
#endif
defaultExceptionHandler = new G4ExceptionHandler();
if(fRunManagerKernel)
{
@@ -760,7 +789,6 @@ void G4RunManagerKernel::InitializePhysics()
G4bool G4RunManagerKernel::RunInitialization(G4bool fakeRun)
{
TIMEMORY_AUTO_TIMER("");
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
@@ -894,7 +922,6 @@ void G4RunManagerKernel::BuildPhysicsTables(G4bool fakeRun)
if(G4ProductionCutsTable::GetProductionCutsTable()->IsModified() ||
physicsNeedsToBeReBuilt)
{
TIMEMORY_AUTO_TIMER("");
#ifdef G4MULTITHREADED
if(runManagerKernelType == masterRMK)
{
+1 -1
View File
@@ -617,7 +617,7 @@ void G4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
G4String vl;
while(!(vl = next()).isNull())
{
seeds[idx] = (long) (StoI(vl));
seeds[idx] = StoL(vl);
idx++;
}
if(idx < 2)
+8 -11
View File
@@ -45,9 +45,6 @@ G4VMPLManager G4VModularPhysicsList::G4VMPLsubInstanceManager;
void G4VMPLData::initialize() { physicsVector = new G4PhysConstVectorData(); }
// G4ThreadLocal G4VModularPhysicsList::G4PhysConstVector*
// G4VModularPhysicsList::physicsVector = 0;
G4VModularPhysicsList::G4VModularPhysicsList()
: G4VUserPhysicsList()
, verboseLevel(0)
@@ -177,7 +174,7 @@ void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
if(verboseLevel > 1)
{
G4cout << "G4VModularPhysicsList::RegisterPhysics: " << pName
<< "with type : " << pType << " is added" << G4endl;
<< " with type : " << pType << " is added" << G4endl;
}
#endif
return;
@@ -199,7 +196,7 @@ void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
<< "a physics with given type already exists " << G4endl;
G4cout << " Type = " << pType << " : "
<< " existing physics is " << (*itr)->GetPhysicsName() << G4endl;
G4cout << pName << " can not be registered " << G4endl;
G4cout << " New " << pName << " can not be registered " << G4endl;
}
#endif
G4String comment = "Duplicate type for ";
@@ -237,7 +234,7 @@ void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
if(verboseLevel > 0)
{
G4cout << "G4VModularPhysicsList::ReplacePhysics: " << pName
<< "with type : " << pType << " is added" << G4endl;
<< " with type : " << pType << " is added" << G4endl;
}
#endif
return;
@@ -262,8 +259,8 @@ void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
if(verboseLevel > 0)
{
G4cout << "G4VModularPhysicsList::ReplacePhysics: "
<< (*itr)->GetPhysicsName() << "with type : " << pType
<< " is replaces with " << pName << G4endl;
<< (*itr)->GetPhysicsName() << " with type : " << pType
<< " is replaced with " << pName << G4endl;
}
#endif
@@ -296,7 +293,7 @@ void G4VModularPhysicsList::RemovePhysics(G4int pType)
if(verboseLevel > 0)
{
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
<< " is removed" << G4endl;
<< " is removed" << G4endl;
}
#endif
G4MT_physicsVector->erase(itr);
@@ -329,7 +326,7 @@ void G4VModularPhysicsList::RemovePhysics(G4VPhysicsConstructor* fPhysics)
if(verboseLevel > 0)
{
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
<< " is removed" << G4endl;
<< " is removed" << G4endl;
}
#endif
G4MT_physicsVector->erase(itr);
@@ -361,7 +358,7 @@ void G4VModularPhysicsList::RemovePhysics(const G4String& name)
if(verboseLevel > 0)
{
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
<< " is removed" << G4endl;
<< " is removed" << G4endl;
}
#endif
G4MT_physicsVector->erase(itr);
+80 -5
View File
@@ -174,7 +174,6 @@ void G4WorkerRunManager::InitializeGeometry()
void G4WorkerRunManager::RunInitialization()
{
TIMEMORY_AUTO_TIMER("");
#ifdef G4MULTITHREADED
if(!visIsSetUp)
{
@@ -250,6 +249,10 @@ void G4WorkerRunManager::RunInitialization()
if(userRunAction)
userRunAction->BeginOfRunAction(currentRun);
#if defined(GEANT4_USE_TIMEMORY)
workerRunProfiler.reset(new ProfilerConfig(currentRun));
#endif
if(isScoreNtupleWriter)
{
G4VScoreNtupleWriter::Instance()->OpenFile();
@@ -274,7 +277,6 @@ void G4WorkerRunManager::RunInitialization()
void G4WorkerRunManager::DoEventLoop(G4int n_event, const char* macroFile,
G4int n_select)
{
TIMEMORY_AUTO_TIMER("");
if(!userPrimaryGeneratorAction)
{
G4Exception("G4RunManager::GenerateEvent()", "Run0032", FatalException,
@@ -324,7 +326,6 @@ void G4WorkerRunManager::DoEventLoop(G4int n_event, const char* macroFile,
void G4WorkerRunManager::ProcessOneEvent(G4int i_event)
{
TIMEMORY_AUTO_TIMER("");
currentEvent = GenerateEvent(i_event);
if(eventLoopOnGoing)
{
@@ -338,7 +339,6 @@ void G4WorkerRunManager::ProcessOneEvent(G4int i_event)
G4Event* G4WorkerRunManager::GenerateEvent(G4int i_event)
{
TIMEMORY_AUTO_TIMER("");
G4Event* anEvent = new G4Event(i_event);
long s1 = 0;
long s2 = 0;
@@ -487,6 +487,9 @@ void G4WorkerRunManager::RunTermination()
{
if(!fakeRun)
{
#if defined(GEANT4_USE_TIMEMORY)
workerRunProfiler.reset();
#endif
MergePartialResults();
// Call a user hook: note this is before the next barrier
@@ -725,9 +728,81 @@ void G4WorkerRunManager::StoreRNGStatus(const G4String& fn)
G4Random::saveEngineStatus(os.str().c_str());
}
void G4WorkerRunManager::rndmSaveThisRun()
{
G4int runNumber = 0;
if(currentRun) runNumber = currentRun->GetRunID();
if(!storeRandomNumberStatus)
{
G4cerr << "Warning from G4RunManager::rndmSaveThisRun():"
<< " Random number status was not stored prior to this run."
<< G4endl << "/random/setSavingFlag command must be issued. "
<< "Command ignored." << G4endl;
return;
}
std::ostringstream oos;
oos << "G4Worker" << workerContext->GetThreadId()
<< "_" << "currentRun.rndm" << "\0";
G4String fileIn = randomNumberStatusDir + oos.str();
std::ostringstream os;
os << "run" << runNumber << ".rndm" << '\0';
G4String fileOut = randomNumberStatusDir + os.str();
#ifdef WIN32
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
#else
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
#endif
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
if(verboseLevel > 0)
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
}
void G4WorkerRunManager::rndmSaveThisEvent()
{
if(currentEvent == 0)
{
G4cerr
<< "Warning from G4RunManager::rndmSaveThisEvent():"
<< " there is no currentEvent available."
<< G4endl << "Command ignored." << G4endl;
return;
}
if(!storeRandomNumberStatus)
{
G4cerr
<< "Warning from G4RunManager::rndmSaveThisEvent():"
<< " Random number engine status is not available."
<< G4endl << "/random/setSavingFlag command must be issued "
<< "prior to the start of the run. Command ignored." << G4endl;
return;
}
std::ostringstream oos;
oos << "G4Worker" << workerContext->GetThreadId()
<< "_" << "currentEvent.rndm" << "\0";
G4String fileIn = randomNumberStatusDir + oos.str();
std::ostringstream os;
os << "run" << currentRun->GetRunID() << "evt" << currentEvent->GetEventID()
<< ".rndm" << '\0';
G4String fileOut = randomNumberStatusDir + os.str();
#ifdef WIN32
G4String copCmd = "/control/shell copy " + fileIn + " " + fileOut;
#else
G4String copCmd = "/control/shell cp " + fileIn + " " + fileOut;
#endif
G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
if(verboseLevel > 0)
{ G4cout << fileIn << " is copied to " << fileOut << G4endl; }
}
void G4WorkerRunManager::DoWork()
{
TIMEMORY_AUTO_TIMER("");
G4MTRunManager* mrm = G4MTRunManager::GetMasterRunManager();
G4MTRunManager::WorkerActionRequest nextAction =
mrm->ThisWorkerWaitForNextAction();