ATLAS Offline Software
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 
14 namespace ORUtils
15 {
16 
17  //---------------------------------------------------------------------------
18  // Constructor
19  //---------------------------------------------------------------------------
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);
40 
41  return StatusCode::SUCCESS;
42  }
43 
44  //---------------------------------------------------------------------------
45  // Identify overlaps
46  //---------------------------------------------------------------------------
49  const xAOD::IParticleContainer& cont2) const
50  {
51  // Check the container types
52  if(typeid(cont1) != typeid(xAOD::TauJetContainer) &&
53  typeid(cont1) != typeid(ConstDataVector<xAOD::TauJetContainer>)) {
54  ATH_MSG_ERROR("First container arg is not of type TauJetContainer!");
55  return StatusCode::FAILURE;
56  }
57  if(typeid(cont2) != typeid(xAOD::ElectronContainer) &&
58  typeid(cont2) != typeid(ConstDataVector<xAOD::ElectronContainer>)) {
59  ATH_MSG_ERROR("Second container arg is not of type ElectronContainer!");
60  return StatusCode::FAILURE;
61  }
62  ATH_CHECK( findOverlaps(static_cast<const xAOD::TauJetContainer&>(cont1),
63  static_cast<const xAOD::ElectronContainer&>(cont2)) );
64  return StatusCode::SUCCESS;
65  }
66 
67  //---------------------------------------------------------------------------
68  // Identify overlaps
69  //---------------------------------------------------------------------------
73  {
74  ATH_MSG_DEBUG("Removing taus from loose electrons");
75 
76  // Initialize output decorations if necessary
77  m_decHelper->initializeDecorations(taus);
78  m_decHelper->initializeDecorations(electrons);
79 
80  // Loop over loose surviving electrons
81  for(auto electron : electrons){
82  if(m_decHelper->isRejectedObject(*electron)) continue;
83 
84  // Check the electron ID
85  bool passID = false;
86  ATH_CHECK( checkElectronID(*electron, passID) );
87  if(!passID) continue;
88 
89  // Loop over surviving taus
90  for(auto tau : taus){
91  if(!m_decHelper->isSurvivingObject(*tau)) continue;
92 
93  // Test for overlap
94  if(m_dRMatcher->objectsMatch(*electron, *tau)){
96  }
97  }
98  }
99 
100  return StatusCode::SUCCESS;
101  }
102 
103  //---------------------------------------------------------------------------
104  // Loose electron criteria
105  //---------------------------------------------------------------------------
107  checkElectronID(const xAOD::Electron& electron, bool& pass) const
108  {
109  try {
110  // Try the configured ID string.
111  if(!electron.passSelection(pass, m_eleID)) {
112  // If the ID wasn't found, try the fallback ID if provided.
113  if(!m_altEleID.empty()) {
114  if(!electron.passSelection(pass, m_altEleID)) {
115  ATH_MSG_ERROR("Electron IDs unavailable: " <<
116  m_eleID << ", " << m_altEleID);
117  return StatusCode::FAILURE;
118  }
119  }
120  else {
121  ATH_MSG_ERROR("Electron ID unavailable: " << m_eleID);
122  return StatusCode::FAILURE;
123  }
124  }
125  }
126  // Workaround for derivations with "int" type ID flags.
127  catch(const SG::ExcAuxTypeMismatch& e) {
129  if(acc.isAvailable(electron)) {
130  pass = acc(electron);
131  }
132  else {
133  throw;
134  }
135  }
136 
137  return StatusCode::SUCCESS;
138  }
139 
140 } // namespace ORUtils
ORUtils::TauLooseEleOverlapTool::m_dRMatcher
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
Definition: TauLooseEleOverlapTool.h:89
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ORUtils::TauLooseEleOverlapTool::m_maxDR
float m_maxDR
Maximum dR for objects flagged as overlap.
Definition: TauLooseEleOverlapTool.h:73
SG::ConstAccessor< int >
ORUtils
Definition: AltMuJetOverlapTool.h:20
TauLooseEleOverlapTool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ORUtils::BaseOverlapTool
Common base class tool for overlap tools.
Definition: BaseOverlapTool.h:38
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ORUtils::TauLooseEleOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: TauLooseEleOverlapTool.cxx:36
ORUtils::BaseOverlapTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper for handling input/output decorations.
Definition: BaseOverlapTool.h:95
ORUtils::TauLooseEleOverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlapping taus and loose electrons.
Definition: TauLooseEleOverlapTool.cxx:48
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ORUtils::TauLooseEleOverlapTool::m_useRapidity
bool m_useRapidity
Calculate delta-R using rapidity.
Definition: TauLooseEleOverlapTool.h:75
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::Electron_v1
Definition: Electron_v1.h:34
ORUtils::BaseOverlapTool::handleOverlap
virtual StatusCode handleOverlap(const xAOD::IParticle *testParticle, const xAOD::IParticle *refParticle) const
Common helper method to handle an overlap result.
Definition: BaseOverlapTool.cxx:64
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
ORUtils::TauLooseEleOverlapTool::TauLooseEleOverlapTool
TauLooseEleOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: TauLooseEleOverlapTool.cxx:20
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
ORUtils::TauLooseEleOverlapTool::checkElectronID
StatusCode checkElectronID(const xAOD::Electron &electron, bool &pass) const
Definition: TauLooseEleOverlapTool.cxx:107
ORUtils::TauLooseEleOverlapTool::m_altEleID
std::string m_altEleID
Alternate fallback loose ID string; mainly convenient for testing.
Definition: TauLooseEleOverlapTool.h:82
ORUtils::TauLooseEleOverlapTool::m_eleID
std::string m_eleID
Loose electron selection criteria string (e.g. Loose)
Definition: TauLooseEleOverlapTool.h:78
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
SG::ExcAuxTypeMismatch
Exception — Type mismatch for aux variable.
Definition: Control/AthContainers/AthContainers/exceptions.h:132