gdata
Loading...
Searching...
No Matches
GDigitizedData Class Reference

Container for digitized (electronics-level) observables for one hit. More...

#include <gDigitizedData.h>

Public Member Functions

 GDigitizedData (const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
 Construct digitized data by copying identity from a hit.
 
std::string getIdentityString () const
 Return a human-readable identity string for debugging and labeling.
 
std::map< std::string, int > getIntObservablesMap (int which) const
 Return a filtered copy of the integer observables map.
 
std::map< std::string, double > getDblObservablesMap (int which) const
 Return a filtered copy of the double observables map.
 
int getTimeAtElectronics ()
 Convenience accessor for TIMEATELECTRONICS.
 
int getIntObservable (const std::string &varName)
 Retrieve one integer observable by name.
 
double getDblObservable (const std::string &varName)
 Retrieve one double observable by name.
 
std::map< std::string, std::vector< int > > getArrayIntObservablesMap () const
 Get the array-valued integer observables map.
 
std::map< std::string, std::vector< double > > getArrayDblObservablesMap () const
 Get the array-valued double observables map.
 
Per-hit insertion API

Store/overwrite observables for a single hit.

These methods are typically called by digitization logic that computes observables for the current hit and wants to attach them to the output record.

Overwrite semantics:

void includeVariable (const std::string &vname, int value)
 Store/overwrite an integer observable for this hit (event-level).
 
void includeVariable (const std::string &vname, double value)
 Store/overwrite a double observable for this hit (event-level).
 
Run-level integration API

Accumulate observables across hits/events (summation).

These are used when a single GDigitizedData is serving as an accumulator.

  • If the key does not exist, it is created.
  • If it exists, the new contribution is added to the stored value.
Note
No normalization is performed.
void accumulateVariable (const std::string &vname, int value)
 Accumulate an integer observable (run-level integration).
 
void accumulateVariable (const std::string &vname, double value)
 Accumulate a double observable (run-level integration).
 
- Public Member Functions inherited from GBase< GDigitizedData >
 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
 

Static Public Member Functions

static std::unique_ptr< GDigitizedDatacreate (const std::shared_ptr< GOptions > &gopts)
 Test/example factory: create a digitized hit with deterministic dummy data.
 

Additional Inherited Members

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

Detailed Description

A GDigitizedData instance corresponds to one hit after digitization. It is designed to be schema-flexible (map-based storage) while still allowing:

  • deterministic inspection via map iteration
  • selective export of readout keys (SRO filtering)
  • run-level integration via summation of scalars

Common usage patterns: 1) Event-level: create a new instance per hit; fill using includeVariable(). 2) Run-level: keep a single instance as an accumulator; integrate contributions with accumulateVariable().

Note
Accumulation is summation only; compute averages/rates in the consumer if needed.

Definition at line 85 of file gDigitizedData.h.

Constructor & Destructor Documentation

◆ GDigitizedData()

GDigitizedData::GDigitizedData ( const std::shared_ptr< GOptions > & gopts,
const GHit * ghit )

The constructor copies the hit identity (GIdentifier vector) from ghit. The identity can be rendered as a human-readable string via getIdentityString().

Ownership:

  • ghit is not owned and only needs to be valid during construction.
Parameters
goptsShared options object used to configure logging and behavior.
ghitPointer to the hit providing identity information (not owned).

Definition at line 29 of file gDigitizedData.cc.

Member Function Documentation

◆ accumulateVariable() [1/2]

void GDigitizedData::accumulateVariable ( const std::string & vname,
double value )

Definition at line 110 of file gDigitizedData.cc.

◆ accumulateVariable() [2/2]

void GDigitizedData::accumulateVariable ( const std::string & vname,
int value )

Definition at line 98 of file gDigitizedData.cc.

◆ create()

static std::unique_ptr< GDigitizedData > GDigitizedData::create ( const std::shared_ptr< GOptions > & gopts)
inlinestatic

This method exists to support examples and unit tests. It does not represent real detector digitization; instead it generates predictable values using a thread-safe counter.

The returned object includes:

  • SRO keys: crate/slot/channel/timeAtElectronics
  • one non-SRO observable: "adc"
Parameters
goptsShared options.
Returns
A new digitized hit object.

Definition at line 258 of file gDigitizedData.h.

◆ getArrayDblObservablesMap()

std::map< std::string, std::vector< double > > GDigitizedData::getArrayDblObservablesMap ( ) const
inline

No filtering is applied to array-valued maps; their interpretation is producer-defined.

Returns
A copy of the array double observables map.

Definition at line 239 of file gDigitizedData.h.

◆ getArrayIntObservablesMap()

std::map< std::string, std::vector< int > > GDigitizedData::getArrayIntObservablesMap ( ) const
inline

Array observables are optional and may represent:

  • waveforms
  • time slices / samples
  • multi-hit or multi-sample payloads
Returns
A copy of the array integer observables map.

Definition at line 227 of file gDigitizedData.h.

◆ getDblObservable()

double GDigitizedData::getDblObservable ( const std::string & varName)

If the key is missing, an error is emitted via GLogger using ERR_VARIABLENOTFOUND.

Parameters
varNameObservable name/key.
Returns
The stored double value.

Definition at line 138 of file gDigitizedData.cc.

◆ getDblObservablesMap()

std::map< std::string, double > GDigitizedData::getDblObservablesMap ( int which) const

Uses the same filtering semantics as getIntObservablesMap().

Parameters
whichFilter mode (0 = non-SRO, 1 = SRO only).
Returns
A filtered copy of the double observables.

Definition at line 53 of file gDigitizedData.cc.

◆ getIdentityString()

std::string GDigitizedData::getIdentityString ( ) const

Format:

name1->value1, name2->value2, ...
Returns
Identity string assembled from the hit identifiers.

Definition at line 147 of file gDigitizedData.cc.

◆ getIntObservable()

int GDigitizedData::getIntObservable ( const std::string & varName)

If the key is missing, an error is emitted via GLogger using ERR_VARIABLENOTFOUND. Return behavior after logging depends on the logger configuration (fatal vs non-fatal).

Parameters
varNameObservable name/key.
Returns
The stored integer value.

Definition at line 129 of file gDigitizedData.cc.

◆ getIntObservablesMap()

std::map< std::string, int > GDigitizedData::getIntObservablesMap ( int which) const

Filtering is based on whether a key is considered "streaming readout" (SRO):

  • which = 0: returns non-SRO variables (digitization outputs / physics-like quantities)
  • which = 1: returns only SRO variables (crate/slot/channel/timeAtElectronics/chargeAtElectronics)
Parameters
whichFilter mode (0 = non-SRO, 1 = SRO only).
Returns
A filtered copy of the integer observables.

Definition at line 40 of file gDigitizedData.cc.

◆ getTimeAtElectronics()

int GDigitizedData::getTimeAtElectronics ( )

If the key is not present, returns TIMEATELECTRONICSNOTDEFINED (a sentinel). This avoids quietly inserting defaults and makes missing-data bugs easier to detect.

Returns
The time at electronics if present, otherwise TIMEATELECTRONICSNOTDEFINED.

Definition at line 122 of file gDigitizedData.cc.

◆ includeVariable() [1/2]

void GDigitizedData::includeVariable ( const std::string & vname,
double value )

Definition at line 92 of file gDigitizedData.cc.

◆ includeVariable() [2/2]

void GDigitizedData::includeVariable ( const std::string & vname,
int value )

Definition at line 86 of file gDigitizedData.cc.


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