gdynamicDigitization
Loading...
Searching...
No Matches

Abstract base class for dynamically loaded digitization plugins. More...

#include <gdynamicdigitization.h>

Public Member Functions

 GDynamicDigitization (const std::shared_ptr< GOptions > &g)
 Constructs the digitization base object.
 ~GDynamicDigitization () override=default
 Virtual destructor.
virtual CollectionMode collection_mode () const
double processStepTime (const std::shared_ptr< GTouchable > &gTouchID, G4Step *thisStep)
 Computes the time associated with a simulation step for electronics binning.
virtual double processStepTimeImpl (const std::shared_ptr< GTouchable > &gTouchID, G4Step *thisStep)
 Implementation hook for step time computation.
std::vector< std::string > variables_to_normalize ()
virtual std::vector< std::string > variables_to_normalizeImpl ()
std::vector< std::shared_ptr< GTouchable > > processTouchable (std::shared_ptr< GTouchable > gtouchable, G4Step *thisStep)
 Processes a touchable based on the current step and readout specs.
virtual std::vector< std::shared_ptr< GTouchable > > processTouchableImpl (std::shared_ptr< GTouchable > gtouchable, G4Step *thisStep)
 Implementation hook for touchable processing.
std::vector< std::shared_ptr< GTouchable > > processGTouchableModifiers (const std::shared_ptr< GTouchable > &gTouchID, const GTouchableModifiers &gmods)
 Applies touchable modifiers.
virtual std::vector< std::shared_ptr< GTouchable > > processGTouchableModifiersImpl (const std::shared_ptr< GTouchable > &gTouchID, const GTouchableModifiers &gmods)
 Implementation hook for touchable modifier application.
std::unique_ptr< GTrueInfoData > collectTrueInformation (GHit *ghit, size_t hitn)
 Collects standardized “true hit information” into a GTrueInfoData record.
virtual std::unique_ptr< GTrueInfoData > collectTrueInformationImpl (GHit *ghit, size_t hitn)
 Implementation hook for true-information collection.
std::unique_ptr< GDigitizedData > digitizeHit (GHit *ghit, size_t hitn)
 Digitizes a hit into a GDigitizedData record.
virtual std::unique_ptr< GDigitizedData > digitizeHitImpl (GHit *ghit, size_t hitn)
 Implementation hook for hit digitization.
virtual void stream_hit (GHit *hit, std::size_t hit_index, const GSROEventContext &event, const GSROEmit &emit) const
bool loadConstants (int runno, std::string const &variation)
 Loads digitization constants (calibration/configuration).
virtual bool loadConstantsImpl (int runno, std::string const &variation)
 Implementation hook for constant loading.
bool loadTT (int runno, std::string const &variation)
 Loads the translation table (identity -> electronics address).
virtual bool loadTTImpl (int runno, std::string const &variation)
 Implementation hook for translation table loading.
void chargeAndTimeAtHardware (int time, int q, const GHit *ghit, GDigitizedData &gdata)
 Adds hardware-level time/charge and address fields to a digitized record.
bool defineReadoutSpecs ()
 Initializes readout specifications.
virtual bool defineReadoutSpecsImpl ()=0
 Implementation hook to define readout specs.
virtual bool decisionToSkipHit (double energy)
 Decides whether a hit should be skipped based on deposited energy.
virtual bool decisionToSkipHit (double energy, const G4Step *thisStep)
 Decides whether a step should be skipped before hit creation.
bool shouldStopTrackAfterHit (const G4Step *thisStep) const
 Ask whether Geant4 should terminate the track after recording this step's hit.
virtual bool shouldStopTrackAfterHitImpl (const G4Step *thisStep) const
 Plugin hook controlling post-hit track termination.
void set_loggers (const std::shared_ptr< GOptions > &g)
 Sets the options pointer required by the digitization base.
void setDigitizationVariation (const std::string &v)
 Sets the variation used when this routine loads constants / translation tables.
std::string getDigitizationVariation () const
 Returns the variation passed to loadConstants() / loadTT().
void setHitRejectionPolicies (const std::string &systemName)
 Resolves this routine's hit-rejection policies from the global options.
bool apply_thresholds (GHit *ghit, GDigitizedData *digitizedData)
 Applies this system's ADC-threshold rejection to a digitized hit.
virtual bool apply_thresholds_impl (GHit *ghit, GDigitizedData *digitizedData)
 Plugin hook: is this digitized hit below the per-channel ADC threshold?
