ATLAS Offline Software
Loading...
Searching...
No Matches
xAODtoTrkConverterAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
9
11
12namespace ActsTrk {
14 ATH_CHECK(m_trackKey.initialize());
15 ATH_CHECK(m_linkKey.initialize());
16 ATH_CHECK(m_writeKey.initialize());
18 return StatusCode::SUCCESS;
19 }
20 StatusCode xAODtoTrkConverterAlg::execute(const EventContext& ctx) const {
21 const xAOD::TrackParticleContainer* inputTracks{nullptr};
22 ATH_CHECK(SG::get(inputTracks, m_trackKey, ctx));
23 auto convertedTracks = std::make_unique<TrackCollection>();
24
27 for (const xAOD::TrackParticle* inTrack: *inputTracks) {
28 // Create the dummy link
29 Link_t& link = dec_link(*inTrack);
30 // Fetch the Acts track from the decorator
31 auto actsTrk = getActsTrack(*inTrack);
32 if (!actsTrk) {
33 ATH_MSG_ERROR("Track particle without ACTS track decoration");
34 return StatusCode::FAILURE;
35 }
36 // convert into trk track
37 auto track = m_ATLASConverterTool->convertTrack(ctx, *actsTrk);
38 if (!track) {
39 ATH_MSG_ERROR("Track conversion failed.");
40 return StatusCode::FAILURE;
41 }
42 link = Link_t{*convertedTracks, convertedTracks->size()};
43 convertedTracks->push_back(std::move(track));
44 }
45 SG::WriteHandle writeHandle{m_writeKey, ctx};
46 ATH_CHECK(writeHandle.record(std::move(convertedTracks)));
47 return StatusCode::SUCCESS;
48 }
49
50}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
ElementLink< xAOD::TruthParticleContainer > Link_t
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Input read handle key collection.
ToolHandle< ITrackConverterTool > m_ATLASConverterTool
Conversion tool to convert from Acts -> Trk tracks.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_linkKey
Declare the data dependency on the trackLink.
virtual StatusCode initialize() override final
SG::WriteHandleKey< TrackCollection > m_writeKey
Declare the output container of the track collection.
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::optional< ActsTrk::TrackContainer::ConstTrackProxy > getActsTrack(const xAOD::TrackParticle &trkPart)
Return the proxy to the Acts track from which the track particle was made frome.
Definition Decoration.cxx:9
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".