ATLAS Offline Software
egPID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: egPID.cxx
8 PACKAGE: offline/Reconstruction/egammaEvent
9 UPDATED:
10  Nov 24, 2009 (FD) use unsigned int
11  Jan 5, 2011 (JM) made set_egammaIDint public, added support for multiple isEMs;
12  removed seperate set_isEM and such functions, since not used. (Willing to put
13  them back if people disagree.)
14 ********************************************************************/
15 
16 // INCLUDE HEADER FILES:
17 
18 #include "egammaEvent/egPID.h"
19 #include "GaudiKernel/GaudiException.h"
20 #include <iomanip>
21 #include <iostream>
22 
23 // END OF HEADER FILES INCLUDE
24 
25 // =========================================================
26 // assignment
27 egPID& egPID::operator=(const egPID& original)
28 {
29  if (this != &original) {
30  // value as unsigned integer
31  m_egammaIDint = original.m_egammaIDint;
32  // value as double
33  m_egammaID = original.m_egammaID;
34  }
35  return *this;
36 }
37 
38 // =========================================================
40 {
41  //
42  // interface method to retrieve value of pid IsEM or weight
43  //
44 
45  // retrieve key for cut-based identification for non-isolated objects
46  switch(key) {
47 
49  case egammaPIDObs::IsEM:
54  return (double)egammaIDint(key, found);
55  default:
56  using elParams = std::pair<egammaPIDObs::PID, double>;
57 
58  std::vector<elParams>::const_iterator p = m_egammaID.begin();
59 
60  for (;p !=m_egammaID.end(); ++p) {
61  if ( (*p).first == key ){
62  if (found != nullptr) {
63  *found = true;
64  }
65  return (*p).second;
66  break;
67  }
68  }
69 
70  if (found != nullptr) {
71  *found = false;
72  }
74  }
75 }
76 
77 // =================================================================
79 {
80  //
81  // set value of PID for IsEM or weight
82  //
83  switch(key) {
85  case egammaPIDObs::IsEM:
90  // Need to convert to an int first, then to unsigned int.
91  // Converting directly from a negative float to an unsigned is undefined.
92  return set_egammaIDint( key, static_cast<long int>(value));
93  default:
94  using elParams = std::pair<egammaPIDObs::PID, double>;
95 
97 
98  for (;p !=m_egammaID.end(); ++p) {
99  if ( (*p).first == key ) break;
100  }
101 
102  if ( p == m_egammaID.end() ) {
103  m_egammaID.emplace_back(key,value );
104  }
105  else {
106  (*p).second = value;
107  }
108 
109  return true;
110  }
111 }
112 
113 // ============================================================
115 {
116  //
117  // method to set value
118  //
119 
120  using elParams = std::pair<egammaPIDObs::PID, unsigned int>;
121 
123 
124  for (;p !=m_egammaIDint.end(); ++p) {
125  if ( (*p).first == key ) break;
126  }
127 
128  if ( p == m_egammaIDint.end() ) {
129  m_egammaIDint.emplace_back(key,value );
130  }
131  else {
132  (*p).second = value;
133  }
134  return true;
135 }
136 
137 
138 // ==================================================
139 unsigned int egPID::isEM(const unsigned int mask,
141  bool *found) const
142 {
143  //
144  // apply mask to the IsEM value
145  //
146 
147  return (egammaIDint(pid, found) & mask);
148 }
149 
150 // ==================================================
151 unsigned int egPID::isEMsofte(const unsigned int mask, bool *found) const
152 {
153  //
154  // apply mask to the SofteIsEM value
155  //
156 
158 }
159 
160 // ==================================================
161 unsigned int egPID::IsGoodOQ(const unsigned int mask, bool *found) const
162 {
163  //
164  // apply mask to the IsGoodOQ value
165  //
166 
168 }
169 
170 
171 // ==================================================
172 unsigned int egPID::egammaIDint(egammaPIDObs::PID key, bool *found) const
173 {
174  //
175  // method to retrieve value
176  //
177 
178  using elParams = std::pair<egammaPIDObs::PID, unsigned int>;
179 
180  std::vector<elParams>::const_iterator p = m_egammaIDint.begin();
181 
182  for (;p !=m_egammaIDint.end(); ++p) {
183  if ( (*p).first == key ){
184  if (found != nullptr) {
185  *found = true;
186  }
187  return (*p).second;
188  }
189  }
190 
191  if (found != nullptr) {
192  *found = false;
193  }
195 }
196 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
egammaPIDObs::IsEM
@ IsEM
cut-based identification for egamma objects (cluster and track-based)
Definition: egammaPIDdefsObs.h:55
egammaPIDObs::IsEMLoose
@ IsEMLoose
cut-based identification for egamma objects (Loose)
Definition: egammaPIDdefsObs.h:84
egPID::m_egammaID
std::vector< std::pair< egammaPIDObs::PID, double > > m_egammaID
Definition: egPID.h:78
egammaPIDObs::EgPidUndefined
const unsigned int EgPidUndefined
Definition: egammaPIDdefsObs.h:127
egammaPIDObs::PID
PID
Definition: egammaPIDdefsObs.h:53
egPID::set_egammaID
bool set_egammaID(egammaPIDObs::PID, double)
set egamma ID, as double to work double values and all possible weights as likelihood
Definition: egPID.cxx:78
athena.value
value
Definition: athena.py:124
egPID::egammaIDint
unsigned int egammaIDint(egammaPIDObs::PID, bool *found) const
retrieve unsinged int value
Definition: egPID.cxx:172
egPID::set_egammaIDint
bool set_egammaIDint(egammaPIDObs::PID, unsigned int)
set egamma ID, for unsigned int values
Definition: egPID.cxx:114
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
egammaPIDObs::IsEMTight
@ IsEMTight
cut-based identification for egamma objects (Tight)
Definition: egammaPIDdefsObs.h:88
egammaPIDObs::IsGoodOQ
@ IsGoodOQ
Object Quality variable.
Definition: egammaPIDdefsObs.h:82
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
egPID::egammaID
double egammaID(egammaPIDObs::PID, bool *found=nullptr) const
retrieve egamma ID, as double to work for IsEM and all possible weights as likelihood; found,...
Definition: egPID.cxx:39
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
egPID::isEM
unsigned int isEM(const unsigned int mask=egammaPIDObs::ALL, egammaPIDObs::PID=egammaPIDObs::IsEM, bool *found=nullptr) const
Metod to define isEM variable.
Definition: egPID.cxx:139
egammaPIDObs::SofteIsEM
@ SofteIsEM
cut-based identification for softe electrons in jets (for btag)
Definition: egammaPIDdefsObs.h:64
egPID::operator=
egPID & operator=(const egPID &original)
Assignment.
Definition: egPID.cxx:27
egPID.h
egPID::isEMsofte
unsigned int isEMsofte(const unsigned int mask=egammaPIDObs::ALL, bool *found=nullptr) const
Method to define isEMse variable.
Definition: egPID.cxx:151
egPID::IsGoodOQ
unsigned int IsGoodOQ(const unsigned int mask=egammaPIDObs::ALLOQ, bool *found=nullptr) const
Method to define Object quality variable.
Definition: egPID.cxx:161
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
egammaPIDObs::IsEMMedium
@ IsEMMedium
cut-based identification for egamma objects (Medium)
Definition: egammaPIDdefsObs.h:86
egPID::m_egammaIDint
std::vector< std::pair< egammaPIDObs::PID, unsigned int > > m_egammaIDint
Definition: egPID.h:76
egPID
Definition: egPID.h:32
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37