virtual bool thresholds_are_intrinsic_impl () const
 Declares that this plugin's threshold is intrinsic to its GEMC2 digitization.
bool apply_efficiency (GHit *ghit, GDigitizedData *digitizedData)
 Applies this system's efficiency rejection to a digitized hit.
virtual bool apply_efficiency_impl (GHit *ghit, GDigitizedData *digitizedData)
 Plugin hook: does this digitized hit fail the per-channel efficiency draw?
virtual bool efficiencies_are_intrinsic_impl () const
 Declares that this plugin's efficiency policy is intrinsic to GEMC2 digitization.
Public Member Functions inherited from GBase< GDynamicDigitization >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
virtual ~GBase ()
GBase & operator= (const GBase &)=default

Static Public Member Functions

static GDynamicDigitization * instantiate (const dlhandle h, std::shared_ptr< GOptions > g)
 Dynamically instantiates a plugin instance from a dynamic library.

Data Fields

std::shared_ptr< const GReadoutSpecs > readoutSpecs
 Readout specs are created during initialization and treated as immutable.
std::shared_ptr< const GTranslationTable > translationTable
 Translation table is typically loaded during initialization and treated as immutable.

Protected Member Functions

void check_if_log_defined () const
 Ensures options/logging are configured before plugin methods run.

Protected Attributes

std::shared_ptr< GOptions > gopts
 Options used by the digitization plugin instance.
Protected Attributes inherited from GBase< GDynamicDigitization >
std::shared_ptr< GLogger > log

Detailed Description

Plugins typically implement:

They may additionally override:

Definition at line 175 of file gdynamicdigitization.h.

Constructor & Destructor Documentation

◆ GDynamicDigitization()

GDynamicDigitization::GDynamicDigitization ( const std::shared_ptr< GOptions > & g)
inlineexplicit
Parameters
gOptions used by this plugin instance.

Definition at line 182 of file gdynamicdigitization.h.

◆ ~GDynamicDigitization()

GDynamicDigitization::~GDynamicDigitization ( )
overridedefault

Member Function Documentation

◆ apply_efficiency()

bool GDynamicDigitization::apply_efficiency ( GHit * ghit,
GDigitizedData * digitizedData )
inlinenodiscard

Wrapper called automatically by the event action after digitizeHit(). It delegates to the plugin when the system is listed in -applyInefficiencies or the plugin declares its efficiency policy intrinsic. The callback may mutate the digitized record; returning true drops it and, when also_reject_true_info is set, its true-info row.

Parameters
ghitThe hit being digitized.
digitizedDataThe digitized record produced by digitizeHit().
Returns
true if the hit fails the efficiency draw and must be dropped.

Definition at line 618 of file gdynamicdigitization.h.

◆ apply_efficiency_impl()

virtual bool GDynamicDigitization::apply_efficiency_impl ( GHit * ghit,
GDigitizedData * digitizedData )
inlinenodiscardvirtual

Implemented by plugins that support efficiency policies. The callback can reject the whole hit or mutate part of its output, such as suppressing only a TDC value. Default: keep.

Definition at line 629 of file gdynamicdigitization.h.

◆ apply_thresholds()

bool GDynamicDigitization::apply_thresholds ( GHit * ghit,
GDigitizedData * digitizedData )
inlinenodiscard

Wrapper called automatically by the event action after digitizeHit(). It delegates to the plugin when the system is listed in -applyThresholds or the plugin declares its threshold intrinsic. Returning true drops the digitized hit and, when also_reject_true_info is set, its true-info row.

Parameters
ghitThe hit being digitized.
digitizedDataThe digitized record produced by digitizeHit().
Returns
true if the hit is below threshold and must be dropped.

Definition at line 582 of file gdynamicdigitization.h.

◆ apply_thresholds_impl()

virtual bool GDynamicDigitization::apply_thresholds_impl ( GHit * ghit,
GDigitizedData * digitizedData )
inlinenodiscardvirtual

Implemented by plugins that support threshold rejection. The mutable digitized record may contain transient decision inputs cached by digitizeHitImpl(). Default: keep the hit.

Definition at line 593 of file gdynamicdigitization.h.

◆ chargeAndTimeAtHardware()

void GDynamicDigitization::chargeAndTimeAtHardware ( int time,
int q,
const GHit * ghit,
GDigitizedData & gdata )

This routine inserts:

  • crate/slot/channel from the translation table
  • TIMEATELECTRONICS and CHARGEATELECTRONICS
