Import Geant4 11.3.0 source tree
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "G4PhysicsLogVector.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4UserEventAction.hh"
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "G4UserStackingAction.hh"
|
||||
@@ -65,7 +66,7 @@ G4AdjointSimManager::G4AdjointSimManager()
|
||||
theAdjointTrackingAction = new G4AdjointTrackingAction(theAdjointSteppingAction);
|
||||
theAdjointStackingAction = new G4AdjointStackingAction(theAdjointTrackingAction);
|
||||
theAdjointTrackingAction->SetListOfPrimaryFwdParticles(
|
||||
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles());
|
||||
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles());
|
||||
|
||||
theMessenger = new G4AdjointSimMessenger(this);
|
||||
}
|
||||
@@ -95,8 +96,7 @@ G4AdjointSimManager* G4AdjointSimManager::GetInstance()
|
||||
//
|
||||
void G4AdjointSimManager::RunAdjointSimulation(G4int nb_evt)
|
||||
{
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() != G4RunManager::sequentialRM)
|
||||
return; // only for sequential mode
|
||||
|
||||
if (welcome_message) {
|
||||
G4cout << "****************************************************************" << std::endl;
|
||||
G4cout << "*** Geant4 Reverse/Adjoint Monte Carlo mode ***" << std::endl;
|
||||
@@ -114,18 +114,16 @@ void G4AdjointSimManager::RunAdjointSimulation(G4int nb_evt)
|
||||
// Make the run
|
||||
//------------
|
||||
nb_evt_of_last_run = nb_evt;
|
||||
G4RunManager::GetRunManager()->BeamOn(
|
||||
if (G4Threading::G4GetThreadId() < 0){
|
||||
G4RunManager::GetRunManager()->BeamOn(
|
||||
G4int(nb_evt * theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes()));
|
||||
|
||||
// Back to Fwd Simulation Mode
|
||||
//--------------------------------
|
||||
BackToFwdSimulationMode();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointSimManager::SetRestOfAdjointActions()
|
||||
{
|
||||
{ if (G4Threading::G4GetThreadId() == -1) return;
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if (!user_action_already_defined) DefineUserActions();
|
||||
@@ -148,9 +146,10 @@ void G4AdjointSimManager::SwitchToAdjointSimulationMode()
|
||||
|
||||
// Update the list of primaries
|
||||
//-----------------------------
|
||||
theAdjointPrimaryGeneratorAction->UpdateListOfPrimaryParticles();
|
||||
if (G4Threading::G4GetThreadId() != -1) theAdjointPrimaryGeneratorAction->UpdateListOfPrimaryParticles();
|
||||
adjoint_sim_mode = true;
|
||||
ID_of_last_particle_that_reach_the_ext_source = 0;
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -167,13 +166,17 @@ void G4AdjointSimManager::BackToFwdSimulationMode()
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
auto theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
|
||||
if (!user_action_already_defined) DefineUserActions();
|
||||
|
||||
|
||||
// Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(this);
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM ||
|
||||
G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::workerRM) {
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointStackingAction);
|
||||
if (use_user_StackingAction)
|
||||
@@ -188,6 +191,7 @@ void G4AdjointSimManager::SetAdjointActions()
|
||||
else
|
||||
theAdjointTrackingAction->SetUserForwardTrackingAction(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
@@ -201,6 +205,7 @@ void G4AdjointSimManager::SetAdjointPrimaryRunAndStackingActions()
|
||||
//-------------------------------------------------
|
||||
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointRunAction);
|
||||
if (G4Threading::G4GetThreadId() != -1) {
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointStackingAction);
|
||||
if (use_user_StackingAction)
|
||||
@@ -208,6 +213,7 @@ void G4AdjointSimManager::SetAdjointPrimaryRunAndStackingActions()
|
||||
else
|
||||
theAdjointStackingAction->SetUserFwdStackingAction(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
@@ -218,17 +224,20 @@ void G4AdjointSimManager::ResetUserActions()
|
||||
// Restore the user defined actions
|
||||
//-------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(fUserRunAction);
|
||||
if (G4Threading::G4GetThreadId() != -1) {
|
||||
theRunManager->G4RunManager::SetUserAction(fUserEventAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserSteppingAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserTrackingAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserStackingAction);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointSimManager::ResetRestOfUserActions()
|
||||
{
|
||||
{
|
||||
if (G4Threading::G4GetThreadId() == -1) return;
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
// Restore the user defined actions
|
||||
@@ -247,8 +256,10 @@ void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
|
||||
// Restore the user defined actions
|
||||
//-------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(fUserRunAction);
|
||||
if (G4Threading::G4GetThreadId() != -1) {
|
||||
theRunManager->G4RunManager::SetUserAction(fUserPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserStackingAction);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -256,15 +267,18 @@ void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
|
||||
void G4AdjointSimManager::DefineUserActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
fUserRunAction =
|
||||
const_cast<G4UserRunAction*>(theRunManager->GetUserRunAction());
|
||||
if (G4Threading::G4GetThreadId() != -1) {
|
||||
fUserTrackingAction = const_cast<G4UserTrackingAction*>(theRunManager->GetUserTrackingAction());
|
||||
fUserEventAction = const_cast<G4UserEventAction*>(theRunManager->GetUserEventAction());
|
||||
fUserSteppingAction = const_cast<G4UserSteppingAction*>(theRunManager->GetUserSteppingAction());
|
||||
theAdjointSteppingAction->SetUserForwardSteppingAction(fUserSteppingAction);
|
||||
fUserPrimaryGeneratorAction =
|
||||
const_cast<G4VUserPrimaryGeneratorAction*>(theRunManager->GetUserPrimaryGeneratorAction());
|
||||
fUserRunAction = const_cast<G4UserRunAction*>(theRunManager->GetUserRunAction());
|
||||
fUserStackingAction = const_cast<G4UserStackingAction*>(theRunManager->GetUserStackingAction());
|
||||
user_action_already_defined = true;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -624,8 +638,14 @@ void G4AdjointSimManager::SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointSimManager::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
fUserRunAction->BeginOfRunAction(aRun);
|
||||
{ if (!adjoint_sim_mode){
|
||||
if(fUserRunAction != nullptr) fUserRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
else {
|
||||
if (theAdjointRunAction != nullptr) theAdjointRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
|
||||
//fUserRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -637,6 +657,9 @@ void G4AdjointSimManager::EndOfRunAction(const G4Run* aRun)
|
||||
}
|
||||
else if (theAdjointRunAction != nullptr)
|
||||
theAdjointRunAction->EndOfRunAction(aRun);
|
||||
|
||||
BackToFwdSimulationMode();
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -60,6 +60,7 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
|
||||
// Start and adjoint Run
|
||||
//---------------------
|
||||
|
||||
|
||||
beamOnCmd = new G4UIcommand("/adjoint/start_run", this);
|
||||
beamOnCmd->SetGuidance("Start an adjoint Run.");
|
||||
beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
|
||||
@@ -220,8 +221,7 @@ void G4AdjointSimMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
const auto nv = (const char*)newValue;
|
||||
std::istringstream is(nv);
|
||||
is >> nev;
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM)
|
||||
theAdjointRunManager->RunAdjointSimulation(nev);
|
||||
theAdjointRunManager->RunAdjointSimulation(nev);
|
||||
}
|
||||
else if (command == ConsiderParticleAsPrimaryCmd) {
|
||||
theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
|
||||
|
||||
@@ -107,6 +107,7 @@ void G4MSSteppingAction::PrintEachMaterialVerbose(std::ostream & oss)
|
||||
oss << G4endl;
|
||||
|
||||
|
||||
std::ios::fmtflags os_flags (oss.flags());
|
||||
for( auto & matInfo : shape_mat_info_v)
|
||||
{
|
||||
oss << std::setw(matname_colwidth) << std::left << matInfo.GetName(matname_colwidth) << " ";
|
||||
@@ -133,6 +134,7 @@ void G4MSSteppingAction::PrintEachMaterialVerbose(std::ostream & oss)
|
||||
oss << G4endl;
|
||||
oss << G4endl;
|
||||
}
|
||||
oss.flags(os_flags); // Restore original stream format
|
||||
}
|
||||
|
||||
void G4MSSteppingAction::PrintIntegratedMaterialVerbose(std::ostream& oss)
|
||||
@@ -140,7 +142,7 @@ void G4MSSteppingAction::PrintIntegratedMaterialVerbose(std::ostream& oss)
|
||||
// create database (db) of material name (key) and information
|
||||
std::map<G4String, shape_mat_info_t> mat_db;
|
||||
// accumulate information for each material name into mat_db
|
||||
for( auto & matInfo : shape_mat_info_v)
|
||||
for(auto & matInfo : shape_mat_info_v)
|
||||
{
|
||||
G4String key = matInfo.material_name;
|
||||
if( 0 == mat_db.count( key ) )
|
||||
@@ -153,11 +155,13 @@ void G4MSSteppingAction::PrintIntegratedMaterialVerbose(std::ostream& oss)
|
||||
mat_db[key].lambda += matInfo.lambda;
|
||||
}
|
||||
|
||||
std::ios::fmtflags os_flags (oss.flags());
|
||||
oss << std::scientific << std::setprecision(2) << '\t';
|
||||
for(auto & [key,mat] : mat_db)
|
||||
oss << '\t' << key
|
||||
<< '\t'<< mat.thickness/CLHEP::mm
|
||||
<< '\t'<< mat.x0
|
||||
<< '\t'<< mat.lambda;
|
||||
oss.flags(os_flags); // Restore original stream format
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "G4WorkerThread.hh"
|
||||
|
||||
G4ScoringManager* G4MTRunManager::masterScM = nullptr;
|
||||
G4MTRunManager::masterWorlds_t G4MTRunManager::masterWorlds = G4MTRunManager::masterWorlds_t();
|
||||
G4MTRunManager* G4MTRunManager::fMasterRM = nullptr;
|
||||
G4int G4MTRunManager::seedOncePerCommunication = 0;
|
||||
G4ThreadId G4MTRunManager::masterThreadId = G4ThisThread::get_id();
|
||||
@@ -89,13 +88,14 @@ G4ScoringManager* G4MTRunManager::GetMasterScoringManager()
|
||||
// --------------------------------------------------------------------
|
||||
G4MTRunManager::masterWorlds_t& G4MTRunManager::GetMasterWorlds()
|
||||
{
|
||||
static masterWorlds_t masterWorlds;
|
||||
return masterWorlds;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4MTRunManager::addWorld(G4int counter, G4VPhysicalVolume* w)
|
||||
{
|
||||
masterWorlds.insert(std::make_pair(counter, w));
|
||||
GetMasterWorlds().insert(std::make_pair(counter, w));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -184,6 +184,7 @@ G4MTRunManager::G4MTRunManager() : G4RunManager(masterRM)
|
||||
}
|
||||
}
|
||||
}
|
||||
G4UImanager::GetUIpointer()->SetAlias("RunMode eventParallel");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -465,7 +466,7 @@ void G4MTRunManager::ConstructScoringWorlds()
|
||||
// Call base class stuff...
|
||||
G4RunManager::ConstructScoringWorlds();
|
||||
|
||||
masterWorlds.clear();
|
||||
GetMasterWorlds().clear();
|
||||
auto nWorlds = (G4int)G4TransportationManager::GetTransportationManager()->GetNoWorlds();
|
||||
auto itrW = G4TransportationManager::GetTransportationManager()->GetWorldsIterator();
|
||||
for (G4int iWorld = 0; iWorld < nWorlds; ++iWorld) {
|
||||
|
||||
@@ -174,7 +174,7 @@ void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
}
|
||||
}
|
||||
// Now initialise worker part of shared objects (geometry/physics)
|
||||
wThreadContext->BuildGeometryAndPhysicsVector();
|
||||
G4WorkerThread::BuildGeometryAndPhysicsVector();
|
||||
G4WorkerRunManager* wrm = masterRM->GetUserWorkerThreadInitialization()->CreateWorkerRunManager();
|
||||
wrm->SetWorkerThread(wThreadContext);
|
||||
G4AutoLock wrmm(&workerRMMutex);
|
||||
@@ -229,7 +229,7 @@ void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
//===============================
|
||||
// Step-7: Cleanup split classes
|
||||
//===============================
|
||||
wThreadContext->DestroyGeometryAndPhysicsVector();
|
||||
G4WorkerThread::DestroyGeometryAndPhysicsVector();
|
||||
wThreadContext = nullptr;
|
||||
|
||||
G4Threading::WorkerThreadLeavesPool();
|
||||
|
||||
@@ -685,6 +685,16 @@ void G4PhysicsListHelper::ReadInDefaultOrderingParameter()
|
||||
theTable->push_back(tmp);
|
||||
sizeOfTable += 1;
|
||||
|
||||
tmp.processTypeName = "XrayReflection";
|
||||
tmp.processType = fElectromagnetic;
|
||||
tmp.processSubType = fGammaReflection;
|
||||
tmp.ordering[0] = -1;
|
||||
tmp.ordering[1] = -1;
|
||||
tmp.ordering[2] = 1000;
|
||||
tmp.isDuplicable = false;
|
||||
theTable->push_back(tmp);
|
||||
sizeOfTable += 1;
|
||||
|
||||
tmp.processTypeName = "PositronGeneral";
|
||||
tmp.processType = fElectromagnetic;
|
||||
tmp.processSubType = fPositronGeneralProcess;
|
||||
|
||||
+13
-10
@@ -48,16 +48,7 @@ G4Run::~G4Run()
|
||||
{
|
||||
for(auto& itr : *eventVector)
|
||||
{
|
||||
// if(itr->ToBeKept()) {
|
||||
// G4ExceptionDescription ede;
|
||||
// ede << "Deleting G4Event (id:" << itr->GetEventID()
|
||||
// << ") that has ToBeKept() flag on.\n"
|
||||
// << " KeepEventFlag : " << itr->KeepTheEventFlag()
|
||||
// << " NoOfGrip : " << itr->GetNumberOfGrips()
|
||||
// << " NoOfSubEvt : " << itr->GetNumberOfRemainingSubEvents();
|
||||
// G4Exception("G4Run::~G4Run()","Run0002",JustWarning,ede);
|
||||
// }
|
||||
// G4RunManager::GetRunManager()->ReportEventDeletion(itr);
|
||||
G4RunManager::GetRunManager()->ReportEventDeletion(itr);
|
||||
delete itr;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +75,18 @@ void G4Run::StoreEvent(G4Event* evt)
|
||||
eventVector->push_back(evt);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4Run::GetNumberOfKeptEvents() const
|
||||
{
|
||||
G4int n = 0;
|
||||
if(eventVector!=nullptr && eventVector->size()>0)
|
||||
{
|
||||
for(auto& ev : *eventVector)
|
||||
{ if(ev->KeepTheEventFlag()) n++; }
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4Run::MergeSubEvent(G4Event* /*masterEv*/, const G4Event* /*subEv*/)
|
||||
{
|
||||
|
||||
@@ -129,6 +129,7 @@ G4RunManager::G4RunManager()
|
||||
randomNumberStatusForThisRun = oss.str();
|
||||
randomNumberStatusForThisEvent = oss.str();
|
||||
runManagerType = sequentialRM;
|
||||
G4UImanager::GetUIpointer()->SetAlias("RunMode sequential");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -580,12 +581,18 @@ void G4RunManager::StackPreviousEvent(G4Event* anEvent)
|
||||
|
||||
if (n_perviousEventsToBeStored == 0) {
|
||||
if (anEvent->GetNumberOfGrips() == 0) {
|
||||
if (!(anEvent->ToBeKept())) delete anEvent;
|
||||
if (!(anEvent->ToBeKept())) {
|
||||
ReportEventDeletion(anEvent);
|
||||
delete anEvent;
|
||||
}
|
||||
}
|
||||
else {
|
||||
previousEvents->push_back(anEvent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
previousEvents->push_back(anEvent);
|
||||
}
|
||||
|
||||
CleanUpUnnecessaryEvents(n_perviousEventsToBeStored);
|
||||
}
|
||||
@@ -593,8 +600,11 @@ void G4RunManager::StackPreviousEvent(G4Event* anEvent)
|
||||
// --------------------------------------------------------------------
|
||||
void G4RunManager::ReportEventDeletion(const G4Event* evt)
|
||||
{
|
||||
if(verboseLevel > 2) {
|
||||
G4cout << "deleting G4Event(" << evt << ") eventID = " << evt->GetEventID();
|
||||
if(verboseLevel > 3) {
|
||||
G4cout << "deleting G4Event(" << evt << ") eventID = " << evt->GetEventID()
|
||||
<< " -- grips = " << evt->GetNumberOfGrips()
|
||||
<< " keepFlag = " << evt->KeepTheEventFlag()
|
||||
<< " subEvt = " << evt->GetNumberOfRemainingSubEvents();
|
||||
if(evt->GetNumberOfCompletedSubEvent()>0) {
|
||||
G4cout << " -- contains " << evt->GetNumberOfCompletedSubEvent() << " completed sub-events";
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4TaskRunManager.hh"
|
||||
#include "G4SubEvtRunManager.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
#include "templates.hh"
|
||||
@@ -68,7 +69,8 @@ G4RunManager* G4RunManagerFactory::CreateRunManager(G4RunManagerType _type,
|
||||
// If the supplied type is not ...Only, then allow override from environment
|
||||
std::string rm_type = GetName(_type);
|
||||
if (_type == G4RunManagerType::SerialOnly || _type == G4RunManagerType::MTOnly
|
||||
|| _type == G4RunManagerType::TaskingOnly || _type == G4RunManagerType::TBBOnly)
|
||||
|| _type == G4RunManagerType::TaskingOnly || _type == G4RunManagerType::TBBOnly
|
||||
|| _type == G4RunManagerType::SubEvtOnly)
|
||||
{
|
||||
// MUST fail if unavail in this case
|
||||
fail_if_unavail = true;
|
||||
@@ -85,7 +87,7 @@ G4RunManager* G4RunManagerFactory::CreateRunManager(G4RunManagerType _type,
|
||||
G4GetEnv<std::string>("G4FORCE_RUN_MANAGER_TYPE", "", "Forcing G4RunManager type...");
|
||||
|
||||
if (force_rm.length() > 0) {
|
||||
rm_type = force_rm;
|
||||
rm_type = std::move(force_rm);
|
||||
fail_if_unavail = true;
|
||||
}
|
||||
else if (rm_type.empty()) {
|
||||
@@ -127,6 +129,15 @@ G4RunManager* G4RunManagerFactory::CreateRunManager(G4RunManagerType _type,
|
||||
case G4RunManagerType::TBB:
|
||||
#if defined(G4MULTITHREADED) && defined(GEANT4_USE_TBB)
|
||||
rm = new G4TaskRunManager(_queue, true);
|
||||
#endif
|
||||
break;
|
||||
case G4RunManagerType::SubEvt:
|
||||
#if defined(G4MULTITHREADED)
|
||||
#if defined(GEANT4_USE_TBB)
|
||||
rm = new G4SubEvtRunManager(_queue, true);
|
||||
#else
|
||||
rm = new G4SubEvtRunManager(_queue, false);
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
// "Only" types are not handled since they are converted above to main type
|
||||
@@ -138,6 +149,8 @@ G4RunManager* G4RunManagerFactory::CreateRunManager(G4RunManagerType _type,
|
||||
break;
|
||||
case G4RunManagerType::TBBOnly:
|
||||
break;
|
||||
case G4RunManagerType::SubEvtOnly:
|
||||
break;
|
||||
case G4RunManagerType::Default:
|
||||
break;
|
||||
}
|
||||
@@ -177,6 +190,7 @@ std::set<std::string> G4RunManagerFactory::GetOptions()
|
||||
# if defined(GEANT4_USE_TBB)
|
||||
options.insert("TBB");
|
||||
# endif
|
||||
options.insert("SubEvt");
|
||||
#endif
|
||||
return options;
|
||||
}();
|
||||
@@ -194,6 +208,7 @@ G4RunManagerType G4RunManagerFactory::GetType(const std::string& key)
|
||||
if (std::regex_match(key, std::regex("^(MT).*", opts))) return G4RunManagerType::MT;
|
||||
if (std::regex_match(key, std::regex("^(Task).*", opts))) return G4RunManagerType::Tasking;
|
||||
if (std::regex_match(key, std::regex("^(TBB).*", opts))) return G4RunManagerType::TBB;
|
||||
if (std::regex_match(key, std::regex("^(SubEvt).*", opts))) return G4RunManagerType::SubEvt;
|
||||
|
||||
return G4RunManagerType::Default;
|
||||
}
|
||||
@@ -219,6 +234,10 @@ std::string G4RunManagerFactory::GetName(G4RunManagerType _type)
|
||||
return "TBB";
|
||||
case G4RunManagerType::TBBOnly:
|
||||
return "TBB";
|
||||
case G4RunManagerType::SubEvt:
|
||||
return "SubEvt";
|
||||
case G4RunManagerType::SubEvtOnly:
|
||||
return "SubEvt";
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -635,7 +635,7 @@ G4bool G4RunManagerKernel::RunInitialization(G4bool fakeRun)
|
||||
BuildPhysicsTables(fakeRun);
|
||||
|
||||
if (geometryNeedsToBeClosed) {
|
||||
ResetNavigator();
|
||||
if(!fakeRun || resetNavigatorAtInitialization) ResetNavigator();
|
||||
// CheckRegularGeometry();
|
||||
// Notify the VisManager as well
|
||||
if (G4Threading::IsMasterThread()) {
|
||||
@@ -674,19 +674,20 @@ void G4RunManagerKernel::PropagateGenericIonID()
|
||||
void G4RunManagerKernel::RunTermination()
|
||||
{
|
||||
if (runManagerKernelType != workerRMK)
|
||||
G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated();
|
||||
{ G4ProductionCutsTable::GetProductionCutsTable()->PhysicsTableUpdated(); }
|
||||
G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4RunManagerKernel::ResetNavigator()
|
||||
{
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
if (runManagerKernelType == workerRMK) {
|
||||
// To ensure that it is called when using G4TaskRunManagerKernel
|
||||
if( G4GeometryManager::IsParallelOptimisationConfigured() &&
|
||||
!G4GeometryManager::IsParallelOptimisationFinished() )
|
||||
if( geomManager->IsParallelOptimisationConfigured() &&
|
||||
!geomManager->IsParallelOptimisationFinished() )
|
||||
{
|
||||
G4GeometryManager::GetInstance()->UndertakeOptimisation();
|
||||
geomManager->UndertakeOptimisation();
|
||||
}
|
||||
geometryNeedsToBeClosed = false;
|
||||
return;
|
||||
@@ -697,7 +698,6 @@ void G4RunManagerKernel::ResetNavigator()
|
||||
// state is reset properly. It is required the geometry to be closed
|
||||
// and previous optimisations to be cleared.
|
||||
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
if (verboseLevel > 1) G4cout << "Start closing geometry." << G4endl;
|
||||
|
||||
geomManager->OpenGeometry();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "G4RunMessenger.hh"
|
||||
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "G4SubEvtRunManager.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
@@ -90,9 +91,11 @@ G4RunMessenger::G4RunMessenger(G4RunManager* runMgr) : runManager(runMgr)
|
||||
verboseCmd->SetGuidance(" 1 : Display main topics");
|
||||
verboseCmd->SetGuidance(" 2 : Display main topics and run summary");
|
||||
verboseCmd->SetGuidance(" 3 : Display some additional information");
|
||||
verboseCmd->SetGuidance(" 4 : Display detailed information");
|
||||
verboseCmd->SetGuidance(" N.B. 3 or 4 may cause significant performance degradation");
|
||||
verboseCmd->SetParameterName("level", true);
|
||||
verboseCmd->SetDefaultValue(0);
|
||||
verboseCmd->SetRange("level >=0 && level <=3");
|
||||
verboseCmd->SetRange("level >=0 && level <=4");
|
||||
|
||||
printProgCmd = new G4UIcmdWithAnInteger("/run/printProgress", this);
|
||||
printProgCmd->SetGuidance("Display begin_of_event information at given frequency.");
|
||||
@@ -167,8 +170,9 @@ G4RunMessenger::G4RunMessenger(G4RunManager* runMgr) : runManager(runMgr)
|
||||
evModCmd->SetGuidance(" group of N events. This option is reserved for the future use when");
|
||||
evModCmd->SetGuidance(" Geant4 allows number of threads to be dynamically changed during an");
|
||||
evModCmd->SetGuidance(" event loop.");
|
||||
evModCmd->SetGuidance("This command is valid only for multi-threaded mode.");
|
||||
evModCmd->SetGuidance("This command is ignored if it is issued in sequential mode.");
|
||||
evModCmd->SetGuidance("This command is valid only for multi-threaded event-level parallel mode.");
|
||||
evModCmd->SetGuidance("This command is ignored if it is issued in sequential mode or in");
|
||||
evModCmd->SetGuidance("sub-event parallel mode.");
|
||||
auto emp1 = new G4UIparameter("N", 'i', true);
|
||||
emp1->SetDefaultValue(0);
|
||||
emp1->SetParameterRange("N >= 0");
|
||||
@@ -361,6 +365,19 @@ G4RunMessenger::G4RunMessenger(G4RunManager* runMgr) : runManager(runMgr)
|
||||
procUICmds->SetGuidance("Force workers to process current stack of UI commands.");
|
||||
procUICmds->SetGuidance("This commands is meaningful only in MT mode.");
|
||||
procUICmds->AvailableForStates(G4State_PreInit, G4State_Idle, G4State_GeomClosed);
|
||||
|
||||
trajMergeCmd = new G4UIcmdWithABool("/run/trajectoriesToBeMerged",this);
|
||||
trajMergeCmd->SetGuidance("Merge trajectories created in sub-event parallel mode.");
|
||||
trajMergeCmd->SetGuidance("In sub-event parallel mode, trajectories created in worker ");
|
||||
trajMergeCmd->SetGuidance("threads are not merged to the event in the master thread by default ");
|
||||
trajMergeCmd->SetGuidance("due to the performance overhead caused by copying them.");
|
||||
trajMergeCmd->SetGuidance("This command enables the merging.");
|
||||
trajMergeCmd->SetGuidance("/tracking/storeTrajectory command must be set to create trajectories.");
|
||||
trajMergeCmd->SetGuidance("This command is valid only for sub-event parallel mode.");
|
||||
trajMergeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
trajMergeCmd->SetParameterName("flag", true);
|
||||
trajMergeCmd->SetDefaultValue(true);
|
||||
trajMergeCmd->SetToBeBroadcasted(false);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -387,6 +404,7 @@ G4RunMessenger::~G4RunMessenger()
|
||||
delete randEvtCmd;
|
||||
delete constScoreCmd;
|
||||
delete procUICmds;
|
||||
delete trajMergeCmd;
|
||||
|
||||
delete seedCmd;
|
||||
delete savingFlagCmd;
|
||||
@@ -485,9 +503,13 @@ void G4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
G4cout << "*** /run/eventModulo command is issued in sequential mode."
|
||||
<< "\nCommand is ignored." << G4endl;
|
||||
}
|
||||
else if (rmType == G4RunManager::subEventMasterRM) {
|
||||
G4cout << "*** /run/eventModulo command is issued in sub-event parallel mode."
|
||||
<< "\nCommand is ignored." << G4endl;
|
||||
}
|
||||
else {
|
||||
G4Exception("G4RunMessenger::ApplyNewCommand", "Run0902", FatalException,
|
||||
"/run/eventModulo command is issued to local thread.");
|
||||
"/run/eventModulo command is issued to worker thread.");
|
||||
}
|
||||
}
|
||||
else if (command == dumpRegCmd) {
|
||||
@@ -596,6 +618,26 @@ void G4RunMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
"/run/workersProcessCmds command is issued to local thread.");
|
||||
}
|
||||
}
|
||||
else if (command == trajMergeCmd) {
|
||||
G4RunManager::RMType rmType = runManager->GetRunManagerType();
|
||||
if (rmType == G4RunManager::subEventMasterRM) {
|
||||
auto rm = dynamic_cast<G4SubEvtRunManager*>(runManager);
|
||||
if (rm != nullptr) {
|
||||
rm->TrajectoriesToBeMerged(trajMergeCmd->GetNewBoolValue(newValue));
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "/run/trajectoriesToBeMerged command is issued on a RunManager class "
|
||||
<< "instance that is not G4SubEvtRunManager.";
|
||||
G4Exception("G4RunManager::ApplyNewCommand", "Run0129", FatalException, ed);
|
||||
}
|
||||
}
|
||||
else {
|
||||
G4cout << "*** /run/trajectoriesToBeMerged command is issued on a RunManager "
|
||||
<< "class instance that is not G4SubEvtRunManager."
|
||||
<< "\nCommand is ignored." << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4ScoringManager.hh"
|
||||
#include "G4THitsMap.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Task.hh"
|
||||
#include "G4TaskGroup.hh"
|
||||
@@ -54,6 +55,7 @@
|
||||
#include "G4WorkerSubEvtRunManager.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4VVisManager.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -66,13 +68,18 @@ namespace
|
||||
{
|
||||
G4Mutex scorerMergerMutex;
|
||||
G4Mutex accessSubEventMutex;
|
||||
G4Mutex registerSubEvtWorkerMutex;
|
||||
} // namespace
|
||||
|
||||
//============================================================================//
|
||||
|
||||
G4SubEvtRunManager::G4SubEvtRunManager(G4VUserTaskQueue* task_queue, G4bool useTBB, G4int grainsize)
|
||||
G4SubEvtRunManager::G4SubEvtRunManager(G4VUserTaskQueue* task_queue,
|
||||
G4bool useTBB, G4int grainsize)
|
||||
: G4TaskRunManager(task_queue, useTBB, grainsize)
|
||||
{ runManagerType = subEventMasterRM; }
|
||||
{
|
||||
runManagerType = subEventMasterRM;
|
||||
G4UImanager::GetUIpointer()->SetAlias("RunMode subEventParallel");
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
@@ -92,6 +99,7 @@ G4SubEvtRunManager::~G4SubEvtRunManager()
|
||||
|
||||
void G4SubEvtRunManager::Initialize()
|
||||
{
|
||||
SetSeedOncePerCommunication(1);
|
||||
G4bool firstTime = (threadPool == nullptr);
|
||||
if (firstTime) G4TaskRunManager::InitializeThreadPool();
|
||||
|
||||
@@ -108,7 +116,8 @@ void G4SubEvtRunManager::Initialize()
|
||||
void G4SubEvtRunManager::RunInitialization()
|
||||
{
|
||||
G4RunManager::RunInitialization();
|
||||
if(!fakeRun) runInProgress = true;
|
||||
if(!fakeRun)
|
||||
{ if(CheckSubEvtTypes()) runInProgress = true; }
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -116,7 +125,7 @@ void G4SubEvtRunManager::RunInitialization()
|
||||
void G4SubEvtRunManager::ProcessOneEvent(G4int i_event)
|
||||
{
|
||||
currentEvent = GenerateEvent(i_event);
|
||||
eventManager->ProcessOneEventForSERM(currentEvent);
|
||||
eventManager->ProcessOneEvent(currentEvent);
|
||||
|
||||
// Following two lines should not be executed here, as spawned sub-events may
|
||||
// be still being processed. These methods are invoked when all sub-events belongings
|
||||
@@ -168,15 +177,15 @@ void G4SubEvtRunManager::StackPreviousEvent(G4Event* anEvent)
|
||||
auto pVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (pVisManager) pVisManager->EventReadyForVis(anEvent);
|
||||
UpdateScoring(anEvent);
|
||||
if(!(anEvent->ToBeKept()))
|
||||
if(anEvent->ToBeKept() || anEvent->GetNumberOfGrips()>0)
|
||||
{ // we keep this event for post-processing (i.e. for vis)
|
||||
currentRun->StoreEvent(anEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportEventDeletion(anEvent);
|
||||
delete anEvent;
|
||||
}
|
||||
else
|
||||
{ // we keep this event for post-processing (i.e. for vis)
|
||||
currentRun->StoreEvent(anEvent);
|
||||
}
|
||||
} else {
|
||||
G4Exception("G4SubEvtRunManager::StackPreviousEvent","SubEvtRM1209",FatalException,"We should not be here!!");
|
||||
}
|
||||
@@ -212,34 +221,41 @@ void G4SubEvtRunManager::CleanUpUnnecessaryEvents(G4int keepNEvents)
|
||||
const G4Event* ev = *eItr;
|
||||
if(ev!=nullptr)
|
||||
{
|
||||
if(!(ev->IsEventCompleted()) && ev->GetNumberOfRemainingSubEvents()==0)
|
||||
{ // This event has been completed since last time we were here
|
||||
ev->EventCompleted();
|
||||
if(userEventAction!=nullptr) userEventAction->EndOfEventAction(ev);
|
||||
auto pVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (pVisManager) pVisManager->EventReadyForVis(ev);
|
||||
UpdateScoring(ev);
|
||||
if(!(ev->ToBeKept()))
|
||||
{
|
||||
ReportEventDeletion(ev);
|
||||
delete ev;
|
||||
eItr = eventVector->erase(eItr);
|
||||
if(!(ev->IsEventCompleted()))
|
||||
{
|
||||
if(ev->GetNumberOfRemainingSubEvents()==0)
|
||||
{ // This event has been completed since last time we were here
|
||||
ev->EventCompleted();
|
||||
if(userEventAction!=nullptr) userEventAction->EndOfEventAction(ev);
|
||||
auto pVisManager = G4VVisManager::GetConcreteInstance();
|
||||
if (pVisManager) pVisManager->EventReadyForVis(ev);
|
||||
UpdateScoring(ev);
|
||||
if(ev->ToBeKept() || ev->GetNumberOfGrips()>0)
|
||||
{ // we keep this event for post-processing (i.e. for vis)
|
||||
eItr++;
|
||||
}
|
||||
else
|
||||
{ // this event is no longer needed
|
||||
ReportEventDeletion(ev);
|
||||
delete ev;
|
||||
eItr = eventVector->erase(eItr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // we keep this event for post-processing (i.e. for vis)
|
||||
{ // this event is still incomplete
|
||||
eItr++;
|
||||
}
|
||||
}
|
||||
else if(!(ev->ToBeKept()))
|
||||
else if(ev->ToBeKept() || ev->GetNumberOfGrips()>0)
|
||||
{ // we still need this event
|
||||
eItr++;
|
||||
}
|
||||
else
|
||||
{ // post-processing done. we no longer need this event
|
||||
ReportEventDeletion(ev);
|
||||
delete ev;
|
||||
eItr = eventVector->erase(eItr);
|
||||
}
|
||||
else
|
||||
{ // we still need this event
|
||||
eItr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // ev is a null pointer
|
||||
@@ -265,8 +281,8 @@ void G4SubEvtRunManager::CreateAndStartWorkers()
|
||||
if (initializeStarted) {
|
||||
auto initCmdStack = GetCommandStack();
|
||||
if (!initCmdStack.empty()) {
|
||||
threadPool->execute_on_all_threads([initCmdStack]() {
|
||||
for (auto& itr : initCmdStack)
|
||||
threadPool->execute_on_all_threads([cmds = std::move(initCmdStack)]() {
|
||||
for (auto& itr : cmds)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
G4WorkerTaskRunManager::GetWorkerRunManager()->DoWork();
|
||||
});
|
||||
@@ -290,8 +306,8 @@ void G4SubEvtRunManager::CreateAndStartWorkers()
|
||||
else {
|
||||
auto initCmdStack = GetCommandStack();
|
||||
if (!initCmdStack.empty()) {
|
||||
threadPool->execute_on_all_threads([initCmdStack]() {
|
||||
for (auto& itr : initCmdStack)
|
||||
threadPool->execute_on_all_threads([cmds = std::move(initCmdStack)]() {
|
||||
for (auto& itr : cmds)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
});
|
||||
}
|
||||
@@ -334,7 +350,7 @@ void G4SubEvtRunManager::CreateAndStartWorkers()
|
||||
|
||||
void G4SubEvtRunManager::AddEventTask(G4int nt)
|
||||
{
|
||||
if (verboseLevel > 1) G4cout << "Adding task " << nt << " to task-group..." << G4endl;
|
||||
if (verboseLevel > 3) G4cout << "Adding task " << nt << " to task-group..." << G4endl;
|
||||
workTaskGroup->exec([]() { G4TaskRunManagerKernel::ExecuteWorkerTask(); });
|
||||
}
|
||||
|
||||
@@ -402,23 +418,17 @@ void G4SubEvtRunManager::InitializeEventLoop(G4int n_event, const char* macroFil
|
||||
if (!_overload && !_functor) {
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
switch (SeedOncePerCommunication()) {
|
||||
case 0:
|
||||
nSeedsFilled = n_event;
|
||||
break;
|
||||
case 1:
|
||||
nSeedsFilled = numberOfTasks;
|
||||
break;
|
||||
case 2:
|
||||
nSeedsFilled = n_event / eventModulo + 1;
|
||||
nSeedsFilled = nworkers;
|
||||
break;
|
||||
default:
|
||||
G4ExceptionDescription msgd;
|
||||
msgd << "Parameter value <" << SeedOncePerCommunication()
|
||||
<< "> of seedOncePerCommunication is invalid. It is reset "
|
||||
"to 0.";
|
||||
"to 1.";
|
||||
G4Exception("G4SubEvtRunManager::InitializeEventLoop()", "Run10036", JustWarning, msgd);
|
||||
SetSeedOncePerCommunication(0);
|
||||
nSeedsFilled = n_event;
|
||||
SetSeedOncePerCommunication(1);
|
||||
nSeedsFilled = nworkers;
|
||||
}
|
||||
|
||||
// Generates up to nSeedsMax seed pairs only.
|
||||
@@ -456,11 +466,37 @@ void G4SubEvtRunManager::RunTermination()
|
||||
// Wait now for all threads to finish event-loop
|
||||
WaitForEndEventLoopWorkers();
|
||||
|
||||
if(currentRun!=nullptr) CleanUpUnnecessaryEvents(0);
|
||||
|
||||
// Now call base-class method
|
||||
G4RunManager::TerminateEventLoop();
|
||||
G4RunManager::RunTermination();
|
||||
|
||||
if(currentRun!=nullptr)
|
||||
{
|
||||
auto eventVector = currentRun->GetEventVector();
|
||||
if(eventVector!=nullptr)
|
||||
{
|
||||
G4int notReady = 1;
|
||||
while(notReady>0)
|
||||
{
|
||||
notReady = 0;
|
||||
for(auto ev:*eventVector)
|
||||
{
|
||||
if(ev->GetNumberOfRemainingSubEvents()>0 || ev->GetNumberOfGrips()>0 )
|
||||
{ notReady++; }
|
||||
}
|
||||
if(notReady>0)
|
||||
{
|
||||
if(verboseLevel>2)
|
||||
{
|
||||
G4cout << "G4SubEvtRunManager::RunTermination - " << notReady
|
||||
<< " events are still incomplete. Waiting for them." << G4endl;
|
||||
}
|
||||
G4THREADSLEEP(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
CleanUpUnnecessaryEvents(0);
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -471,7 +507,7 @@ void G4SubEvtRunManager::ConstructScoringWorlds()
|
||||
// Call base class stuff...
|
||||
G4RunManager::ConstructScoringWorlds();
|
||||
|
||||
masterWorlds.clear();
|
||||
GetMasterWorlds().clear();
|
||||
auto nWorlds = (G4int)G4TransportationManager::GetTransportationManager()->GetNoWorlds();
|
||||
auto itrW = G4TransportationManager::GetTransportationManager()->GetWorldsIterator();
|
||||
for (G4int iWorld = 0; iWorld < nWorlds; ++iWorld) {
|
||||
@@ -621,36 +657,55 @@ void G4SubEvtRunManager::SetUpSeedsForSubEvent(G4long& s1, G4long& s2, G4long& s
|
||||
void G4SubEvtRunManager::SubEventFinished(const G4SubEvent* se,const G4Event* evt)
|
||||
{
|
||||
G4AutoLock l(&accessSubEventMutex);
|
||||
auto masterEvt = se->GetEvent();
|
||||
if(masterEvt==nullptr) {
|
||||
G4Exception("G4SubEvtRunManager::SubEventFinished()","SERM0001",
|
||||
FatalException,"Pointer of master event is null. PANIC!");
|
||||
return; // NOLINT: required to help Coverity recognise FatalException as exit point
|
||||
}
|
||||
|
||||
if(userEventAction) {
|
||||
userEventAction->MergeSubEvent(masterEvt,evt);
|
||||
}
|
||||
if(trajectoriesToBeMerged) MergeTrajectories(se,evt);
|
||||
UpdateScoringForSubEvent(se,evt);
|
||||
evt->ScoresRecorded();
|
||||
eventManager->TerminateSubEvent(se,evt);
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
void G4SubEvtRunManager::MergeTrajectories(const G4SubEvent* se,const G4Event* evt)
|
||||
{
|
||||
auto masterEvt = se->GetEvent();
|
||||
auto* trajVector = evt->GetTrajectoryContainer()->GetVector();
|
||||
auto* masterTrajContainer = masterEvt->GetTrajectoryContainer();
|
||||
if(masterTrajContainer==nullptr)
|
||||
{
|
||||
masterTrajContainer = new G4TrajectoryContainer;
|
||||
masterEvt->SetTrajectoryContainer(masterTrajContainer);
|
||||
}
|
||||
for(auto& traj : *trajVector)
|
||||
{
|
||||
if(traj!=nullptr) {
|
||||
auto* cloned = traj->CloneForMaster();
|
||||
masterTrajContainer->push_back(cloned);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
void G4SubEvtRunManager::UpdateScoringForSubEvent(const G4SubEvent* se,const G4Event* evt)
|
||||
{
|
||||
auto masterEvt = se->GetEvent();
|
||||
if(masterEvt==nullptr) {
|
||||
G4Exception("G4SubEvtRunManager::UpdateScoringForSubEvent()","SERM0001",
|
||||
FatalException,"Pointer of master event is null. PANIC!");
|
||||
}
|
||||
|
||||
if(userEventAction) {
|
||||
userEventAction->MergeSubEvent(masterEvt,evt);
|
||||
}
|
||||
//if (isScoreNtupleWriter) {
|
||||
// G4VScoreNtupleWriter::Instance()->Fill(evt->GetHCofThisEvent(),
|
||||
// se->GetEvent()->GetEventID());
|
||||
//}
|
||||
|
||||
evt->ScoresRecorded();
|
||||
|
||||
G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
if (ScM == nullptr) return;
|
||||
auto nPar = (G4int)ScM->GetNumberOfMesh();
|
||||
if (nPar < 1) return;
|
||||
|
||||
if(verboseLevel>2) {
|
||||
if(verboseLevel>3) {
|
||||
G4cout << "merging scores of sub-event belonging to event id #" << masterEvt->GetEventID()
|
||||
<< " --- sub-event has " << evt->GetHCofThisEvent()->GetCapacity()
|
||||
<< " hits collections" << G4endl;
|
||||
@@ -658,9 +713,24 @@ void G4SubEvtRunManager::UpdateScoringForSubEvent(const G4SubEvent* se,const G4E
|
||||
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
|
||||
if (HCE == nullptr) return;
|
||||
auto nColl = (G4int)HCE->GetCapacity();
|
||||
G4HCofThisEvent* masterHCE = masterEvt->GetHCofThisEvent();
|
||||
if (masterHCE == nullptr || (G4int)masterHCE->GetCapacity() != nColl)
|
||||
{
|
||||
G4Exception("G4SubEvtRunManager::UpdateScoringForSubEvent()","SERM0002",
|
||||
FatalException,"Number of hits colleactions for scrorers mismatch!! PANIC!!");
|
||||
return;
|
||||
}
|
||||
for (G4int i = 0; i < nColl; ++i) {
|
||||
G4VHitsCollection* HC = HCE->GetHC(i);
|
||||
if (HC != nullptr) ScM->Accumulate(HC);
|
||||
auto* HC = dynamic_cast<G4THitsMap<G4double>*>(HCE->GetHC(i));
|
||||
auto* masterHC = dynamic_cast<G4THitsMap<G4double>*>(masterHCE->GetHC(i));
|
||||
if (HC != nullptr && masterHC != nullptr)
|
||||
{ *masterHC += *HC; }
|
||||
else
|
||||
{
|
||||
G4Exception("G4SubEvtRunManager::UpdateScoringForSubEvent()","SERM0003",
|
||||
FatalException,"HitsCollection is not type of G4THitsMap<G4double>. PANIC!!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -781,6 +851,44 @@ void G4SubEvtRunManager::ThisWorkerProcessCommandsStackDone() {}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
void G4SubEvtRunManager::RegisterSubEventType(G4int ty, G4int maxEnt)
|
||||
{
|
||||
G4AutoLock l(®isterSubEvtWorkerMutex);
|
||||
fSubEvtTypeMap[ty] = maxEnt;
|
||||
eventManager->UseSubEventParallelism();
|
||||
eventManager->GetStackManager()->RegisterSubEventType(ty,maxEnt);
|
||||
}
|
||||
|
||||
void G4SubEvtRunManager::RegisterSubEvtWorker(G4WorkerSubEvtRunManager*wrm,G4int typ)
|
||||
{
|
||||
G4AutoLock l(®isterSubEvtWorkerMutex);
|
||||
fWorkerMap[wrm] = typ;
|
||||
}
|
||||
|
||||
G4bool G4SubEvtRunManager::CheckSubEvtTypes()
|
||||
{
|
||||
for(auto& seT : fSubEvtTypeMap)
|
||||
{
|
||||
G4int ty = seT.first;
|
||||
G4int seTyp = -1;
|
||||
for(auto& worker : fWorkerMap)
|
||||
{
|
||||
if(worker.second==ty)
|
||||
{ seTyp = ty; break; }
|
||||
}
|
||||
if(seTyp==-1)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "There is no worker with sub-event type " << ty
|
||||
<< " registered. There must be at least one worker who is responsible.";
|
||||
G4Exception("G4SubEvtRunManager::CheckSubEvtTypes",
|
||||
"SubEvtRM1210",FatalException,ed);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void G4SubEvtRunManager::SetUserInitialization(G4UserWorkerInitialization* userInit)
|
||||
{
|
||||
userWorkerInitialization = userInit;
|
||||
|
||||
@@ -134,9 +134,6 @@ G4TaskRunManager::G4TaskRunManager(G4VUserTaskQueue* task_queue, G4bool useTBB,
|
||||
}
|
||||
useTBB = false;
|
||||
#endif
|
||||
|
||||
// handle TBB
|
||||
G4ThreadPool::set_use_tbb(useTBB);
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -240,7 +237,6 @@ void G4TaskRunManager::InitializeThreadPool()
|
||||
return;
|
||||
}
|
||||
|
||||
PTL::TaskRunManager::SetVerbose(GetVerbose());
|
||||
PTL::TaskRunManager::Initialize(nworkers);
|
||||
|
||||
// create the joiners
|
||||
@@ -320,7 +316,7 @@ void G4TaskRunManager::ComputeNumberOfTasks()
|
||||
numberOfEventsPerTask = nEvtsPerTask;
|
||||
eventModulo = numberOfEventsPerTask;
|
||||
|
||||
if (fakeRun && verboseLevel > 1) {
|
||||
if (fakeRun && verboseLevel > 2) {
|
||||
std::stringstream msg;
|
||||
msg << "--> G4TaskRunManager::ComputeNumberOfTasks() --> " << numberOfTasks << " tasks with "
|
||||
<< numberOfEventsPerTask << " events/task...";
|
||||
@@ -349,8 +345,8 @@ void G4TaskRunManager::CreateAndStartWorkers()
|
||||
if (initializeStarted) {
|
||||
auto initCmdStack = GetCommandStack();
|
||||
if (!initCmdStack.empty()) {
|
||||
threadPool->execute_on_all_threads([initCmdStack]() {
|
||||
for (auto& itr : initCmdStack)
|
||||
threadPool->execute_on_all_threads([cmds = std::move(initCmdStack)]() {
|
||||
for (auto& itr : cmds)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
G4WorkerTaskRunManager::GetWorkerRunManager()->DoWork();
|
||||
});
|
||||
@@ -374,8 +370,8 @@ void G4TaskRunManager::CreateAndStartWorkers()
|
||||
else {
|
||||
auto initCmdStack = GetCommandStack();
|
||||
if (!initCmdStack.empty()) {
|
||||
threadPool->execute_on_all_threads([initCmdStack]() {
|
||||
for (auto& itr : initCmdStack)
|
||||
threadPool->execute_on_all_threads([cmds = std::move(initCmdStack)]() {
|
||||
for (auto& itr : cmds)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
});
|
||||
}
|
||||
@@ -409,8 +405,11 @@ void G4TaskRunManager::CreateAndStartWorkers()
|
||||
|
||||
void G4TaskRunManager::AddEventTask(G4int nt)
|
||||
{
|
||||
if (verboseLevel > 1) G4cout << "Adding task " << nt << " to task-group..." << G4endl;
|
||||
workTaskGroup->exec([]() { G4TaskRunManagerKernel::ExecuteWorkerTask(); });
|
||||
if (verboseLevel > 3) G4cout << "Adding task " << nt << " to task-group..." << G4endl;
|
||||
workTaskGroup->exec([this, nt]() {
|
||||
if (verboseLevel > 3) G4cout << "Starting task " << nt << "..." << G4endl;
|
||||
G4TaskRunManagerKernel::ExecuteWorkerTask();
|
||||
});
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -538,7 +537,7 @@ void G4TaskRunManager::ConstructScoringWorlds()
|
||||
// Call base class stuff...
|
||||
G4RunManager::ConstructScoringWorlds();
|
||||
|
||||
masterWorlds.clear();
|
||||
GetMasterWorlds().clear();
|
||||
auto nWorlds = (G4int)G4TransportationManager::GetTransportationManager()->GetNoWorlds();
|
||||
auto itrW = G4TransportationManager::GetTransportationManager()->GetWorldsIterator();
|
||||
for (G4int iWorld = 0; iWorld < nWorlds; ++iWorld) {
|
||||
|
||||
@@ -183,7 +183,7 @@ void G4TaskRunManagerKernel::InitializeWorker()
|
||||
if (sv != nullptr) G4VSteppingVerbose::SetInstance(sv);
|
||||
}
|
||||
// Now initialize worker part of shared objects (geometry/physics)
|
||||
context()->BuildGeometryAndPhysicsVector();
|
||||
G4WorkerThread::BuildGeometryAndPhysicsVector();
|
||||
workerRM().reset(static_cast<G4WorkerTaskRunManager*>(
|
||||
mrm->GetUserWorkerThreadInitialization()->CreateWorkerRunManager()));
|
||||
auto& wrm = workerRM();
|
||||
@@ -265,9 +265,19 @@ void G4TaskRunManagerKernel::TerminateWorkerRunEventLoop()
|
||||
|
||||
void G4TaskRunManagerKernel::TerminateWorker()
|
||||
{
|
||||
if (workerRM()) TerminateWorker(workerRM().get());
|
||||
//===============================
|
||||
// Step-6: Terminate worker thread
|
||||
//===============================
|
||||
G4TaskRunManager* mrm = G4TaskRunManager::GetMasterRunManager();
|
||||
if ((mrm != nullptr) && (mrm->GetUserWorkerInitialization() != nullptr))
|
||||
mrm->GetUserWorkerInitialization()->WorkerStop();
|
||||
|
||||
workerRM().reset();
|
||||
context().reset();
|
||||
|
||||
G4WorkerThread::DestroyGeometryAndPhysicsVector();
|
||||
|
||||
G4Threading::WorkerThreadLeavesPool();
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -282,25 +292,6 @@ void G4TaskRunManagerKernel::TerminateWorkerRunEventLoop(G4WorkerTaskRunManager*
|
||||
|
||||
//============================================================================//
|
||||
|
||||
void G4TaskRunManagerKernel::TerminateWorker(G4WorkerTaskRunManager* wrm)
|
||||
{
|
||||
if (wrm == nullptr) return;
|
||||
|
||||
//===============================
|
||||
// Step-6: Terminate worker thread
|
||||
//===============================
|
||||
G4TaskRunManager* mrm = G4TaskRunManager::GetMasterRunManager();
|
||||
if ((mrm != nullptr) && (mrm->GetUserWorkerInitialization() != nullptr))
|
||||
mrm->GetUserWorkerInitialization()->WorkerStop();
|
||||
|
||||
G4WorkerThread* _context = wrm->GetWorkerThread();
|
||||
_context->DestroyGeometryAndPhysicsVector();
|
||||
|
||||
G4Threading::WorkerThreadLeavesPool();
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
std::vector<G4String>& G4TaskRunManagerKernel::InitCommandStack()
|
||||
{
|
||||
return initCmdStack;
|
||||
|
||||
@@ -78,19 +78,21 @@ void G4UserTaskThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngine
|
||||
// Need to make these calls thread safe
|
||||
if (dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::HepJamesRandom;
|
||||
if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr) retRNG = new CLHEP::MixMaxRng;
|
||||
if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::MixMaxRng;
|
||||
else if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::RanecuEngine;
|
||||
if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::Ranlux64Engine;
|
||||
if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::RanluxppEngine;
|
||||
if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::MTwistEngine;
|
||||
if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr) retRNG = new CLHEP::DualRand;
|
||||
if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::DualRand;
|
||||
else if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::RanluxEngine;
|
||||
if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr)
|
||||
else if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr)
|
||||
retRNG = new CLHEP::RanshiEngine;
|
||||
|
||||
if (retRNG != nullptr)
|
||||
|
||||
@@ -88,30 +88,30 @@ void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngi
|
||||
if (dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::HepJamesRandom;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::MixMaxRng;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::RanecuEngine;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::RanluxppEngine*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::RanluxppEngine;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) != nullptr) {
|
||||
const auto theRNG = dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
|
||||
retRNG = new CLHEP::Ranlux64Engine(123, theRNG->getLuxury());
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::MTwistEngine;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::DualRand*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::DualRand;
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) != nullptr) {
|
||||
const auto theRNG = dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
|
||||
retRNG = new CLHEP::RanluxEngine(123, theRNG->getLuxury());
|
||||
}
|
||||
if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr) {
|
||||
else if (dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) != nullptr) {
|
||||
retRNG = new CLHEP::RanshiEngine;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ G4WorkerRunManager::~G4WorkerRunManager()
|
||||
userWorkerInitialization = nullptr;
|
||||
userWorkerThreadInitialization = nullptr;
|
||||
userActionInitialization = nullptr;
|
||||
physicsList->TerminateWorker();
|
||||
physicsList = nullptr;
|
||||
if (verboseLevel > 1) G4cout << "Destroying WorkerRunManager (" << this << ")" << G4endl;
|
||||
}
|
||||
@@ -144,10 +145,11 @@ void G4WorkerRunManager::InitializeGeometry()
|
||||
}
|
||||
|
||||
// Step 0: Contribute to the voxelisation of the geometry
|
||||
if( G4GeometryManager::IsParallelOptimisationConfigured() ) {
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
if( geomManager->IsParallelOptimisationConfigured() ) {
|
||||
G4cout << "G4RunManager::InitializeGeometry calling GeometryManager's UndertakeOptimisation"
|
||||
<< G4endl; // TODO - suppress / delete this in final version
|
||||
G4GeometryManager::GetInstance()->UndertakeOptimisation();
|
||||
geomManager->UndertakeOptimisation();
|
||||
}
|
||||
// A barrier must ensure that all that all threads have finished this work.
|
||||
// Currently we rely on the (later) barrier at the end of initialisation.
|
||||
@@ -421,38 +423,15 @@ void G4WorkerRunManager::MergePartialResults(G4bool mergeEvents)
|
||||
G4MTRunManager* mtRM = G4MTRunManager::GetMasterRunManager();
|
||||
G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
if (ScM != nullptr) mtRM->MergeScores(ScM);
|
||||
/************************** MAMAMAMAMA
|
||||
if(mergeEvents) {
|
||||
G4int ctr = 0;
|
||||
G4int ctrD = 0;
|
||||
G4int ctrK = 0;
|
||||
G4int ctrG = 0;
|
||||
#ifdef G4VERBOSE
|
||||
if(mergeEvents && verboseLevel>3) {
|
||||
auto eventVector = currentRun->GetEventVector();
|
||||
if(eventVector!=nullptr || !(eventVector->empty())) {
|
||||
auto eItr = eventVector->cbegin();
|
||||
while(eItr != eventVector->cend())
|
||||
{
|
||||
ctr++;
|
||||
const G4Event* ev = *eItr;
|
||||
if(ev->ToBeKept()) { ctrD++; }
|
||||
if(ev->KeepTheEventFlag()) { ctrK++; }
|
||||
if(ev->GetNumberOfGrips()>0) { ctrG++; }
|
||||
eItr++;
|
||||
}
|
||||
// if(!(ev->ToBeKept()))
|
||||
// {
|
||||
// ReportEventDeletion(ev);
|
||||
// delete ev;
|
||||
// eItr = eventVector->erase(eItr);
|
||||
// ctrD++;
|
||||
// }
|
||||
// else
|
||||
// { eItr++; }
|
||||
// }
|
||||
G4cout<<"G4WorkerRunManager::MergePartialResults : merging "
|
||||
<<eventVector->size()<<" events."<<G4endl;
|
||||
}
|
||||
G4cout<<"MAMAMAMAMA ctr="<<ctr<<" - ctrD="<<ctrD<<" - ctrK="<<ctrK<<" - ctrG="<<ctrG<<G4endl;
|
||||
}
|
||||
********************************/
|
||||
#endif
|
||||
if(mergeEvents) mtRM->MergeRun(currentRun);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,10 @@ G4WorkerSubEvtRunManagerKernel* G4WorkerSubEvtRunManager::GetWorkerRunManagerKer
|
||||
//============================================================================//
|
||||
|
||||
G4WorkerSubEvtRunManager::G4WorkerSubEvtRunManager(G4int seType)
|
||||
: fSubEventType(seType)
|
||||
{ runManagerType = subEventWorkerRM; }
|
||||
{
|
||||
runManagerType = subEventWorkerRM;
|
||||
SetSubEventType(seType);
|
||||
}
|
||||
|
||||
void G4WorkerSubEvtRunManager::RunInitialization()
|
||||
{
|
||||
@@ -160,6 +162,7 @@ void G4WorkerSubEvtRunManager::RunInitialization()
|
||||
|
||||
runAborted = false;
|
||||
numberOfEventProcessed = 0;
|
||||
if(verboseLevel > 0) timer->Start();
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
@@ -368,10 +371,10 @@ void G4WorkerSubEvtRunManager::TerminateEventLoop()
|
||||
G4cout << prefix << "Thread-local run terminated." << G4endl;
|
||||
G4cout << prefix << "Run Summary" << G4endl;
|
||||
if (runAborted)
|
||||
G4cout << prefix << " Run Aborted after " << numberOfEventProcessed << " events processed."
|
||||
G4cout << prefix << " Run Aborted after " << numberOfEventProcessed << " sub-events processed."
|
||||
<< G4endl;
|
||||
else
|
||||
G4cout << prefix << " Number of events processed : " << numberOfEventProcessed << G4endl;
|
||||
G4cout << prefix << " Number of sub-events processed : " << numberOfEventProcessed << G4endl;
|
||||
G4cout << prefix << " " << *timer << G4endl;
|
||||
}
|
||||
}
|
||||
@@ -421,7 +424,7 @@ void G4WorkerSubEvtRunManager::ProcessUI()
|
||||
if (!matching) {
|
||||
for (const auto& itr : command_stack)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
processedCommandStack = command_stack;
|
||||
processedCommandStack = std::move(command_stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,6 +506,7 @@ void G4WorkerSubEvtRunManager::DoWork()
|
||||
auto masterEvent = subEv->GetEvent();
|
||||
G4Event* ev = new G4Event(masterEvent->GetEventID());
|
||||
ev->FlagAsSubEvent(masterEvent,fSubEventType);
|
||||
++numberOfEventProcessed;
|
||||
|
||||
// Create a G4TrackVector as the input
|
||||
G4TrackVector* tv = new G4TrackVector();
|
||||
@@ -512,8 +516,6 @@ void G4WorkerSubEvtRunManager::DoWork()
|
||||
// and thus they must not be deleted by the worker thread. They must be cloned.
|
||||
G4Track* tr = new G4Track();
|
||||
tr->CopyTrackInfo(*(stackedTrack.GetTrack()),false);
|
||||
|
||||
//MAMAMAMAMA cloning of trajectory object is not yet implemented.
|
||||
tv->push_back(tr);
|
||||
}
|
||||
|
||||
@@ -540,6 +542,13 @@ void G4WorkerSubEvtRunManager::DoWork()
|
||||
|
||||
}
|
||||
|
||||
void G4WorkerSubEvtRunManager::SetSubEventType(G4int ty)
|
||||
{
|
||||
auto* mrm = G4SubEvtRunManager::GetMasterRunManager();
|
||||
mrm->RegisterSubEvtWorker(this,ty);
|
||||
fSubEventType = ty;
|
||||
}
|
||||
|
||||
//============================================================================//
|
||||
|
||||
void G4WorkerSubEvtRunManager::SetUserInitialization(G4UserWorkerInitialization*)
|
||||
|
||||
@@ -409,7 +409,7 @@ void G4WorkerTaskRunManager::ProcessUI()
|
||||
if (!matching) {
|
||||
for (const auto& itr : command_stack)
|
||||
G4UImanager::GetUIpointer()->ApplyCommand(itr);
|
||||
processedCommandStack = command_stack;
|
||||
processedCommandStack = std::move(command_stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ void G4WorkerTaskRunManager::DoWork()
|
||||
}
|
||||
|
||||
// Start this run
|
||||
G4int nevts = mrm->GetNumberOfEventsToBeProcessed();
|
||||
G4int nevts = mrm->GetNumberOfEventsPerTask();
|
||||
G4int numSelect = mrm->GetNumberOfSelectEvents();
|
||||
G4String macroFile = mrm->GetSelectMacro();
|
||||
G4bool empty_macro = (macroFile.empty() || macroFile == " ");
|
||||
|
||||
Reference in New Issue
Block a user