diff --git a/include/RMGHardware.hh b/include/RMGHardware.hh index b1852f4b..01ddc406 100644 --- a/include/RMGHardware.hh +++ b/include/RMGHardware.hh @@ -75,6 +75,7 @@ class RMGHardware : public G4VUserDetectorConstruction { /// List of GDML files to load std::vector fGDMLFiles; + bool fGDMLDisableOverlapCheck = false; /// Mapping between physical volume names and maximum (user) step size to apply std::map fPhysVolStepLimits; diff --git a/include/RMGRunAction.hh b/include/RMGRunAction.hh index 622e6757..53a39463 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 { 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/RMGHardware.cc b/src/RMGHardware.cc index b86418ac..82e7ed29 100644 --- a/src/RMGHardware.cc +++ b/src/RMGHardware.cc @@ -43,7 +43,7 @@ G4VPhysicalVolume* RMGHardware::Construct() { if (!fGDMLFiles.empty()) { RMGLog::Out(RMGLog::debug, "Setting up G4GDMLParser"); G4GDMLParser parser; - parser.SetOverlapCheck(true); + parser.SetOverlapCheck(!fGDMLDisableOverlapCheck); for (const auto& file : fGDMLFiles) { RMGLog::Out(RMGLog::detail, "Reading ", file, " GDML file"); if (!fs::exists(fs::path(file.data()))) RMGLog::Out(RMGLog::fatal, file, " does not exist"); @@ -58,8 +58,6 @@ G4VPhysicalVolume* RMGHardware::Construct() { "Did you forget to reimplement the base class method, or to specify a GDML file?"); } - // TODO: build and return world volume? - // attach user max step sizes to logical volumes for (const auto& el : fPhysVolStepLimits) { RMGLog::OutFormat(RMGLog::debug, "Setting max user step size for volume '{}' to {}", el.first, @@ -190,6 +188,11 @@ void RMGHardware::DefineCommands() { fMessenger = std::make_unique(this, "/RMG/Geometry/", "Commands for controlling geometry definitions"); + fMessenger->DeclareProperty("GDMLDisableOverlapCheck", fGDMLDisableOverlapCheck) + .SetGuidance("Disable the automatic overlap check after loading a GDML file") + .SetStates(G4State_PreInit) + .SetToBeBroadcasted(false); + fMessenger->DeclareMethod("IncludeGDMLFile", &RMGHardware::IncludeGDMLFile) .SetGuidance("Use GDML file for geometry definition") .SetParameterName("filename", false) 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 diff --git a/tests/basics/macros/print-volumes.mac b/tests/basics/macros/print-volumes.mac index d9e9396b..2f80ae7a 100644 --- a/tests/basics/macros/print-volumes.mac +++ b/tests/basics/macros/print-volumes.mac @@ -1,3 +1,6 @@ +# note: this file cannot be overlap-checked on G4 with USolids. +/RMG/Geometry/GDMLDisableOverlapCheck true + /run/initialize /RMG/Geometry/PrintListOfLogicalVolumes diff --git a/tests/basics/macros/run-2nbb.mac b/tests/basics/macros/run-2nbb.mac index 66fac7cd..f6cf1faa 100644 --- a/tests/basics/macros/run-2nbb.mac +++ b/tests/basics/macros/run-2nbb.mac @@ -1,3 +1,6 @@ +# note: this file cannot be overlap-checked on G4 with USolids. +/RMG/Geometry/GDMLDisableOverlapCheck true + /run/initialize /RMG/Generator/Confine Volume