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_ctxProvider.initialize());
16 ATH_CHECK(m_tracksKey.key().find("Tracks") != std::string::npos);
18
19 return StatusCode::SUCCESS;
20}
21
22StatusCode TrackContainerReader::execute(const EventContext& context) const
23{
24 std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry = m_trackingGeometrySvc->trackingGeometry();
25 Acts::GeometryContext geoContext = m_ctxProvider.getGeometryContext(context);
26
27 // Create persistent (i.e. xAOD backended) track collection
28 std::unique_ptr<ActsTrk::PersistentTrackContainer> trackContainer = m_tracksBackendHandlesHelper.build(trackingGeometry.get(), geoContext, context);
29 ATH_MSG_DEBUG("read track container size " << trackContainer->size());
30
31 // We convert to non-xAOD backend for StoreGate
32 // Transient declination
33 Acts::VectorTrackContainer trackBackend;
34 Acts::VectorMultiTrajectory trackStateBackend;
35 ActsTrk::MutableTrackContainer tc( std::move(trackBackend),
36 std::move(trackStateBackend) );
37
38 // copy
39 for ( auto track : *trackContainer ) {
40 auto destProxy = tc.makeTrack();
41 destProxy.copyFrom(track);
42 }
43
44 // Constant declination
45 Acts::ConstVectorTrackContainer ctrackBackend( std::move(tc.container()) );
46 Acts::ConstVectorMultiTrajectory ctrackStateBackend( std::move(tc.trackStateContainer()) );
47 std::unique_ptr<ActsTrk::TrackContainer> ctc = std::make_unique<ActsTrk::TrackContainer>( std::move(ctrackBackend),
48 std::move(ctrackStateBackend) );
49 ATH_MSG_DEBUG("store track container size " << ctc->size());
50
51 // Store
52 auto handle = SG::makeHandle(m_tracksKey, context);
53 ATH_CHECK(handle.record(std::move(ctc)));
54 return StatusCode::SUCCESS;
55}
56
57}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t tc
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
ActsTrk::ContextUtility m_ctxProvider
Context provider for geometry, magnetic field and calibration contexts.
SG::WriteHandleKey< ActsTrk::TrackContainer > m_tracksKey
virtual StatusCode execute(const EventContext &context) const override final
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())