13#include "HepMC3/Version.h"
20HEPMC3_DECLARE_WRITER_FILE(WriterRootTree)
25 m_tree_name("hepmc3_tree"),
26 m_branch_name("hepmc3_event")
28 m_file = TFile::Open(filename.c_str(),
"RECREATE");
29 if (!init(run))
return;
35 m_tree_name(treename.c_str()),
36 m_branch_name(branchname.c_str())
38 m_file = TFile::Open(filename.c_str(),
"RECREATE");
39 if (!
init(run))
return;
61 if ( !
m_file->IsOpen() )
return;
103 if ( !
m_file->IsOpen() )
return true;
#define HEPMC3_ERROR(MESSAGE)
Macro for printing error messages.
Definition of class WriterRootTree.
Stores event-related information.
void write_data(GenEventData &data) const
Fill GenEventData object.
std::shared_ptr< GenRunInfo > run_info() const
Get a pointer to the the GenRunInfo object.
Stores run-related information.
GenEvent I/O serialization for root files based on root TTree.
TTree * m_tree
Tree handler. Public to allow simple access, e.g. custom branches.
bool failed() override
Get stream error state flag.
WriterRootTree(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
Default constructor.
GenEventData * m_event_data
Pointer to structure that holds event data.
int m_events_count
Events count. Needed to read the tree.
void close() override
Close file stream.
bool init(std::shared_ptr< GenRunInfo > run)
init routine
std::string m_tree_name
Name of TTree.
std::string m_branch_name
Name of TBranch in TTree.
TFile * m_file
File handler.
GenRunInfoData * m_run_info_data
Pointer to structure that holds run info data.
void write_event(const GenEvent &evt) override
Write event to file.
void write_run_info()
Write the GenRunInfo object to file.
std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Stores serializable event information.
std::vector< GenVertexData > vertices
Vertices.
std::vector< int > links2
Second id of the vertex links.
std::vector< std::string > attribute_string
Attribute serialized as string.
std::vector< GenParticleData > particles
Particles.
std::vector< int > links1
First id of the vertex links.
std::vector< std::string > attribute_name
Attribute name.
std::vector< int > attribute_id
Attribute owner id.
Stores serializable run information.
std::vector< std::string > tool_name
Tool names.
std::vector< std::string > tool_version
Tool versions.
std::vector< std::string > attribute_string
Attribute serialized as string.
std::vector< std::string > attribute_name
Attribute name.
std::vector< std::string > tool_description
Tool descriptions.
std::vector< std::string > weight_names
Weight names.