ATLAS Offline Software
EleJetOverlapTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 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
15 {
17  const double GeV = 1e3;
18 }
19 
20 namespace ORUtils
21 {
22 
23  //---------------------------------------------------------------------------
24  // Constructor
25  //---------------------------------------------------------------------------
28  {
29  declareProperty("BJetLabel", m_bJetLabel = "",
30  "Input b-jet flag. Disabled by default.");
31  declareProperty("MaxElePtForBJetAwareOR", m_maxElePtForBJetAwareOR = 100.*GeV,
32  "Max electron PT for b-tag aware OR. 100 GeV by default.");
33  declareProperty("ApplyPtRatio", m_applyPtRatio = false,
34  "Toggle ele/jet PT ratio requirement");
35  declareProperty("EleJetPtRatio", m_eleJetPtRatio = 0.8,
36  "Ele/jet PT ratio threshold to remove a jet");
37  declareProperty("InnerDR", m_innerDR = 0.2,
38  "Inner cone for removing jets");
39  declareProperty("OuterDR", m_outerDR = 0.4,
40  "Outer cone for removing electrons");
41  declareProperty("UseSlidingDR", m_useSlidingDR = false,
42  "Use sliding dR cone to reject electrons");
43  declareProperty("SlidingDRC1", m_slidingDRC1 = 0.04,
44  "The constant offset for sliding dR");
45  declareProperty("SlidingDRC2", m_slidingDRC2 = 10.*GeV,
46  "The inverse muon pt factor for sliding dR");
47  declareProperty("SlidingDRMaxCone", m_slidingDRMaxCone = 0.4,
48  "Maximum size of sliding dR cone");
49  declareProperty("UseRapidity", m_useRapidity = true,
50  "Calculate delta-R using rapidity");
51  }
52 
53  //---------------------------------------------------------------------------
54  // Initialize
55  //---------------------------------------------------------------------------
57  {
58  // Initialize the b-jet helper
59  if(!m_bJetLabel.empty()) {
60 
61  if (m_maxElePtForBJetAwareOR < 0){
63  ATH_MSG_DEBUG("Configuring btag-aware OR with btag label " <<
64  m_bJetLabel << " for all electrons");
65  }
66  else{
67  ATH_MSG_DEBUG("Configuring btag-aware OR with btag label " <<
68  m_bJetLabel << " for electrons below "
69  << m_maxElePtForBJetAwareOR/GeV << " GeV");
70  }
71  m_bJetHelper = std::make_unique<BJetHelper>(m_bJetLabel);
72  }
73 
74  // Initialize the dR matchers
75  ATH_MSG_DEBUG("Configuring ele-jet inner cone size " << m_innerDR);
76  m_dRMatchCone1 = std::make_unique<DeltaRMatcher>(m_innerDR, m_useRapidity);
77  if(m_useSlidingDR) {
78  ATH_MSG_DEBUG("Configuring sliding outer cone for ele-jet OR with " <<
79  "constants C1 = " << m_slidingDRC1 << ", C2 = " <<
80  m_slidingDRC2 << ", MaxCone = " << m_slidingDRMaxCone);
82  std::make_unique<SlidingDeltaRMatcher>
84  }
85  else {
86  ATH_MSG_DEBUG("Configuring ele-jet outer cone size " << m_outerDR);
87  m_dRMatchCone2 = std::make_unique<DeltaRMatcher>(m_outerDR, m_useRapidity);
88  }
89 
90  // Additional debug printouts
91  if(m_applyPtRatio) {
92  ATH_MSG_DEBUG("Apply ele/jet PT ratio requirement at " << m_eleJetPtRatio);
93  }
94 
95  return StatusCode::SUCCESS;
96  }
97 
98  //---------------------------------------------------------------------------
99  // Identify overlaps
100  //---------------------------------------------------------------------------
103  const xAOD::IParticleContainer& cont2) const
104  {
105  // Check the container types
106  if(typeid(cont1) != typeid(xAOD::ElectronContainer) &&
107  typeid(cont1) != typeid(ConstDataVector<xAOD::ElectronContainer>)) {
108  ATH_MSG_ERROR("First container arg is not an ElectronContainer!");
109  return StatusCode::FAILURE;
110  }
111  if(typeid(cont2) != typeid(xAOD::JetContainer) &&
112  typeid(cont2) != typeid(ConstDataVector<xAOD::JetContainer>)) {
113  ATH_MSG_ERROR("Second container arg is not of type JetContainer!");
114  return StatusCode::FAILURE;
115  }
116  ATH_CHECK( findOverlaps(static_cast<const xAOD::ElectronContainer&>(cont1),
117  static_cast<const xAOD::JetContainer&>(cont2)) );
118  return StatusCode::SUCCESS;
119  }
120 
121  //---------------------------------------------------------------------------
122  // Identify overlaps
123  //---------------------------------------------------------------------------
126  const xAOD::JetContainer& jets) const
127  {
128  ATH_MSG_DEBUG("Removing overlapping electrons and jets");
129 
130  // Initialize output decorations if necessary
131  m_decHelper->initializeDecorations(electrons);
132  m_decHelper->initializeDecorations(jets);
133 
134  // First flag overlapping jets
135  for(const auto electron : electrons){
136  if(!m_decHelper->isSurvivingObject(*electron)) continue;
137 
138  for(const auto jet : jets){
139  if(!m_decHelper->isSurvivingObject(*jet)) continue;
140  // Don't reject user-defined b-tagged jets below an electron pT threshold
141  if(m_bJetHelper && m_bJetHelper->isBJet(*jet) &&
142  electron->pt() < m_maxElePtForBJetAwareOR) continue;
143  // Don't reject jets with high relative PT
144  if(m_applyPtRatio && (electron->pt()/jet->pt() < m_eleJetPtRatio)) continue;
145 
146  if(m_dRMatchCone1->objectsMatch(*jet, *electron)){
148  }
149  }
150  }
151 
152  // Now flag overlapping electrons
153  for(const auto jet: jets){
154  if(!m_decHelper->isSurvivingObject(*jet)) continue;
155 
156  for(const auto electron : electrons){
157  if(!m_decHelper->isSurvivingObject(*electron)) continue;
158 
159  if(m_dRMatchCone2->objectsMatch(*electron, *jet)){
161  }
162  }
163  }
164 
165  return StatusCode::SUCCESS;
166  }
167 
168 } // namespace ORUtils
EleJetOverlapTool.h
ORUtils::EleJetOverlapTool::m_dRMatchCone2
std::unique_ptr< IParticleAssociator > m_dRMatchCone2
Delta-R matcher for the outer cone.
Definition: EleJetOverlapTool.h:114
ORUtils::EleJetOverlapTool::m_slidingDRMaxCone
double m_slidingDRMaxCone
Sliding cone max size.
Definition: EleJetOverlapTool.h:98
max
#define max(a, b)
Definition: cfImp.cxx:41
ORUtils::EleJetOverlapTool::m_eleJetPtRatio
double m_eleJetPtRatio
Minimum e/jet pt ratio to remove a jet.
Definition: EleJetOverlapTool.h:84
ORUtils::EleJetOverlapTool::m_bJetLabel
std::string m_bJetLabel
Input jet decoration which labels a bjet.
Definition: EleJetOverlapTool.h:76
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
Definition: AltMuJetOverlapTool.h:20
ORUtils::EleJetOverlapTool::EleJetOverlapTool
EleJetOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: EleJetOverlapTool.cxx:26
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
ORUtils::EleJetOverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlapping electrons and jets.
Definition: EleJetOverlapTool.cxx:102
ORUtils::BaseOverlapTool
Common base class tool for overlap tools.
Definition: BaseOverlapTool.h:38
ORUtils::EleJetOverlapTool::m_useSlidingDR
bool m_useSlidingDR
Activate sliding dR for the cone which removes electrons.
Definition: EleJetOverlapTool.h:92
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::EleJetOverlapTool::m_outerDR
float m_outerDR
Outer dR cone within which electrons get removed.
Definition: EleJetOverlapTool.h:89
ORUtils::BaseOverlapTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper for handling input/output decorations.
Definition: BaseOverlapTool.h:95
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ORUtils::EleJetOverlapTool::m_dRMatchCone1
std::unique_ptr< IParticleAssociator > m_dRMatchCone1
Delta-R matcher for the inner cone.
Definition: EleJetOverlapTool.h:112
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
ORUtils::EleJetOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: EleJetOverlapTool.cxx:56
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
ORUtils::EleJetOverlapTool::m_applyPtRatio
bool m_applyPtRatio
Toggle PT ratio criteria.
Definition: EleJetOverlapTool.h:82
ORUtils::EleJetOverlapTool::m_slidingDRC2
double m_slidingDRC2
Sliding cone C2.
Definition: EleJetOverlapTool.h:96
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ORUtils::EleJetOverlapTool::m_maxElePtForBJetAwareOR
double m_maxElePtForBJetAwareOR
Max electron PT for b-tag aware OR.
Definition: EleJetOverlapTool.h:79
ORUtils::EleJetOverlapTool::m_slidingDRC1
double m_slidingDRC1
Sliding cone C1.
Definition: EleJetOverlapTool.h:94
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
ORUtils::EleJetOverlapTool::m_useRapidity
bool m_useRapidity
Calculate deltaR using rapidity.
Definition: EleJetOverlapTool.h:101
ORUtils::EleJetOverlapTool::m_innerDR
float m_innerDR
Inner dR cone within which jets get removed.
Definition: EleJetOverlapTool.h:87
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
ORUtils::EleJetOverlapTool::m_bJetHelper
std::unique_ptr< BJetHelper > m_bJetHelper
BJet helper.
Definition: EleJetOverlapTool.h:109