ATLAS Offline Software
AltMuJetOverlapTool.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 #include <limits>
8 
9 // Framework includes
11 
12 // Local includes
15 
16 namespace
17 {
19  const double GeV = 1e3;
20 }
21 
22 namespace ORUtils
23 {
24 
25  //---------------------------------------------------------------------------
26  // Constructor
27  //---------------------------------------------------------------------------
30  {
31  declareProperty("BJetLabel", m_bJetLabel = "",
32  "Input b-jet flag. Disabled by default.");
33  // Disabled by default
35  "Min number of jet tracks to keep jet and remove muon");
36  // Disabled by default
37  declareProperty("MuJetPtRatio", m_muJetPtRatio = 0.,
38  "Max PT ratio to keep jet and remove muon");
39  declareProperty("InnerDR", m_innerDR = 0.2,
40  "Inner cone for removing jets");
41  declareProperty("SlidingDRC1", m_slidingDRC1 = 0.04,
42  "The constant offset for sliding dR");
43  declareProperty("SlidingDRC2", m_slidingDRC2 = 10.*GeV,
44  "The inverse muon pt factor for sliding dR");
45  declareProperty("SlidingDRMaxCone",
47  "Maximum allowed size of sliding dR cone");
48  declareProperty("UseRapidity", m_useRapidity = true,
49  "Calculate delta-R using rapidity");
50  }
51 
52  //---------------------------------------------------------------------------
53  // Initialize
54  //---------------------------------------------------------------------------
56  {
57  // Initialize the b-jet helper
58  if(!m_bJetLabel.empty())
59  m_bJetHelper = std::make_unique<BJetHelper> (m_bJetLabel);
60 
61  // Initialize the inner cone dR matcher
63  std::make_unique<DeltaRMatcher> (m_innerDR, m_useRapidity);
64  // Initialize the sliding dR matcher
66  std::make_unique<SlidingDeltaRMatcher>
68 
69  return StatusCode::SUCCESS;
70  }
71 
72  //---------------------------------------------------------------------------
73  // Identify overlaps
74  //---------------------------------------------------------------------------
77  const xAOD::IParticleContainer& cont2) const
78  {
79  // Check the container types
80  if(typeid(cont1) != typeid(xAOD::MuonContainer) &&
81  typeid(cont1) != typeid(ConstDataVector<xAOD::MuonContainer>)) {
82  ATH_MSG_ERROR("First container arg is not of type MuonContainer!");
83  return StatusCode::FAILURE;
84  }
85  if(typeid(cont2) != typeid(xAOD::JetContainer) &&
86  typeid(cont2) != typeid(ConstDataVector<xAOD::JetContainer>)) {
87  ATH_MSG_ERROR("Second container arg is not of type JetContainer!");
88  return StatusCode::FAILURE;
89  }
90  ATH_CHECK( findOverlaps(static_cast<const xAOD::MuonContainer&>(cont1),
91  static_cast<const xAOD::JetContainer&>(cont2)) );
92  return StatusCode::SUCCESS;
93  }
94 
95  //---------------------------------------------------------------------------
96  // Identify overlaps
97  //---------------------------------------------------------------------------
100  const xAOD::JetContainer& jets) const
101  {
102  ATH_MSG_DEBUG("Removing overlapping muons and jets");
103 
104  // Initialize output decorations if necessary
105  m_decHelper->initializeDecorations(muons);
106  m_decHelper->initializeDecorations(jets);
107 
108  // Remove jets that overlap with muons in first cone.
109  for(const auto muon : muons){
110  if(!m_decHelper->isSurvivingObject(*muon)) continue;
111 
112  for(const auto jet : jets){
113  if(!m_decHelper->isSurvivingObject(*jet)) continue;
114  // User-defined jet criteria include b-tagging,
115  // numTrack, and the mu/jet PT ratio
116  if(m_bJetHelper && m_bJetHelper->isBJet(*jet)) continue;
117  if(getNumTracks(jet) >= m_numJetTrk) continue;
118  float ptRatio = muon->pt() / jet->pt();
119  if(ptRatio < m_muJetPtRatio) continue;
120 
121  if(m_dRMatchCone1->objectsMatch(*jet, *muon)){
123  }
124  }
125  }
126 
127  // Remove muons from remaining overlapping jets
128  for(const auto jet : jets){
129  if(!m_decHelper->isSurvivingObject(*jet)) continue;
130 
131  for(const auto muon : muons){
132  if(!m_decHelper->isSurvivingObject(*muon)) continue;
133 
134  if(m_dRMatchCone2->objectsMatch(*muon, *jet)){
136  }
137  }
138  }
139 
140  return StatusCode::SUCCESS;
141  }
142 
143  //---------------------------------------------------------------------------
144  // Retrieve the primary vertex
145  //---------------------------------------------------------------------------
147  {
148  const char* contName = "PrimaryVertices";
149  const xAOD::VertexContainer* vertices = nullptr;
150  if(evtStore()->retrieve(vertices, contName).isSuccess()) {
151  for(auto vtx : *vertices) {
152  if(vtx->vertexType() == xAOD::VxType::PriVtx)
153  return vtx;
154  }
155  }
156  else {
157  ATH_MSG_WARNING("Failed to retrieve " << contName);
158  }
159  return nullptr;
160  }
161 
162  //---------------------------------------------------------------------------
163  // Retrieve the primary vertex
164  //---------------------------------------------------------------------------
166  {
167  // Find the primary vertex
168  auto vtx = getPrimVtx();
169  if(!vtx) return -1;
170  static const SG::AuxElement::ConstAccessor< std::vector<int> > acc("NumTrkPt500");
171  return acc(*jet)[vtx->index()];
172  }
173 
174 } // namespace ORUtils
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
ORUtils::AltMuJetOverlapTool::getPrimVtx
const xAOD::Vertex * getPrimVtx() const
Retrieve the primary vertex used to count jet tracks.
Definition: AltMuJetOverlapTool.cxx:146
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::AltMuJetOverlapTool::m_useRapidity
bool m_useRapidity
Calculate deltaR using rapidity.
Definition: AltMuJetOverlapTool.h:108
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
ORUtils::AltMuJetOverlapTool::m_slidingDRC2
double m_slidingDRC2
Outer cone C2, the inverse pt factor in sliding dR.
Definition: AltMuJetOverlapTool.h:104
ORUtils::AltMuJetOverlapTool::m_innerDR
float m_innerDR
Inner dR cone within which jets get removed.
Definition: AltMuJetOverlapTool.h:100
ORUtils::AltMuJetOverlapTool::m_slidingDRC1
double m_slidingDRC1
Outer cone C1, the constant offset in sliding dR.
Definition: AltMuJetOverlapTool.h:102
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
ORUtils
Definition: AltMuJetOverlapTool.h:20
ORUtils::AltMuJetOverlapTool::m_bJetLabel
std::string m_bJetLabel
Input jet decoration which labels a bjet.
Definition: AltMuJetOverlapTool.h:92
ORUtils::AltMuJetOverlapTool::m_bJetHelper
std::unique_ptr< BJetHelper > m_bJetHelper
BJet helper.
Definition: AltMuJetOverlapTool.h:115
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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::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::AltMuJetOverlapTool::m_dRMatchCone1
std::unique_ptr< IParticleAssociator > m_dRMatchCone1
Delta-R matcher for the inner cone.
Definition: AltMuJetOverlapTool.h:118
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
ORUtils::BaseOverlapTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper for handling input/output decorations.
Definition: BaseOverlapTool.h:95
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AltMuJetOverlapTool.h
ORUtils::AltMuJetOverlapTool::m_slidingDRMaxCone
double m_slidingDRMaxCone
MaxCone, the upper limit of the sliding cone.
Definition: AltMuJetOverlapTool.h:106
ORUtils::AltMuJetOverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlapping muons and jets.
Definition: AltMuJetOverlapTool.cxx:76
ORUtils::AltMuJetOverlapTool::getNumTracks
int getNumTracks(const xAOD::Jet *jet) const
Helper method to get the number of tracks in a jet w.r.t.
Definition: AltMuJetOverlapTool.cxx:165
ORUtils::AltMuJetOverlapTool::m_dRMatchCone2
std::unique_ptr< IParticleAssociator > m_dRMatchCone2
Delta-R matcher for the outer cone.
Definition: AltMuJetOverlapTool.h:120
ORUtils::AltMuJetOverlapTool::m_numJetTrk
int m_numJetTrk
Minimum number of tracks to keep an overlapping jet.
Definition: AltMuJetOverlapTool.h:95
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DeltaRMatcher.h
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
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ORUtils::AltMuJetOverlapTool::AltMuJetOverlapTool
AltMuJetOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: AltMuJetOverlapTool.cxx:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
ORUtils::AltMuJetOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: AltMuJetOverlapTool.cxx:55
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ORUtils::AltMuJetOverlapTool::m_muJetPtRatio
float m_muJetPtRatio
Maximum ratio of mu/jet PT to keep an overlapping jet.
Definition: AltMuJetOverlapTool.h:97