ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace
15{
17 const double GeV = 1e3;
18}
19
20namespace ORUtils
21{
22
23 //---------------------------------------------------------------------------
24 // Constructor
25 //---------------------------------------------------------------------------
26 EleJetOverlapTool::EleJetOverlapTool(const std::string& name)
27 : BaseOverlapTool(name)
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
62 m_maxElePtForBJetAwareOR = std::numeric_limits<double>::max();
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 resetAccessor (m_accessors->m_bJetAcc, *m_accessors, 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);
78 addSubtool(*m_dRMatchCone1);
79 if(m_useSlidingDR) {
80 ATH_MSG_DEBUG("Configuring sliding outer cone for ele-jet OR with " <<
81 "constants C1 = " << m_slidingDRC1 << ", C2 = " <<
82 m_slidingDRC2 << ", MaxCone = " << m_slidingDRMaxCone);
84 std::make_unique<SlidingDeltaRMatcher>
86 }
87 else {
88 ATH_MSG_DEBUG("Configuring ele-jet outer cone size " << m_outerDR);
89 m_dRMatchCone2 = std::make_unique<DeltaRMatcher>(m_outerDR, m_useRapidity);
90 }
92 addSubtool(*m_dRMatchCone2);
93
94 // Additional debug printouts
95 if(m_applyPtRatio) {
96 ATH_MSG_DEBUG("Apply ele/jet PT ratio requirement at " << m_eleJetPtRatio);
97 }
98
99 return StatusCode::SUCCESS;
100 }
101
102 //---------------------------------------------------------------------------
103 // Identify overlaps
104 //---------------------------------------------------------------------------
108 columnar::EventContextId /*eventContext*/) const
109 {
110 // Check the container types
111 ATH_CHECK (checkForXAODContainer<xAOD::ElectronContainer>(cont1, "First container arg is not an ElectronContainer!"));
112 ATH_CHECK (checkForXAODContainer<xAOD::JetContainer>(cont2, "Second container arg is not of type JetContainer!"));
113
114 ATH_CHECK( internalFindOverlaps(cont1, cont2) );
115 return StatusCode::SUCCESS;
116 }
117
118 //---------------------------------------------------------------------------
119 // Identify overlaps
120 //---------------------------------------------------------------------------
123 columnar::Particle2Range jets) const
124 {
125 ATH_MSG_DEBUG("Removing overlapping electrons and jets");
126 auto& acc = *m_accessors;
127
128 // Initialize output decorations if necessary
129 initializeDecorations(electrons);
131
132 // First flag overlapping jets
133 for(const auto electron : electrons){
134 if(!isSurvivingObject(electron)) continue;
135
136 for(const auto jet : jets){
137 if(!isSurvivingObject(jet)) continue;
138 // Don't reject user-defined b-tagged jets below an electron pT threshold
139 if(!m_bJetLabel.empty() && acc.m_bJetAcc(jet) &&
140 electron(acc.m_elePtAcc) < m_maxElePtForBJetAwareOR) continue;
141 // Don't reject jets with high relative PT
142 if(m_applyPtRatio && (electron(acc.m_elePtAcc)/jet(acc.m_jetPtAcc) < m_eleJetPtRatio)) continue;
143
144 if(m_dRMatchCone1->objectsMatch(jet, electron)){
145 ATH_CHECK( handleOverlap(jet, electron) );
146 }
147 }
148 }
149
150 // Now flag overlapping electrons
151 for(const auto jet: jets){
152 if(!isSurvivingObject(jet)) continue;
153
154 for(const auto electron : electrons){
155 if(!isSurvivingObject(electron)) continue;
156
157 if(m_dRMatchCone2->objectsMatch(electron, jet)){
158 ATH_CHECK( handleOverlap(electron, jet) );
159 }
160 }
161 }
162
163 return StatusCode::SUCCESS;
164 }
165
166} // namespace ORUtils
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
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 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
bool m_applyPtRatio
Toggle PT ratio criteria.
std::unique_ptr< IParticleAssociator > m_dRMatchCone1
Delta-R matcher for the inner cone.
std::unique_ptr< IParticleAssociator > m_dRMatchCone2
Delta-R matcher for the outer cone.
float m_outerDR
Outer dR cone within which electrons get removed.
bool m_useSlidingDR
Activate sliding dR for the cone which removes electrons.
double m_slidingDRMaxCone
Sliding cone max size.
virtual StatusCode initializeDerived() override
Initialize the tool.
double m_slidingDRC2
Sliding cone C2.
double m_slidingDRC1
Sliding cone C1.
double m_eleJetPtRatio
Minimum e/jet pt ratio to remove a jet.
bool m_useRapidity
Calculate deltaR using rapidity.
virtual StatusCode internalFindOverlaps(columnar::Particle1Range electrons, columnar::Particle2Range jets) const
Identify overlapping electrons and jets.
float m_innerDR
Inner dR cone within which jets get removed.
std::unique_ptr< Accessors > m_accessors
virtual StatusCode findOverlaps(columnar::Particle1Range cont1, columnar::Particle2Range cont2, columnar::EventContextId eventContext) const override
Identify overlapping electrons and jets.
double m_maxElePtForBJetAwareOR
Max electron PT for b-tag aware OR.
std::string m_bJetLabel
Input jet decoration which labels a bjet.
EleJetOverlapTool(const std::string &name)
Create proper constructor for Athena.
ObjectId< ContainerId::eventContext > EventContextId
ObjectRange< ContainerId::particle2 > Particle2Range
Definition ParticleDef.h:53
ObjectRange< ContainerId::particle1 > Particle1Range
Definition ParticleDef.h:47
@ Jet
The object is a jet.
Definition ObjectType.h:40
@ Electron
The object is an electron.
Definition ObjectType.h:46