HepMC3 event record library
WriterRootTreeOPAL.cc
1// -*- C++ -*-
2//
4#include "TTree.h"
5namespace HepMC3
6{
7WriterRootTreeOPAL::WriterRootTreeOPAL(const std::string &filename,std::shared_ptr<GenRunInfo> run):WriterRootTree::WriterRootTree(filename,"h10","h10",run) {}
9{
10 m_tree->Branch("Irun", &m_Irun);
11 m_tree->Branch("Ievnt", &m_Ievnt);
12 m_tree->Branch("Ebeam",&m_Ebeam);
13}
15{
17 std::vector<size_t> beams;
18 for (size_t i=0; i<evt.particles().size(); i++)
19 if (evt.particles().at(i)->status()==4&&std::abs(evt.particles().at(i)->pid())==11)
20 beams.push_back(i);
21
22 if (beams.size()==2)
23 m_Ebeam=std::abs(evt.particles().at(beams[0])->momentum().e());
24 else
25 m_Ebeam=std::abs(evt.particles().at(0)->momentum().e());
27}
29} // namespace HepMC3
Definition of class WriterRootTreeOPAL.
Stores event-related information.
Definition: GenEvent.h:41
int event_number() const
Get event number.
Definition: GenEvent.h:148
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Definition: GenEvent.cc:39
float m_Ebeam
Beam energy in GEV.
void set_run_number(const int nr)
Set run number.
void init_branches()
Init ROOT branches.
WriterRootTreeOPAL(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
Constructor.
void write_event(const GenEvent &evt)
Write event.
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.
void write_event(const GenEvent &evt) override
Write event to file.
HepMC3 main namespace.