HepMC3 event record library
|
GenEvent I/O serialization for root files based on root TTree. More...
#include <WriterRootTree.h>
Public Member Functions | |
WriterRootTree (const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >()) | |
Default constructor. More... | |
WriterRootTree (const std::string &filename, const std::string &treename, const std::string &branchname, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >()) | |
Constructor with tree name. More... | |
void | write_event (const GenEvent &evt) override |
Write event to file. More... | |
void | write_run_info () |
Write the GenRunInfo object to file. More... | |
void | close () override |
Close file stream. More... | |
bool | failed () override |
Get stream error state flag. More... | |
void | set_run_info (std::shared_ptr< GenRunInfo > run) |
Set the global GenRunInfo object. More... | |
std::shared_ptr< GenRunInfo > | run_info () const |
Get the global GenRunInfo object. More... | |
void | set_options (const std::map< std::string, std::string > &options) |
Set options. More... | |
std::map< std::string, std::string > | get_options () const |
Set options. More... | |
Data Fields | |
TTree * | m_tree |
Tree handler. Public to allow simple access, e.g. custom branches. More... | |
Protected Attributes | |
std::map< std::string, std::string > | m_options |
options More... | |
Private Member Functions | |
bool | init (std::shared_ptr< GenRunInfo > run) |
init routine More... | |
Private Attributes | |
TFile * | m_file |
File handler. More... | |
int | m_events_count |
Events count. Needed to read the tree. More... | |
GenEventData * | m_event_data |
Pointer to structure that holds event data. More... | |
GenRunInfoData * | m_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... | |
GenEvent I/O serialization for root files based on root TTree.
If HepMC was compiled with path to ROOT available, this class can be used for root writing in the same manner as with HepMC::WriterAscii class.
Definition at line 38 of file WriterRootTree.h.
WriterRootTree | ( | const std::string & | filename, |
std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() |
||
) |
Default constructor.
Definition at line 22 of file WriterRootTree.cc.
WriterRootTree | ( | const std::string & | filename, |
const std::string & | treename, | ||
const std::string & | branchname, | ||
std::shared_ptr< GenRunInfo > | run = std::shared_ptr<GenRunInfo>() |
||
) |
Constructor with tree name.
Definition at line 32 of file WriterRootTree.cc.
References WriterRootTree::init(), and WriterRootTree::m_file.
|
overridevirtual |
Close file stream.
Implements Writer.
Definition at line 93 of file WriterRootTree.cc.
References WriterRootTree::m_event_data, WriterRootTree::m_file, WriterRootTree::m_run_info_data, and WriterRootTree::m_tree.
|
overridevirtual |
Get stream error state flag.
Implements Writer.
Definition at line 102 of file WriterRootTree.cc.
References WriterRootTree::m_file.
|
inlineinherited |
|
private |
init routine
Definition at line 42 of file WriterRootTree.cc.
References HEPMC3_ERROR, WriterRootTree::m_branch_name, WriterRootTree::m_event_data, WriterRootTree::m_file, WriterRootTree::m_run_info_data, WriterRootTree::m_tree, WriterRootTree::m_tree_name, Writer::run_info(), and Writer::set_run_info().
|
inlineinherited |
Get the global GenRunInfo object.
Definition at line 47 of file Writer.h.
References Writer::m_run_info.
|
inlineinherited |
|
inlineinherited |
Set the global GenRunInfo object.
Definition at line 42 of file Writer.h.
References Writer::m_run_info.
|
overridevirtual |
Write event to file.
[in] | evt | Event to be serialized |
Implements Writer.
Definition at line 59 of file WriterRootTree.cc.
References GenEventData::attribute_id, GenRunInfoData::attribute_name, GenEventData::attribute_name, GenRunInfoData::attribute_string, GenEventData::attribute_string, GenEventData::links1, GenEventData::links2, WriterRootTree::m_event_data, WriterRootTree::m_events_count, WriterRootTree::m_file, WriterRootTree::m_run_info_data, WriterRootTree::m_tree, GenEventData::particles, Writer::run_info(), GenEvent::run_info(), Writer::set_run_info(), GenRunInfoData::tool_description, GenRunInfoData::tool_name, GenRunInfoData::tool_version, GenEventData::vertices, GenRunInfoData::weight_names, and GenEvent::write_data().
void write_run_info | ( | ) |
Write the GenRunInfo object to file.
Definition at line 91 of file WriterRootTree.cc.
|
private |
Name of TBranch in TTree.
Definition at line 87 of file WriterRootTree.h.
|
private |
Pointer to structure that holds event data.
Definition at line 84 of file WriterRootTree.h.
|
private |
Events count. Needed to read the tree.
Definition at line 83 of file WriterRootTree.h.
|
private |
File handler.
Definition at line 79 of file WriterRootTree.h.
|
protectedinherited |
|
private |
Pointer to structure that holds run info data.
Definition at line 85 of file WriterRootTree.h.
TTree* m_tree |
Tree handler. Public to allow simple access, e.g. custom branches.
Definition at line 81 of file WriterRootTree.h.
|
private |
Name of TTree.
Definition at line 86 of file WriterRootTree.h.