gsd
Loading...
Searching...
No Matches
GSensitiveDetector Class Reference

Thread-local sensitive detector bridging Geant4 steps to GEMC hits via digitization plugins. More...

#include <gsd.h>

Public Member Functions

 GSensitiveDetector (const std::string &sdName, const std::shared_ptr< GOptions > &goptions)
 Constructs a sensitive detector instance for a given detector name.
 
void Initialize (G4HCofThisEvent *g4hc) override
 Per-event initialization hook called by Geant4.
 
G4bool ProcessHits (G4Step *thisStep, G4TouchableHistory *g4th) override
 Processes a Geant4 step and creates or updates hits in the current hits collection.
 
void EndOfEvent (G4HCofThisEvent *g4HitCollection) override
 End-of-event 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.
 
void registerGVolumeTouchable (const std::string &name, std::shared_ptr< GTouchable > gt)
 Registers a GTouchable for a given gvolume name into the internal lookup map.
 
- Public Member Functions inherited from GBase< GSensitiveDetector >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GSensitiveDetector >
std::shared_ptr< GLoggerlog
 

Detailed Description

GSensitiveDetector implements the G4VSensitiveDetector interface and participates in the Geant4 event loop through:

Responsibilities

  • Own a per-event Geant4 hits collection (GHitsCollection) and register it into G4HCofThisEvent.
  • Use the assigned GDynamicDigitization routine to:
    • decide whether a step should be ignored,
    • map the Geant4 step to one or more logical touchables,
    • read the HitBitSet describing which information is stored in hits.
  • Track whether a touchable has already produced a hit in the current event and either create a new GHit or update an existing one.

Threading and lifetime

  • Instances are intended to be thread-local.
  • The digitization routine must be assigned with assign_digi_routine() before processing begins.
  • Touchables are registered once at construction/setup time and then treated as read-only during event processing.

Definition at line 100 of file gsd.h.

Constructor & Destructor Documentation

◆ GSensitiveDetector()

GSensitiveDetector::GSensitiveDetector ( const std::string & sdName,
const std::shared_ptr< GOptions > & goptions )

The constructor initializes the logging base and forwards the sensitive detector name to G4VSensitiveDetector. It also initializes the Geant4 collection name vector with a module-specific collection name based on sdName.

Parameters
sdNameName of the sensitive detector instance (used by Geant4 and for collection naming).
goptionsShared options object used to configure logging and module behavior.

Definition at line 9 of file gsd.cc.

Member Function Documentation

◆ assign_digi_routine()

void GSensitiveDetector::assign_digi_routine ( std::shared_ptr< GDynamicDigitization > digi_routine)
inline

The assigned routine is expected to remain valid for the lifetime of this sensitive detector instance.

Parameters
digi_routineDigitization routine responsible for readout specs and step processing.

Definition at line 159 of file gsd.h.

◆ EndOfEvent()

void GSensitiveDetector::EndOfEvent ( G4HCofThisEvent * g4HitCollection)
override

This method is invoked after all steps have been processed for the event. The Geant4 event system will own the hits collection registered during Initialize().

Parameters
g4HitCollectionGeant4 event hit container (not used by this implementation).

Definition at line 133 of file gsd.cc.

◆ Initialize()

void GSensitiveDetector::Initialize ( G4HCofThisEvent * g4hc)
override

This method:

  • retrieves the HitBitSet from the digitization routine readout specifications,
  • clears the per-event touchable cache,
  • allocates a new Geant4 hits collection (GHitsCollection),
  • registers it into the event hit container (G4HCofThisEvent).
Parameters
g4hcGeant4 event hit container that will own/track the hits collection for this event.

Definition at line 26 of file gsd.cc.

◆ ProcessHits()

G4bool GSensitiveDetector::ProcessHits ( G4Step * thisStep,
G4TouchableHistory * g4th )
override

The digitization routine can choose to skip hits based on deposited energy and can transform the input touchable into one or more logical touchables. For each resulting touchable, this method either:

  • creates a new GHit and inserts it in the hits collection, or
  • locates an existing GHit and appends step information according to the HitBitSet.
Parameters
thisStepGeant4 step being processed.
g4thGeant4 touchable history (not used by this implementation).
Returns
true to indicate the step was handled (even if skipped by policy).

Definition at line 50 of file gsd.cc.

◆ registerGVolumeTouchable()

void GSensitiveDetector::registerGVolumeTouchable ( const std::string & name,
std::shared_ptr< GTouchable > gt )
inline

This function is typically used during detector construction (e.g., from GDetectorConstruction) to populate the mapping between volume names and their corresponding touchables.

Parameters
nameVolume name (key) used later to locate the touchable during ProcessHits().
gtTouchable instance associated with name.

Definition at line 253 of file gsd.h.


The documentation for this class was generated from the following files: