ATLAS Offline Software
Loading...
Searching...
No Matches
PhotonIDBDT::AsgPhotonBDTSelector Class Reference

#include <AsgPhotonBDTSelector.h>

Inheritance diagram for PhotonIDBDT::AsgPhotonBDTSelector:
Collaboration diagram for PhotonIDBDT::AsgPhotonBDTSelector:

Public Member Functions

 AsgPhotonBDTSelector (const std::string &name)
virtual ~AsgPhotonBDTSelector () override=default
virtual StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual asg::AcceptData accept (const xAOD::IParticle *part) const override
 accept with pointer to IParticle so as to not hide the IAsgSelectionTool one
virtual asg::AcceptData accept (const EventContext &ctx, const xAOD::IParticle *part) const override
virtual asg::AcceptData accept (const EventContext &ctx, const xAOD::Egamma *part) const override
 accept with pointer to Egamma object
virtual asg::AcceptData accept (const EventContext &ctx, const xAOD::Photon *part) const override
 accept with Photon pointer
virtual asg::AcceptData accept (const EventContext &ctx, const xAOD::Electron *part) const override
 accept with Electron reference
virtual StatusCode execute (const EventContext &ctx, const xAOD::Egamma *eg, unsigned int &isEM) const override
 Add a legacy execute method - return isEM value.
virtual std::string getOperatingPointName () const override
 Report the current operating point.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode loadConfig ()
asg::AcceptData acceptBDT (const EventContext &ctx, const xAOD::Photon &ph, unsigned int *isEM=nullptr) const
virtual const asg::AcceptInfogetAcceptInfo () const override
 Declare the interface ID for this pure-virtual interface class to the Athena framework.
bool isConverted (const xAOD::Photon &ph) const
bool findBin (const float absEta, const float etGeV, size_t &iEta, size_t &iEt) const
float getCut (const bool converted, const size_t iEta, const size_t iEt) const
asg::AcceptData makeReject (const asg::AcceptInfo &info) const
float getShowerShape (const xAOD::Photon &ph, xAOD::EgammaParameters::ShowerShapeType t, const char *name="") const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< PhotonBDTCalculatorm_bdtTool {this, "BDTTool", "", "Photon BDT calculator tool"}
Gaudi::Property< std::string > m_workingPoint {this, "WorkingPoint", "", "Name of the Photon ID BDT Working point"}
Gaudi::Property< std::string > m_scoreDecoration {this, "ScoreDecoration", "BDTScore", "Name of the float decoration containing the score"}
Gaudi::Property< bool > m_computeIfMissing {this, "ComputeIfMissing", true, "Compute score with BDTTool if decoration missing"}
Gaudi::Property< bool > m_excludeTRT {this, "ExcludeTRT", true, "Conversion definition for Run 3"}
Gaudi::Property< bool > m_reapplyWPIfNoShowerShapes {this, "ReapplyWPIfNoShowerShapes", true, "Reapply the WP calculation, based on the BDT score and isEM word (works only if these are available!) "}
Gaudi::Property< std::string > m_isEMDecoration {this, "IsEMDecoration", "BDTIsEM", "Name of the int decoration containing the isEM word (used if ReapplyWPIfNoShowerShapes is true)"}
std::string m_configFile
std::vector< float > m_etaBins
std::vector< float > m_etBinsGeV
std::vector< float > m_cutF1Conv
std::vector< float > m_cutF1Unconv
std::vector< float > m_cutE277Conv
std::vector< float > m_cutE277Unconv
std::vector< float > m_cutConv
std::vector< float > m_cutUnconv
asg::AcceptInfo m_acceptInfo
int m_cutPosScore {-1}
int m_cutPosInRange {-1}
int m_cutPosHasScore {-1}
int m_cutPosPreF1 {-1}
int m_cutPosPreE277 {-1}
int m_cutPosPassPreselection {-1}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 53 of file AsgPhotonBDTSelector.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ AsgPhotonBDTSelector()

AsgPhotonBDTSelector::AsgPhotonBDTSelector ( const std::string & name)

Definition at line 42 of file AsgPhotonBDTSelector.cxx.

43 : asg::AsgTool(name),
44 m_configFile("")
45{}

◆ ~AsgPhotonBDTSelector()

virtual PhotonIDBDT::AsgPhotonBDTSelector::~AsgPhotonBDTSelector ( )
overridevirtualdefault

Member Function Documentation

◆ accept() [1/5]

asg::AcceptData AsgPhotonBDTSelector::accept ( const EventContext & ctx,
const xAOD::Egamma * part ) const
overridevirtual

accept with pointer to Egamma object

Implements IAsgEGammaIsEMSelector.

Definition at line 172 of file AsgPhotonBDTSelector.cxx.

174{
175 if (!eg) return makeReject(m_acceptInfo);
176
177 const auto* ph = dynamic_cast<const xAOD::Photon*>(eg);
178 if (!ph) return makeReject(m_acceptInfo);
179
180 return accept(ctx, ph);
181}
asg::AcceptData makeReject(const asg::AcceptInfo &info) const
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override
accept with pointer to IParticle so as to not hide the IAsgSelectionTool one
Photon_v1 Photon
Definition of the current "egamma version".

◆ accept() [2/5]

asg::AcceptData AsgPhotonBDTSelector::accept ( const EventContext & ctx,
const xAOD::Electron * part ) const
overridevirtual

accept with Electron reference

Implements IAsgEGammaIsEMSelector.

Definition at line 190 of file AsgPhotonBDTSelector.cxx.

192{
193 // This tool is photon-only
194 return makeReject(m_acceptInfo);
195}

◆ accept() [3/5]

asg::AcceptData AsgPhotonBDTSelector::accept ( const EventContext & ctx,
const xAOD::IParticle * part ) const
overridevirtual

Implements IAsgEGammaIsEMSelector.

Definition at line 158 of file AsgPhotonBDTSelector.cxx.

160{
161 if (!part) return makeReject(m_acceptInfo);
162
163 if (const auto* ph = dynamic_cast<const xAOD::Photon*>(part)) {
164 return accept(ctx, ph);
165 }
166 if (const auto* eg = dynamic_cast<const xAOD::Egamma*>(part)) {
167 return accept(ctx, eg);
168 }
169 return makeReject(m_acceptInfo);
170}
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17

◆ accept() [4/5]

asg::AcceptData AsgPhotonBDTSelector::accept ( const EventContext & ctx,
const xAOD::Photon * part ) const
overridevirtual

accept with Photon pointer

Implements IAsgEGammaIsEMSelector.

Definition at line 183 of file AsgPhotonBDTSelector.cxx.

185{
186 if (!ph) return makeReject(m_acceptInfo);
187 return acceptBDT(ctx, *ph, nullptr);
188}
asg::AcceptData acceptBDT(const EventContext &ctx, const xAOD::Photon &ph, unsigned int *isEM=nullptr) const

◆ accept() [5/5]

asg::AcceptData AsgPhotonBDTSelector::accept ( const xAOD::IParticle * part) const
overridevirtual

accept with pointer to IParticle so as to not hide the IAsgSelectionTool one

Implements IAsgEGammaIsEMSelector.

Definition at line 153 of file AsgPhotonBDTSelector.cxx.

154{
155 return accept(Gaudi::Hive::currentContext(), part);
156}

◆ acceptBDT()

asg::AcceptData AsgPhotonBDTSelector::acceptBDT ( const EventContext & ctx,
const xAOD::Photon & ph,
unsigned int * isEM = nullptr ) const
private

Definition at line 266 of file AsgPhotonBDTSelector.cxx.

