ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: egPID.cxx
8PACKAGE: offline/Reconstruction/egammaEvent
9UPDATED:
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
27egPID& egPID::operator=(const egPID& original)
28{
29 if (this != &original) {
30 // value as unsigned integer
32 // value as double
33 m_egammaID = original.m_egammaID;
34 }
35 return *this;
36}
37
38// =========================================================
39double egPID::egammaID(egammaPIDObs::PID key, bool *found) const
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
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// =================================================================
78bool egPID::set_egammaID(egammaPIDObs::PID key, double value)
79{
80 //
81 // set value of PID for IsEM or weight
82 //
83 switch(key) {
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
96 std::vector<elParams>::iterator p = m_egammaID.begin();
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// ============================================================
114bool egPID::set_egammaIDint(egammaPIDObs::PID key, unsigned int value)
115{
116 //
117 // method to set value
118 //
119
120 using elParams = std::pair<egammaPIDObs::PID, unsigned int>;
121
122 std::vector<elParams>::iterator p = m_egammaIDint.begin();
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// ==================================================
139unsigned 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// ==================================================
151unsigned int egPID::isEMsofte(const unsigned int mask, bool *found) const
152{
153 //
154 // apply mask to the SofteIsEM value
155 //
156
157 return (egammaIDint(egammaPIDObs::SofteIsEM, found) & mask);
158}
159
160// ==================================================
161unsigned int egPID::IsGoodOQ(const unsigned int mask, bool *found) const
162{
163 //
164 // apply mask to the IsGoodOQ value
165 //
166
167 return (egammaIDint(egammaPIDObs::IsGoodOQ, found) & mask);
168}
169
170
171// ==================================================
172unsigned 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
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
unsigned int IsGoodOQ(const unsigned int mask=egammaPIDObs::ALLOQ, bool *found=nullptr) const
Method to define Object quality variable.
Definition egPID.cxx:161
egPID()=default
Default constructor.
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
egPID & operator=(const egPID &original)
Assignment.
Definition egPID.cxx:27
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
unsigned int egammaIDint(egammaPIDObs::PID, bool *found) const
retrieve unsinged int value
Definition egPID.cxx:172
std::vector< std::pair< egammaPIDObs::PID, double > > m_egammaID
Definition egPID.h:67
std::vector< std::pair< egammaPIDObs::PID, unsigned int > > m_egammaIDint
Definition egPID.h:65
bool set_egammaIDint(egammaPIDObs::PID, unsigned int)
set egamma ID, for unsigned int values
Definition egPID.cxx:114
unsigned int isEMsofte(const unsigned int mask=egammaPIDObs::ALL, bool *found=nullptr) const
Method to define isEMse variable.
Definition egPID.cxx:151
const unsigned int EgPidUndefined
@ IsEMLoose
cut-based identification for egamma objects (Loose)
@ IsEMTight
cut-based identification for egamma objects (Tight)
@ IsEMMedium
cut-based identification for egamma objects (Medium)
@ IsGoodOQ
Object Quality variable.
@ SofteIsEM
cut-based identification for softe electrons in jets (for btag)
@ IsEM
cut-based identification for egamma objects (cluster and track-based)