ATLAS Offline Software
Loading...
Searching...
No Matches
TrackContainerReader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "Acts/Geometry/TrackingGeometry.hpp"
6
8
9namespace ActsTrk{
10
12{
14 ATH_CHECK(m_tracksKey.initialize());
15 ATH_CHECK(m_tracksKey.key().find("Tracks") != std::string::npos);
17
18 return StatusCode::SUCCESS;
19}
20
21StatusCode TrackContainerReader::execute(const EventContext& context) const
22{
23 std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry = m_trackingGeometryTool->trackingGeometry();
24 Acts::GeometryContext geoContext = m_trackingGeometryTool->getGeometryContext(context).context();
25
26 // Create persistent (i.e. xAOD backended) track collection
27 std::unique_ptr<ActsTrk::PersistentTrackContainer> trackContainer = m_tracksBackendHandlesHelper.build(trackingGeometry.get(), geoContext, context);
28 ATH_MSG_DEBUG("read track container size " << trackContainer->size());
29
30 // We convert to non-xAOD backend for StoreGate
31 // Transient declination
32 Acts::VectorTrackContainer trackBackend;
33 Acts::VectorMultiTrajectory trackStateBackend;
34 ActsTrk::MutableTrackContainer tc( std::move(trackBackend),
35 std::move(trackStateBackend) );
36
37 // copy
38 for ( auto track : *trackContainer ) {
39 auto destProxy = tc.makeTrack();
40 destProxy.copyFrom(track);
41 }
42
43 // Constant declination
44 Acts::ConstVectorTrackContainer ctrackBackend( std::move(tc.container()) );
45 Acts::ConstVectorMultiTrajectory ctrackStateBackend( std::move(tc.trackStateContainer()) );
46 std::unique_ptr<ActsTrk::TrackContainer> ctc = std::make_unique<ActsTrk::TrackContainer>( std::move(ctrackBackend),
47 std::move(ctrackStateBackend) );
48 ATH_MSG_DEBUG("store track container size " << ctc->size());
49
50 // Store
51 auto handle = SG::makeHandle(m_tracksKey, context);
52 ATH_CHECK(handle.record(std::move(ctc)));
53 return StatusCode::SUCCESS;
54}
55
56}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t tc
SG::WriteHandleKey< ActsTrk::TrackContainer > m_tracksKey
virtual StatusCode execute(const EventContext &context) const override final
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
ActsTrk::ConstTrackContainerHandlesHelper m_tracksBackendHandlesHelper
virtual StatusCode initialize() override final
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::string prefixFromTrackContainerName(const std::string &tracks)
Parse TrackContainer name to get the prefix for backends The name has to contain XYZTracks,...
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())