266 {
267 // Helper for isEM word
268 auto setBit = [&](unsigned int bit) {
269 if (isEM) *isEM |= bit;
270 };
271 // I assume that the photon exists and is valid
272
273 // start to retrieve the acceptor
274 // Start with all cuts failed
275 asg::AcceptData acc = makeReject(m_acceptInfo);
276
277 // Ensure BDT score is available
278 const SG::AuxElement::Accessor<float> accScore(m_scoreDecoration);
279 bool hasScore = accScore.isAvailable(ph);
280 // If the score is not available, we try to compute it on the fly
281 if (!hasScore && m_computeIfMissing) {
282 if (m_bdtTool->decorate(ph).isSuccess()) {
283 hasScore = accScore.isAvailable(ph);
284 }
285 }
286 // if we are not allowed to compute the score and it's not there
287 // reject and set the bit for missing score
288 else if (!hasScore) {
289 setBit(FailMissingScore);
290 return acc;
291 }
292 // now we should have the score available, if we recomputed it
293 // If it is not available even after trying to compute, reject and set the bit for missing score
294 if (!hasScore) {
295 setBit(FailMissingScore);
296 return acc;
297 }
298
299 // Ok now we assume that we have the score
300 const float score = accScore(ph);
301 acc.setCutResult(m_cutPosHasScore, true);
302
303 // Now we check the photon kinematics and the binning
304 const float absEta = std::abs(ph.eta());
305 const float etGeV = ph.pt() * 1e-3f;
306
307 size_t iEta=0, iEt=0;
308 if (!findBin(absEta, etGeV, iEta, iEt)) {
309 setBit(FailOutOfRange); // failOutOfRange
310 return acc;
311 }
312 // If we are here, the photon is in the correct eta range
313 acc.setCutResult(m_cutPosInRange, true);
314
315 // check if the photon is converted
316 const bool conv = isConverted(ph);
317
318 // Check F1 and e277 preselection cuts
319 bool passF1 = false, passE277 = false, passPre = false;
320 // Before trying to access the shower shape variables, we check if they are available.
321 // If not, we can either fail or reapply the WP based on the score and isEM word (if enabled and available)
323 float tmp = 0.f;
324 const bool hasF1 = ph.showerShapeValue(tmp, xAOD::EgammaParameters::f1);
325 const bool hasE277 = ph.showerShapeValue(tmp, xAOD::EgammaParameters::e277);
326 if (!hasF1 || !hasE277) {
327 // Check if isEM decoration is available
329 if (accIsEM.isAvailable(ph)) {
330 const int previousIsEM = accIsEM(ph);
331 passF1 = !(previousIsEM & FailPreselectionF1);
332 passE277 = !(previousIsEM & FailPreselectionE277);
333 passPre = passF1 && passE277;
334 }
335 else {
336 ATH_MSG_ERROR("Missing f1 and e277 shower shapes and isEM decoration, cannot reapply WP. Rejecting photon.");
337 acc.setCutResult(m_cutPosPreF1, false);
338 acc.setCutResult(m_cutPosPreE277, false);
339 acc.setCutResult(m_cutPosPassPreselection, false);
340 setBit(FailPreselectionF1);
341 setBit(FailPreselectionE277);
342 return acc;
343 }
344 }
345 }
346 else {
347 // If we are missing shower shapes and we are not reapplying the WP, we throw an error
348 float f1 = 0.f, e277 = 0.f;
351
352 const float cutF1 = conv ? m_cutF1Conv.at(0) : m_cutF1Unconv.at(0);
353 const float cutE277 = conv ? m_cutE277Conv.at(0) : m_cutE277Unconv.at(0);
354 passF1 = (f1 > cutF1);
355 passE277 = (e277 > cutE277);
356 passPre = passF1 && passE277;
357 }
358
359 // Decorate the accept data with the results of the preselection cuts
360 acc.setCutResult(m_cutPosPreF1, passF1);
361 acc.setCutResult(m_cutPosPreE277, passE277);
362 acc.setCutResult(m_cutPosPassPreselection, passPre);
363
364 // Set bits for failed preselections
365 if (!passF1) setBit(FailPreselectionF1);
366 if (!passE277) setBit(FailPreselectionE277);
367 // If failed preselection, reject and return
368 if (!passPre) return acc;
369
370 // Check the BDT score cut
371 const float cut = getCut(conv, iEta, iEt);
372 const bool passBDT = (score > cut);
373 acc.setCutResult(m_cutPosScore, (score > cut));
374 if (!passBDT) setBit(FailBDTScore);
375
376 return acc;
377}
#define ATH_MSG_ERROR(x)
static void setBit(unsigned char &field, unsigned num, bool val)
float getShowerShape(const xAOD::Photon &ph, xAOD::EgammaParameters::ShowerShapeType t, const char *name="") const
Gaudi::Property< bool > m_reapplyWPIfNoShowerShapes
bool isConverted(const xAOD::Photon &ph) const
ToolHandle< PhotonBDTCalculator > m_bdtTool
Gaudi::Property< std::string > m_scoreDecoration
float getCut(const bool converted, const size_t iEta, const size_t iEt) const
Gaudi::Property< bool > m_computeIfMissing
Gaudi::Property< std::string > m_isEMDecoration
bool findBin(const float absEta, const float etGeV, size_t &iEta, size_t &iEt) const
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
constexpr unsigned int bit(int n)
bool absEta(const xAOD::TauJet &tau, float &out)
@ e277
uncalibrated energy (sum of cells) of the middle sampling in a rectangle of size 7x7
Definition EgammaEnums.h:81
@ f1
E1/E = fraction of energy reconstructed in the first sampling, where E1 is energy in all strips belon...
Definition EgammaEnums.h:53
setScale setgFexType iEta

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode AsgPhotonBDTSelector::execute ( const EventContext & ctx,
const xAOD::Egamma * eg,
unsigned int & isEM ) const
overridevirtual

