ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
14
16
17#include <cmath>
18#include <vector>
19
20
21namespace {
22 namespace MC = MCTruthPartClassifier;
23}
24
26
28 const std::string& name, ISvcLocator* loc)
29 : AthReentrantAlgorithm(name, loc)
30 {
31 }
32
34 ATH_CHECK(m_jetKey.initialize());
40
41 return StatusCode::SUCCESS;
42 }
43
45 const EventContext& ctx) const {
46
48 if (!jets.isValid()) {
49 ATH_MSG_ERROR("Failed to retrieve jet container: "
50 << m_jetKey.key());
51 return StatusCode::FAILURE;
52 }
53
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 = [&](
69 if (key.empty()) return;
71 if (!container.isValid()) return; // gracefully skip (e.g. data)
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
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
An algorithm that can be simultaneously executed in multiple threads.
JetOverlapLeptonDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthElectronKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_dec_hasOverlapLepton
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuonKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthElectronOriginKey
SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > m_truthMuonOriginKey
virtual StatusCode execute(const EventContext &ctx) const override
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
Property holding a SG store/key/clid from which a ReadHandle is made.
Handle class for adding a decoration to an object.
Jet_v1 Jet
Definition of the current "jet version".
TruthParticle_v1 TruthParticle
Typedef to implementation.