ATLAS Offline Software
EleMuSharedTrkOverlapTool.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 // EDM includes
13 
14 // Local includes
16 
17 namespace ORUtils
18 {
19 
20  //---------------------------------------------------------------------------
21  // Constructor
22  //---------------------------------------------------------------------------
25  {
26  declareProperty("RemoveCaloMuons", m_removeCaloMuons = true,
27  "Turn on removal of overlapping calo muons");
28  declareProperty("UseDRMatching", m_useDRMatching = false,
29  "Remove electrons in DR cone of muons");
30  declareProperty("DR", m_maxDR = 0.01,
31  "Delta-R cone for flagging overlaps");
32  declareProperty("UseRapidity", m_useRapidity = true,
33  "Calculate delta-R using rapidity");
34  }
35 
36  //---------------------------------------------------------------------------
37  // Initialize the tool
38  //---------------------------------------------------------------------------
40  {
41 
42  if(m_removeCaloMuons) {
43  ATH_MSG_DEBUG("Configuring removal of overlapping calo muons");
44  }
45 
46  if(m_useDRMatching){
47  ATH_MSG_DEBUG("Configuring removal of electrons in delta R cone of " << m_maxDR);
48  m_dRMatcher = std::make_unique<DeltaRMatcher>(m_maxDR, m_useRapidity);
49  }
50 
51  return StatusCode::SUCCESS;
52  }
53 
54  //---------------------------------------------------------------------------
55  // Identify overlaps
56  //---------------------------------------------------------------------------
59  const xAOD::IParticleContainer& cont2) const
60  {
61  // Check the container types
62  if(typeid(cont1) != typeid(xAOD::ElectronContainer) &&
63  typeid(cont1) != typeid(ConstDataVector<xAOD::ElectronContainer>)) {
64  ATH_MSG_ERROR("First container arg is not of type ElectronContainer!");
65  return StatusCode::FAILURE;
66  }
67  if(typeid(cont2) != typeid(xAOD::MuonContainer) &&
68  typeid(cont2) != typeid(ConstDataVector<xAOD::MuonContainer>)) {
69  ATH_MSG_ERROR("Second container arg is not of type MuonContainer!");
70  return StatusCode::FAILURE;
71  }
72  ATH_CHECK( findOverlaps(static_cast<const xAOD::ElectronContainer&>(cont1),
73  static_cast<const xAOD::MuonContainer&>(cont2)) );
74  return StatusCode::SUCCESS;
75  }
76 
77  //---------------------------------------------------------------------------
78  // Identify overlaps between electrons and muons
79  //---------------------------------------------------------------------------
82  const xAOD::MuonContainer& muons) const
83  {
84  ATH_MSG_DEBUG("Removing overlapping electrons and muons");
85 
86  // Initialize output decorations if necessary
87  m_decHelper->initializeDecorations(electrons);
88  m_decHelper->initializeDecorations(muons);
89 
90  // If removing calo-muons that overlap with electrons,
91  // then we need to do it in a separate loop first.
92  if(m_removeCaloMuons) {
93 
94  // Loop over electrons
95  for(const auto electron : electrons){
96  if(!m_decHelper->isSurvivingObject(*electron)) continue;
97 
98  // Get the original ID track
99  const xAOD::TrackParticle* elTrk =
101 
102  // Loop over input calo muons
103  for(const auto muon : muons) {
104  if(!m_decHelper->isSurvivingObject(*muon)) continue;
105  if(muon->muonType() != xAOD::Muon::CaloTagged) continue;
106 
107  // Get the muon ID track
108  const xAOD::TrackParticle* muTrk =
109  muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
110 
111  // Flag the calo muon as overlapping if they share the track
112  if(elTrk == muTrk) {
114  }
115  }
116  }
117  }
118 
119  // Loop over muons
120  for(const auto muon : muons){
121  if(!m_decHelper->isSurvivingObject(*muon)) continue;
122 
123  // Get the muon ID track
124  const xAOD::TrackParticle* muTrk =
125  muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
126 
127  // Loop over electrons
128  for(const auto electron : electrons) {
129  if(!m_decHelper->isSurvivingObject(*electron)) continue;
130 
131  // Get the original ID track
132  const xAOD::TrackParticle* elTrk =
134 
135  // Flag the electron as overlapping if they share the track
136  // or if they are DR matched
137  bool removeEle = (elTrk == muTrk);
138  if( (m_useDRMatching)
139  && (m_dRMatcher->objectsMatch(*electron, *muon)) ){
140  removeEle = true;
141  }
142  if(removeEle){
144  }
145  }
146  }
147  return StatusCode::SUCCESS;
148  }
149 
150 } // namespace ORUtils
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
ORUtils::EleMuSharedTrkOverlapTool::m_removeCaloMuons
bool m_removeCaloMuons
Flag to remove calo-muons overlapping with electrons.
Definition: EleMuSharedTrkOverlapTool.h:73
ORUtils::EleMuSharedTrkOverlapTool::findOverlaps
virtual StatusCode findOverlaps(const xAOD::IParticleContainer &cont1, const xAOD::IParticleContainer &cont2) const override
Identify overlaps via shared ID track.
Definition: EleMuSharedTrkOverlapTool.cxx:58
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
EleMuSharedTrkOverlapTool.h
ElectronxAODHelpers.h
ORUtils
Definition: AltMuJetOverlapTool.h:20
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::EleMuSharedTrkOverlapTool::EleMuSharedTrkOverlapTool
EleMuSharedTrkOverlapTool(const std::string &name)
Create proper constructor for Athena.
Definition: EleMuSharedTrkOverlapTool.cxx:23
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ORUtils::EleMuSharedTrkOverlapTool::initializeDerived
virtual StatusCode initializeDerived() override
Initialize the tool.
Definition: EleMuSharedTrkOverlapTool.cxx:39
ORUtils::BaseOverlapTool::m_decHelper
std::unique_ptr< OverlapDecorationHelper > m_decHelper
Helper for handling input/output decorations.
Definition: BaseOverlapTool.h:95
ORUtils::EleMuSharedTrkOverlapTool::m_maxDR
float m_maxDR
Maximum dR between electrons and muons if m_useDRMatching is used.
Definition: EleMuSharedTrkOverlapTool.h:78
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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::EleMuSharedTrkOverlapTool::m_useDRMatching
bool m_useDRMatching
Flag to remove electrons in a dR cone of muons (default: false)
Definition: EleMuSharedTrkOverlapTool.h:76
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
ORUtils::EleMuSharedTrkOverlapTool::m_dRMatcher
std::unique_ptr< DeltaRMatcher > m_dRMatcher
Delta-R matcher.
Definition: EleMuSharedTrkOverlapTool.h:87
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
xAOD::EgammaHelpers::getOriginalTrackParticle
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
Definition: ElectronxAODHelpers.cxx:11
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
ORUtils::EleMuSharedTrkOverlapTool::m_useRapidity
bool m_useRapidity
Calculate delta-R using rapidity.
Definition: EleMuSharedTrkOverlapTool.h:80