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

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.
 AsgTool (const std::string &name)
 Constructor specifying the tool instance's name.
 AsgTool (const AsgTool &)=delete
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
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>

Static Private Member Functions

static asg::AcceptData makeReject (const asg::AcceptInfo &info)

Private Attributes

Gaudi::Property< std::string > m_workingPoint {this, "WorkingPoint", "", "Name of the Photon ID BDT Working point"}
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}
SG::ReadHandleKey< xAOD::EgammaContainerm_ContainerName { this, "ContainerName", "", "Input" }
SG::ReadDecorHandleKey< xAOD::EgammaContainerm_decoratorScore
Gaudi::Property< bool > m_suppressInputDeps {this, "SuppressInputDependence", false, "Will BDT score be created in the same algorithm that uses this tool?"}
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 57 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.

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 175 of file AsgPhotonBDTSelector.cxx.

177{
178 if (!eg) return makeReject(m_acceptInfo);
179
180 const auto* ph = dynamic_cast<const xAOD::Photon*>(eg);
181 if (!ph) return makeReject(m_acceptInfo);
182
183 return accept(ctx, ph);
184}
static asg::AcceptData makeReject(const asg::AcceptInfo &info)
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 193 of file AsgPhotonBDTSelector.cxx.

195{
196 // This tool is photon-only
197 return makeReject(m_acceptInfo);
198}

◆ accept() [3/5]

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

Implements IAsgEGammaIsEMSelector.

Definition at line 161 of file AsgPhotonBDTSelector.cxx.

163{
164 if (!part) return makeReject(m_acceptInfo);
165
166 if (const auto* ph = dynamic_cast<const xAOD::Photon*>(part)) {
167 return accept(ctx, ph);
168 }
169 if (const auto* eg = dynamic_cast<const xAOD::Egamma*>(part)) {
170 return accept(ctx, eg);
171 }
172 return makeReject(m_acceptInfo);
173}
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 186 of file AsgPhotonBDTSelector.cxx.

188{
189 if (!ph) return makeReject(m_acceptInfo);
190 return acceptBDT(ctx, *ph, nullptr);
191}
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 156 of file AsgPhotonBDTSelector.cxx.

157{
158 return accept(Gaudi::Hive::currentContext(), part);
159}

◆ acceptBDT()

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

Definition at line 269 of file AsgPhotonBDTSelector.cxx.

269 {
270 // Helper for isEM word
271 auto setBit = [&](unsigned int bit) {
272 if (isEM) *isEM |= bit;
273 };
274 // I assume that the photon exists and is valid
275
276 // start to retrieve the acceptor
277 // Start with all cuts failed
278 asg::AcceptData acc = makeReject(m_acceptInfo);
279
280 // Ok now we assume that we have the score
281 SG::ReadDecorHandle<xAOD::EgammaContainer, float> decoratorScore{m_decoratorScore, ctx};
282 const float score = decoratorScore(ph);
283 acc.setCutResult(m_cutPosHasScore, true);
284
285 // Now we check the photon kinematics from cluster and the binning
286 const xAOD::CaloCluster* cluster = ph.caloCluster();
287 if (!cluster) {
288 setBit(FailOutOfRange);
289 return acc;
290 }
291 const float absEta = std::abs(cluster->eta());
292 const float etGeV = cluster->pt() * 1e-3f;
293
294 size_t iEta=0, iEt=0;
295 if (!findBin(absEta, etGeV, iEta, iEt)) {
296 setBit(FailOutOfRange); // failOutOfRange
297 return acc;
298 }
299 // If we are here, the photon is in the correct eta range
300 acc.setCutResult(m_cutPosInRange, true);
301
302 // check if the photon is converted
303 const bool conv = isConverted(ph);
304
305 // Check F1 and e277 preselection cuts
306 bool passF1 = false, passE277 = false, passPre = false;
307 // Before trying to access the shower shape variables, we check if they are available.
308 // If not, we can either fail or reapply the WP based on the score and isEM word (if enabled and available)
310 float tmp = 0.f;
311 const bool hasF1 = ph.showerShapeValue(tmp, xAOD::EgammaParameters::f1);
312 const bool hasE277 = ph.showerShapeValue(tmp, xAOD::EgammaParameters::e277);
313 if (!hasF1 || !hasE277) {
314 // Check if isEM decoration is available
315 const SG::AuxElement::Accessor<int> accIsEM(m_isEMDecoration);
316 if (accIsEM.isAvailable(ph)) {
317 const int previousIsEM = accIsEM(ph);
318 passF1 = !(previousIsEM & FailPreselectionF1);
319 passE277 = !(previousIsEM & FailPreselectionE277);
320 passPre = passF1 && passE277;
321 }
322 else {
323 ATH_MSG_ERROR("Missing f1 and e277 shower shapes and isEM decoration, cannot reapply WP. Rejecting photon.");
324 acc.setCutResult(m_cutPosPreF1, false);
325 acc.setCutResult(m_cutPosPreE277, false);
326 acc.setCutResult(m_cutPosPassPreselection, false);
327 setBit(FailPreselectionF1);
328 setBit(FailPreselectionE277);
329 return acc;
330 }
331 }
332 }
333 else {
334 // If we are missing shower shapes and we are not reapplying the WP, we throw an error
335 float f1 = 0.f, e277 = 0.f;
338
339 const float cutF1 = conv ? m_cutF1Conv.at(0) : m_cutF1Unconv.at(0);
340 const float cutE277 = conv ? m_cutE277Conv.at(0) : m_cutE277Unconv.at(0);
341 passF1 = (f1 > cutF1);
342 passE277 = (e277 > cutE277);
343 passPre = passF1 && passE277;
344 }
345
346 // Decorate the accept data with the results of the preselection cuts
347 acc.setCutResult(m_cutPosPreF1, passF1);
348 acc.setCutResult(m_cutPosPreE277, passE277);
349 acc.setCutResult(m_cutPosPassPreselection, passPre);
350
351 // Set bits for failed preselections
352 if (!passF1) setBit(FailPreselectionF1);
353 if (!passE277) setBit(FailPreselectionE277);
354 // If failed preselection, reject and return
355 if (!passPre) return acc;
356
357 // Check the BDT score cut
358 const float cut = getCut(conv, iEta, iEt);
359 const bool passBDT = (score > cut);
360 acc.setCutResult(m_cutPosScore, (score > cut));
361 if (!passBDT) setBit(FailBDTScore);
362
363 return acc;
364}
#define ATH_MSG_ERROR(x)
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
SG::ReadDecorHandleKey< xAOD::EgammaContainer > m_decoratorScore
float getCut(const bool converted, const size_t iEta, const size_t iEt) const
Gaudi::Property< std::string > m_isEMDecoration
bool findBin(const float absEta, const float etGeV, size_t &iEta, size_t &iEt) const
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
virtual double eta() const
The pseudorapidity ( ) of the particle.
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
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
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ AsgTool() [1/2]

asg::AsgTool::AsgTool ( const AsgTool & )
delete

◆ AsgTool() [2/2]

asg::AsgTool::AsgTool ( const std::string & name)

Constructor specifying the tool instance's name.

Definition at line 51 of file AsgTool.cxx.

60#ifndef XAOD_STANDALONE
61 ::getType(name), ::getName(name), ::getParent(name)
62#else // not XAOD_STANDALONE
63 name
64#endif // not XAOD_STANDALONE
65 )
66#ifdef XAOD_STANDALONE
67 , m_event()
68#endif // XAOD_STANDALONE
69 {
70 ToolStore::put( this ).ignore(); // Register the tool in the ToolStore
71 }
const std::string & getName(const void *ptr) const
Get the name of an object that is / should be in the event store.
Definition AsgTool.cxx:106
::AthAlgTool AsgToolBase
Definition AsgTool.h:33

◆ 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 201 of file AsgPhotonBDTSelector.cxx.

204{
205 isEM = 0u;
206 if (!eg) return StatusCode::SUCCESS;;
207
208 const auto* ph = dynamic_cast<const xAOD::Photon*>(eg);
209 if (!ph) {
210 isEM = 1u; // or define a bit for wrong type
211 return StatusCode::SUCCESS;
212 }
213
214 (void) acceptBDT(ctx, *ph, &isEM);
215 return StatusCode::SUCCESS;
216}
@ 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 226 of file AsgPhotonBDTSelector.cxx.

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

◆ 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 148 of file AsgPhotonBDTSelector.cxx.

148 {
149 return m_acceptInfo;
150}

◆ getCut()

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

Definition at line 243 of file AsgPhotonBDTSelector.cxx.

243 {
244 const size_t nEta = m_etaBins.size() - 1;
245 const size_t idx = iEt * nEta + iEta;
246 const float cut = converted ? m_cutConv.at(idx) : m_cutUnconv.at(idx);
247 return cut;
248}
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::Event 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::Event, 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::Event 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::Event, 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 140 of file AsgPhotonBDTSelector.cxx.

141{
142 return m_workingPoint;
143}
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 256 of file AsgPhotonBDTSelector.cxx.

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

◆ 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 44 of file AsgPhotonBDTSelector.cxx.

44 {
45 // Load the configuration file and parse it
47 // Register the cuts in the AcceptInfo
48 m_cutPosHasScore = m_acceptInfo.addCut("HasScore", "Photon has BDT score decoration");
49 m_cutPosPreF1 = m_acceptInfo.addCut("PreselectionF1", "Photon passes preselection on f1");
50 m_cutPosPreE277 = m_acceptInfo.addCut("PreselectionE277", "Photon passes preselection on e277");
51 m_cutPosPassPreselection = m_acceptInfo.addCut("PassPreselection", "Photon passes all preselections");
52 m_cutPosInRange = m_acceptInfo.addCut("InRange", "Photon kinematics within eta range and binned in Et");
53 m_cutPosScore = m_acceptInfo.addCut("BDTScore", "Passes the BDT score cut");
54 // Check if it went well
55 if (m_cutPosScore < 0 || m_cutPosInRange < 0 || m_cutPosHasScore < 0 ||
57 ATH_MSG_ERROR("Failed to register cuts in AcceptInfo");
58 return StatusCode::FAILURE;
59 }
60
61 ATH_CHECK(m_ContainerName.initialize());
62 ATH_CHECK(m_decoratorScore.initialize());
63
64#ifndef XAOD_STANDALONE
66 // The user has promised that this will be produced by the same alg.
67 // Tell the scheduler to ignore it to avoid circular dependencies.
69 }
70#endif
71
72 return StatusCode::SUCCESS;
73}
#define ATH_CHECK
Evaluate an expression and check for errors.
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)
Gaudi::Property< bool > m_suppressInputDeps
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName

◆ 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 221 of file AsgPhotonBDTSelector.cxx.

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

◆ loadConfig()

StatusCode AsgPhotonBDTSelector::loadConfig ( )
private

Definition at line 78 of file AsgPhotonBDTSelector.cxx.

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

Definition at line 250 of file AsgPhotonBDTSelector.cxx.

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

◆ 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 }

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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 106 of file AsgPhotonBDTSelector.h.

◆ m_configFile

std::string PhotonIDBDT::AsgPhotonBDTSelector::m_configFile = ""
private

Definition at line 90 of file AsgPhotonBDTSelector.h.

◆ m_ContainerName

SG::ReadHandleKey<xAOD::EgammaContainer> PhotonIDBDT::AsgPhotonBDTSelector::m_ContainerName { this, "ContainerName", "", "Input" }
private

Definition at line 121 of file AsgPhotonBDTSelector.h.

121{ this, "ContainerName", "", "Input" };

◆ m_cutConv

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

Definition at line 102 of file AsgPhotonBDTSelector.h.

◆ m_cutE277Conv

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

Definition at line 98 of file AsgPhotonBDTSelector.h.

◆ m_cutE277Unconv

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

Definition at line 99 of file AsgPhotonBDTSelector.h.

◆ m_cutF1Conv

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

Definition at line 96 of file AsgPhotonBDTSelector.h.

◆ m_cutF1Unconv

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

Definition at line 97 of file AsgPhotonBDTSelector.h.

◆ m_cutPosHasScore

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

Definition at line 109 of file AsgPhotonBDTSelector.h.

109{-1};

◆ m_cutPosInRange

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

Definition at line 108 of file AsgPhotonBDTSelector.h.

108{-1};

◆ m_cutPosPassPreselection

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

Definition at line 112 of file AsgPhotonBDTSelector.h.

112{-1};

◆ m_cutPosPreE277

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

Definition at line 111 of file AsgPhotonBDTSelector.h.

111{-1};

◆ m_cutPosPreF1

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

Definition at line 110 of file AsgPhotonBDTSelector.h.

110{-1};

◆ m_cutPosScore

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

Definition at line 107 of file AsgPhotonBDTSelector.h.

107{-1};

◆ m_cutUnconv

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

Definition at line 103 of file AsgPhotonBDTSelector.h.

◆ m_decoratorScore

SG::ReadDecorHandleKey<xAOD::EgammaContainer> PhotonIDBDT::AsgPhotonBDTSelector::m_decoratorScore
private
Initial value:
{ this,
"ScoreDecoration", m_ContainerName, "", "" }

Definition at line 122 of file AsgPhotonBDTSelector.h.

122 { this,
123 "ScoreDecoration", m_ContainerName, "", "" };

◆ 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 93 of file AsgPhotonBDTSelector.h.

◆ m_etBinsGeV

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

Definition at line 94 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 85 of file AsgPhotonBDTSelector.h.

85{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 87 of file AsgPhotonBDTSelector.h.

87{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 86 of file AsgPhotonBDTSelector.h.

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

◆ m_suppressInputDeps

Gaudi::Property<bool> PhotonIDBDT::AsgPhotonBDTSelector::m_suppressInputDeps {this, "SuppressInputDependence", false, "Will BDT score be created in the same algorithm that uses this tool?"}
private

Definition at line 125 of file AsgPhotonBDTSelector.h.

125{this, "SuppressInputDependence", false, "Will BDT score be created in the same algorithm that uses this tool?"};

◆ 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: