ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
TruthParticleLevelAnalysisAlgorithms
Root
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
7
#include "
TruthParticleLevelAnalysisAlgorithms/ParticleLevelOverlapRemovalAlg.h
"
8
9
#include <
AsgDataHandles/ReadHandle.h
>
10
#include <
AsgDataHandles/WriteDecorHandle.h
>
11
#include <
FourMomUtils/xAODP4Helpers.h
>
12
13
namespace
CP
{
14
15
StatusCode
ParticleLevelOverlapRemovalAlg::initialize
() {
16
17
ANA_CHECK
(
m_jetsKey
.initialize());
18
ANA_CHECK
(
m_electronsKey
.initialize(
SG::AllowEmpty
));
19
ANA_CHECK
(
m_muonsKey
.initialize(
SG::AllowEmpty
));
20
ANA_CHECK
(
m_photonsKey
.initialize(
SG::AllowEmpty
));
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
30
ANA_CHECK
(
m_decORelectron
.initialize(
SG::AllowEmpty
));
31
ANA_CHECK
(
m_decORmuon
.initialize(
SG::AllowEmpty
));
32
ANA_CHECK
(
m_decORphoton
.initialize(
SG::AllowEmpty
));
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
47
float
ParticleLevelOverlapRemovalAlg::dressedDeltaR
(
const
xAOD::Jet
* p1,
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
{
58
SG::ReadHandle<xAOD::TruthParticleContainer>
electrons, muons, photons;
59
if
(
m_doJetElectronOR
)
60
electrons =
SG::makeHandle
(
m_electronsKey
, ctx);
61
if
(
m_doJetMuonOR
)
62
muons =
SG::makeHandle
(
m_muonsKey
, ctx);
63
if
(
m_doJetPhotonOR
)
64
photons =
SG::makeHandle
(
m_photonsKey
, ctx);
65
SG::ReadHandle<xAOD::JetContainer>
jets(
m_jetsKey
, ctx);
66
67
SG::WriteDecorHandle<xAOD::TruthParticleContainer, char>
dec_electrons_OR(
68
m_decORelectron
, ctx);
69
SG::WriteDecorHandle<xAOD::TruthParticleContainer, char>
dec_muons_OR(
70
m_decORmuon
, ctx);
71
SG::WriteDecorHandle<xAOD::TruthParticleContainer, char>
dec_photons_OR(
72
m_decORphoton
, ctx);
73
SG::WriteDecorHandle<xAOD::JetContainer, char>
dec_jets_OR(
m_decORjet
, 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) {
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) {
93
if
(
m_electronSelection
)
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) {
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
)) {
135
if
(
m_useDressedProperties
) {
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
{
143
if
(
xAOD::P4Helpers::deltaR
(
jet
,
muon
,
m_useRapidity
) < 0.4)
144
dec_muons_OR(*
muon
) =
false
;
145
}
146
}
147
}
148
}
149
if
(
m_doJetElectronOR
) {
150
for
(
const
auto
*
electron
: *electrons) {
151
if
(
m_electronSelection
&& !
m_electronSelection
.getBool(*
electron
))
152
continue
;
153
if
(dec_electrons_OR(*
electron
)) {
154
if
(
m_useDressedProperties
) {
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) {
170
if
(
m_photonSelection
&& !
m_photonSelection
.getBool(*
photon
))
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
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:322
ParticleLevelOverlapRemovalAlg.h
CP::ParticleLevelOverlapRemovalAlg::m_photonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_photonsKey
Definition
ParticleLevelOverlapRemovalAlg.h:32
CP::ParticleLevelOverlapRemovalAlg::m_decORmuon
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORmuon
Definition
ParticleLevelOverlapRemovalAlg.h:38
CP::ParticleLevelOverlapRemovalAlg::m_muonsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_muonsKey
Definition
ParticleLevelOverlapRemovalAlg.h:30
CP::ParticleLevelOverlapRemovalAlg::m_jetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey
Definition
ParticleLevelOverlapRemovalAlg.h:26
CP::ParticleLevelOverlapRemovalAlg::dressedDeltaR
float dressedDeltaR(const xAOD::Jet *p1, TLorentzVector &p2, bool useRapidity) const
Definition
ParticleLevelOverlapRemovalAlg.cxx:47
CP::ParticleLevelOverlapRemovalAlg::m_decORphoton
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORphoton
Definition
ParticleLevelOverlapRemovalAlg.h:40
CP::ParticleLevelOverlapRemovalAlg::m_decORelectron
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_decORelectron
Definition
ParticleLevelOverlapRemovalAlg.h:36
CP::ParticleLevelOverlapRemovalAlg::m_jetSelection
CP::SelectionReadHandle m_jetSelection
Definition
ParticleLevelOverlapRemovalAlg.h:42
CP::ParticleLevelOverlapRemovalAlg::m_muonSelection
CP::SelectionReadHandle m_muonSelection
Definition
ParticleLevelOverlapRemovalAlg.h:47
CP::ParticleLevelOverlapRemovalAlg::m_useDressedProperties
Gaudi::Property< bool > m_useDressedProperties
Definition
ParticleLevelOverlapRemovalAlg.h:55
CP::ParticleLevelOverlapRemovalAlg::execute
virtual StatusCode execute(const EventContext &ctx) const final
Definition
ParticleLevelOverlapRemovalAlg.cxx:57
CP::ParticleLevelOverlapRemovalAlg::m_decORjet
SG::WriteDecorHandleKey< xAOD::JetContainer > m_decORjet
Definition
ParticleLevelOverlapRemovalAlg.h:34
CP::ParticleLevelOverlapRemovalAlg::initialize
virtual StatusCode initialize() final
Definition
ParticleLevelOverlapRemovalAlg.cxx:15
CP::ParticleLevelOverlapRemovalAlg::m_electronsKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_electronsKey
Definition
ParticleLevelOverlapRemovalAlg.h:28
CP::ParticleLevelOverlapRemovalAlg::m_doJetPhotonOR
Gaudi::Property< bool > m_doJetPhotonOR
Definition
ParticleLevelOverlapRemovalAlg.h:65
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_doJetMuonOR
Gaudi::Property< bool > m_doJetMuonOR
Definition
ParticleLevelOverlapRemovalAlg.h:62
CP::ParticleLevelOverlapRemovalAlg::m_useRapidity
Gaudi::Property< bool > m_useRapidity
Definition
ParticleLevelOverlapRemovalAlg.h:51
CP::ParticleLevelOverlapRemovalAlg::m_decLabelOR
Gaudi::Property< std::string > m_decLabelOR
Definition
ParticleLevelOverlapRemovalAlg.h:68
CP::ParticleLevelOverlapRemovalAlg::m_photonSelection
CP::SelectionReadHandle m_photonSelection
Definition
ParticleLevelOverlapRemovalAlg.h:49
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:268
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
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::photon
@ photon
Definition
TrackingPrimitives.h:200
xAOD::muon
@ muon
Definition
TrackingPrimitives.h:196
xAOD::electron
@ electron
Definition
TrackingPrimitives.h:195
xAODP4Helpers.h
Generated on
for ATLAS Offline Software by
1.17.0