ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
RecoTools
TrackToCalo
src
PreselCaloExtensionBuilderAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PreselCaloExtensionBuilderAlg.h
"
6
7
#include <memory>
8
9
#include "
StoreGate/ReadHandle.h
"
10
#include "
StoreGate/WriteHandle.h
"
11
12
namespace
Trk
{
13
PreselCaloExtensionBuilderAlg::PreselCaloExtensionBuilderAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
14
AthReentrantAlgorithm
(name, pSvcLocator) {}
15
16
PreselCaloExtensionBuilderAlg::~PreselCaloExtensionBuilderAlg
() =
default
;
17
18
StatusCode
PreselCaloExtensionBuilderAlg::initialize
() {
19
ATH_CHECK
(
m_particleCaloExtensionTool
.retrieve());
20
ATH_CHECK
(
m_inputTracksKey
.initialize());
21
ATH_CHECK
(
m_outputCacheKey
.initialize());
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
PreselCaloExtensionBuilderAlg::execute
(
const
EventContext& ctx)
const
{
26
auto
tracks =
SG::makeHandle
(
m_inputTracksKey
, ctx);
27
if
(!tracks.isValid()) {
28
ATH_MSG_ERROR
(
"Failed to retrieve "
<<
m_inputTracksKey
);
29
return
StatusCode::FAILURE;
30
}
31
auto
cache
= std::make_unique<CaloExtensionCollection>();
32
if
(!tracks->empty())
33
// Use the index of the last track as a good guess of the largest index
34
// present in the container. This will be the right value if the view
35
// has not been sorted differently from the original container
36
cache
->resize(tracks->back()->index() + 1);
37
for
(
const
xAOD::TrackParticle
* itrk : *tracks) {
38
if
(itrk->index() >=
cache
->size())
39
// Handle the case where the above assumption does not hold
40
cache
->resize(itrk->index() + 1);
41
cache
->at(itrk->index()) =
m_particleCaloExtensionTool
->caloExtension(ctx, *itrk);
42
}
43
auto
outputHandle =
SG::makeHandle
(
m_outputCacheKey
, ctx);
44
ATH_CHECK
(outputHandle.record(std::move(
cache
)));
45
return
StatusCode::SUCCESS;
46
}
47
}
// namespace Trk
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
PreselCaloExtensionBuilderAlg.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
Trk::PreselCaloExtensionBuilderAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
PreselCaloExtensionBuilderAlg.cxx:25
Trk::PreselCaloExtensionBuilderAlg::m_particleCaloExtensionTool
ToolHandle< Trk::IParticleCaloExtensionTool > m_particleCaloExtensionTool
Definition
PreselCaloExtensionBuilderAlg.h:40
Trk::PreselCaloExtensionBuilderAlg::~PreselCaloExtensionBuilderAlg
~PreselCaloExtensionBuilderAlg()
Trk::PreselCaloExtensionBuilderAlg::PreselCaloExtensionBuilderAlg
PreselCaloExtensionBuilderAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
PreselCaloExtensionBuilderAlg.cxx:13
Trk::PreselCaloExtensionBuilderAlg::m_outputCacheKey
SG::WriteHandleKey< CaloExtensionCollection > m_outputCacheKey
Definition
PreselCaloExtensionBuilderAlg.h:43
Trk::PreselCaloExtensionBuilderAlg::m_inputTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTracksKey
Definition
PreselCaloExtensionBuilderAlg.h:42
Trk::PreselCaloExtensionBuilderAlg::initialize
virtual StatusCode initialize() override
Definition
PreselCaloExtensionBuilderAlg.cxx:18
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::cache
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
Generated on
for ATLAS Offline Software by
1.17.0