HepMC3 event record library: ReaderRootTree Class Reference

HepMC3 event record library

Public Member Functions | Data Fields | Protected Attributes | 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.

Definition at line 35 of file ReaderRootTree.h.

`#include <ReaderRootTree.h>`

Inheritance diagram for ReaderRootTree:
[legend]
Collaboration diagram for ReaderRootTree:
[legend]

## Public Member Functions
| ReaderRootTree (const std::string &filename)
| Default constructor.
| ReaderRootTree (const std::string &filename, const std::string &treename, const std::string &branchname)
| Constructor with tree name.
bool | skip (const int) override
| skip events
bool | read_event (GenEvent &evt) override
| Read event from file.
void | close () override
| Close file.
bool | failed () override
| Get file error state.
virtual std::shared_ptr< GenRunInfo > | run_info () const
| Get the global GenRunInfo object.
virtual void | set_options (const std::map< std::string, std::string > &options)
| Set options.
virtual std::map< std::string, std::string > | get_options () const
| Get options.
virtual void | set_run_info (std::shared_ptr< GenRunInfo > run)
| Set the global GenRunInfo object.

## Data Fields
TTree * | m_tree = nullptr
| Tree handler. Public to allow simple access, e.g. custom branches.

## Protected Attributes
std::map< std::string, std::string > | m_options
| Options.

## Private Member Functions
bool | init ()
| init routine

## Private Attributes
TFile * | m_file = nullptr
| File handler.
int | m_events_count = 0
| Events count. Needed to read the tree.
GenEventData * | m_event_data = nullptr
| Pointer to structure that holds event data.
GenRunInfoData * | m_run_info_data = nullptr
| Pointer to structure that holds run info data.
std::string | m_tree_name
| Name of TTree.
std::string | m_branch_name
| Name of TBranch in TTree.
std::shared_ptr< GenRunInfo > | m_run_info
| The global GenRunInfo object.

## Constructor & Destructor Documentation

## ◆ ReaderRootTree() [1/2]

ReaderRootTree | ( | const std::string & | filename | ) |

Default constructor.

Definition at line 18 of file ReaderRootTree.cc.

References init(), m_branch_name, m_file, m_tree_name, and ReaderRootTree().

## ◆ ReaderRootTree() [2/2]

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

Constructor with tree name.

Definition at line 26 of file ReaderRootTree.cc.

References init(), m_branch_name, m_file, and m_tree_name.

## Member Function Documentation

## ◆ close()

void close | ( |  | ) |
| overridevirtual

Close file.

Implements Reader.

Definition at line 112 of file ReaderRootTree.cc.

References m_file.

## ◆ failed()

bool failed | ( |  | ) |
| overridevirtual

Get file error state.

Implements Reader.

Definition at line 117 of file ReaderRootTree.cc.

References m_events_count, m_file, and m_tree.

## ◆ get_options()

virtual std::map< std::string, std::string > get_options | ( |  | ) | const
| inlinevirtualinherited

Get options.

Reimplemented in ReaderPlugin.

Definition at line 53 of file Reader.h.

References m_options.

## ◆ init()

bool init | ( |  | ) |
| private

init routine

Definition at line 33 of file ReaderRootTree.cc.

References HEPMC3_ERROR_LEVEL, HEPMC3_WARNING_LEVEL, m_branch_name, m_event_data, m_file, m_run_info_data, m_tree, m_tree_name, and Reader::set_run_info().

## ◆ read_event()

bool read_event | ( | GenEvent & | evt | ) |
| overridevirtual

Read event from file.

Parameters

  [out] | evt | Contains parsed event

Implements Reader.

Definition at line 84 of file ReaderRootTree.cc.

References m_event_data, m_events_count, m_run_info_data, m_tree, GenEvent::read_data(), Reader::run_info(), and GenEvent::set_run_info().

## ◆ run_info()

virtual std::shared_ptr< GenRunInfo > run_info | ( |  | ) | const
| inlinevirtualinherited

Get the global GenRunInfo object.

Reimplemented in ReaderGZ< T >, and ReaderPlugin.

Examples
  LHEF_example_cat.cc.

Definition at line 44 of file Reader.h.

References m_run_info.

## ◆ set_options()

virtual void set_options | ( | const std::map< std::string, std::string > & | options | ) |
| inlinevirtualinherited

Set options.

Reimplemented in ReaderPlugin.

Definition at line 51 of file Reader.h.

References m_options.

## ◆ set_run_info()

virtual void set_run_info | ( | std::shared_ptr< GenRunInfo > | run | ) |
| inlinevirtualinherited

Set the global GenRunInfo object.

Reimplemented in ReaderGZ< T >, and ReaderPlugin.

Definition at line 56 of file Reader.h.

References m_run_info.

## ◆ skip()

bool skip | ( | const int | n | ) |
| overridevirtual

skip events

Reimplemented from Reader.

Definition at line 76 of file ReaderRootTree.cc.

References m_events_count, and m_tree.

## Field Documentation

## ◆ m_branch_name

std::string m_branch_name
| private

Name of TBranch in TTree.

Definition at line 80 of file ReaderRootTree.h.

## ◆ m_event_data

GenEventData* m_event_data = nullptr
| private

Pointer to structure that holds event data.

Definition at line 77 of file ReaderRootTree.h.

## ◆ m_events_count

int m_events_count = 0
| private

Events count. Needed to read the tree.

Definition at line 76 of file ReaderRootTree.h.

## ◆ m_file

TFile* m_file = nullptr
| private

File handler.

Definition at line 72 of file ReaderRootTree.h.

## ◆ m_options

std::map<std::string, std::string> m_options
| protectedinherited

Options.

Definition at line 60 of file Reader.h.

## ◆ m_run_info

std::shared_ptr<GenRunInfo> m_run_info
| privateinherited

The global GenRunInfo object.

Definition at line 63 of file Reader.h.

## ◆ m_run_info_data

GenRunInfoData* m_run_info_data = nullptr
| private

Pointer to structure that holds run info data.

Definition at line 78 of file ReaderRootTree.h.

## ◆ m_tree

TTree* m_tree = nullptr

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

Definition at line 74 of file ReaderRootTree.h.

## ◆ m_tree_name

std::string m_tree_name
| private

Name of TTree.

Definition at line 79 of file ReaderRootTree.h.

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

- ReaderRootTree.h
- ReaderRootTree.cc