gstreamer
Loading...
Searching...
No Matches
GRootTree Class Reference

Helper class encapsulating one ROOT TTree and its branch storage. More...

#include <gRootTree.h>

Public Member Functions

 ~GRootTree ()
 Destructor emitting a debug trace when a logger is available.
 
 GRootTree (const std::unique_ptr< GEventHeader > &gevent_header, std::shared_ptr< GLogger > &log)
 Construct an event-header tree and register its branches.
 
 GRootTree (const std::unique_ptr< GRunHeader > &grun_header, std::shared_ptr< GLogger > &log)
 Construct a run-header tree and register its branches.
 
 GRootTree (const std::string &detectorName, const GTrueInfoData *gdata, std::shared_ptr< GLogger > &log)
 Construct a true-information tree for one detector and register its branches.
 
 GRootTree (const std::string &detectorName, const GDigitizedData *gdata, std::shared_ptr< GLogger > &log)
 Construct a digitized-data tree for one detector and register its branches.
 
 GRootTree (const std::string &treeName, const GGeneratedParticleBank &particles, std::shared_ptr< GLogger > &log)
 Construct a generated-particle tree and register its branches.
 
bool fillTree (const std::unique_ptr< GEventHeader > &gevent_header)
 Fill the event-header tree with one event header entry.
 
bool fillTree (const std::unique_ptr< GRunHeader > &run_header)
 Fill the run-header tree with one run header entry.
 
bool fillTree (const std::vector< const GTrueInfoData * > &trueInfoData)
 Fill a true-information detector tree with one detector collection.
 
bool fillTree (const std::vector< const GDigitizedData * > &digitizedData)
 Fill a digitized detector tree with one detector collection.
 
bool fillTree (const GGeneratedParticleBank &particles)
 Fill a generated-particle tree with one event bank.
 

Detailed Description

This class adapts GEMC header and hit data models to ROOT vector branches. It owns:

  • one TTree
  • one set of branch storage maps keyed by variable name
  • the logic needed to clear, refill, and write one entry per publish call

Data organization:

  • integer variables are stored in std::vector<int> branches
  • floating-point variables are stored in std::vector<double> branches
  • text variables are stored in std::vector<std::string> branches

For hit-based trees, one branch vector entry corresponds to one hit in the published detector collection. The same hit index therefore lines up across all branch vectors in a given tree fill. Generated-particle trees use the same vector-branch model, with one branch vector entry per generated-particle row in the bank.

Definition at line 53 of file gRootTree.h.

Constructor & Destructor Documentation

◆ ~GRootTree()

GRootTree::~GRootTree ( )
inline

Definition at line 57 of file gRootTree.h.

◆ GRootTree() [1/5]

GRootTree::GRootTree ( const std::unique_ptr< GEventHeader > & gevent_header,
std::shared_ptr< GLogger > & log )

The event-header schema contains:

  • g4localEventNumber
  • threadID
  • timeStamp
Parameters
gevent_headerEvent header used to determine and initialize the schema.
logLogger used for diagnostics.

Definition at line 10 of file gRootTree.cc.

◆ GRootTree() [2/5]

GRootTree::GRootTree ( const std::unique_ptr< GRunHeader > & grun_header,
std::shared_ptr< GLogger > & log )

The run-header schema contains the run identifier.

Parameters
grun_headerRun header used to determine and initialize the schema.
logLogger used for diagnostics.

Definition at line 59 of file gRootTree.cc.

◆ GRootTree() [3/5]

GRootTree::GRootTree ( const std::string & detectorName,
const GTrueInfoData * gdata,
std::shared_ptr< GLogger > & log )

Branches are inferred from the variable maps exposed by the sample hit:

  • double-valued variables become std::vector<double> branches
  • string-valued variables become std::vector<std::string> branches
Parameters
detectorNameFinal ROOT tree name for this detector collection.
gdataSample true-information hit used to determine the schema.
logLogger used for diagnostics.

Definition at line 74 of file gRootTree.cc.

◆ GRootTree() [4/5]

GRootTree::GRootTree ( const std::string & detectorName,
const GDigitizedData * gdata,
std::shared_ptr< GLogger > & log )

Branches are inferred from the observable maps exposed by the sample hit:

  • integer observables become std::vector<int> branches
  • floating-point observables become std::vector<double> branches
Parameters
detectorNameFinal ROOT tree name for this detector collection.
gdataSample digitized hit used to determine the schema.
logLogger used for diagnostics.

Definition at line 116 of file gRootTree.cc.

◆ GRootTree() [5/5]

GRootTree::GRootTree ( const std::string & treeName,
const GGeneratedParticleBank & particles,
std::shared_ptr< GLogger > & log )

The schema contains name, pid, type, multiplicity, p, theta, phi, vx, vy, and vz.

Parameters
treeNameFinal ROOT tree name, normally generated or generated_tracked.
particlesSample bank used to initialize the schema.
logLogger used for diagnostics.

Definition at line 91 of file gRootTree.cc.

Member Function Documentation

◆ fillTree() [1/5]

bool GRootTree::fillTree ( const GGeneratedParticleBank & particles)

Each generated-particle row contributes one entry to each registered branch vector.

Parameters
particlesGenerated-particle bank for the current event.
Returns
true on success.

Definition at line 184 of file gRootTree.cc.

◆ fillTree() [2/5]

bool GRootTree::fillTree ( const std::unique_ptr< GEventHeader > & gevent_header)

The method clears the branch storage vectors, inserts the current header values, and calls TTree::Fill().

Parameters
gevent_headerEvent header providing the values for this entry.
Returns
true on success.

Definition at line 28 of file gRootTree.cc.

◆ fillTree() [3/5]

bool GRootTree::fillTree ( const std::unique_ptr< GRunHeader > & run_header)
Parameters
run_headerRun header providing the values for this entry.
Returns
true on success.

Definition at line 47 of file gRootTree.cc.

◆ fillTree() [4/5]

bool GRootTree::fillTree ( const std::vector< const GDigitizedData * > & digitizedData)

Each hit contributes one entry to each registered branch vector.

Parameters
digitizedDataRaw-pointer view of the detector digitized hits.
Returns
true on success.

Definition at line 161 of file gRootTree.cc.

◆ fillTree() [5/5]

bool GRootTree::fillTree ( const std::vector< const GTrueInfoData * > & trueInfoData)

Each hit contributes one entry to each registered branch vector.

Parameters
trueInfoDataRaw-pointer view of the detector true-information hits.
Returns
true on success.

Definition at line 137 of file gRootTree.cc.


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