ATLAS Offline Software
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 
7 #include "TrackContainerReader.h"
8 
9 namespace ActsTrk{
10 
12 {
15  ATH_CHECK(m_tracksKey.key().find("Tracks") != std::string::npos);
17 
18  return StatusCode::SUCCESS;
19 }
20 
21 StatusCode 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 }
ActsTrk::TrackContainerReader::execute
virtual StatusCode execute(const EventContext &context) const override final
Definition: TrackContainerReader.cxx:21
ActsTrk::TrackContainerReader::m_tracksBackendHandlesHelper
ActsTrk::ConstTrackContainerHandlesHelper m_tracksBackendHandlesHelper
Definition: TrackContainerReader.h:33
ActsTrk::MutableTrackContainer
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Definition: TrackContainer.h:26
ActsTrk::prefixFromTrackContainerName
std::string prefixFromTrackContainerName(const std::string &tracks)
Parse TrackContainer name to get the prefix for backends The name has to contain XYZTracks,...
Definition: TrackContainerHandlesHelper.cxx:20
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ActsTrk::TrackContainerReader::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: TrackContainerReader.h:32
ActsTrk::ConstTrackContainerHandlesHelper::initialize
StatusCode initialize(const std::string &prefix)
Sets up the handles.
Definition: TrackContainerHandlesHelper.cxx:173
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
TrackContainerReader.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.TrackLeptonConfig.trackContainer
string trackContainer
Definition: TrackLeptonConfig.py:23
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
ActsTrk::ConstTrackContainerHandlesHelper::build
std::unique_ptr< ActsTrk::PersistentTrackContainer > build(const Acts::TrackingGeometry *geo, const Acts::GeometryContext &geoContext, const EventContext &context) const
Definition: TrackContainerHandlesHelper.cxx:252
ActsTrk::TrackContainerReader::m_tracksKey
SG::WriteHandleKey< ActsTrk::TrackContainer > m_tracksKey
Definition: TrackContainerReader.h:34
ActsTrk::TrackContainerReader::initialize
virtual StatusCode initialize() override final
Definition: TrackContainerReader.cxx:11
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
xAOD::track
@ track
Definition: TrackingPrimitives.h:513