23 m_tree_name(
"hepmc3_tree"),
24 m_branch_name(
"hepmc3_event")
26 m_file = TFile::Open(filename.c_str(),
"RECREATE");
27 if (!
init(run))
return;
33 m_tree_name(treename.c_str()),
34 m_branch_name(branchname.c_str())
36 m_file = TFile::Open(filename.c_str(),
"RECREATE");
37 if (!
init(run))
return;
44 ERROR(
"WriterRootTree: problem opening file: " <<
m_file->GetName() )
51 m_tree=
new TTree(m_tree_name.c_str(),
"hepmc3_tree");
52 m_tree->Branch(m_branch_name.c_str(), m_event_data);
53 m_tree->Branch(
"GenRunInfo", m_run_info_data);
59 if ( !
m_file->IsOpen() )
return;
70 run_info()->write_data(*m_run_info_data);
77 m_event_data->
links1.clear();
78 m_event_data->
links2.clear();
97 delete m_run_info_data;
102 if ( !
m_file->IsOpen() )
return true;
std::vector< int > attribute_id
Attribute owner id.
#define ERROR(MESSAGE)
Macro for printing error messages.
std::vector< std::string > attribute_name
Attribute name.
std::vector< int > links2
Second id of the vertex links.
Definition of class WriterRootTree.
void close()
Close file stream.
shared_ptr< GenRunInfo > run_info() const
Get a pointer to the the GenRunInfo object.
TTree * m_tree
Tree handler. Public to allow simple access, e.g. custom branches.
void write_event(const GenEvent &evt)
Write event to file.
std::vector< int > links1
First id of the vertex links.
std::vector< std::string > attribute_string
Attribute serialized as string.
shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
int m_events_count
Events count. Needed to read the tree.
Stores event-related information.
Stores serializable event information.
void write_data(GenEventData &data) const
Fill GenEventData object.
std::vector< std::string > attribute_string
Attribute serialized as string.
std::vector< std::string > tool_name
Tool names.
std::vector< std::string > attribute_name
Attribute name.
Stores serializable run information.
bool failed()
Get stream error state flag.
bool init(shared_ptr< GenRunInfo > run)
init routine
void set_run_info(shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
std::vector< GenParticleData > particles
Particles.
WriterRootTree(const std::string &filename, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >())
Default constructor.
TFile * m_file
File handler.
std::vector< GenVertexData > vertices
Vertices.
std::vector< std::string > tool_version
Tool versions.
void write_run_info()
Write the GenRunInfo object to file.
std::vector< std::string > weight_names
Weight names.
std::vector< std::string > tool_description
Tool descriptions.