ATLAS Offline Software
Loading...
Searching...
No Matches
Egamma_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
7// Local include(s):
10#include "EgammaAccessors_v1.h"
14#include <format>
15#include <stdexcept>
16
17#include <Math/GenVector/PtEtaPhiM4D.h>
18
19namespace xAOD {
20
21namespace MatrixHelpers{
22//Can not use the template in the EventPrimitiveHelpers
23//Too specialized (i.e only double cov matrices not float)
24//Write a more "general" one (hopefully will makes its way).
25
26template <int N>
27
28void compress(const Eigen::Matrix<float,N,N,0,N,N>& covMatrix, std::vector<float>& vec ) {
30 for (unsigned int i = 0; i < N ; ++i){
31 for (unsigned int j = 0; j <= i; ++j){
32 vec.push_back(covMatrix(i,j));
33 }
34 }
35}
36template <int N>
37void expand(std::vector<float>::const_iterator it,
38 std::vector<float>::const_iterator, Eigen::Matrix<float,N,N,0,N,N>& covMatrix) {
39 for (unsigned int i = 0; i < N; ++i) {
40 for (unsigned int j = 0; j <= i; ++j) {
41 covMatrix.fillSymmetric(i,j, *it);
42 ++it;
43 }
44 }
45}
46}
47
51
52Egamma_v1::Egamma_v1(const Egamma_v1& eg) = default;
53
55
56 if (this != &eg){ // protect against invalid self-assignment
57 if (!this->container() && !this->hasStore() ) {
59 }
60 this->IParticle::operator=( eg );
61 }
62 // by convention, always return *this
63 return *this;
64}
65
66double Egamma_v1::pt() const {
67 static const Accessor< float > acc( "pt" );
68 return acc(*this);
69}
70
71double Egamma_v1::eta() const {
72 static const Accessor<float > acc( "eta" );
73 return acc(*this);
74}
75
76double Egamma_v1::phi() const {
77 static const Accessor< float > acc( "phi" );
78 return acc(*this);
79}
80
85
86double Egamma_v1::e() const{
87 return genvecP4().E();
88}
89
90double Egamma_v1::rapidity() const {
91 return genvecP4().Rapidity();
92}
93
96 p4.SetPtEtaPhiM( pt(), eta(), phi(),m());
97 return p4;
98}
99
100void Egamma_v1::setPtEtaPhi(float pt, float eta, float phi){
101 static const Accessor< float > acc1( "pt" );
102 acc1(*this) = pt;
103 static const Accessor< float > acc2( "eta" );
104 acc2(*this) = eta;
105 static const Accessor< float > acc3( "phi" );
106 acc3(*this) = phi;
107}
108
110 static const Accessor< float > acc( "pt" );
111 acc(*this) = pt;
112}
113
115 static const Accessor< float > acc( "eta" );
116 acc(*this) = eta;
117}
118
120 static const Accessor< float > acc( "phi" );
121 acc(*this) = phi;
122}
123
125
126 static const Accessor< std::vector<float> > acc( "EgammaCovarianceMatrix" );
128 cov.setZero();
129
130 if(!acc.isAvailable(*this) ) {
131 return cov;
132 }
133 const std::vector<float>& v = acc(*this);
134 size_t size= v.size();
135 if(size==16){
136 //up to 21.0.11
137 cov = Eigen::Map<const EgammaCovMatrix_t> (v.data());
138 }
139 else {
140 //from >21.0.11
142 MatrixHelpers::expand(v.begin(),v.end(),cov );
143 }
144 return cov;
145}
146
148 //The internal storage is an std::vector
149 static const Accessor< std::vector < float > > acc( "EgammaCovarianceMatrix" );
150 //from >21.0.11
151 MatrixHelpers::compress(cov,acc(*this));
152}
153
156 static const Accessor< uint16_t > acc( "author" );
157 uint16_t author = acc(*this);
158 return author & mask;
159}
160
162 static const Accessor< uint16_t > acc( "author" );
163 uint16_t author = acc(*this);
164 acc(*this) = author | newAuthor;
165}
166
168 static const Accessor< uint16_t > acc( "author" );
169 acc(*this) = newAuthor;
170}
171
179 ambiguityLinkAcc( "ambiguityLink" );
180
183
184 if( ! ambiguityLinkAcc.isAvailable( *this ) ) {
185 return nullptr;
186 }
188 if( ! link.isValid() ) {
189 return nullptr;
190 }
191 return *link;
192}
193
194
196bool Egamma_v1::showerShapeValue(float& value, const EgammaParameters::ShowerShapeType information) const {
198 if( !acc ) {
199 return false;
200 }
201 if(!acc->isAvailable(*this) ) {
202 return false;
203 }
204 // Retrieve the value:
205 value = ( *acc )(*this);
206 return true;
207}
208
211 if(!acc ) throw std::runtime_error( "Unknown/Unavailable Shower Shape type requested" );
212 return ( *acc )(*this);
213}
214
217 if( !acc ) return false;
218 // Set the value:
219 ( *acc )(*this) = value;
220 return true;
221
222}
223
226 static const Accessor< uint32_t > acc( "OQ" );
227 uint32_t OQ = acc(*this);
228 return (OQ & mask)==0;
229}
230
232 static const Accessor< uint32_t > acc( "OQ" );
233 return acc(*this) ;
234}
235
237 static const Accessor< uint32_t > acc( "OQ" );
238 acc(*this) = newOQ;
239}
240
242bool Egamma_v1::isolation(float& value, const Iso::IsolationType information) const {
244 if( !acc ) {
245 return false;
246 }
247 if(!acc->isAvailable(*this) ) {
248 return false;
249 }
250 // Retrieve the value:
251 value = ( *acc )(*this);
252 return true;
253}
254
255float Egamma_v1::isolation( const Iso::IsolationType information) const {
257 if( !acc ) throw std::runtime_error( "Unknown/Unavailable Isolation type requested" );
258 return ( *acc )(*this);
259}
260
261bool Egamma_v1::setIsolation(float value, const Iso::IsolationType information) {
263 if( !acc ) return false;
264 // Set the value:
265 ( *acc )(*this) = value;
266 return true;
267}
268
271 const Iso::IsolationCorrectionParameter param) const{
273 if(!acc.isAvailable(*this) ) {
274 return false;
275 }
276 // Retrieve the value:
277 value = acc(*this);
278 return true;
279}
280
282 const Iso::IsolationCorrectionParameter param) const{
283
285 if( !acc.isAvailable(*this) ) {throw std::runtime_error( "Unknown/Unavailable Isolation correction requested" );}
286 return acc(*this);
287}
288
292 // Set the value:
293 acc(*this) = value;
294 return true;
295}
296
299 if(!acc.isAvailable(*this) ) {
300 return false;
301 }
302 // Retrieve the value:
303 value = acc(*this);
304 return true;
305}
306
309 if( !acc.isAvailable(*this) ) {throw std::runtime_error( "Unknown/Unavailable Isolation correction requested" );}
310 return acc(*this);
311}
312
318
321 if(!acc.isAvailable(*this) ) {
322 return false;
323 }
324 // Retrieve the value:
325 value = acc(*this);
326 return true;
327}
328
331 if( !acc.isAvailable(*this) ) {throw std::runtime_error( "Unknown/Unavailable Isolation correction requested" );}
332 return acc(*this);
333}
334
337 // Set the value:
338 acc(*this) = value;
339 return true;
340}
341
342bool Egamma_v1::isolationCorrectionBitset( std::bitset<32>& value, const Iso::IsolationFlavour flavour ) const{
344 if(!acc.isAvailable(*this) ) {
345 return false;
346 }
347 // Retrieve the value:
348 value = std::bitset<32>(acc(*this));
349 return true;
350}
351
354 if( !acc.isAvailable(*this) ) {throw std::runtime_error( "Unknown/Unavailable Isolation BitSet requested" );}
355 return {acc(*this)};
356}
357
360 // Set the value:
361 acc(*this) = value;
362 return true;
363}
364
367
369 clusterAcc( "caloClusterLinks" );
370
371 if( clusterAcc.isAvailable(*this) ) {
372 return clusterAcc(*this).size();
373 }
374 return 0;
375}
376
378
379 if( index >= nCaloClusters() ) {
380 return nullptr;
381 }
382 const CLELVec_t& cls = caloClusterLinks();
383 if( ! cls[ index ].isValid() ) {
384 return nullptr;
385 }
386 return *( cls[ index ] );
387}
388
391
392 if( index >= nCaloClusters() ) {
393 static const ElementLink< CaloClusterContainer > dummy;
394 return dummy;
395 }
396 return caloClusterLinks()[ index ];
397}
398
400 caloClusterLinks, setCaloClusterLinks)
401
402
403bool Egamma_v1::passSelection(bool& value, const std::string& menu ) const {
405 if(!acc.isAvailable(*this) ) {
406 return false;
407 }
408 value= acc(*this);
409 return true;
410}
411
412bool Egamma_v1::passSelection(const std::string& menu ) const {
414 return acc(*this);
415}
416
417void Egamma_v1::setPassSelection(bool value, const std::string& menu){
418 const SG::AuxElement::Accessor< char > acc( menu );
419 acc(*this)=value;
420}
421
422bool Egamma_v1::selectionisEM(unsigned int& value, const std::string& isEM) const{
424 if(!acc.isAvailable(*this) ) {
425 return false;
426 }
427 value= acc(*this);
428 return true;
429}
430
431unsigned int Egamma_v1::selectionisEM(const std::string& isEM) const{
433 return acc(*this);
434}
435
436void Egamma_v1::setSelectionisEM(unsigned int value, const std::string& isEM){
438 acc(*this)=value;
439}
440
441} // namespace xAOD
442
443// LocalWords: const el hasStore makePrivateStore
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
std::vector< size_t > vec
void makePrivateStore()
Create a new (empty) private store for this object.
bool hasStore() const
Return true if this object has an associated store.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
const SG::AuxVectorData * container() const
Return the container holding this element.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
make the sidebar many part of the config
Definition hcg.cxx:552
void setSelectionisEM(unsigned int value, const std::string &isEM)
Set the isEM word for a selection menu (using the name)
void setAuthor(uint16_t)
set author
bool setShowerShapeValue(float value, const EgammaParameters::ShowerShapeType information)
Set method for Shower Shape values.
const ElementLink< CaloClusterContainer > & caloClusterLink(size_t index=0) const
ElementLink to the xAOD::CaloCluster/s that match the electron candidate.
void setPassSelection(bool value, const std::string &menu)
Set the selection decision for a menu (using the name)
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : internal egamma type.
Definition Egamma_v1.cxx:82
EgammaCovMatrix_t covMatrix() const
Returns the 4x4 symmetric covariance matrix .
bool isolation(float &value, const Iso::IsolationType information) const
Accessor for Isolation values.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
Definition Egamma_v1.h:104
void setCovMatrix(const EgammaCovMatrix_t &cov)
set the 4x4 symmetric covariance matrix .
void setEta(float eta)
set the eta
bool isolationCaloCorrection(float &value, const Iso::IsolationFlavour flavour, const Iso::IsolationCaloCorrection corr, const Iso::IsolationCorrectionParameter param) const
Accessor for flavour and type depended Isolation Calo correction.
virtual double e() const override
The total energy of the particle.
Definition Egamma_v1.cxx:86
void setPhi(float phi)
set the phi
size_t nCaloClusters() const
Return the number of xAOD::CaloClusters that define the electron candidate.
virtual Type::ObjectType type() const override=0
The type of the object as a simple enumeration, remains pure virtual in e/gamma.
void setOQ(uint32_t newOQ)
Set the object quality.
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type for egamma.
Definition Egamma_v1.h:119
std::vector< ElementLink< CaloClusterContainer > > CLELVec_t
Helper type definition.
Definition Egamma_v1.h:168
Egamma_v1()
Default constructor.
Definition Egamma_v1.cxx:48
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
bool selectionisEM(unsigned int &value, const std::string &isEM) const
Return the isEM word for a selection menu If the menu isEM is stored in this xAOD::Egamma,...
bool isGoodOQ(uint32_t mask) const
Check object quality. Return True is it is Good Object Quality.
void setPt(float pt)
set the Pt
uint32_t OQ() const
Return the object quality bit word.
bool passSelection(bool &value, const std::string &menu) const
Check if the egamma object pass a selection menu (using the name) If the menu decision is stored in t...
bool setIsolation(float value, const Iso::IsolationType information)
set method for Isolation values.
bool isolationCorrectionBitset(std::bitset< 32 > &value, const Iso::IsolationFlavour flavour) const
Accessor for Isolation corection Bitset.
bool isolationTrackCorrection(float &value, const Iso::IsolationFlavour flavour, const Iso::IsolationTrackCorrection corr) const
Accessor for Isolation Track correction.
virtual double rapidity() const override
The true rapidity (y) of the particle.
Definition Egamma_v1.cxx:90
void setPtEtaPhi(float pt, float eta, float phi)
set the 4-vec
Egamma_v1 & operator=(const Egamma_v1 &eg)
Assignment Operator. Using the assignment of SG::AuxElement.
Definition Egamma_v1.cxx:54
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
void addAuthor(uint16_t)
add author
Eigen::Matrix< float, 4, 4 > EgammaCovMatrix_t
4x4 Covariance Matrix in EtEtaPhiM (needs decision)
Definition Egamma_v1.h:142
const Egamma_v1 * ambiguousObject() const
Get ambiguous.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle as a TLoretzVector.
Definition Egamma_v1.cxx:94
bool setIsolationTrackCorrection(float value, const Iso::IsolationFlavour flavour, const Iso::IsolationTrackCorrection corr)
Set method for Isolation Track Corrections.
bool setIsolationCorrectionBitset(uint32_t value, const Iso::IsolationFlavour flavour)
Set method for Isolation corection Bitset.
const CLELVec_t & caloClusterLinks() const
Get all cluster links.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition Egamma_v1.cxx:76
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
bool setIsolationCaloCorrection(float value, const Iso::IsolationFlavour flavour, const Iso::IsolationCaloCorrection corr, const Iso::IsolationCorrectionParameter param)
set method for flavour and type depended Isolation Calo Corrections.
IParticle & operator=(const IParticle &)=default
IParticle()=default
virtual double m() const =0
The invariant mass of the particle.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
constexpr int CalculateCompressedSize(int n)
Definition index.py:1
IsolationType
Overall enumeration for isolation types in xAOD files.
IsolationFlavour
Enumeration for different ways of calculating isolation in xAOD files.
IsolationCaloCorrection
Enumeration for different ways of correcting isolation in xAOD files.
void expand(std::vector< float >::const_iterator it, std::vector< float >::const_iterator, Eigen::Matrix< float, N, N, 0, N, N > &covMatrix)
Definition Egamma_v1.cxx:37
void compress(const Eigen::Matrix< float, N, N, 0, N, N > &covMatrix, std::vector< float > &vec)
Definition Egamma_v1.cxx:28
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
const SG::AuxElement::Accessor< uint32_t > getIsolationCorrectionBitsetAccessor(Iso::IsolationFlavour type)
Returns an accessor for the correction bitset corresponding to this IsolationType.
const SG::AuxElement::Accessor< float > * showerShapeAccessorV1(xAOD::EgammaParameters::ShowerShapeType type)
Explicit Instantiation of Template.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const SG::AuxElement::Accessor< float > getIsolationCorrectionAccessor(Iso::IsolationFlavour type, Iso::IsolationCaloCorrection corr, Iso::IsolationCorrectionParameter param)
const SG::AuxElement::Accessor< float > * getIsolationAccessor(Iso::IsolationType type)
Get the Accessor object for a given isolation type.
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
setWord1 uint16_t
static const SG::AuxElement::Accessor< ElementLink< xAOD::EgammaContainer > > ambiguityLinkAcc("ambiguityLink")
Accessor for the "ambiguityLink" dynamic variable.
setEventNumber uint32_t