HepMC3 event record library
examples
ConvertExample
src
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) {}
8
void
WriterRootTreeOPAL::init_branches
()
9
{
10
m_tree
->Branch(
"Irun"
, &
m_Irun
);
11
m_tree
->Branch(
"Ievnt"
, &
m_Ievnt
);
12
m_tree
->Branch(
"Ebeam"
,&
m_Ebeam
);
13
}
14
void
WriterRootTreeOPAL::write_event
(
const
GenEvent
&evt)
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());
26
WriterRootTree::write_event
(evt);
27
}
28
void
WriterRootTreeOPAL::set_run_number
(
const
int
nr) {
m_Irun
=nr;}
29
}
// namespace HepMC3
HepMC3::WriterRootTreeOPAL::set_run_number
void set_run_number(const int nr)
Set run number.
Definition:
WriterRootTreeOPAL.cc:28
HepMC3::GenEvent::event_number
int event_number() const
Get event number.
Definition:
GenEvent.h:135
HepMC3::GenEvent
Stores event-related information.
Definition:
GenEvent.h:41
HepMC3
HepMC3 main namespace.
Definition:
AnalysisExample.h:19
HepMC3::WriterRootTree::m_tree
TTree * m_tree
Tree handler. Public to allow simple access, e.g. custom branches.
Definition:
WriterRootTree.h:81
HepMC3::abs
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you'd expect. If foo is a valid Feature,...
Definition:
Feature.h:316
HepMC3::WriterRootTreeOPAL::m_Irun
int m_Irun
Run number.
Definition:
WriterRootTreeOPAL.h:31
HepMC3::WriterRootTreeOPAL::init_branches
void init_branches()
Init ROOT branches.
Definition:
WriterRootTreeOPAL.cc:8
HepMC3::WriterRootTree::write_event
void write_event(const GenEvent &evt) override
Write event to file.
Definition:
WriterRootTree.cc:59
HepMC3::WriterRootTreeOPAL::m_Ievnt
int m_Ievnt
Event number.
Definition:
WriterRootTreeOPAL.h:32
HepMC3::GenEvent::particles
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Definition:
GenEvent.cc:39
WriterRootTreeOPAL.h
Definition of class WriterRootTreeOPAL.
HepMC3::WriterRootTreeOPAL::m_Ebeam
float m_Ebeam
Beam energy in GEV.
Definition:
WriterRootTreeOPAL.h:30
HepMC3::WriterRootTree
GenEvent I/O serialization for root files based on root TTree.
Definition:
WriterRootTree.h:39
HepMC3::WriterRootTreeOPAL::WriterRootTreeOPAL
WriterRootTreeOPAL(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
Constructor.
Definition:
WriterRootTreeOPAL.cc:7
HepMC3::WriterRootTreeOPAL::write_event
void write_event(const GenEvent &evt)
Write event.
Definition:
WriterRootTreeOPAL.cc:14
Generated on Tue Jul 14 2020 00:00:00 for HepMC3 event record library by
1.8.18