4#include "G4VSensitiveDetector.hh"
7#include <gemc/goptions/goptions.h>
8#include <gemc/gdynamicDigitization/gdynamicdigitization.h>
9#include <gemc/gbase/gbase.h>
12#include <unordered_map>
115 const std::shared_ptr<GOptions>&
goptions);
125 void Initialize(G4HCofThisEvent* g4hc)
override;
139 G4bool
ProcessHits(G4Step* thisStep, G4TouchableHistory* g4th)
override;
149 void EndOfEvent(G4HCofThisEvent* g4HitCollection)
override;
158 void assign_digi_routine(std::shared_ptr<GDynamicDigitization> digi_routine) { digitization_routine = digi_routine; }
178 std::shared_ptr<GDynamicDigitization> digitization_routine;
186 std::map<std::string, std::shared_ptr<GTouchable>> gTouchableMap;
197 inline std::shared_ptr<GTouchable> getGTouchable(
const G4Step* thisStep) {
198 std::string vname = thisStep->GetPreStepPoint()->GetTouchable()->GetVolume()->GetName();
200 auto it = gTouchableMap.find(vname);
203 if (it != gTouchableMap.end()) {
return std::make_shared<GTouchable>(*it->second); }
215 std::unordered_map<std::string, GHit*> hitsByCellKey;
236 log->info(2,
"Registering touchable gvolume <" + name +
"> with value: " + gt->getIdentityString());
239 gTouchableMap[name] = gt;
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
GSensitiveDetector(const std::string &sdName, const std::shared_ptr< GOptions > &goptions)
Constructs a sensitive detector instance for a given detector name.
void EndOfEvent(G4HCofThisEvent *g4HitCollection) override
End-of-event hook called by Geant4.
void resetTouchableMap()
Clears the volume-to-touchable map so a reused SD reflects the current geometry.
void Initialize(G4HCofThisEvent *g4hc) override
Per-event initialization hook called by Geant4.
void assign_digi_routine(std::shared_ptr< GDynamicDigitization > digi_routine)
Assigns the digitization routine used to interpret steps and define hit content.
G4bool ProcessHits(G4Step *thisStep, G4TouchableHistory *g4th) override
Processes a Geant4 step and creates or updates hits in the current hits collection.
void registerGVolumeTouchable(const std::string &name, std::shared_ptr< GTouchable > gt)
Registers a GTouchable for a given gvolume name into the internal lookup map.
G4THitsCollection< GHit > GHitsCollection
GOptions defineOptions()
Defines the module options for GSensitiveDetector.
G4THitsCollection< GHit > GHitsCollection
Convenience alias for the Geant4 hits collection used by this module.
constexpr int ERR_NOCOLLECTION
Error code used when the Geant4 hits collection is unexpectedly missing.
constexpr int ERR_DYNAMICPLUGINNOTFOUND
Error code used when a required dynamic plugin-dependent resource is missing.
constexpr int ERR_HITNOTFOUNDINCOLLECTION
Error code used when a hit is expected to exist but cannot be found in the current hit collection.
constexpr const char * GSENSITIVE_LOGGER
Logger name used by this module.