ATLAS Offline Software
Loading...
Searching...
No Matches
CalibratedMuonsProvider.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4// Local include(s):
6
9
10namespace CP {
11
12 CalibratedMuonsProvider::CalibratedMuonsProvider(const std::string& name, ISvcLocator* svcLoc) : AthAlgorithm(name, svcLoc) {}
13
15 ATH_CHECK(m_eventInfo.initialize());
16 ATH_CHECK(m_inputKey.initialize());
17 ATH_CHECK(m_outputKey.initialize());
19 m_ptDecorKeys.emplace_back(m_outputKey.key() + ".InnerDetectorPt");
20 m_ptDecorKeys.emplace_back(m_outputKey.key() + ".MuonSpectrometerPt");
21 ATH_CHECK(m_ptDecorKeys.initialize());
23 ATH_CHECK(m_tool.retrieve());
24 return StatusCode::SUCCESS;
25 }
26
27 StatusCode CalibratedMuonsProvider::execute(const EventContext& ctx) {
29 if (!muons.isValid()) {
30 ATH_MSG_FATAL("No muon container found");
31 return StatusCode::FAILURE;
32 }
33
35 xAOD::shallowCopy(*muons, ctx);
36
37 if (!output.first || !output.second) {
38 ATH_MSG_FATAL("Creation of shallow copy failed");
39 return StatusCode::FAILURE;
40 }
41
42 if (!setOriginalObjectLink(*muons, *output.first)) {
43 ATH_MSG_ERROR("Failed to add original object links to shallow copy of " << m_inputKey);
44 return StatusCode::FAILURE;
45 }
46 for (xAOD::Muon* iParticle : *(output.first)) {
47 ATH_MSG_DEBUG(" Old pt=" << iParticle->pt());
48 if (m_tool->applyCorrection(*iParticle).code() == CorrectionCode::Error) return StatusCode::FAILURE;
49 ATH_MSG_DEBUG(" New pt=" << iParticle->pt());
50 }
52 ATH_CHECK(writeHandle.recordNonConst(std::move(output.first), std::move(output.second)));
53 // Return gracefully:
54 return StatusCode::SUCCESS;
55 }
56
57} // namespace CP
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
virtual StatusCode execute(const EventContext &ctx) override
Function executing the algorithm.
virtual StatusCode initialize() override
Function initialising the algorithm.
ToolHandle< IMuonCalibrationAndSmearingTool > m_tool
Muon calibration tool.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Gaudi::Property< bool > m_useRndNumber
SG::ReadHandleKey< xAOD::MuonContainer > m_inputKey
muon container
CalibratedMuonsProvider(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
SG::WriteHandleKey< xAOD::MuonContainer > m_outputKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_rndNumKey
SG::WriteDecorHandleKeyArray< xAOD::MuonContainer > m_ptDecorKeys
Additionally declare the two decorations made by MCAST.
@ Error
Some error happened during the object correction.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
Select isolated Photons, Electrons and Muons.
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition ShallowCopy.h:68
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...
Muon_v1 Muon
Reference the current persistent version: