ATLAS Offline Software
Loading...
Searching...
No Matches
JetCalibrationDecoratorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10
11namespace FlavorTagDiscriminants {
12
14 const std::string& name, ISvcLocator* loc)
15 : AthReentrantAlgorithm(name, loc)
16 {
17 declareProperty("JetCalibrationTool", m_calibTool, "Jet calibration tool");
18 }
19
21 ATH_CHECK(m_calibTool.retrieve());
22 ATH_CHECK(m_jetKey.initialize());
23 ATH_CHECK(m_ptCalibKey.initialize());
24 ATH_CHECK(m_etaCalibKey.initialize());
25 ATH_CHECK(m_massCalibKey.initialize());
26 ATH_CHECK(m_phiCalibKey.initialize());
27 return StatusCode::SUCCESS;
28 }
29
31 const EventContext& ctx) const
32 {
34 ATH_CHECK(jets.isValid());
35
37 m_ptCalibKey, ctx);
39 m_etaCalibKey, ctx);
41 m_massCalibKey, ctx);
43 m_phiCalibKey, ctx);
44
45 // Shallow-copy jets so calibration doesn't modify originals
46 std::pair<std::unique_ptr<xAOD::JetContainer>,
47 std::unique_ptr<xAOD::ShallowAuxContainer>> shallowCopy =
49 std::unique_ptr<xAOD::JetContainer>& copyUP = shallowCopy.first;
50 [[maybe_unused]] std::unique_ptr<xAOD::ShallowAuxContainer>& auxUP =
51 shallowCopy.second;
52
53 // Apply calibration to the copies
54 ATH_CHECK(m_calibTool->modify(*copyUP));
55
56 // Decorate originals with calibrated kinematics from copies
57 for (size_t i = 0; i < jets->size(); ++i) {
58 const xAOD::Jet& originalJet = *jets->at(i);
59 const xAOD::Jet& calibratedJet = *copyUP->at(i);
60
61 ptDec(originalJet) = calibratedJet.pt();
62 etaDec(originalJet) = calibratedJet.eta();
63 massDec(originalJet) = calibratedJet.m();
64 phiDec(originalJet) = calibratedJet.phi();
65 }
66
67 return StatusCode::SUCCESS;
68 }
69
70} // namespace FlavorTagDiscriminants
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteDecorHandleKey< xAOD::JetContainer > m_massCalibKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_etaCalibKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_phiCalibKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_ptCalibKey
virtual StatusCode execute(const EventContext &ctx) const override
JetCalibrationDecoratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Handle class for adding a decoration to an object.
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition Jet_v1.cxx:54
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual double m() const
The invariant mass of the particle.
Definition Jet_v1.cxx:59
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
Jet_v1 Jet
Definition of the current "jet version".
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.