ATLAS Offline Software
Loading...
Searching...
No Matches
HIJetAugmentationTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <format>
8
10{
12 const std::string& n,
13 const IInterface* p ) : base_class(t,n,p)
14 {
15 }
16
17 // Destructor
21
22 // Athena initialize and finalize
24 {
25 ATH_CHECK(m_eventInfoKey.initialize());
26 ATH_CHECK(m_hiJet_key.initialize());
27 ATH_CHECK(m_caloJet_key.initialize());
28 ATH_CHECK(m_jvtUpdateTool.retrieve());
29
30 m_jvtMatchedKey = m_hiJet_key.key() + "." + m_jvtMatchedKey.key();
31 ATH_CHECK(m_jvtMatchedKey.initialize());
32
33 ATH_MSG_INFO("DeltaRJetMatching = "<< m_deltaR.value());
34
35
36 return StatusCode::SUCCESS;
37 }
38
40 {
41
42 ATH_CHECK(m_jvtUpdateTool->finalize());
43
44 return StatusCode::SUCCESS;
45 }
46
47 double deltaR(double eta1, double eta2, double phi1, double phi2) {
48 double deltaPhi = TVector2::Phi_mpi_pi(phi1 - phi2);
49 double deltaEta = eta1 - eta2;
50 return std::sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi);
51 }
52
53 StatusCode HIJetAugmentationTool::addBranches(const EventContext &ctx) const {
55
56 // Load jet containers
58 if (!hiJets.isValid()) {
59 ATH_MSG_ERROR("Couldn't retrieve JetContainer with key " << m_hiJet_key);
60 return StatusCode::FAILURE;
61 }
63 if (!caloJets.isValid()) {
64 ATH_MSG_ERROR("Couldn't retrieve JetContainer with key "
65 << m_caloJet_key);
66 return StatusCode::FAILURE;
67 }
68
70
71 // first loop over calibrated HI jets
72 for (const auto *hjet : *hiJets) {
73 float mindR = 999.;
74 float matchedJvt = -1;
75 // second loop over topo jets
76 for (const auto *tjet : *caloJets) {
77 float newjvt = m_jvtUpdateTool->updateJvt(*tjet);
78
79 // perform the matching
80 float dR =
81 deltaR(tjet->eta(), hjet->eta(), hjet->phi(), tjet->phi());
82
83 if (dR < m_deltaR.value() && dR < mindR) {
84 mindR = dR;
85 matchedJvt = newjvt;
86 }
87 }
88
89 if (mindR < m_deltaR.value()) {
90 (jvtMatchedHandle)(*hjet) = matchedJvt;
91 } else {
92 (jvtMatchedHandle)(*hjet) = -1;
93 }
94
95 }
96
97 return StatusCode::SUCCESS;
98 }
99}
100
101
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Handle class for adding a decoration to an object.
PublicToolHandle< IJetUpdateJvt > m_jvtUpdateTool
JVT update tool.
virtual StatusCode addBranches(const EventContext &ctx) const
SG::WriteDecorHandleKey< xAOD::JetContainer > m_jvtMatchedKey
SG::ReadHandleKey< xAOD::JetContainer > m_caloJet_key
HIJetAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
SG::ReadHandleKey< xAOD::JetContainer > m_hiJet_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
THE reconstruction tool.
double deltaR(double eta1, double eta2, double phi1, double phi2)