Parameters
timeTime value (time unit follows project conventions; often ns).
qCharge value (ADC-like integer).
ghitInput hit providing the translation-table id.
gdataDigitized record to augment (caller retains ownership).

Definition at line 104 of file gdynamicdigitization.cc.

◆ check_if_log_defined()

void GDynamicDigitization::check_if_log_defined ( ) const
inlineprotected

If options are not set, prints an error message and exits.

Definition at line 664 of file gdynamicdigitization.h.

◆ collection_mode()

virtual CollectionMode GDynamicDigitization::collection_mode ( ) const
inlinenodiscardvirtual

Reimplemented in GDosimeterDigitization.

Definition at line 189 of file gdynamicdigitization.h.

◆ collectTrueInformation()

std::unique_ptr< GTrueInfoData > GDynamicDigitization::collectTrueInformation ( GHit * ghit,
size_t hitn )
inlinenodiscard

Wrapper that logs/checks and delegates to collectTrueInformationImpl().

Parameters
ghitInput hit from the sensitive detector.
hitnSequential hit index.
Returns
Newly created true-information record.

Definition at line 302 of file gdynamicdigitization.h.

◆ collectTrueInformationImpl()

std::unique_ptr< GTrueInfoData > GDynamicDigitization::collectTrueInformationImpl ( GHit * ghit,
size_t hitn )
nodiscardvirtual
Parameters
ghitInput hit.
hitnSequential hit index.
Returns
Newly created true-information record.

Definition at line 46 of file gdynamicdigitization.cc.

◆ decisionToSkipHit() [1/2]

virtual bool GDynamicDigitization::decisionToSkipHit ( double energy)
inlinevirtual

Default behavior skips hits with exactly zero energy if the recordZeroEdep option is disabled.

Parameters
energyTotal deposited energy for the hit.
Returns
true if the hit should be skipped.

Definition at line 483 of file gdynamicdigitization.h.

◆ decisionToSkipHit() [2/2]

virtual bool GDynamicDigitization::decisionToSkipHit ( double energy,
const G4Step * thisStep )
inlinevirtual

This overload gives digitization routines access to the full Geant4 step while preserving the legacy energy-only hook for existing plugins.

Parameters
energyTotal deposited energy for the step.
thisStepGeant4 step being processed.
Returns
true if the step should be skipped.

Reimplemented in GPhotonDetectorDigitization.

Definition at line 500 of file gdynamicdigitization.h.

◆ defineReadoutSpecs()

bool GDynamicDigitization::defineReadoutSpecs ( )
inlinenodiscard

Wrapper that logs/checks and delegates to defineReadoutSpecsImpl().

Returns
true on success.

Definition at line 433 of file gdynamicdigitization.h.

◆ defineReadoutSpecsImpl()

virtual bool GDynamicDigitization::defineReadoutSpecsImpl ( )
pure virtual

Must be implemented by derived classes.

Returns
true on success.

Implemented in GDosimeterDigitization, GFluxDigitization, GParticleCounterDigitization, and GPlugin_test_example.

◆ digitizeHit()

std::unique_ptr< GDigitizedData > GDynamicDigitization::digitizeHit ( GHit * ghit,
size_t hitn )
inlinenodiscard

Wrapper that logs/checks and delegates to digitizeHitImpl().

Parameters
ghitInput hit from the sensitive detector.
hitnSequential hit index.
Returns
Newly created digitized record (or nullptr if not implemented).

Definition at line 327 of file gdynamicdigitization.h.

◆ digitizeHitImpl()

virtual std::unique_ptr< GDigitizedData > GDynamicDigitization::digitizeHitImpl ( GHit * ghit,
size_t hitn )
inlinenodiscardvirtual

Default implementation returns nullptr to indicate "not implemented".

Parameters
ghitInput hit.
hitnSequential hit index.
Returns
Newly created digitized record, or nullptr.

Reimplemented in GDosimeterDigitization, GFluxDigitization, GParticleCounterDigitization, and GPlugin_test_example.

Definition at line 342 of file gdynamicdigitization.h.

◆ efficiencies_are_intrinsic_impl()

virtual bool GDynamicDigitization::efficiencies_are_intrinsic_impl ( ) const
inlinenodiscardvirtual

Intrinsic efficiency policies run even when the system is absent from applyInefficiencies. The default remains configuration-controlled.

Definition at line 640 of file gdynamicdigitization.h.

◆ getDigitizationVariation()

std::string GDynamicDigitization::getDigitizationVariation ( ) const
inlinenodiscard
Returns
The effective digitization variation for this routine.

