4#include "G4VUserDetectorConstruction.hh"
7#include <gemc/goptions/goptions.h>
8#include <gemc/g4system/g4world.h>
9#include <gemc/gfields/gmagneto.h>
10#include <gemc/gsd/gsd.h>
11#include <gemc/gbase/gbase.h>
146 return digitization_routines_map->at(sd_name);
158 return digitization_routines_map;
168 return g4world !=
nullptr;
179 if (g4world ==
nullptr) {
195 std::unordered_map<std::string, const GVolume*> result;
196 if (!gworld)
return result;
197 for (
const auto& [sysName, sysPtr] : *gworld->
getSystemsMap()) {
198 for (
const auto& [volName, volPtr] : sysPtr->getGVolumesMap()) {
199 const std::string g4name = volPtr->getG4Name();
201 result[g4name] = volPtr.get();
213 std::shared_ptr<GOptions> gopt;
220 std::shared_ptr<GWorld> gworld;
227 std::shared_ptr<G4World> g4world;
235 std::shared_ptr<gdynamicdigitization::dRoutinesMap> digitization_routines_map;
243 static G4ThreadLocal
GMagneto* gmagneto;
256 static G4ThreadLocal std::map<std::string, GSensitiveDetector*>* tlSDMap;
265 void loadDigitizationPlugins();
275 bool digiplugins_need_reload =
true;
std::unordered_map< std::string, G4Volume * > get_g4volumes_map() const
bool is_empty() const noexcept
std::shared_ptr< GLogger > log
Builds and (optionally) reloads the Geant4 geometry from GEMC world definitions.
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::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.
void error(int exit_code, Args &&... args) const
SystemMap * getSystemsMap() const
#define ERR_G4VOLUMEBUILDFAILED
std::vector< SystemPtr > SystemList