ATLAS Offline Software
Loading...
Searching...
No Matches
TruthEtIsolations.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// TruthEtIsolations.cxx
7// Implementation file for class TruthEtIsolations
8// Author: S.Binet<binet@cern.ch>
10
11
12// STL includes
13#include <sstream>
14#include <ostream>
15#include <iomanip>
16#include <stdexcept>
17
18// CLHEP includes
19#include "CLHEP/Units/SystemOfUnits.h"
21#include "AtlasHepMC/GenEvent.h"
24
25// McParticleEvent includes
27
30
32 {
33 -999.*CLHEP::GeV, -999.*CLHEP::GeV, -999.*CLHEP::GeV, -999.*CLHEP::GeV,
34 -999.*CLHEP::GeV, -999.*CLHEP::GeV, -999.*CLHEP::GeV, -999.*CLHEP::GeV
35 }
36};
37
38
40// Public methods:
42
43// Constructors
49
54
55
57 m_genEvtLink ( genEvtLink ),
59{}
60
61TruthEtIsolations::TruthEtIsolations( const std::string& genEvtName,
62 const std::size_t genEvtIdx ) :
63 m_genEvtLink ( genEvtName, genEvtIdx ),
65{}
66
69{
70 if ( this != &rhs ) {
73 }
74 return *this;
75}
76
77// Destructor
79
82
84// Const methods:
86
87const std::string& TruthEtIsolations::genEventName() const
88{
89 return m_genEvtLink.dataID();
90}
91
93{
94 return m_genEvtLink.index();
95}
96
97bool
99{
100 return ( 0 == p )
101 ? false
103}
104
107{
108 return ( 0 == p )
109 ? 0
111}
112
113double
115 const TruthParticleParameters::ConeSize idx ) const
116{
117 return ( 0 == p )
118 ? m_dfltEtIsols[idx]
119 : etIsol( HepMC::barcode(p), idx );
120}
121
123// Non-const methods:
125
126void
129 const double etIsol )
130{
131 m_etIsolations[HepMC::barcode(genParticle)][coneIdx] = etIsol;
132}
133
134void
136 const std::vector<double>& etIsols )
137{
138 EtIsol_t& et = m_etIsolations[HepMC::barcode(genParticle)];
139 for ( std::size_t i = 0, iMax = std::min<std::size_t>( etIsols.size(), TruthParticleParameters::NbrOfCones ); i != iMax;++i ) {
140 et[i] = etIsols[i];
141 }
142
143 return;
144}
145
146void
148 const EtIsol_t& etIsols )
149{
150 m_etIsolations[HepMC::barcode(genParticle)] = etIsols;
151}
152
154// I/O functions
156std::ostream&
157operator<<( std::ostream& out, const TruthEtIsolations& etIsols )
158{
159 const std::size_t nEtIsols = etIsols.size();
160 out << "nbr of EtIsols: " << nEtIsols;
161 std::ostringstream buf;
162 buf << std::right << std::scientific << std::setprecision(8);
163 for ( TruthEtIsolations::const_iterator i = etIsols.begin(), iEnd = etIsols.end(); i != iEnd; ++i ) {
164 buf.str("");
165 buf << "\nbc: " << i->first << " [ ";
166 std::copy( i->second.begin(), i->second.end(), std::ostream_iterator<double>( buf, " " ) );
167 out << buf.str() << "]";
168 }
169 return out;
170}
171
TruthEtIsolations::GenEventLink_t GenEventLink_t
TruthEtIsolations::EtIsol_t EtIsol_t
std::ostream & operator<<(std::ostream &out, const TruthEtIsolations &etIsols)
container which holds isolation informations for a given HepMC::GenParticle (labelled by barcode) for...
double etIsol(const HepMC::ConstGenParticlePtr &genParticle, const TruthParticleParameters::ConeSize coneIdx) const
Return the transverse energy in a given cone size of isolation, for a given HepMC::GenParticle.
TruthEtIsolations()
Default constructor.
static const EtIsol_t m_dfltEtIsols
The default Et isolation energy which is being returned when I don't know what to return.
std::size_t size() const
Return the number of HepMC::GenParticle for which Et isolations have been stored into this TruthEtIso...
bool hasEtIsol(const HepMC::ConstGenParticlePtr &genParticle) const
Return true if this TruthEtIsolations container holds Et isolations for that HepMC::GenParticle.
std::size_t genEventIdx() const
Return the index in the McEventCollection container holding the HepMC::GenEvent from which the Et iso...
~TruthEtIsolations()
Default destructor:
ElementLink< McEventCollection > GenEventLink_t
A (persistent) link to a HepMC::GenEvent.
EtIsolMap_t::const_iterator const_iterator
The iterator over the map of barcode-to-Et-isolations.
const EtIsol_t * etIsolations(const HepMC::ConstGenParticlePtr &genParticle) const
Return the transverse energies for all cone sizes of isolation, for a given HepMC::GenParticle's barc...
const_iterator end() const
Const iterator over the barcodes of the HepMC::GenParticle for which we have Et isolations computed.
const_iterator begin() const
Const iterator over the barcodes of the HepMC::GenParticle for which we have Et isolations computed.
const std::string & genEventName() const
Return the name (ie: the StoreGate key) of the McEventCollection holding the HepMC::GenEvent from whi...
GenEventLink_t m_genEvtLink
ElementLink to the HepMC::GenEvent from which the Et isolations have been (or will be) computed
void setEtIsol(const HepMC::ConstGenParticlePtr &genParticle, const TruthParticleParameters::ConeSize coneIdx, const double etIsol)
Set the transverse energy isolation of a HepMC::GenParticle for a given Cone size.
McAod::EtIsolations EtIsol_t
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
EtIsolMap_t m_etIsolations
Holds transverse energy isolations for different isolation cones The key of this map is the barcode o...
TruthEtIsolations & operator=(const TruthEtIsolations &rhs)
Assignment operator.
int barcode(const T *p)
Definition Barcode.h:16
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
ConeSize
Enum for Cone size indexes (for isolation)
Extra patterns decribing particle interation process.