ATLAS Offline Software
Loading...
Searching...
No Matches
ReclusteredJetCalibrationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
11
13#include <vector>
14#include <string>
15//
16// method implementations
17//
18
19namespace
20{
21 const std::string manualCalibScaleStr{"JetManualCalibScaleMomentum"};
22}
23
24namespace CP
25{
26
27 StatusCode ReclusteredJetCalibrationAlg ::
28 initialize ()
29 {
32
33 ANA_CHECK (m_systematicsList.initialize());
34 return StatusCode::SUCCESS;
35 }
36
37
38
39 StatusCode ReclusteredJetCalibrationAlg ::
40 execute (const EventContext &ctx) const
41 {
42 for (const auto& sys : m_systematicsList.systematicsVector())
43 {
44 // container we read in
45 xAOD::JetContainer *reclusteredJets = nullptr;
46 ATH_CHECK(m_reclusteredJetHandle.getCopy(reclusteredJets, sys, ctx));
47
48 const xAOD::JetContainer *smallRJets = nullptr;
49 ATH_CHECK(m_smallRJetHandle.retrieve(smallRJets, sys, ctx));
50
51 // loop over jets
52
53 for (xAOD::Jet *jet : *reclusteredJets)
54 {
55 const std::vector< ElementLink< xAOD::IParticleContainer > >& element_links = jet->constituentLinks();
56 if (element_links.empty()) {
57 ATH_MSG_ERROR("Reclustered jet has no constituent links, cannot recalibrate it from the small-R jets");
58 return StatusCode::FAILURE;
59 }
60
61 xAOD::JetFourMom_t calibP4;
62 calibP4.SetPxPyPzE(0,0,0,0);
63 std::size_t nValid = 0;
64 for (const auto& element_link: element_links){
65 if (! element_link.isValid() ) {
66 ATH_MSG_WARNING("Subjet element link invalid !!!!");
67 continue;
68 }
69 const auto subjet = *element_link;
70 const SG::AuxVectorData* subjetContainer = subjet->container();
71 if (subjetContainer == nullptr || subjetContainer->size_v() != smallRJets->size()) {
72 ATH_MSG_ERROR("Size of the reclustered jet constituents' parent container does not match "
73 "the size of the small-R jet container " << m_smallRJetHandle.getName(sys)
74 << ", check the smallRJets configuration");
75 return StatusCode::FAILURE;
76 }
77 int index = subjet->index();
78 const xAOD::Jet* subjetCal = smallRJets->at(index);
79 calibP4 += subjetCal->jetP4();
80 ++nValid;
81 }
82 if (nValid == 0) {
83 ATH_MSG_WARNING("Reclustered jet has no valid constituent links, its four-momentum is set to zero");
84 }
85 // Set calibrated P4
86 jet->setAttribute<xAOD::JetFourMom_t>(manualCalibScaleStr,calibP4);
87 jet->setJetP4( calibP4 );
88 }
89 }
90
91 return StatusCode::SUCCESS;
92 }
93}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ANA_CHECK(EXP)
check whether the given expression was successful
SysCopyHandle< xAOD::JetContainer > m_reclusteredJetHandle
the jet collection we run on
SysReadHandle< xAOD::JetContainer > m_smallRJetHandle
SysListHandle m_systematicsList
the systematics list we run
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
Manage lookup of vectors of auxiliary data.
virtual size_t size_v() const =0
Return the size of the container.
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition Jet_v1.cxx:76
Select isolated Photons, Electrons and Muons.
Definition index.py:1
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17