4#include "G4VUserDetectorConstruction.hh"
5#include "G4UserLimits.hh"
8#include <gemc/goptions/goptions.h>
9#include <gemc/g4system/g4world.h>
10#include <gemc/gfields/gmagneto.h>
11#include <gemc/gsd/gsd.h>
12#include <gemc/gbase/gbase.h>
109 [[nodiscard]]
bool is_empty()
const {
return g4world->is_empty(); }
147 return digitization_routines_map->at(sd_name);
159 return digitization_routines_map;
169 return g4world !=
nullptr;
180 if (g4world ==
nullptr) {
183 return g4world->get_g4volumes_map();
196 std::unordered_map<std::string, const GVolume*> result;
197 if (!gworld)
return result;
198 for (
const auto& [sysName, sysPtr] : *gworld->getSystemsMap()) {
199 for (
const auto& [volName, volPtr] : sysPtr->getGVolumesMap()) {
200 const std::string g4name = volPtr->getG4Name();
202 result[g4name] = volPtr.get();
217 std::unordered_map<std::string, const GMirror*> result;
218 if (!gworld)
return result;
219 for (
const auto& [sysName, sysPtr] : *gworld->getSystemsMap()) {
220 for (
const auto& [mirrorName, mirrorPtr] : sysPtr->getGMirrorsMap()) {
221 result[sysName +
"/" + mirrorName] = mirrorPtr.get();
233 std::shared_ptr<GOptions> gopt;
240 std::shared_ptr<GWorld> gworld;
247 std::shared_ptr<G4World> g4world;
255 std::shared_ptr<gdynamicdigitization::dRoutinesMap> digitization_routines_map;
263 static G4ThreadLocal
GMagneto* gmagneto;
276 static G4ThreadLocal std::map<std::string, GSensitiveDetector*>* tlSDMap;
285 void loadDigitizationPlugins();
293 void assignUserLimits();
301 std::vector<std::unique_ptr<G4UserLimits>> user_limits;
310 bool digiplugins_need_reload =
true;
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
GDetectorConstruction(std::shared_ptr< GOptions > gopts)
Constructs a detector builder configured by the provided options.
void reload_geometry(SystemList sl)
Reloads the geometry using a new list of GSystem objects.
std::unordered_map< std::string, const GVolume * > get_gvolumes_flat_map() const
Returns a flat map of GEMC volume descriptors indexed by their G4 names.
std::unordered_map< std::string, G4Volume * > get_g4volumes_map() const
Returns a map of built Geant4 volumes indexed by their GEMC/G4World names.
G4VPhysicalVolume * Construct() override
Geant4 geometry construction hook.
std::shared_ptr< GDynamicDigitization > get_digitization_routines_for_sdname(const std::string &sd_name) const
Returns the digitization routine for a given sensitive detector name.
void ConstructSDandField() override
Geant4 SD/field construction hook.
std::unordered_map< std::string, const GMirror * > get_gmirrors_flat_map() const
Returns a flat map of GEMC mirror descriptors indexed by their qualified names.
std::shared_ptr< gdynamicdigitization::dRoutinesMap > get_digitization_routines_map() const
Returns the full map of digitization routines.
void prepare_geometry_for_run()
Reinitializes geometry through Geant4 before running events.
bool has_built_geometry() const
Return whether a Geant4 world has been built.
bool is_empty() const
Returns whether the currently built geometry is empty.
std::vector< SystemPtr > SystemList
constexpr int ERR_G4VOLUMEBUILDFAILED