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

Stores simulation-level observables for one hit. More...

#include <gTrueInfoData.h>

Public Member Functions

 GTrueInfoData (const std::shared_ptr< GOptions > &gopts, const GHit *ghit)
 Constructs the object and copies the hit identity from the source hit.
 
std::string getIdentityString () const
 Builds a readable identity string from the stored hit identifiers.
 
void includeVariable (const std::string &varName, double var)
 Stores or overwrites one numeric truth observable.
 
void includeVariable (const std::string &varName, std::string var)
 Stores or overwrites one string truth observable.
 
void accumulateVariable (const std::string &vname, double value)
 Accumulates a numeric observable into the current object.
 
std::map< std::string, double > getDoubleVariablesMap () const
 Returns a copy of the numeric truth observables.
 
std::map< std::string, std::string > getStringVariablesMap () const
 Returns a copy of the 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)
 Creates deterministic example data for tests and examples.
 

Friends

std::ostream & operator<< (std::ostream &os, const GTrueInfoData &data)
 

Additional Inherited Members

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

Detailed Description

A GTrueInfoData object represents the truth-side data model for one hit. It is typically produced from tracking or stepping information and later attached to:

Main responsibilities:

  • hold numeric truth observables
  • hold string metadata associated with the hit
  • preserve a copy of the detector identity for later labeling, debugging, and export

Accumulation model:

Note
Accumulation is purely additive. Any normalization, averaging, or rate computation belongs in higher-level consumer code.

Definition at line 105 of file gTrueInfoData.h.

Constructor & Destructor Documentation

◆ GTrueInfoData()

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

The constructor initializes the base logging domain and copies the vector of GIdentifier entries from the provided hit so that this object becomes self-contained.

Ownership and lifetime:

  • ghit is not owned
  • ghit only needs to remain valid during construction
  • after construction, this object no longer depends on the source hit
Parameters
goptsShared options used to configure logging and related behavior.
ghitSource hit providing the identity vector.

Definition at line 19 of file gTrueInfoData.cc.

Member Function Documentation

◆ accumulateVariable()

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

This method supports run-level or integrated accumulation.

Behavior:

  • if the key does not exist, it is created with value
  • if the key already exists, value is added to the stored entry
Parameters
vnameObservable key.
valueContribution to add to the running sum.

Definition at line 37 of file gTrueInfoData.cc.

◆ create()

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

This helper is intended only for demonstrations and tests. It does not model real detector truth generation.

The returned object contains a small conventional set of numeric variables:

  • totalEDeposited
  • avgTime
  • avgx
  • avgy
  • avgz
  • hitn

Uniqueness across calls is derived from a static atomic counter.

Parameters
goptsShared options.
Returns
Newly created example object.

Definition at line 237 of file gTrueInfoData.h.

◆ getDoubleVariablesMap()

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

Returning by value preserves encapsulation and prevents external mutation of the internal map.

Returns
Copy of the double-valued observables map.

Definition at line 200 of file gTrueInfoData.h.

◆ getIdentityString()

std::string GTrueInfoData::getIdentityString ( ) const

The generated format is:

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

This string is intended for:

  • logs
  • debugging output
  • human-readable summaries
Returns
Identity string assembled from the stored gidentity vector.

Definition at line 51 of file gTrueInfoData.cc.

◆ getStringVariablesMap()

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

These values are usually categorical or provenance-oriented and are typically not merged during run-level integration in GDataCollection.

Returns
Copy of the string-valued observables map.

Definition at line 213 of file gTrueInfoData.h.

◆ includeVariable() [1/2]

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

This method is typically used during event-level filling. Repeated insertion with the same key replaces the previous value.

Common examples include:

  • total deposited energy
  • average time
  • average coordinates
Parameters
varNameObservable key.
varNumeric value to store.

Definition at line 25 of file gTrueInfoData.cc.

◆ includeVariable() [2/2]

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

This method is intended for per-hit metadata that is better represented as text, such as:

  • process names
  • particle names
  • volume labels
  • provenance tags

Repeated insertion with the same key replaces the previous value.

Parameters
varNameObservable key.
varString value to store.

Definition at line 31 of file gTrueInfoData.cc.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const GTrueInfoData & data )
friend

Definition at line 61 of file gTrueInfoData.cc.


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