ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
MuonID
MuonIDAnalysis
MuonMomentumCorrections
src
CalibratedTracksProvider.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Local include(s):
6
#include "
CalibratedTracksProvider.h
"
7
8
#include "
xAODBase/IParticleHelpers.h
"
9
#include "
xAODCore/ShallowCopy.h
"
10
11
namespace
CP
{
12
13
CalibratedTracksProvider::CalibratedTracksProvider
(
const
std::string&
name
, ISvcLocator* svcLoc) :
AthAlgorithm
(
name
, svcLoc) {}
14
15
StatusCode
CalibratedTracksProvider::initialize
() {
16
ATH_CHECK
(
m_eventInfo
.initialize());
17
ATH_CHECK
(
m_inputKey
.initialize());
18
ATH_CHECK
(
m_outputKey
.initialize());
19
ATH_CHECK
(
m_rndNumKey
.initialize(
m_useRndNumber
));
20
ATH_CHECK
(
m_tool
.retrieve());
21
return
StatusCode::SUCCESS;
22
}
23
24
StatusCode
CalibratedTracksProvider::execute
(
const
EventContext& ctx) {
25
SG::ReadHandle<xAOD::TrackParticleContainer>
tracks{
m_inputKey
, ctx};
26
if
(!tracks.
isValid
()) {
27
ATH_MSG_FATAL
(
"No muon container found"
);
28
return
StatusCode::FAILURE;
29
}
30
31
xAOD::ShallowCopyResult_t<xAOD::TrackParticleContainer>
output =
32
xAOD::shallowCopy
(*tracks, ctx);
33
34
if
(!output.first || !output.second) {
35
ATH_MSG_FATAL
(
"Creation of shallow copy failed"
);
36
return
StatusCode::FAILURE;
37
}
38
39
if
(!
setOriginalObjectLink
(*tracks, *output.first)) {
40
ATH_MSG_ERROR
(
"Failed to add original object links to shallow copy of "
<<
m_inputKey
);
41
return
StatusCode::FAILURE;
42
}
43
44
for
(
xAOD::TrackParticle
* iParticle : *(output.first)) {
45
ATH_MSG_VERBOSE
(
"Old pt="
<< iParticle->pt());
46
if
(
m_tool
->applyCorrectionTrkOnly(*iParticle,
m_detType
).code() ==
CorrectionCode::Error
)
return
StatusCode::FAILURE;
47
ATH_MSG_VERBOSE
(
"New pt="
<< iParticle->pt());
48
}
49
SG::WriteHandle<xAOD::TrackParticleContainer>
writeHandle{
m_outputKey
, ctx};
50
ATH_CHECK
(writeHandle.
recordNonConst
(std::move(output.first), std::move(output.second)));
51
52
// Return gracefully:
53
return
StatusCode::SUCCESS;
54
}
55
56
}
// namespace CP
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
CalibratedTracksProvider.h
IParticleHelpers.h
ShallowCopy.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
CP::CalibratedTracksProvider::m_useRndNumber
Gaudi::Property< bool > m_useRndNumber
Definition
CalibratedTracksProvider.h:49
CP::CalibratedTracksProvider::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition
CalibratedTracksProvider.h:33
CP::CalibratedTracksProvider::m_tool
ToolHandle< IMuonCalibrationAndSmearingTool > m_tool
Calibration tool handle.
Definition
CalibratedTracksProvider.h:43
CP::CalibratedTracksProvider::m_rndNumKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_rndNumKey
Definition
CalibratedTracksProvider.h:50
CP::CalibratedTracksProvider::m_inputKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputKey
track container
Definition
CalibratedTracksProvider.h:36
CP::CalibratedTracksProvider::m_detType
Gaudi::Property< int > m_detType
detector type of track (MS or ID)
Definition
CalibratedTracksProvider.h:46
CP::CalibratedTracksProvider::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition
CalibratedTracksProvider.cxx:15
CP::CalibratedTracksProvider::execute
virtual StatusCode execute(const EventContext &ctx) override
Function executing the algorithm.
Definition
CalibratedTracksProvider.cxx:24
CP::CalibratedTracksProvider::CalibratedTracksProvider
CalibratedTracksProvider(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
Definition
CalibratedTracksProvider.cxx:13
CP::CalibratedTracksProvider::m_outputKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputKey
Definition
CalibratedTracksProvider.h:39
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition
CorrectionCode.h:36
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::recordNonConst
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::ShallowCopyResult_t
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition
ShallowCopy.h:68
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAOD::setOriginalObjectLink
bool setOriginalObjectLink(const IParticle &original, IParticle ©)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
Definition
IParticleHelpers.cxx:30
Generated on
for ATLAS Offline Software by
1.17.0