16#ifndef _RMG_HARDWARE_HH_
17#define _RMG_HARDWARE_HH_
23#include <unordered_map>
26#include "G4GenericMessenger.hh"
28#include "G4VUserDetectorConstruction.hh"
30#include "RMGDetectorMetadata.hh"
31#include "RMGHardwareMessenger.hh"
33#include "RMGNavigationTools.hh"
34#include "RMGVOutputScheme.hh"
95 const std::string& pv_name,
98 bool allow_uid_reuse =
false,
99 const std::string& ntuple_name =
""
118 RMGDetectorType type,
119 const std::string& pv_name,
121 const std::string& copy_nr =
"0",
122 bool allow_uid_reuse =
false,
123 const std::string& ntuple_name =
""
134 return fDetectorMetadata.at(det);
138 const auto& GetActiveDetectorList() {
return fActiveDetectors; }
139 [[nodiscard]]
const auto& GetAllActiveOutputSchemes() {
return fActiveOutputSchemes; }
177 const std::string& particle_name
180 void PrintListOfLogicalVolumes() { RMGNavigationTools::PrintListOfLogicalVolumes(); }
181 void PrintListOfPhysicalVolumes() { RMGNavigationTools::PrintListOfPhysicalVolumes(); }
191 std::vector<std::string> fGDMLFiles;
192 bool fGDMLDisableOverlapCheck =
false;
193 int fGDMLOverlapCheckNumPoints = 3000;
194 bool fGDMLDisableXmlCheck =
false;
196 std::map<std::string, double> fPhysVolStepLimits;
198 struct RMGSelectiveEminLimit {
200 std::set<std::string> particles;
202 std::map<std::string, RMGSelectiveEminLimit> fPhysVolEminLimits;
203 static std::unordered_map<const G4LogicalVolume*, std::set<std::string>> fLogicalVolEminParticles;
206 std::map<std::pair<std::string, int>, RMGDetectorMetadata> fDetectorMetadata;
208 std::set<RMGDetectorType> fActiveDetectors;
209 static G4ThreadLocal std::vector<std::shared_ptr<RMGVOutputScheme>> fActiveOutputSchemes;
210 static G4ThreadLocal
bool fActiveDetectorsInitialized;
212 std::set<RMGDetectorType> fRegisterDetectorsFromGDML;
213 void RegisterDetectorsFromGDML(std::string s);
215 std::unique_ptr<G4GenericMessenger> fMessenger;
216 std::unique_ptr<RMGHardwareMessenger> fHwMessenger;
217 void DefineCommands();
220 G4VPhysicalVolume* fWorld =
nullptr;
225 G4Region* fSensitiveRegion =
new G4Region(
"SensitiveRegion");
227 struct RMGStagedDetector {
228 RMGDetectorType type;
232 bool allow_uid_reuse;
233 std::string ntuple_name;
237 std::map<std::pair<std::string, std::string>, RMGStagedDetector> fStagedDetectors;
virtual G4VPhysicalVolume * DefineGeometry()
Method to define geometry directly, the user must reimplement the base class method.
Definition RMGHardware.hh:186
void SetMaxStepLimit(double max_step, std::string name)
Set the maximum step size.
Definition RMGHardware.cc:543
static bool IsEminLimitParticleSelected(const G4LogicalVolume *logical, const std::string &particle_name)
Check if selective EkinMin should be applied for the current track context.
Definition RMGHardware.cc:582
void StageDetector(RMGDetectorType type, const std::string &pv_name, int uid, const std::string ©_nr="0", bool allow_uid_reuse=false, const std::string &ntuple_name="")
Stage a detector for later registration.
Definition RMGHardware.cc:444
const auto & GetDetectorMetadataMap()
Extract a map of the detector metadata, one element for each sensitive detector physical volume and c...
Definition RMGHardware.hh:127
RMGHardware()
Constructor based on calling the macro commands (with DefineCommands ).
Definition RMGHardware.cc:60
void RegisterDetector(RMGDetectorType type, const std::string &pv_name, int uid, int copy_nr=0, bool allow_uid_reuse=false, const std::string &ntuple_name="")
Register a physical volume as sensitive detector.
Definition RMGHardware.cc:481
G4VPhysicalVolume * Construct() override
Construct the detector.
Definition RMGHardware.cc:62
G4VPhysicalVolume * GetDefinedWorldVolume()
Get the instance of the world volume, after Construct had been called once.
Definition RMGHardware.hh:151
void IncludeGDMLFile(std::string filename)
Add a GDML file to the geometry.
Definition RMGHardware.hh:145
const auto & GetDetectorMetadata(const std::pair< std::string, int > &det)
Extract the detector metadata for a given detector.
Definition RMGHardware.hh:133
const G4VPhysicalVolume * GetDefinedWorldVolume() const
Get the instance of the world volume, after Construct had been called once.
Definition RMGHardware.hh:148
void ConstructSDandField() override
Setup thread-local geometry data.
Definition RMGHardware.cc:316
void SetEminLimitForParticle(double ekin_min, std::string name, std::string particle_name)
Set a minimum kinetic energy cut for one selected particle in a volume.
Definition RMGHardware.cc:550