ATLAS Offline Software
ActsToXAODTrackConverterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace ActsTrk {
8 
10  ISvcLocator *pSvcLocator)
11  : AthReentrantAlgorithm(name, pSvcLocator)
12  {}
13 
15  {
16  ATH_MSG_DEBUG( "Initializing " << name() << " ..." );
17 
20 
23 
24  return StatusCode::SUCCESS;
25  }
26 
27  StatusCode ActsToXAODTrackConverterAlg::execute(const EventContext &ctx) const
28  {
29  ATH_MSG_DEBUG( "Executing " << name() << " ..." );
30 
31  // Read inputs
33  ATH_CHECK( inputTracksHandle.isValid() );
34  const ActsTrk::TrackContainer* actsTracks = inputTracksHandle.cptr();
35 
36  // Convert to xAOD version
38  for ( auto track : *actsTracks ) {
39  auto destProxy = tracksContainer.makeTrack();
40  destProxy.copyFrom(track);
41  }
42  ATH_MSG_DEBUG(" \\__ Converted " << tracksContainer.size() << " tracks");
43 
44  // Make const
45  std::unique_ptr< ActsTrk::PersistentTrackContainer > constTracksContainer = m_tracksBackendHandlesHelper.moveToConst( std::move(tracksContainer),
46  m_trackingGeometryTool->getGeometryContext(ctx).context(),
47  ctx );
48 
49  // Store into StoreGate
51  ATH_CHECK( trackContainerHandle.record(std::move(constTracksContainer)) );
52  return StatusCode::SUCCESS;
53  }
54 
55 } // namespace
56 
ActsTrk::MutablePersistentTrackContainer
Definition: PersistentTrackContainer.h:49
ActsTrk::TrackContainer
Definition: TrackContainer.h:30
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
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::ActsToXAODTrackConverterAlg::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: ActsToXAODTrackConverterAlg.h:33
ActsToXAODTrackConverterAlg.h
ActsTrk::MutableTrackContainerHandlesHelper::initialize
StatusCode initialize(const std::string &prefix)
Sets up the handles.
Definition: TrackContainerHandlesHelper.cxx:47
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
ActsTrk::ActsToXAODTrackConverterAlg::m_tracksBackendHandlesHelper
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
Definition: ActsToXAODTrackConverterAlg.h:32
ActsTrk::ActsToXAODTrackConverterAlg::m_inputTrackContainerKey
SG::ReadHandleKey< ActsTrk::TrackContainer > m_inputTrackContainerKey
Definition: ActsToXAODTrackConverterAlg.h:29
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
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::MutableTrackContainerHandlesHelper::moveToConst
std::unique_ptr< ActsTrk::PersistentTrackContainer > moveToConst(ActsTrk::MutablePersistentTrackContainer &&tc, const Acts::GeometryContext &geoContext, const EventContext &evtContext) const
produces ActsTrk::ConstTrackContainer with all backends stored in SG
Definition: TrackContainerHandlesHelper.cxx:126
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ActsTrk::ActsToXAODTrackConverterAlg::m_outputTrackContainerKey
SG::WriteHandleKey< ActsTrk::PersistentTrackContainer > m_outputTrackContainerKey
Definition: ActsToXAODTrackConverterAlg.h:30
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
ActsTrk::ActsToXAODTrackConverterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: ActsToXAODTrackConverterAlg.cxx:27
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
ActsTrk::ActsToXAODTrackConverterAlg::ActsToXAODTrackConverterAlg
ActsToXAODTrackConverterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ActsToXAODTrackConverterAlg.cxx:9
ActsTrk::ActsToXAODTrackConverterAlg::initialize
virtual StatusCode initialize() override
Definition: ActsToXAODTrackConverterAlg.cxx:14