ATLAS Offline Software
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"
20 #include "AtlasHepMC/GenParticle.h"
21 #include "AtlasHepMC/GenEvent.h"
22 #include "AtlasHepMC/GenVertex.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
46  m_genEvtLink ( ),
47  m_etIsolations ( )
48 {}
49 
51  m_genEvtLink ( rhs.m_genEvtLink ),
52  m_etIsolations ( rhs.m_etIsolations )
53 {}
54 
55 
57  m_genEvtLink ( genEvtLink ),
58  m_etIsolations ( )
59 {}
60 
61 TruthEtIsolations::TruthEtIsolations( const std::string& genEvtName,
62  const std::size_t genEvtIdx ) :
63  m_genEvtLink ( genEvtName, genEvtIdx ),
64  m_etIsolations( )
65 {}
66 
69 {
70  if ( this != &rhs ) {
73  }
74  return *this;
75 }
76 
77 // Destructor
79 
81 {}
82 
84 // Const methods:
86 
87 const std::string& TruthEtIsolations::genEventName() const
88 {
89  return m_genEvtLink.dataID();
90 }
91 
92 std::size_t TruthEtIsolations::genEventIdx() const
93 {
94  return m_genEvtLink.index();
95 }
96 
97 bool
99 {
100  return ( 0 == p )
101  ? false
102  : hasEtIsol( HepMC::barcode(p) );
103 }
104 
107 {
108  return ( 0 == p )
109  ? 0
111 }
112 
113 double
116 {
117  return ( 0 == p )
118  ? m_dfltEtIsols[idx]
119  : etIsol( HepMC::barcode(p), idx );
120 }
121 
123 // Non-const methods:
125 
126 void
128  const TruthParticleParameters::ConeSize coneIdx,
129  const double etIsol )
130 {
131  m_etIsolations[HepMC::barcode(genParticle)][coneIdx] = etIsol;
132 }
133 
134 void
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 
146 void
148  const EtIsol_t& etIsols )
149 {
150  m_etIsolations[HepMC::barcode(genParticle)] = etIsols;
151 }
152 
154 // I/O functions
156 std::ostream&
157 operator<<( 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 
et
Extra patterns decribing particle interation process.
TruthParticleParameters::NbrOfCones
@ NbrOfCones
Definition: TruthParticleParamDefs.h:31
GenEvent.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TruthEtIsolations::m_genEvtLink
GenEventLink_t m_genEvtLink
ElementLink to the HepMC::GenEvent from which the Et isolations have been (or will be) computed
Definition: TruthEtIsolations.h:200
GenVertex.h
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
TruthEtIsolations::~TruthEtIsolations
~TruthEtIsolations()
Default destructor:
Definition: TruthEtIsolations.cxx:80
TruthEtIsolations::EtIsol_t
McAod::EtIsolations EtIsol_t
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
Definition: TruthEtIsolations.h:52
TruthEtIsolations::genEventIdx
std::size_t genEventIdx() const
Return the index in the McEventCollection container holding the HepMC::GenEvent from which the Et iso...
Definition: TruthEtIsolations.cxx:92
TruthEtIsolations::setEtIsol
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.
Definition: TruthEtIsolations.cxx:127
TruthEtIsolations::m_etIsolations
EtIsolMap_t m_etIsolations
Holds transverse energy isolations for different isolation cones The key of this map is the barcode o...
Definition: TruthEtIsolations.h:205
TruthParticleParameters::ConeSize
ConeSize
Enum for Cone size indexes (for isolation)
Definition: TruthParticleParamDefs.h:20
TruthEtIsolations::genEventName
const std::string & genEventName() const
Return the name (ie: the StoreGate key) of the McEventCollection holding the HepMC::GenEvent from whi...
Definition: TruthEtIsolations.cxx:87
TruthEtIsolations::hasEtIsol
bool hasEtIsol(const HepMC::ConstGenParticlePtr &genParticle) const
Return true if this TruthEtIsolations container holds Et isolations for that HepMC::GenParticle.
Definition: TruthEtIsolations.cxx:98
GenParticle.h
TruthEtIsolations.h
TruthEtIsolations::etIsol
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.
Definition: TruthEtIsolations.cxx:114
TruthEtIsolations::operator=
TruthEtIsolations & operator=(const TruthEtIsolations &rhs)
Assignment operator.
Definition: TruthEtIsolations.cxx:68
McEventCollection.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
TruthEtIsolations::m_dfltEtIsols
static const EtIsol_t m_dfltEtIsols
The default Et isolation energy which is being returned when I don't know what to return.
Definition: TruthEtIsolations.h:210
TruthEtIsolations::size
std::size_t size() const
Return the number of HepMC::GenParticle for which Et isolations have been stored into this TruthEtIso...
Definition: TruthEtIsolations.h:223
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
GenEventLink_t
TruthEtIsolations::GenEventLink_t GenEventLink_t
Definition: TruthEtIsolations.cxx:28
TruthEtIsolations::const_iterator
EtIsolMap_t::const_iterator const_iterator
The iterator over the map of barcode-to-Et-isolations.
Definition: TruthEtIsolations.h:58
TruthEtIsolations::TruthEtIsolations
TruthEtIsolations()
Default constructor.
Definition: TruthEtIsolations.cxx:45
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
TruthEtIsolations::begin
const_iterator begin() const
Const iterator over the barcodes of the HepMC::GenParticle for which we have Et isolations computed.
Definition: TruthEtIsolations.h:249
TruthEtIsolations
Definition: TruthEtIsolations.h:40
TruthEtIsolations::etIsolations
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...
Definition: TruthEtIsolations.cxx:106
TruthEtIsolations::end
const_iterator end() const
Const iterator over the barcodes of the HepMC::GenParticle for which we have Et isolations computed.
Definition: TruthEtIsolations.h:252
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
calibdata.copy
bool copy
Definition: calibdata.py:27
operator<<
std::ostream & operator<<(std::ostream &out, const TruthEtIsolations &etIsols)
Definition: TruthEtIsolations.cxx:157
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
EtIsol_t
TruthEtIsolations::EtIsol_t EtIsol_t
Definition: TruthEtIsolations.cxx:29