Add a legacy execute method - return isEM value.

Implements IAsgEGammaIsEMSelector.

Definition at line 198 of file AsgPhotonBDTSelector.cxx.

201{
202 isEM = 0u;
203 if (!eg) return StatusCode::SUCCESS;
204
205 const auto* ph = dynamic_cast<const xAOD::Photon*>(eg);
206 if (!ph) {
207 isEM = 1u; // or define a bit for wrong type
208 return StatusCode::SUCCESS;
209 }
210
211 (void) acceptBDT(ctx, *ph, &isEM);
212 return StatusCode::SUCCESS;
213}
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ findBin()

bool AsgPhotonBDTSelector::findBin ( const float absEta,
const float etGeV,
size_t & iEta,
size_t & iEt ) const
private

Definition at line 223 of file AsgPhotonBDTSelector.cxx.

224 {
225 // bins defined as [edge_i, edge_{i+1})
226 // Eta binning
227 auto itEta = std::upper_bound(m_etaBins.begin(), m_etaBins.end(), absEta);
228 if (itEta == m_etaBins.begin() || itEta == m_etaBins.end()) return false; // Eta out of range
229 iEta = (itEta - m_etaBins.begin()) - 1; // regular bin
230
231 // ET binning
232 auto itEt = std::upper_bound(m_etBinsGeV.begin(), m_etBinsGeV.end(), etGeV);
233 if (itEt == m_etBinsGeV.begin()) { iEt = 0; } // underflow: first bin
234 else if (itEt == m_etBinsGeV.end()) { iEt = m_etBinsGeV.size() - 2; } // overflow: last bin
235 else { iEt = (itEt - m_etBinsGeV.begin()) - 1; } // regular bin
236
237 return true;
238}

◆ getAcceptInfo()

const asg::AcceptInfo & AsgPhotonBDTSelector::getAcceptInfo ( ) const
overrideprivatevirtual

Declare the interface ID for this pure-virtual interface class to the Athena framework.

Method to get the AcceptInfo to query what cuts are defined.

Implements IAsgSelectionTool.

Definition at line 145 of file AsgPhotonBDTSelector.cxx.

145 {
146 return m_acceptInfo;
147}

◆ getCut()

float AsgPhotonBDTSelector::getCut ( const bool converted,
const size_t iEta,
const size_t iEt ) const
private

Definition at line 240 of file AsgPhotonBDTSelector.cxx.

