ATLAS Offline Software
Loading...
Searching...
No Matches
TrackSmearingAlg.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#include "TrackSmearingAlg.h"
9
10namespace InDet {
12{
13 ATH_CHECK(m_smearingTool.retrieve());
14 if (!m_biasingTool.empty())
15 ATH_CHECK(m_biasingTool.retrieve());
16
17 if (!m_systematicVariation.value().empty())
19
20 // The tools silently ignore unknown systematics, so catch typos here.
21 if (m_strictMode && !m_systSet.empty()) {
22 const CP::SystematicVariation& var = *m_systSet.begin();
23 bool anyAffected = m_smearingTool->isAffectedBySystematic(var);
24 if (!m_biasingTool.empty()) {
25 anyAffected |= m_biasingTool->isAffectedBySystematic(var);
26 }
27 if (!anyAffected) {
28 ATH_MSG_ERROR("Systematic '" << m_systematicVariation.value()
29 << "' is not known to the smearing or biasing tool");
30 return StatusCode::FAILURE;
31 }
32 }
33
34 // Pre-register the systematic set in each tool's cache so the
35 // reentrant applyCorrection(track, syst) overload can look it up.
36 ATH_CHECK(m_smearingTool->applySystematicVariation(m_systSet));
37 if (!m_biasingTool.empty())
38 ATH_CHECK(m_biasingTool->applySystematicVariation(m_systSet));
39
40 ATH_CHECK(m_inTrackKey.initialize());
41 ATH_CHECK(m_outTrackKey.initialize());
42 return StatusCode::SUCCESS;
43}
44
45StatusCode TrackSmearingAlg::execute(const EventContext& ctx) const
46{
48 ATH_CHECK(inTracks.isValid());
49
50 auto [outTracks, outAux] =
51 xAOD::shallowCopyContainer(*inTracks, ctx);
52
53 for (xAOD::TrackParticle* trk : *outTracks) {
54 if (m_smearingTool->applyCorrection(*trk, m_systSet)
56 ATH_MSG_ERROR("Could not apply InDetTrackSmearingTool.");
57 return StatusCode::FAILURE;
58 }
59 if (!m_biasingTool.empty()) {
60 if (m_biasingTool->applyCorrection(*trk, m_systSet)
62 ATH_MSG_ERROR("Could not apply InDetTrackBiasingTool.");
63 return StatusCode::FAILURE;
64 }
65 }
66 }
67
69 ATH_CHECK(outHandle.record(std::move(outTracks), std::move(outAux)));
70 return StatusCode::SUCCESS;
71}
72
73} // namespace InDet
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
@ Error
Some error happened during the object correction.
Class to wrap a set of SystematicVariations.
CP::SystematicSet m_systSet
Gaudi::Property< std::string > m_systematicVariation
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inTrackKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outTrackKey
PublicToolHandle< IInDetTrackSmearingTool > m_smearingTool
Gaudi::Property< bool > m_strictMode
StatusCode execute(const EventContext &ctx) const override
PublicToolHandle< IInDetTrackBiasingTool > m_biasingTool
StatusCode initialize() override
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Primary Vertex Finder.
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.
TrackParticle_v1 TrackParticle
Reference the current persistent version: