4#include "G4VSensitiveDetector.hh"
113 const std::shared_ptr<GOptions>&
goptions);
126 void Initialize(G4HCofThisEvent* g4hc)
override;
140 G4bool
ProcessHits(G4Step* thisStep, G4TouchableHistory* g4th)
override;
150 void EndOfEvent(G4HCofThisEvent* g4HitCollection)
override;
159 void assign_digi_routine(std::shared_ptr<GDynamicDigitization> digi_routine) { digitization_routine = digi_routine; }
170 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);
201 if (it != gTouchableMap.end()) {
return it->second; }
212 std::vector<GTouchable> touchableVector;
223 bool isThisANewTouchable(
const std::shared_ptr<GTouchable>& thisTouchable);
241 GHit* getHitInHitCollectionUsingTouchable(
const std::shared_ptr<GTouchable>&
gtouchable);
254 log->
info(2,
"Registering touchable gvolume <" + name +
"> with value: " + gt->getIdentityString());
257 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 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.
std::bitset< NHITBITS > HitBitSet
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.