240 {
241 const size_t nEta = m_etaBins.size() - 1;
242 const size_t idx = iEt * nEta + iEta;
243 const float cut = converted ? m_cutConv.at(idx) : m_cutUnconv.at(idx);
244 return cut;
245}
constexpr int nEta
Default bin number of eta for vertex map.

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::TEvent, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::TEvent both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::TEvent, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getOperatingPointName()

std::string AsgPhotonBDTSelector::getOperatingPointName ( ) const
overridevirtual

Report the current operating point.

Implements IAsgEGammaIsEMSelector.

Definition at line 137 of file AsgPhotonBDTSelector.cxx.

138{
139 return m_workingPoint;
140}
Gaudi::Property< std::string > m_workingPoint

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getShowerShape()

float AsgPhotonBDTSelector::getShowerShape ( const xAOD::Photon & ph,
xAOD::EgammaParameters::ShowerShapeType t,
const char * name = "" ) const
private

Definition at line 253 of file AsgPhotonBDTSelector.cxx.

253 {
254 float out = 0.f;
255 if (!ph.showerShapeValue(out, t)) {
256 ATH_MSG_ERROR("AsgPhotonBDTSelector: missing shower shape variable '" << name);
257 // Fail loudly
258 throw std::runtime_error(std::string("AsgPhotonBDTSelector: missing shower shape ") + name);
259 }
260 return out;
261}

◆ initialize()

StatusCode AsgPhotonBDTSelector::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 50 of file AsgPhotonBDTSelector.cxx.

50 {
51 // Load the configuration file and parse it
53 // Register the cuts in the AcceptInfo
54 m_cutPosHasScore = m_acceptInfo.addCut("HasScore", "Photon has BDT score decoration");
55 m_cutPosPreF1 = m_acceptInfo.addCut("PreselectionF1", "Photon passes preselection on f1");
56 m_cutPosPreE277 = m_acceptInfo.addCut("PreselectionE277", "Photon passes preselection on e277");
57 m_cutPosPassPreselection = m_acceptInfo.addCut("PassPreselection", "Photon passes all preselections");
58 m_cutPosInRange = m_acceptInfo.addCut("InRange", "Photon kinematics within eta range and binned in Et");
59 m_cutPosScore = m_acceptInfo.addCut("BDTScore", "Passes the BDT score cut");
60 // Check if it went well
61 if (m_cutPosScore < 0 || m_cutPosInRange < 0 || m_cutPosHasScore < 0 ||
63 ATH_MSG_ERROR("Failed to register cuts in AcceptInfo");
64 return StatusCode::FAILURE;
65 }
66 // Retrieve PhotonBDTCalculator tool
67 ATH_CHECK(m_bdtTool.retrieve());
68
69 return StatusCode::SUCCESS;
70}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isConverted()

bool AsgPhotonBDTSelector::isConverted ( const xAOD::Photon & ph) const
private

Definition at line 218 of file AsgPhotonBDTSelector.cxx.

218 {
220}
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon

◆ loadConfig()

StatusCode AsgPhotonBDTSelector::loadConfig ( )
private

Definition at line 75 of file AsgPhotonBDTSelector.cxx.

