ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
FlavorTagJetDecorators
src
JetOverlapLeptonDecoratorAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Ported from TDD's JetTruthAssociator (overlapLepton selection) and
6
// processEvent overlap check. Computes ftag_hasOverlapLepton per jet
7
// at derivation time, enabling TruthElectrons and TruthMuons removal
8
// from the DAOD.
9
10
#include "
JetOverlapLeptonDecoratorAlg.h
"
11
12
#include "
StoreGate/ReadDecorHandle.h
"
13
#include "
StoreGate/WriteDecorHandle.h
"
14
15
#include "
xAODTruth/TruthParticle.h
"
16
17
#include <cmath>
18
#include <vector>
19
20
21
namespace
{
22
namespace
MC
=
MCTruthPartClassifier
;
23
}
24
25
namespace
FlavorTagJetDecorators
{
26
27
JetOverlapLeptonDecoratorAlg::JetOverlapLeptonDecoratorAlg
(
28
const
std::string& name, ISvcLocator* loc)
29
:
AthReentrantAlgorithm
(name, loc)
30
{
31
}
32
33
StatusCode
JetOverlapLeptonDecoratorAlg::initialize
() {
34
ATH_CHECK
(
m_jetKey
.initialize());
35
ATH_CHECK
(
m_truthElectronKey
.initialize(
SG::AllowEmpty
));
36
ATH_CHECK
(
m_truthMuonKey
.initialize(
SG::AllowEmpty
));
37
ATH_CHECK
(
m_truthElectronOriginKey
.initialize(
SG::AllowEmpty
));
38
ATH_CHECK
(
m_truthMuonOriginKey
.initialize(
SG::AllowEmpty
));
39
ATH_CHECK
(
m_dec_hasOverlapLepton
.initialize());
40
41
return
StatusCode::SUCCESS;
42
}
43
44
StatusCode
JetOverlapLeptonDecoratorAlg::execute
(
45
const
EventContext& ctx)
const
{
46
47
SG::ReadHandle<xAOD::JetContainer>
jets(
m_jetKey
, ctx);
48
if
(!jets.isValid()) {
49
ATH_MSG_ERROR
(
"Failed to retrieve jet container: "
50
<<
m_jetKey
.key());
51
return
StatusCode::FAILURE;
52
}
53
54
SG::WriteDecorHandle<xAOD::JetContainer, char>
decOverlap(
55
m_dec_hasOverlapLepton
, ctx);
56
57
// Collect overlap-candidate leptons from both truth containers.
58
// Apply kinematic and origin selection here (mirrors TDD's
59
// baseline-truth-kinematics.json + overlapLepton particle selector).
60
const
float
drCut =
m_overlapDR
.value();
61
const
float
ptMin =
m_ptMinimum
.value();
62
const
float
absEtaMax =
m_absEtaMaximum
.value();
63
64
std::vector<const xAOD::TruthParticle*> leptons;
65
66
auto
collectLeptons = [&](
67
const
SG::ReadHandleKey<xAOD::TruthParticleContainer>
& key,
68
const
SG::ReadDecorHandleKey<xAOD::TruthParticleContainer>
& originKey) {
69
if
(key.empty())
return
;
70
SG::ReadHandle<xAOD::TruthParticleContainer>
container(key, ctx);
71
if
(!container.isValid())
return
;
// gracefully skip (e.g. data)
72
SG::ReadDecorHandle<xAOD::TruthParticleContainer, unsigned int>
origin(originKey, ctx);
73
for
(
const
xAOD::TruthParticle
* tp : *container) {
74
if
(tp->status() != 1)
continue
;
75
if
(tp->pt() < ptMin)
continue
;
76
if
(std::abs(tp->eta()) > absEtaMax)
continue
;
77
unsigned
int
o = origin(*tp);
78
if
(o != MC::WBoson && o != MC::ZBoson && o != MC::top)
continue
;
79
leptons.push_back(tp);
80
}
81
};
82
83
collectLeptons(
m_truthElectronKey
,
m_truthElectronOriginKey
);
84
collectLeptons(
m_truthMuonKey
,
m_truthMuonOriginKey
);
85
86
// Decorate each jet
87
for
(
const
xAOD::Jet
*
jet
: *jets) {
88
char
hasOverlap = 0;
89
for
(
const
xAOD::TruthParticle
* lep : leptons) {
90
if
(
jet
->p4().DeltaR(lep->p4()) < drCut) {
91
hasOverlap = 1;
92
break
;
93
}
94
}
95
decOverlap(*
jet
) = hasOverlap;
96
}
97
98
return
StatusCode::SUCCESS;
99
}
100
101
}
// namespace FlavorTagJetDecorators
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
TruthParticle.h
JetOverlapLeptonDecoratorAlg.h
ReadDecorHandle.h
Handle class for reading a decoration on an object.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_jetKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
Definition
JetOverlapLeptonDecoratorAlg.h:45
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::JetOverlapLeptonDecoratorAlg
JetOverlapLeptonDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
JetOverlapLeptonDecoratorAlg.cxx:27
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_truthElectronKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthElectronKey
Definition
JetOverlapLeptonDecoratorAlg.h:47
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_ptMinimum
Gaudi::Property< float > m_ptMinimum
Definition
JetOverlapLeptonDecoratorAlg.h:69
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_absEtaMaximum
Gaudi::Property< float > m_absEtaMaximum
Definition
JetOverlapLeptonDecoratorAlg.h:72
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_dec_hasOverlapLepton
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_hasOverlapLepton
Definition
JetOverlapLeptonDecoratorAlg.h:77
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_truthMuonKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonKey
Definition
JetOverlapLeptonDecoratorAlg.h:50
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_truthElectronOriginKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthElectronOriginKey
Definition
JetOverlapLeptonDecoratorAlg.h:56
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_overlapDR
Gaudi::Property< float > m_overlapDR
Definition
JetOverlapLeptonDecoratorAlg.h:66
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::m_truthMuonOriginKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthMuonOriginKey
Definition
JetOverlapLeptonDecoratorAlg.h:60
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
JetOverlapLeptonDecoratorAlg.cxx:44
FlavorTagJetDecorators::JetOverlapLeptonDecoratorAlg::initialize
virtual StatusCode initialize() override
Definition
JetOverlapLeptonDecoratorAlg.cxx:33
SG::ReadDecorHandleKey
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Definition
StoreGate/StoreGate/ReadDecorHandleKey.h:86
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition
StoreGate/StoreGate/ReadDecorHandle.h:94
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition
StoreGate/StoreGate/ReadHandleKey.h:40
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
FlavorTagJetDecorators
Definition
JetOverlapLeptonDecoratorAlg.cxx:25
MCTruthPartClassifier
Definition
TruthClasses.h:8
MC
Definition
HepMCHelpers.h:20
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
Generated on
for ATLAS Offline Software by
1.17.0