4#include "G4VSensitiveDetector.hh"
7#include <gemc/goptions/goptions.h>
8#include <gemc/gdynamicDigitization/gdynamicdigitization.h>
9#include <gemc/gbase/gbase.h>
112 const std::shared_ptr<GOptions>&
goptions);
122 void Initialize(G4HCofThisEvent* g4hc)
override;
136 G4bool
ProcessHits(G4Step* thisStep, G4TouchableHistory* g4th)
override;
146 void EndOfEvent(G4HCofThisEvent* g4HitCollection)
override;
155 void assign_digi_routine(std::shared_ptr<GDynamicDigitization> digi_routine) { digitization_routine = digi_routine; }
175 std::shared_ptr<GDynamicDigitization> digitization_routine;
183 std::map<std::string, std::shared_ptr<GTouchable>> gTouchableMap;
194 inline std::shared_ptr<GTouchable> getGTouchable(
const G4Step* thisStep) {
195 std::string vname = thisStep->GetPreStepPoint()->GetTouchable()->GetVolume()->GetName();
197 auto it = gTouchableMap.find(vname);
200 if (it != gTouchableMap.end()) {
return std::make_shared<GTouchable>(*it->second); }
211 std::vector<GTouchable> touchableVector;
222 bool isThisANewTouchable(
const std::shared_ptr<GTouchable>& thisTouchable);
240 GHit* getHitInHitCollectionUsingTouchable(
const std::shared_ptr<GTouchable>&
gtouchable);
253 log->
info(2,
"Registering touchable gvolume <" + name +
"> with value: " + gt->getIdentityString());
256 gTouchableMap[name] = gt;
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
Thread-local sensitive detector bridging Geant4 steps to GEMC hits via digitization plugins.
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.
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.