75 {
76 // If we specified the WP, look for the corresponding config file in the mapping
77 if (!m_workingPoint.empty()) {
80 );
81 ATH_MSG_INFO("Photon ID BDT working point: " << getOperatingPointName());
82 }
83
84 if (m_configFile.empty()) {
85 ATH_MSG_ERROR("Empty configFile. WorkingPoint: " << m_workingPoint);
86 return StatusCode::FAILURE;
87 }
88
90 if (configFile.empty()) {
91 ATH_MSG_ERROR("Could not locate config via PathResolver: " << m_configFile);
92 return StatusCode::FAILURE;
93 }
94
95 ATH_MSG_DEBUG("Using config file: " << m_configFile << " (resolved: " << configFile << ")");
96
97 // Parse config file
98 TEnv env;
99 env.ReadFile(configFile.c_str(), kEnvLocal);
100
101 // Load WP binning
102 m_etaBins = AsgConfigHelper::HelperFloat("CutBinEta", env);
103 m_etBinsGeV = AsgConfigHelper::HelperFloat("CutBinEtGeV", env);
104 // Load preselection cuts on f1 and e277 variables
105 m_cutF1Conv = AsgConfigHelper::HelperFloat("CutF1Conv", env);
106 m_cutF1Unconv = AsgConfigHelper::HelperFloat("CutF1Unconv", env);
107 m_cutE277Conv = AsgConfigHelper::HelperFloat("CutE277Conv", env);
108 m_cutE277Unconv= AsgConfigHelper::HelperFloat("CutE277Unconv", env);
109 // Load BDT score cuts
110 m_cutConv = AsgConfigHelper::HelperFloat("BDTCutConv", env);
111 m_cutUnconv = AsgConfigHelper::HelperFloat("BDTCutUnconv", env);
112
113 // Validate binning
114 const unsigned nEta = (m_etaBins.size() >= 2) ? (m_etaBins.size() - 1) : 0;
115 const unsigned nEt = (m_etBinsGeV.size() >= 2) ? (m_etBinsGeV.size() - 1) : 0;
116
117 if (nEta == 0 || nEt == 0) {
118 ATH_MSG_ERROR("Need at least 2 edges for eta and Et binning.");
119 return StatusCode::FAILURE;
120 }
121
122 const unsigned nExpected = nEta * nEt;
123 if (m_cutConv.size() != nExpected || m_cutUnconv.size() != nExpected) {
124 ATH_MSG_ERROR("Size mismatch between eta and Et binning and BDT cut maps: expected " << nExpected
125 << " (= " << nEta << "*" << nEt << ")"
126 << " got BDTCutConv=" << m_cutConv.size()
127 << " BDTCutUnconv=" << m_cutUnconv.size());
128 return StatusCode::FAILURE;
129 }
130
131 return StatusCode::SUCCESS;
132}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
virtual std::string getOperatingPointName() const override
Report the current operating point.
std::string findConfigFile(const std::string &input, const std::map< std::string, std::string > &configmap)
std::vector< float > HelperFloat(const std::string &input, TEnv &env)
const std::map< std::string, std::string > PhotonBDTPointToConfFile

◆ makeReject()

asg::AcceptData AsgPhotonBDTSelector::makeReject ( const asg::AcceptInfo & info) const
private

Definition at line 247 of file AsgPhotonBDTSelector.cxx.

247 {
248 asg::AcceptData acc(&info);
249 for (unsigned i = 0; i < info.getNCuts(); ++i) acc.setCutResult(i, false);
250 return acc;
251}

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_acceptInfo

asg::AcceptInfo PhotonIDBDT::AsgPhotonBDTSelector::m_acceptInfo
private

Definition at line 108 of file AsgPhotonBDTSelector.h.

◆ m_bdtTool

ToolHandle<PhotonBDTCalculator> PhotonIDBDT::AsgPhotonBDTSelector::m_bdtTool {this, "BDTTool", "", "Photon BDT calculator tool"}
private

Definition at line 81 of file AsgPhotonBDTSelector.h.

81{this, "BDTTool", "", "Photon BDT calculator tool"};

◆ m_computeIfMissing

Gaudi::Property<bool> PhotonIDBDT::AsgPhotonBDTSelector::m_computeIfMissing {this, "ComputeIfMissing", true, "Compute score with BDTTool if decoration missing"}
private

Definition at line 86 of file AsgPhotonBDTSelector.h.

86{this, "ComputeIfMissing", true, "Compute score with BDTTool if decoration missing"};

◆ m_configFile

std::string PhotonIDBDT::AsgPhotonBDTSelector::m_configFile
private

Definition at line 92 of file AsgPhotonBDTSelector.h.

◆ m_cutConv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutConv
private

Definition at line 104 of file AsgPhotonBDTSelector.h.

◆ m_cutE277Conv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutE277Conv
private

Definition at line 100 of file AsgPhotonBDTSelector.h.

◆ m_cutE277Unconv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutE277Unconv
private

Definition at line 101 of file AsgPhotonBDTSelector.h.

◆ m_cutF1Conv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutF1Conv
private

Definition at line 98 of file AsgPhotonBDTSelector.h.

◆ m_cutF1Unconv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutF1Unconv
private

Definition at line 99 of file AsgPhotonBDTSelector.h.

◆ m_cutPosHasScore

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosHasScore {-1}
private

Definition at line 111 of file AsgPhotonBDTSelector.h.

111{-1};

◆ m_cutPosInRange

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosInRange {-1}
private

Definition at line 110 of file AsgPhotonBDTSelector.h.

110{-1};

◆ m_cutPosPassPreselection

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosPassPreselection {-1}
private

Definition at line 114 of file AsgPhotonBDTSelector.h.

114{-1};

◆ m_cutPosPreE277

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosPreE277 {-1}
private

Definition at line 113 of file AsgPhotonBDTSelector.h.

113{-1};

◆ m_cutPosPreF1

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosPreF1 {-1}
private

Definition at line 112 of file AsgPhotonBDTSelector.h.

112{-1};

◆ m_cutPosScore

int PhotonIDBDT::AsgPhotonBDTSelector::m_cutPosScore {-1}
private

Definition at line 109 of file AsgPhotonBDTSelector.h.

109{-1};

◆ m_cutUnconv

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_cutUnconv
private

Definition at line 105 of file AsgPhotonBDTSelector.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_etaBins

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_etaBins
private

Definition at line 95 of file AsgPhotonBDTSelector.h.

◆ m_etBinsGeV

std::vector<float> PhotonIDBDT::AsgPhotonBDTSelector::m_etBinsGeV
private

Definition at line 96 of file AsgPhotonBDTSelector.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_excludeTRT

Gaudi::Property<bool> PhotonIDBDT::AsgPhotonBDTSelector::m_excludeTRT {this, "ExcludeTRT", true, "Conversion definition for Run 3"}
private

Definition at line 87 of file AsgPhotonBDTSelector.h.

87{this, "ExcludeTRT", true, "Conversion definition for Run 3"};

◆ m_isEMDecoration

Gaudi::Property<std::string> PhotonIDBDT::AsgPhotonBDTSelector::m_isEMDecoration {this, "IsEMDecoration", "BDTIsEM", "Name of the int decoration containing the isEM word (used if ReapplyWPIfNoShowerShapes is true)"}
private

Definition at line 89 of file AsgPhotonBDTSelector.h.

89{this, "IsEMDecoration", "BDTIsEM", "Name of the int decoration containing the isEM word (used if ReapplyWPIfNoShowerShapes is true)"};

◆ m_reapplyWPIfNoShowerShapes

Gaudi::Property<bool> PhotonIDBDT::AsgPhotonBDTSelector::m_reapplyWPIfNoShowerShapes {this, "ReapplyWPIfNoShowerShapes", true, "Reapply the WP calculation, based on the BDT score and isEM word (works only if these are available!) "}
private

Definition at line 88 of file AsgPhotonBDTSelector.h.

88{this, "ReapplyWPIfNoShowerShapes", true, "Reapply the WP calculation, based on the BDT score and isEM word (works only if these are available!) "};

◆ m_scoreDecoration

Gaudi::Property<std::string> PhotonIDBDT::AsgPhotonBDTSelector::m_scoreDecoration {this, "ScoreDecoration", "BDTScore", "Name of the float decoration containing the score"}
private

Definition at line 85 of file AsgPhotonBDTSelector.h.

85{this, "ScoreDecoration", "BDTScore", "Name of the float decoration containing the score"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_workingPoint

Gaudi::Property<std::string> PhotonIDBDT::AsgPhotonBDTSelector::m_workingPoint {this, "WorkingPoint", "", "Name of the Photon ID BDT Working point"}
private

Definition at line 84 of file AsgPhotonBDTSelector.h.

84{this, "WorkingPoint", "", "Name of the Photon ID BDT Working point"};

The documentation for this class was generated from the following files: