HepMC3 event record library
Public Member Functions | Data Fields | Protected Member Functions | Private Member Functions | Private Attributes
ReaderRootTree Class Reference

Detailed Description

GenEvent I/O parsing and serialization for root files based on root TTree.

If HepMC was compiled with path to ROOT available, this class can be used for root file I/O in the same manner as with HepMC::ReaderAscii class.

Examples:
convert_example.cc.

Definition at line 34 of file ReaderRootTree.h.

#include <ReaderRootTree.h>

+ Inheritance diagram for ReaderRootTree:
+ Collaboration diagram for ReaderRootTree:

Public Member Functions

 ReaderRootTree (const std::string &filename)
 Default constructor. More...
 
 ReaderRootTree (const std::string &filename, const std::string &treename, const std::string &branchname)
 Constructor with tree name. More...
 
bool read_event (GenEvent &evt)
 Read event from file. More...
 
void close ()
 Close file. More...
 
bool failed ()
 Get file error state. More...
 
shared_ptr< GenRunInforun_info () const
 Get the global GenRunInfo object. More...
 

Data Fields

TTree * m_tree
 Tree handler. Public to allow simple access, e.g. custom branches. More...
 

Protected Member Functions

void set_run_info (shared_ptr< GenRunInfo > run)
 Set the global GenRunInfo object. More...
 

Private Member Functions

bool init ()
 init routine More...
 

Private Attributes

TFile * m_file
 File handler. More...
 
int m_events_count
 Events count. Needed to read the tree. More...
 
GenEventDatam_event_data
 Pointer to structure that holds event data. More...
 
GenRunInfoDatam_run_info_data
 Pointer to structure that holds run info data. More...
 
std::string m_tree_name
 Name of TTree. More...
 
std::string m_branch_name
 Name of TBranch in TTree. More...
 

Constructor & Destructor Documentation

◆ ReaderRootTree() [1/2]

ReaderRootTree ( const std::string &  filename)

Default constructor.

Definition at line 17 of file ReaderRootTree.cc.

References ReaderRootTree::init(), and ReaderRootTree::m_file.

◆ ReaderRootTree() [2/2]

ReaderRootTree ( const std::string &  filename,
const std::string &  treename,
const std::string &  branchname 
)

Constructor with tree name.

Definition at line 25 of file ReaderRootTree.cc.

References ReaderRootTree::init(), and ReaderRootTree::m_file.

Member Function Documentation

◆ close()

void close ( )
virtual

Close file.

Implements Reader.

Definition at line 96 of file ReaderRootTree.cc.

References ReaderRootTree::m_file.

◆ failed()

bool failed ( )
virtual

Get file error state.

Implements Reader.

Definition at line 101 of file ReaderRootTree.cc.

References ReaderRootTree::m_events_count, ReaderRootTree::m_file, and ReaderRootTree::m_tree.

◆ init()

bool init ( )
private

◆ read_event()

bool read_event ( GenEvent evt)
virtual

◆ run_info()

shared_ptr<GenRunInfo> run_info ( ) const
inlineinherited

Get the global GenRunInfo object.

Examples:
convert_example.cc, and LHEF_example_cat.cc.

Definition at line 39 of file Reader.h.

References Reader::m_run_info.

◆ set_run_info()

void set_run_info ( shared_ptr< GenRunInfo run)
inlineprotectedinherited

Set the global GenRunInfo object.

Definition at line 46 of file Reader.h.

References Reader::m_run_info.

Field Documentation

◆ m_branch_name

std::string m_branch_name
private

Name of TBranch in TTree.

Definition at line 77 of file ReaderRootTree.h.

◆ m_event_data

GenEventData* m_event_data
private

Pointer to structure that holds event data.

Definition at line 74 of file ReaderRootTree.h.

◆ m_events_count

int m_events_count
private

Events count. Needed to read the tree.

Definition at line 73 of file ReaderRootTree.h.

◆ m_file

TFile* m_file
private

File handler.

Definition at line 69 of file ReaderRootTree.h.

◆ m_run_info_data

GenRunInfoData* m_run_info_data
private

Pointer to structure that holds run info data.

Definition at line 75 of file ReaderRootTree.h.

◆ m_tree

TTree* m_tree

Tree handler. Public to allow simple access, e.g. custom branches.

Definition at line 71 of file ReaderRootTree.h.

◆ m_tree_name

std::string m_tree_name
private

Name of TTree.

Definition at line 76 of file ReaderRootTree.h.


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