Definition at line 556 of file gdynamicdigitization.h.

◆ instantiate()

GDynamicDigitization * GDynamicDigitization::instantiate ( const dlhandle h,
std::shared_ptr< GOptions > g )
inlinestatic

This function looks up the GDynamicDigitizationFactory symbol and calls it.

Parameters
hDynamic library handle.
gOptions to pass to the plugin instance.
Returns
Newly created plugin instance, or nullptr on failure.

Definition at line 463 of file gdynamicdigitization.h.

◆ loadConstants()

bool GDynamicDigitization::loadConstants ( int runno,
std::string const & variation )
inlinenodiscard

Wrapper that logs/checks and delegates to loadConstantsImpl().

Parameters
runnoRun number.
variationVariation string.
Returns
true on success.

Definition at line 366 of file gdynamicdigitization.h.

◆ loadConstantsImpl()

virtual bool GDynamicDigitization::loadConstantsImpl ( int runno,
std::string const & variation )
inlinevirtual

Default implementation does nothing and returns true.

Parameters
runnoRun number.
variationVariation string.
Returns
true on success.

Reimplemented in GDosimeterDigitization, and GPlugin_test_example.

Definition at line 381 of file gdynamicdigitization.h.

◆ loadTT()

bool GDynamicDigitization::loadTT ( int runno,
std::string const & variation )
inlinenodiscard

Wrapper that logs/checks and delegates to loadTTImpl().

Parameters
runnoRun number.
variationVariation string.
Returns
true on success.

Definition at line 394 of file gdynamicdigitization.h.

◆ loadTTImpl()

virtual bool GDynamicDigitization::loadTTImpl ( int runno,
std::string const & variation )
inlinevirtual

Default implementation does nothing and returns true.

Parameters
runnoRun number.
variationVariation string.
Returns
true on success.

Reimplemented in GPlugin_test_example.

Definition at line 410 of file gdynamicdigitization.h.

◆ processGTouchableModifiers()

std::vector< std::shared_ptr< GTouchable > > GDynamicDigitization::processGTouchableModifiers ( const std::shared_ptr< GTouchable > & gTouchID,
const GTouchableModifiers & gmods )
inlinenodiscard

Wrapper that logs/checks and delegates to processGTouchableModifiersImpl(). Example use: energy-sharing

Parameters
gTouchIDInput touchable to modify.
gmodsModifier container describing how to modify touchables.
Returns
A vector of modified touchables (possibly empty).

Definition at line 273 of file gdynamicdigitization.h.

◆ processGTouchableModifiersImpl()

std::vector< std::shared_ptr< GTouchable > > GDynamicDigitization::processGTouchableModifiersImpl ( const std::shared_ptr< GTouchable > & gTouchID,
const GTouchableModifiers & gmods )
virtual

Default implementation returns an empty vector (no modifiers applied).

Parameters
gTouchIDInput touchable.
gmodsModifier container.
Returns
Modified touchables (default: empty).

Definition at line 196 of file gdynamicdigitization.cc.

◆ processStepTime()

double GDynamicDigitization::processStepTime ( const std::shared_ptr< GTouchable > & gTouchID,
G4Step * thisStep )
inlinenodiscard

This wrapper logs, checks that options are configured, and delegates to processStepTimeImpl().

Parameters
gTouchIDTouchable associated with the current step.
thisStepPointer to the current G4Step.
Returns
Time value used for electronics time binning (unit follows project conventions).

Definition at line 201 of file gdynamicdigitization.h.

◆ processStepTimeImpl()

double GDynamicDigitization::processStepTimeImpl ( const std::shared_ptr< GTouchable > & gTouchID,
G4Step * thisStep )
nodiscardvirtual

Default behavior returns the post-step global time from G4Step.

Parameters
gTouchIDTouchable associated with the current step.
thisStepPointer to the current G4Step.
Returns
Time value used for electronics time binning.

Definition at line 162 of file gdynamicdigitization.cc.

◆ processTouchable()

std::vector< std::shared_ptr< GTouchable > > GDynamicDigitization::processTouchable ( std::shared_ptr< GTouchable > gtouchable,
G4Step * thisStep )
inlinenodiscard

The default behavior bins the step time into an electronics time-cell index using readoutSpecs->timeCellIndex(). If the index changes relative to the current touchable, a second touchable instance is created.

Parameters
gtouchableInput touchable for this step.
thisStepPointer to the current G4Step.
Returns
One or more touchables representing the time-binned view of the input.

Definition at line 246 of file gdynamicdigitization.h.

◆ processTouchableImpl()

std::vector< std::shared_ptr< GTouchable > > GDynamicDigitization::processTouchableImpl ( std::shared_ptr< GTouchable > gtouchable,
G4Step * thisStep )
nodiscardvirtual
Parameters
gtouchableInput touchable for this step.
thisStepPointer to the current G4Step.
Returns
One or more touchables representing the time-binned view of the input.

Definition at line 169 of file gdynamicdigitization.cc.

◆ set_loggers()

void GDynamicDigitization::set_loggers ( const std::shared_ptr< GOptions > & g)
inline
Parameters
gOptions object to store for later use.
Warning
A future refactor may remove this pattern; currently it is required for legacy flows.

Definition at line 539 of file gdynamicdigitization.h.

◆ setDigitizationVariation()

void GDynamicDigitization::setDigitizationVariation ( const std::string & v)
inline

Resolved once per geometry load: defaults to the variation of the gsystem the routine belongs to, and is overridden by the digitization_variation option when that is set.

Parameters
vVariation string to use.

Definition at line 549 of file gdynamicdigitization.h.

◆ setHitRejectionPolicies()

void GDynamicDigitization::setHitRejectionPolicies ( const std::string & systemName)

Reads the applyThresholds and applyInefficiencies options (each a list of system names, or "all") and records whether systemName should apply threshold and/or efficiency rejection during digitization. Called once per geometry load, alongside setDigitizationVariation().

Parameters
systemNameName of the gsystem / digitization routine.

Definition at line 205 of file gdynamicdigitization.cc.

◆ shouldStopTrackAfterHit()

bool GDynamicDigitization::shouldStopTrackAfterHit ( const G4Step * thisStep) const
inlinenodiscard

The sensitive detector evaluates this hook only after all processed touchables have created or updated their GHit. Returning true therefore preserves the current hit and prevents the track from taking another step.

Parameters
thisStepGeant4 step that was recorded.
Returns
true when the framework should apply fStopAndKill to the track.

Definition at line 514 of file gdynamicdigitization.h.

◆ shouldStopTrackAfterHitImpl()

virtual bool GDynamicDigitization::shouldStopTrackAfterHitImpl ( const G4Step * thisStep) const
inlinenodiscardvirtual

The default keeps the track alive. Detector plugins can override this for terminal sensitive elements such as optical-photon collectors.

Definition at line 525 of file gdynamicdigitization.h.

◆ stream_hit()

virtual void GDynamicDigitization::stream_hit ( GHit * hit,
std::size_t hit_index,
const GSROEventContext & event,
const GSROEmit & emit ) const
inlinevirtual

Produce owned SRO payloads on the simulation worker, independently of ordinary event digitization. Called only when SRO is enabled and this detector is not suppressed by no_digitized. Emit zero or more contributions immediately; the action supplies event/sequence IDs. The implementation supplies crate IDs and absolute run-relative times consistent with its GSROTiming model. Do not retain the hit or emit callback. The shared digitizer must not mutate shared state here; use local or thread-local state. Default: this detector does not contribute to SRO. Frame/overlap policy belongs to crate plugins.

Definition at line 353 of file gdynamicdigitization.h.

◆ thresholds_are_intrinsic_impl()

virtual bool GDynamicDigitization::thresholds_are_intrinsic_impl ( ) const
inlinenodiscardvirtual

Intrinsic thresholds run even when the system is absent from applyThresholds. The default remains configuration-controlled for backward compatibility.

Definition at line 604 of file gdynamicdigitization.h.

◆ variables_to_normalize()

std::vector< std::string > GDynamicDigitization::variables_to_normalize ( )
inlinenodiscard

Definition at line 220 of file gdynamicdigitization.h.

◆ variables_to_normalizeImpl()

virtual std::vector< std::string > GDynamicDigitization::variables_to_normalizeImpl ( )
inlinenodiscardvirtual

Definition at line 229 of file gdynamicdigitization.h.

Field Documentation

◆ gopts

std::shared_ptr<GOptions> GDynamicDigitization::gopts
protected

Definition at line 657 of file gdynamicdigitization.h.

◆ readoutSpecs

std::shared_ptr<const GReadoutSpecs> GDynamicDigitization::readoutSpecs

Definition at line 449 of file gdynamicdigitization.h.

◆ translationTable

std::shared_ptr<const GTranslationTable> GDynamicDigitization::translationTable

Definition at line 452 of file gdynamicdigitization.h.


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