Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable overlap check #82

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/RMGHardware.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RMGHardware : public G4VUserDetectorConstruction {

/// List of GDML files to load
std::vector<std::string> fGDMLFiles;
bool fGDMLDisableOverlapCheck = false;
/// Mapping between physical volume names and maximum (user) step size to apply
std::map<std::string, double> fPhysVolStepLimits;

Expand Down
4 changes: 4 additions & 0 deletions include/RMGRunAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -62,6 +64,8 @@ class RMGRunAction : public G4UserRunAction {
bool fIsAnaManInitialized = false;
RMGMasterGenerator* fRMGMasterGenerator = nullptr;

int fCurrentPrintModulo = -1;

std::map<RMGHardware::DetectorType, std::unique_ptr<RMGVOutputScheme>> fOutputDataFields;
};

Expand Down
2 changes: 1 addition & 1 deletion src/RMGEventAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<const RMGRun*>(G4RunManager::GetRunManager()->GetCurrentRun());
Expand Down
9 changes: 6 additions & 3 deletions src/RMGHardware.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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,
Expand Down Expand Up @@ -190,6 +188,11 @@ void RMGHardware::DefineCommands() {
fMessenger = std::make_unique<G4GenericMessenger>(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)
Expand Down
11 changes: 4 additions & 7 deletions src/RMGRunAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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*) {
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions tests/basics/macros/print-volumes.mac
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# note: this file cannot be overlap-checked on G4 with USolids.
/RMG/Geometry/GDMLDisableOverlapCheck true

/run/initialize

/RMG/Geometry/PrintListOfLogicalVolumes
Expand Down
3 changes: 3 additions & 0 deletions tests/basics/macros/run-2nbb.mac
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading