ATLAS Offline Software
Loading...
Searching...
No Matches
TauLooseEleOverlapTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// System includes
6#include <typeinfo>
7
8// Framework includes
10
11// Local includes
13
14namespace ORUtils
15{
16
17 //---------------------------------------------------------------------------
18 // Constructor
19 //---------------------------------------------------------------------------
21 : BaseOverlapTool(name)
22 {
23 declareProperty("DR", m_maxDR = 0.2,
24 "Delta-R cone for flagging overlaps");
25 declareProperty("UseRapidity", m_useRapidity = true,
26 "Calculate delta-R using rapidity");
27 declareProperty("ElectronID", m_eleID = "DFCommonElectronsLHLoose",
28 "Loose electron ID selection string");
29 declareProperty("AltElectronID", m_altEleID = "",
30 "Optional alternate ID in case primary one unavailable");
31 }
32
33 //---------------------------------------------------------------------------
34 // Initialize
35 //---------------------------------------------------------------------------
37 {
38 // Initialize the dR matcher
39 m_dRMatcher = std::make_unique<DeltaRMatcher>(m_maxDR, m_useRapidity);
41 addSubtool(*m_dRMatcher);
42
43 resetAccessor(m_accessors->m_eleIDAcc, *m_accessors, m_eleID, {.isOptional = !m_eleID.empty()});
44 if (!m_altEleID.empty())
45 resetAccessor(m_accessors->m_altEleIDAcc, *m_accessors, m_altEleID, {.isOptional = true});
46
47 return StatusCode::SUCCESS;
48 }
49
50 //---------------------------------------------------------------------------
51 // Identify overlaps
52 //---------------------------------------------------------------------------
56 columnar::EventContextId /*eventContext*/) const
57 {
58 // Check the container types
59 ATH_CHECK( checkForXAODContainer<xAOD::TauJetContainer>(cont1, "First container arg is not of type TauJetContainer!") );
60 ATH_CHECK( checkForXAODContainer<xAOD::ElectronContainer>(cont2, "Second container arg is not of type ElectronContainer!") );
61
62 ATH_CHECK( internalFindOverlaps(cont1, cont2) );
63 return StatusCode::SUCCESS;
64 }
65
66 //---------------------------------------------------------------------------
67 // Identify overlaps
68 //---------------------------------------------------------------------------
71 columnar::Particle2Range electrons) const
72 {
73 ATH_MSG_DEBUG("Removing taus from loose electrons");
74
75 // Initialize output decorations if necessary
77 initializeDecorations(electrons);
78
79 // Loop over loose surviving electrons
80 for(auto electron : electrons){
81 if(isRejectedObject(electron)) continue;
82
83 // Check the electron ID
84 bool passID = false;
85 ATH_CHECK( checkElectronID(electron, passID) );
86 if(!passID) continue;
87
88 // Loop over surviving taus
89 for(auto tau : taus){
90 if(!isSurvivingObject(tau)) continue;
91
92 // Test for overlap
93 if(m_dRMatcher->objectsMatch(electron, tau)){
94 ATH_CHECK( handleOverlap(tau, electron) );
95 }
96 }
97 }
98
99 return StatusCode::SUCCESS;
100 }
101
102 //---------------------------------------------------------------------------
103 // Loose electron criteria
104 //---------------------------------------------------------------------------
106 checkElectronID(columnar::Particle2Id electron, bool& pass) const
107 {
108 auto& acc = *m_accessors;
109 // Try the configured ID string.
110 if (acc.m_eleIDAcc.isAvailable(electron)) {
111 pass = acc.m_eleIDAcc(electron);
112 } else {
113 // If the ID wasn't found, try the fallback ID if provided.
114 if(!m_altEleID.empty()) {
115 if (acc.m_altEleIDAcc.isAvailable(electron)) {
116 pass = acc.m_altEleIDAcc(electron);
117 } else {
118 ATH_MSG_ERROR("Electron IDs unavailable: " <<
119 m_eleID << ", " << m_altEleID);
120 return StatusCode::FAILURE;
121 }
122 } else {
123 ATH_MSG_ERROR("Electron ID unavailable: " << m_eleID);
124 return StatusCode::FAILURE;
125 }
126 }
127
128 return StatusCode::SUCCESS;
129 }
130
131} // namespace ORUtils
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
static Double_t taus
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
void initializeDecorations(columnar::Particle1Range container) const
BaseOverlapTool(const std::string &name)
Create proper constructor for Athena.
StatusCode handleOverlap(const columnar::ObjectId< CI1, CM > &testParticle, const columnar::ObjectId< CI2, CM > &refParticle) const
Common helper method to handle an overlap result.
bool isRejectedObject(columnar::Particle1Id obj) const
bool isSurvivingObject(columnar::Particle1Id obj) const
StatusCode checkForXAODContainer(columnar::ObjectRange< CI, CM > cont, std::string_view message) const
check whether the container is of the right type
TauLooseEleOverlapTool(const std::string &name)
Create proper constructor for Athena.
bool m_useRapidity
Calculate delta-R using rapidity.
std::unique_ptr< Accessors > m_accessors
virtual StatusCode initializeDerived() override
Initialize the tool.
StatusCode checkElectronID(columnar::Particle2Id electron, bool &pass) const
float m_maxDR
Maximum dR for objects flagged as overlap.
virtual StatusCode findOverlaps(columnar::Particle1Range cont1, columnar::Particle2Range cont2, columnar::EventContextId eventContext) const override
Identify overlapping taus and loose electrons.
std::string m_eleID
Loose electron selection criteria string (e.g. Loose)
std::string m_altEleID
Alternate fallback loose ID string; mainly convenient for testing.
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
virtual StatusCode internalFindOverlaps(columnar::Particle1Range taus, columnar::Particle2Range electrons) const
Identify overlapping taus and loose electrons.
ObjectId< ContainerId::particle2 > Particle2Id
Definition ParticleDef.h:54
ObjectId< ContainerId::eventContext > EventContextId
ObjectRange< ContainerId::particle2 > Particle2Range
Definition ParticleDef.h:53
ObjectRange< ContainerId::particle1 > Particle1Range
Definition ParticleDef.h:47
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Tau
The object is a tau (jet)
Definition ObjectType.h:49