gdetector
Loading...
Searching...
No Matches
gdetectorConstruction.h
Go to the documentation of this file.
1#pragma once
2
3// geant4
4#include "G4VUserDetectorConstruction.hh"
5
6// gemc
7#include "goptions.h"
8#include "g4world.h"
9#include "gmagneto.h"
10#include "gsd.h"
11#include "gbase.h"
12
13// c++
14#include <vector>
15
59class GDetectorConstruction : public GBase<GDetectorConstruction>, public G4VUserDetectorConstruction {
60public:
70 explicit GDetectorConstruction(std::shared_ptr<GOptions> gopts);
71
72public:
84 G4VPhysicalVolume* Construct() override;
85
96 void ConstructSDandField() override;
97
106 [[nodiscard]] bool is_empty() const { return g4world->is_empty(); }
107
119
132 std::shared_ptr<GDynamicDigitization> get_digitization_routines_for_sdname(const std::string &sd_name) const {
133 return digitization_routines_map->at(sd_name);
134 }
135
144 std::shared_ptr<gdynamicdigitization::dRoutinesMap> get_digitization_routines_map() const {
145 return digitization_routines_map;
146 }
147
155 [[nodiscard]] std::unordered_map<std::string, G4Volume*> get_g4volumes_map() const {
156 if (g4world == nullptr) {
157 log->error(ERR_G4VOLUMEBUILDFAILED, "No g4world ");
158 }
159 return g4world->get_g4volumes_map();
160 }
161
162private:
168 std::shared_ptr<GOptions> gopt; // need options inside Constructs() methods
169
175 std::shared_ptr<GWorld> gworld;
176
182 std::shared_ptr<G4World> g4world;
183
190 std::shared_ptr<gdynamicdigitization::dRoutinesMap> digitization_routines_map;
191
198 static G4ThreadLocal GMagneto* gmagneto;
199
207 void loadDigitizationPlugins();
208
215 SystemList gsystems;
216};
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, 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.
bool is_empty() const
Returns whether the currently built geometry is empty.
void error(int exit_code, Args &&... args) const
#define ERR_G4VOLUMEBUILDFAILED
std::vector< SystemPtr > SystemList