diff --git a/include/RMGRunAction.hh b/include/RMGRunAction.hh index 622e6757..9f9fa567 100644 --- a/include/RMGRunAction.hh +++ b/include/RMGRunAction.hh @@ -48,6 +48,8 @@ class RMGRunAction : public G4UserRunAction { void BeginOfRunAction(const G4Run*) override; void EndOfRunAction(const G4Run*) override; + inline int GetCurrentRunPrintModulo() const const const { return fCurrentPrintModulo; } + inline auto& GetOutputDataFields(RMGHardware::DetectorType d_type) { return fOutputDataFields.at(d_type); } @@ -62,6 +64,8 @@ class RMGRunAction : public G4UserRunAction { bool fIsAnaManInitialized = false; RMGMasterGenerator* fRMGMasterGenerator = nullptr; + int fCurrentPrintModulo = -1; + std::map> fOutputDataFields; }; diff --git a/src/RMGEventAction.cc b/src/RMGEventAction.cc index 0fa76f9a..c4828b01 100644 --- a/src/RMGEventAction.cc +++ b/src/RMGEventAction.cc @@ -36,7 +36,7 @@ RMGEventAction::RMGEventAction(RMGRunAction* run_action) : fRunAction(run_action void RMGEventAction::BeginOfEventAction(const G4Event* event) { - auto print_modulo = RMGManager::Instance()->GetPrintModulo(); + auto print_modulo = fRunAction->GetCurrentRunPrintModulo(); if ((event->GetEventID() + 1) % print_modulo == 0) { auto current_run = dynamic_cast(G4RunManager::GetRunManager()->GetCurrentRun()); diff --git a/src/RMGRunAction.cc b/src/RMGRunAction.cc index 938760f7..b6eeccda 100644 --- a/src/RMGRunAction.cc +++ b/src/RMGRunAction.cc @@ -138,9 +138,10 @@ void RMGRunAction::BeginOfRunAction(const G4Run*) { auto g4manager = G4RunManager::GetRunManager(); auto tot_events = g4manager->GetNumberOfEventsToBeProcessed(); - if (manager->GetPrintModulo() <= 0 and tot_events >= 100) - manager->SetPrintModulo(tot_events / 10); - else if (tot_events < 100) manager->SetPrintModulo(100); + + fCurrentPrintModulo = manager->GetPrintModulo(); + if (fCurrentPrintModulo <= 0 and tot_events >= 100) fCurrentPrintModulo = tot_events / 10; + else if (tot_events < 100) fCurrentPrintModulo = 100; } void RMGRunAction::EndOfRunAction(const G4Run*) { @@ -203,10 +204,6 @@ void RMGRunAction::EndOfRunAction(const G4Run*) { G4AnalysisManager::Instance()->Write(); G4AnalysisManager::Instance()->CloseFile(); } - - // reset print modulo - // TODO: if it's user specified, it shouldn't be reset - RMGManager::Instance()->SetPrintModulo(-1); } // vim: tabstop=2 shiftwidth=2 expandtab