15 m_file(filename.c_str(),
"RECREATE"),
18 m_tree_name(
"hepmc3_tree"),
19 m_branch_name(
"hepmc3_event")
21 if (!
init(run))
return;
25 m_file(filename.c_str(),
"RECREATE"),
28 m_tree_name(treename.c_str()),
29 m_branch_name(branchname.c_str())
31 if (!
init(run))
return;
38 ERROR(
"WriterRootTree: problem opening file: " <<
m_file.GetName() )
43 m_tree=
new TTree(m_tree_name.c_str(),
"hepmc3_tree");
44 m_tree->Branch(m_branch_name.c_str(), m_event_data);
51 if ( !
m_file.IsOpen() )
return;
58 WARNING(
"WriterAscii::write_event: GenEvents contain " 59 "different GenRunInfo objects from - only the " 60 "first such object will be serialized." )
67 m_event_data->
links1.clear();
68 m_event_data->
links2.clear();
85 int nbytes =
m_file.WriteObject(&data,
"GenRunInfoData");
88 ERROR(
"WriterRootTree: error writing GenRunInfo")
103 if ( !
m_file.IsOpen() )
return true;
TTree * m_tree
Tree handler. Public to allow simple access, e.g. custom branches.
std::vector< std::string > attribute_string
Attribute serialized as string.
std::vector< int > links1
First id of the vertex links.
bool init(shared_ptr< GenRunInfo > run)
init routine
void close()
Close file stream.
void set_run_info(shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
Stores serializable run information.
TFile m_file
File handler.
Definition of class WriterRootTree.
std::vector< GenVertexData > vertices
Vertices.
int m_events_count
Events count. Needed to read the tree.
shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
shared_ptr< GenRunInfo > run_info() const
Get a pointer to the the GenRunInfo object.
Stores event-related information.
std::vector< int > attribute_id
Attribute owner id.
std::vector< int > links2
Second id of the vertex links.
void write_run_info()
Write the GenRunInfo object to file.
std::vector< std::string > attribute_name
Attribute name.
Definition of template class SmartPointer.
std::vector< GenParticleData > particles
Particles.
bool failed()
Get stream error state flag.
WriterRootTree(const std::string &filename, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >())
Default constructor.
void write_event(const GenEvent &evt)
Write event to file.
Stores serializable event information.
void write_data(GenEventData &data) const
Fill GenEventData object.