ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace CP {
14
16
17 ANA_CHECK(m_jetsKey.initialize());
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
33 ANA_CHECK(m_decORjet.initialize());
34
35 if (!m_jetSelection.empty())
36 ANA_CHECK(m_jetSelection.initialize());
37 if (!m_electronSelection.empty())
38 ANA_CHECK(m_electronSelection.initialize());
39 if (!m_muonSelection.empty())
40 ANA_CHECK(m_muonSelection.initialize());
41 if (!m_photonSelection.empty())
42 ANA_CHECK(m_photonSelection.initialize());
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
57StatusCode ParticleLevelOverlapRemovalAlg::execute(const EventContext &ctx) const {
58 SG::ReadHandle<xAOD::TruthParticleContainer> electrons, muons, photons;
60 electrons = SG::makeHandle(m_electronsKey, ctx);
61 if (m_doJetMuonOR)
62 muons = SG::makeHandle(m_muonsKey, ctx);
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::ConstAccessor<float> acc_pt_dressed(
77 "pt_dressed");
78 static const SG::ConstAccessor<float> acc_eta_dressed(
79 "eta_dressed");
80 static const SG::ConstAccessor<float> acc_phi_dressed(
81 "phi_dressed");
82 static const SG::ConstAccessor<float> acc_e_dressed("e_dressed");
83
84 // Default decorations: all objects pass!
85 for (const auto* jet : *jets) {
87 dec_jets_OR(*jet) = m_jetSelection.getBool(*jet);
88 else
89 dec_jets_OR(*jet) = true;
90 }
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) {
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) {
128 if (m_jetSelection && !m_jetSelection.getBool(*jet))
129 continue;
130 if (m_doJetMuonOR) {
131 for (const auto* muon : *muons) {
132 if (m_muonSelection && !m_muonSelection.getBool(*muon))
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 {
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)) {
174 dec_jets_OR(*jet) = false;
175 }
176 }
177 }
178 }
179
180 return StatusCode::SUCCESS;
181}
182
183} // namespace CP
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
#define ANA_CHECK(EXP)
check whether the given expression was successful
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_photonsKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORmuon
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_muonsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
float dressedDeltaR(const xAOD::Jet *p1, TLorentzVector &p2, bool useRapidity) const
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORphoton
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORelectron
virtual StatusCode execute(const EventContext &ctx) const final
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decORjet
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_electronsKey
Helper class to provide constant type-safe access to aux data.
Handle class for adding a decoration to an object.
Select isolated Photons, Electrons and Muons.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".