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

Container for true (simulation-level) observables for one hit. More...

#include <gTrueInfoData.h>

Public Member Functions

 GTrueInfoData (const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
 Construct true-hit data by copying identity from a hit.
 
std::string getIdentityString () const
 Return a human-readable identity string for debugging and labeling.
 
void includeVariable (const std::string &varName, double var)
 Store/overwrite a numeric "true" observable for this hit.
 
void includeVariable (const std::string &varName, std::string var)
 Store/overwrite a string "true" observable for this hit.
 
void accumulateVariable (const std::string &vname, double value)
 Accumulate a numeric observable into this object (run-level integration).
 
std::map< std::string, double > getDoubleVariablesMap () const
 Get a copy of all numeric truth observables.
 
std::map< std::string, std::string > getStringVariablesMap () const
 Get a copy of all string truth observables.
 
- Public Member Functions inherited from GBase< GTrueInfoData >
 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< GTrueInfoDatacreate (const std::shared_ptr< GOptions > &gopts)
 Test/example factory: create a true-hit object with deterministic dummy data.
 

Additional Inherited Members

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

Detailed Description

A GTrueInfoData instance conceptually corresponds to one simulated hit.

  • It stores numeric and string observables keyed by name.
  • It stores an identity vector derived from GHit, typically encoding geometry indices.

The container supports two usage patterns: 1) Event-level storage: create a new instance per hit and populate it using includeVariable(). 2) Run-level integration: keep a single instance as an accumulator and call accumulateVariable() to sum contributions across hits/events.

Note
Accumulation is summation only; do not expect averages unless you compute them externally.

Definition at line 91 of file gTrueInfoData.h.

Constructor & Destructor Documentation

◆ GTrueInfoData()

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

Ownership:

  • ghit is not owned; it must remain valid only for the duration of the constructor.
Parameters
goptsShared options object used to configure logging and behavior.
ghitPointer to the hit providing identity information (not owned).

Definition at line 24 of file gTrueInfoData.cc.

Member Function Documentation

◆ accumulateVariable()

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

Summation semantics:

  • If vname is absent, it is created with value.
  • If present, value is added to the existing entry.

This method is typically used when integrating many hits/events into a run-level summary.

Parameters
vnameObservable name/key.
valueContribution to add.

Definition at line 57 of file gTrueInfoData.cc.

◆ create()

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

This method exists to support examples and unit tests. It does not represent real physics truth generation. Values are created using a thread-safe counter so that:

  • each call produces different values
  • behavior is deterministic given call order

The returned object includes a small set of conventional truth keys used in examples:

  • "totalEDeposited", "avgTime", "avgx", "avgy", "avgz", and "hitn".
Parameters
goptsShared options.
Returns
Newly created true-hit object.

Definition at line 216 of file gTrueInfoData.h.

◆ getDoubleVariablesMap()

std::map< std::string, double > GTrueInfoData::getDoubleVariablesMap ( ) const
inline

Returning by value keeps the internal storage encapsulated and avoids exposing a mutable reference. For very large maps, consider whether a const reference accessor is desirable at higher layers.

Returns
Copy of the double observables map.

Definition at line 184 of file gTrueInfoData.h.

◆ getIdentityString()

std::string GTrueInfoData::getIdentityString ( ) const

Format:

name1->value1, name2->value2, ...

The underlying identity is the gidentity vector copied from the GHit.

Returns
Identity string assembled from the hit identifiers.

Definition at line 75 of file gTrueInfoData.cc.

◆ getStringVariablesMap()

std::map< std::string, std::string > GTrueInfoData::getStringVariablesMap ( ) const
inline

String observables are typically per-hit categorical/provenance values and are not accumulated by GDataCollection in run mode.

Returns
Copy of the string observables map.

Definition at line 197 of file gTrueInfoData.h.

◆ includeVariable() [1/2]

void GTrueInfoData::includeVariable ( const std::string & varName,
double var )

Overwrite semantics:

  • If varName already exists, the stored value is replaced.
  • If it does not exist, a new entry is created.

Typical numeric truth keys (examples, not enforced):

  • "totalEDeposited"
  • "avgTime"
  • "avgx", "avgy", "avgz"
Parameters
varNameObservable name/key.
varValue to store.

Definition at line 36 of file gTrueInfoData.cc.

◆ includeVariable() [2/2]

void GTrueInfoData::includeVariable ( const std::string & varName,
std::string var )

String observables are typically used for categorical metadata such as:

  • physics process name
  • volume name
  • particle name
  • provenance tags

Semantics:

  • Overwrite: repeated calls with the same key replace the stored value.
Parameters
varNameObservable name/key.
varString value to store (moved into the map).

Definition at line 45 of file gTrueInfoData.cc.


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