Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ParticleLevelOverlapRemovalAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
12 
13 namespace CP {
14 
16 
21 
22  if (!m_electronsKey.empty())
23  m_decORelectron = m_electronsKey.key() + "." + m_decLabelOR.value();
24  if (!m_muonsKey.empty())
25  m_decORmuon = m_muonsKey.key() + "." + m_decLabelOR.value();
26  if (!m_photonsKey.empty())
27  m_decORphoton = m_photonsKey.key() + "." + m_decLabelOR.value();
28  m_decORjet = m_jetsKey.key() + "." + m_decLabelOR.value();
29 
34 
35  if (!m_jetSelection.empty())
39  if (!m_muonSelection.empty())
41  if (!m_photonSelection.empty())
43 
44  return StatusCode::SUCCESS;
45 }
46 
48  TLorentzVector& p2,
49  bool useRapidity) const {
50  if (useRapidity)
51  return xAOD::P4Helpers::deltaR(p1->rapidity(), p1->phi(), p2.Rapidity(),
52  p2.Phi());
53  else
54  return xAOD::P4Helpers::deltaR(p1->eta(), p1->phi(), p2.Eta(), p2.Phi());
55 }
56 
57 StatusCode ParticleLevelOverlapRemovalAlg::execute(const EventContext &ctx) const {
61  if (m_doJetMuonOR)
62  muons = SG::makeHandle(m_muonsKey, ctx);
63  if (m_doJetPhotonOR)
64  photons = SG::makeHandle(m_photonsKey, ctx);
66 
68  m_decORelectron, ctx);
70  m_decORmuon, ctx);
72  m_decORphoton, ctx);
74 
75  // accessors
76  static const SG::AuxElement::ConstAccessor<float> acc_pt_dressed(
77  "pt_dressed");
78  static const SG::AuxElement::ConstAccessor<float> acc_eta_dressed(
79  "eta_dressed");
80  static const SG::AuxElement::ConstAccessor<float> acc_phi_dressed(
81  "phi_dressed");
82  static const SG::AuxElement::ConstAccessor<float> acc_e_dressed("e_dressed");
83 
84  // Default decorations: all objects pass!
85  for (const auto* jet : *jets) {
86  if (m_jetSelection)
87  dec_jets_OR(*jet) = m_jetSelection.getBool(*jet);
88  else
89  dec_jets_OR(*jet) = true;
90  }
91  if (m_doJetElectronOR) {
92  for (const auto* electron : *electrons) {
94  dec_electrons_OR(*electron) = m_electronSelection.getBool(*electron);
95  else
96  dec_electrons_OR(*electron) = true;
97  }
98  }
99  if (m_doJetMuonOR) {
100  for (const auto* muon : *muons) {
101  if (m_muonSelection)
102  dec_muons_OR(*muon) = m_muonSelection.getBool(*muon);
103  else
104  dec_muons_OR(*muon) = true;
105  }
106  }
107  if (m_doJetPhotonOR) {
108  for (const auto* photon : *photons) {
109  if (m_photonSelection)
110  dec_photons_OR(*photon) = m_photonSelection.getBool(*photon);
111  else
112  dec_photons_OR(*photon) = true;
113  }
114  }
115 
116  // ----------------------
117  // OVERLAP REMOVAL
118  // ----------------------
119  // Removal Steps:
120  // 1. Jets & Muons:
121  // Remove Muons with dR < 0.4
122  // 2. Jets & Electrons:
123  // Remove Electrons with dR < 0.4
124  // 3. Photons & Jets:
125  // Remove Jets with dR < 0.4
126 
127  for (const auto* jet : *jets) {
129  continue;
130  if (m_doJetMuonOR) {
131  for (const auto* muon : *muons) {
133  continue;
134  if (dec_muons_OR(*muon)) {
136  TLorentzVector dressed_muon;
137  dressed_muon.SetPtEtaPhiE(
138  acc_pt_dressed(*muon), acc_eta_dressed(*muon),
139  acc_phi_dressed(*muon), acc_e_dressed(*muon));
140  if (dressedDeltaR(jet, dressed_muon, m_useRapidity) < 0.4)
141  dec_muons_OR(*muon) = false;
142  } else {
144  dec_muons_OR(*muon) = false;
145  }
146  }
147  }
148  }
149  if (m_doJetElectronOR) {
150  for (const auto* electron : *electrons) {
152  continue;
153  if (dec_electrons_OR(*electron)) {
155  TLorentzVector dressed_electron;
156  dressed_electron.SetPtEtaPhiE(
157  acc_pt_dressed(*electron), acc_eta_dressed(*electron),
158  acc_phi_dressed(*electron), acc_e_dressed(*electron));
159  if (dressedDeltaR(jet, dressed_electron, m_useRapidity) < 0.4)
160  dec_electrons_OR(*electron) = false;
161  } else {
162  if (xAOD::P4Helpers::deltaR(jet, electron, m_useRapidity) < 0.4)
163  dec_electrons_OR(*electron) = false;
164  }
165  }
166  }
167  }
168  if (m_doJetPhotonOR) {
169  for (const auto* photon : *photons) {
171  continue;
172  if (dec_photons_OR(*photon)) {
173  if (xAOD::P4Helpers::deltaR(jet, photon) < 0.4)
174  dec_jets_OR(*jet) = false;
175  }
176  }
177  }
178  }
179 
180  return StatusCode::SUCCESS;
181 }
182 
183 } // namespace CP
CP::SelectionReadHandle::initialize
StatusCode initialize()
initialize the accessor
Definition: SelectionReadHandle.cxx:39
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
CP::ParticleLevelOverlapRemovalAlg::m_doJetPhotonOR
Gaudi::Property< bool > m_doJetPhotonOR
Definition: ParticleLevelOverlapRemovalAlg.h:65
CP::ParticleLevelOverlapRemovalAlg::m_decORelectron
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORelectron
Definition: ParticleLevelOverlapRemovalAlg.h:36
CP::ParticleLevelOverlapRemovalAlg::dressedDeltaR
float dressedDeltaR(const xAOD::Jet *p1, TLorentzVector &p2, bool useRapidity) const
Definition: ParticleLevelOverlapRemovalAlg.cxx:47
SG::ReadHandle< xAOD::TruthParticleContainer >
xAODP4Helpers.h
CP::ParticleLevelOverlapRemovalAlg::m_photonSelection
CP::SelectionReadHandle m_photonSelection
Definition: ParticleLevelOverlapRemovalAlg.h:49
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
CP::ParticleLevelOverlapRemovalAlg::m_muonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_muonsKey
Definition: ParticleLevelOverlapRemovalAlg.h:30
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
CP::ParticleLevelOverlapRemovalAlg::m_jetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
Definition: ParticleLevelOverlapRemovalAlg.h:26
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
CP::ParticleLevelOverlapRemovalAlg::m_muonSelection
CP::SelectionReadHandle m_muonSelection
Definition: ParticleLevelOverlapRemovalAlg.h:47
ParticleLevelOverlapRemovalAlg.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
CP::SelectionReadHandle::empty
bool empty() const noexcept
whether we have a name configured
Definition: SelectionReadHandle.cxx:23
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
CP::ParticleLevelOverlapRemovalAlg::m_decORphoton
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORphoton
Definition: ParticleLevelOverlapRemovalAlg.h:40
CP::ParticleLevelOverlapRemovalAlg::m_doJetElectronOR
Gaudi::Property< bool > m_doJetElectronOR
Definition: ParticleLevelOverlapRemovalAlg.h:59
CP::ParticleLevelOverlapRemovalAlg::m_electronSelection
CP::SelectionReadHandle m_electronSelection
Definition: ParticleLevelOverlapRemovalAlg.h:44
CP::ParticleLevelOverlapRemovalAlg::m_decLabelOR
Gaudi::Property< std::string > m_decLabelOR
Definition: ParticleLevelOverlapRemovalAlg.h:68
CP::ParticleLevelOverlapRemovalAlg::m_doJetMuonOR
Gaudi::Property< bool > m_doJetMuonOR
Definition: ParticleLevelOverlapRemovalAlg.h:62
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CP::ParticleLevelOverlapRemovalAlg::m_jetSelection
CP::SelectionReadHandle m_jetSelection
Definition: ParticleLevelOverlapRemovalAlg.h:42
CP::ParticleLevelOverlapRemovalAlg::m_useRapidity
Gaudi::Property< bool > m_useRapidity
Definition: ParticleLevelOverlapRemovalAlg.h:51
WriteDecorHandle.h
Handle class for adding a decoration to an object.
CP::SelectionReadHandle::getBool
bool getBool(const SG::AuxElement &element) const
get the selection as a bool
CP::ParticleLevelOverlapRemovalAlg::m_electronsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_electronsKey
Definition: ParticleLevelOverlapRemovalAlg.h:28
ReadHandle.h
Handle class for reading from StoreGate.
CP::ParticleLevelOverlapRemovalAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
Definition: ParticleLevelOverlapRemovalAlg.h:55
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::ParticleLevelOverlapRemovalAlg::m_photonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_photonsKey
Definition: ParticleLevelOverlapRemovalAlg.h:32
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
CP::ParticleLevelOverlapRemovalAlg::initialize
virtual StatusCode initialize() final
Definition: ParticleLevelOverlapRemovalAlg.cxx:15
CP::ParticleLevelOverlapRemovalAlg::execute
virtual StatusCode execute(const EventContext &ctx) const final
Definition: ParticleLevelOverlapRemovalAlg.cxx:57
CP::ParticleLevelOverlapRemovalAlg::m_decORmuon
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORmuon
Definition: ParticleLevelOverlapRemovalAlg.h:38
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::ParticleLevelOverlapRemovalAlg::m_decORjet
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decORjet
Definition: ParticleLevelOverlapRemovalAlg.h:34
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17