HepMC3 event record library
WriterRootTreeOPAL.cc
1 // -*- C++ -*-
2 //
3 #include "WriterRootTreeOPAL.h"
4 #include "TTree.h"
5 namespace HepMC3
6 {
7 WriterRootTreeOPAL::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 {
16  m_Ievnt=evt.event_number();
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
void write_event(const GenEvent &evt)
Write event.
int event_number() const
Get event number.
Definition: GenEvent.h:135
TTree * m_tree
Tree handler. Public to allow simple access, e.g. custom branches.
void set_run_number(const int nr)
Set run number.
void write_event(const GenEvent &evt) override
Write event to file.
float m_Ebeam
Beam energy in GEV.
Stores event-related information.
Definition: GenEvent.h:41
WriterRootTreeOPAL(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
Constructor.
GenEvent I/O serialization for root files based on root TTree.
void init_branches()
Init ROOT branches.
Definition of class WriterRootTreeOPAL.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Definition: GenEvent.cc:39
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you&#39;d expect. If foo is a valid Feature...
Definition: Feature.h:316