ATLAS Offline Software
Loading...
Searching...
No Matches
CalibratedJetCopyAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
11
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_copyKey.initialize());
24 ATH_CHECK(m_linkKey.initialize());
25 return StatusCode::SUCCESS;
26}
27
28StatusCode CalibratedJetCopyAlg::execute(const EventContext& ctx) const
29{
31 ATH_CHECK(jets.isValid());
32
33 auto [copy, aux] = xAOD::shallowCopy(*jets, ctx);
34
35 ATH_CHECK(m_calibTool->modify(*copy));
36
37 if (!xAOD::setOriginalObjectLink(*jets, *copy)) {
38 ATH_MSG_ERROR("Failed to set original object links on " << m_copyKey);
39 return StatusCode::FAILURE;
40 }
41
43 ATH_CHECK(copyHandle.record(std::move(copy), std::move(aux)));
44
46 linkDec(m_linkKey, ctx);
47 for (size_t i = 0; i < jets->size(); ++i) {
48 linkDec(*jets->at(i)) =
49 ElementLink<xAOD::JetContainer>(*copyHandle, i, ctx);
50 }
51
52 return StatusCode::SUCCESS;
53}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode initialize() override
CalibratedJetCopyAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandle< IJetModifier > m_calibTool
SG::WriteHandleKey< xAOD::JetContainer > m_copyKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
SG::WriteDecorHandleKey< xAOD::JetContainer > m_linkKey
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
bool setOriginalObjectLink(const IParticle &original, IParticle &copy)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...