ATLAS Offline Software
TauJetOverlapTool.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
14 
15 namespace ORUtils
16 {
17 
18  //---------------------------------------------------------------------------
19  // Constructor
20  //---------------------------------------------------------------------------
23  {
24  declareProperty("BJetLabel", m_bJetLabel = "",
25  "Input b-jet flag. Disabled by default.");
26  declareProperty("DR", m_dR = 0.2, "Maximum dR for overlap match");
27  declareProperty("UseRapidity", m_useRapidity = true,
28  "Calculate delta-R using rapidity");
29  }
30 
31  //---------------------------------------------------------------------------
32  // Initialize
33  //---------------------------------------------------------------------------
35  {
36  // Initialize the b-jet helper
37  if(!m_bJetLabel.empty()) {
38  ATH_MSG_DEBUG("Configuring btag-aware OR with btag label: " << m_bJetLabel);
39  m_bJetHelper = std::make_unique<BJetHelper>(m_bJetLabel);
40  }
41 
42  // Initialize the dR matcher
43  m_dRMatcher = std::make_unique<DeltaRMatcher>(m_dR, m_useRapidity);
44 
45  return StatusCode::SUCCESS;
46  }
47 
48  //---------------------------------------------------------------------------
49  // Identify overlaps
50  //---------------------------------------------------------------------------
53  const xAOD::IParticleContainer& cont2) const
54  {
55  // Check the container types
56  if(typeid(cont1) != typeid(xAOD::JetContainer) &&
57  typeid(cont1) != typeid(ConstDataVector<xAOD::JetContainer>)) {
58  ATH_MSG_ERROR("First container arg is not of type JetContainer!");
59  return StatusCode::FAILURE;
60  }
61  if(typeid(cont2) != typeid(xAOD::TauJetContainer) &&
62  typeid(cont2) != typeid(ConstDataVector<xAOD::TauJetContainer>)) {
63  ATH_MSG_ERROR("Second container arg is not of type TauJetContainer!");
64  return StatusCode::FAILURE;
65  }
66  ATH_CHECK( findOverlaps(static_cast<const xAOD::JetContainer&>(cont1),
67  static_cast<const xAOD::TauJetContainer&>(cont2)) );
68  return StatusCode::SUCCESS;
69  }
70 
71  //---------------------------------------------------------------------------
72  // Identify overlaps
73  //---------------------------------------------------------------------------
76  const xAOD::TauJetContainer& taus) const
77  {
78  ATH_MSG_DEBUG("Removing overlapping taus and jets");
79 
80  // Initialize output decorations if necessary
81  m_decHelper->initializeDecorations(taus);
82  m_decHelper->initializeDecorations(jets);
83 
84  // TODO: add anti-tau support.
85 
86  // Remove non-btagged jets that overlap with taus.
87  for(const auto tau : taus){
88  if(!m_decHelper->isSurvivingObject(*tau)) continue;
89  for(const auto jet : jets){
90  if(!m_decHelper->isSurvivingObject(*jet)) continue;
91 
92  // Don't reject user-defined b-tagged jets
93  if(m_bJetHelper && m_bJetHelper->isBJet(*jet)) continue;
94 
95  if(m_dRMatcher->objectsMatch(*tau, *jet)){
96  ATH_CHECK( handleOverlap(jet, tau) );
97  }
98  }
99  }
100 
101  // Remove taus that overlap with remaining jets
102  for(const auto jet : jets) {
103  if(!m_decHelper->isSurvivingObject(*jet)) continue;
104  for(const auto tau : taus){
105  if(!m_decHelper->isSurvivingObject(*tau)) continue;
106 
107  if(m_dRMatcher->objectsMatch(*jet, *tau)) {
108  ATH_CHECK( handleOverlap(tau, jet) );
109  }
110  }
111  }
112 
113  return StatusCode::SUCCESS;
114  }
115 
116 } // namespace ORUtils
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::TauJetOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: TauJetOverlapTool.cxx:34
ORUtils
Definition: AltMuJetOverlapTool.h:20
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
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
ORUtils::TauJetOverlapTool::m_bJetLabel
std::string m_bJetLabel
Input jet decoration which labels a bjet.
Definition: TauJetOverlapTool.h:72
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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:794
TauJetOverlapTool.h
ORUtils::TauJetOverlapTool::m_useRapidity
bool m_useRapidity
Calculate deltaR using rapidity.
Definition: TauJetOverlapTool.h:77
ORUtils::TauJetOverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlapping taus and jets.
Definition: TauJetOverlapTool.cxx:52
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
ORUtils::TauJetOverlapTool::m_dR
float m_dR
Flat delta-R cone for matching objects.
Definition: TauJetOverlapTool.h:75
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
ORUtils::TauJetOverlapTool::m_bJetHelper
std::unique_ptr< BJetHelper > m_bJetHelper
BJet helper.
Definition: TauJetOverlapTool.h:85
ORUtils::TauJetOverlapTool::TauJetOverlapTool
TauJetOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: TauJetOverlapTool.cxx:21
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ORUtils::TauJetOverlapTool::m_dRMatcher
std::unique_ptr< IParticleAssociator > m_dRMatcher
Delta-R matcher.
Definition: TauJetOverlapTool.h:88