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.
 
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.
 

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.

Definition at line 50 of file gRootTree.h.

Constructor & Destructor Documentation

◆ ~GRootTree()

GRootTree::~GRootTree ( )
inline

Definition at line 54 of file gRootTree.h.

◆ GRootTree() [1/4]

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/4]

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 28 of file gRootTree.cc.

◆ GRootTree() [3/4]

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 44 of file gRootTree.cc.

◆ GRootTree() [4/4]

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 61 of file gRootTree.cc.

Member Function Documentation

◆ fillTree() [1/4]

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 75 of file gRootTree.cc.

◆ fillTree() [2/4]

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 94 of file gRootTree.cc.

◆ fillTree() [3/4]

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 123 of file gRootTree.cc.

◆ fillTree() [4/4]

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 107 of file gRootTree.cc.


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