ATLAS Offline Software
Loading...
Searching...
No Matches
SeedToTrackCnvAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <vector>
8#include "Acts/Definitions/Algebra.hpp"
10
13#include "Acts/Surfaces/PerigeeSurface.hpp"
14#include "Acts/Surfaces/Surface.hpp"
16
18
19
20#include "SeedToTrackCnvAlg.h"
21
22namespace ActsTrk {
23
25{
26 ATH_CHECK(m_seedContainerKey.initialize());
27 ATH_CHECK(m_trackContainerKey.initialize());
29 ATH_CHECK(m_actsTrackParamsKey.initialize());
32 if (m_seedContainerKey.size() != m_actsTrackParamsKey.size()) {
33 ATH_MSG_ERROR("Seed and Parameter containers have different sizes: "
34 << m_seedContainerKey.size() << " for seeds and "
35 << m_actsTrackParamsKey.size() << " for the parameters");
36 return StatusCode::FAILURE;
37 }
38
39
40 return StatusCode::SUCCESS;
41}
42
43
44StatusCode SeedToTrackCnvAlg::execute(const EventContext& context) const {
45 Acts::VectorTrackContainer trackBackend;
46 Acts::VectorMultiTrajectory trackStateBackend;
47 ActsTrk::MutableTrackContainer tracksContainer( std::move(trackBackend),
48 std::move(trackStateBackend) );
49
50 Acts::GeometryContext gctx = m_trackingGeometryTool->getGeometryContext(context).context();
51 std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry = m_trackingGeometryTool->trackingGeometry();
52
53 for (std::size_t i(0); i<m_seedContainerKey.size(); ++i) {
54 ATH_MSG_DEBUG("Retrieving Seed Collection with key: " << m_seedContainerKey.at(i).key());
55 ATH_MSG_DEBUG("Retrieving Track Parameter Estimation Collection with key: " << m_actsTrackParamsKey.at(i).key());
58 ATH_CHECK(seedsHandle.isValid());
59 ATH_CHECK(parameterHandle.isValid());
60
61 for (std::size_t seedIndex = 0 ; seedIndex < seedsHandle->size() ;++seedIndex){
62 ActsTrk::Seed seed = seedsHandle->at(seedIndex);
63 const Acts::BoundTrackParameters* paramsPointer = parameterHandle->at(seedIndex);
64
65 if (paramsPointer == nullptr) {
66 ATH_MSG_DEBUG("Track Parameters is nullptr");
67 continue;
68 }
69
70 auto actsTrack = tracksContainer.makeTrack();
71 auto& trackStateContainer = tracksContainer.trackStateContainer();
72
73 actsTrack.parameters() = paramsPointer->parameters();
74 actsTrack.covariance() = (*paramsPointer->covariance());
75 actsTrack.setReferenceSurface(paramsPointer->referenceSurface().getSharedPtr());
76 std::size_t tsosPreviousIndex = Acts::MultiTrajectoryTraits::kInvalid;
77 for (const xAOD::SpacePoint_v1* spacepoint: seed.sp()) {
78 const auto& measurements = spacepoint->measurements();
79 for (const xAOD::UncalibratedMeasurement *umeas : measurements) {
80 const Acts::Surface *surf = m_surfAcc.get(umeas);
81 assert(surf);
82 auto actsTSOS = trackStateContainer.getTrackState(trackStateContainer.addTrackState(Acts::TrackStatePropMask::None, tsosPreviousIndex));
83 actsTSOS.setReferenceSurface(surf->getSharedPtr());
84 actsTSOS.setUncalibratedSourceLink(detail::xAODUncalibMeasCalibrator::pack(umeas));
85 actsTrack.tipIndex() = actsTSOS.index();
86 tsosPreviousIndex = actsTrack.tipIndex();
87 }
88 }
89 }
90
91 }
92
93 Acts::ConstVectorTrackContainer ctrackBackend( std::move(tracksContainer.container()) );
94 Acts::ConstVectorMultiTrajectory ctrackStateBackend( std::move(tracksContainer.trackStateContainer()) );
95 std::unique_ptr< ActsTrk::TrackContainer > ctracksContainer = std::make_unique< ActsTrk::TrackContainer >( std::move(ctrackBackend),
96 std::move(ctrackStateBackend) );
97
99 ATH_MSG_DEBUG("Tracks Container `" << m_trackContainerKey.key() << "` created ...");
100 ATH_MSG_DEBUG("Created container with size: " << ctracksContainer->size());
101 ATH_CHECK(trackContainerHandle.record(std::move(ctracksContainer)));
102 if (!trackContainerHandle.isValid())
103 {
104 ATH_MSG_FATAL("Failed to write TrackContainer with key " << m_trackContainerKey.key());
105 return StatusCode::FAILURE;
106 }
107 return StatusCode::SUCCESS;
108}
109
110} // namespace ActsTrk
111
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Handle class for recording to StoreGate.
virtual StatusCode execute(const EventContext &context) const override
detail::xAODUncalibMeasSurfAcc m_surfAcc
SG::ReadHandleKeyArray< ActsTrk::BoundTrackParametersContainer > m_actsTrackParamsKey
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
SG::ReadHandleKeyArray< ActsTrk::SeedContainer > m_seedContainerKey
virtual StatusCode initialize() override
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
static Acts::SourceLink pack(const xAOD::UncalibratedMeasurement *meas)
Helper method to pack an uncalibrated measurement to an Acts source link.
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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())
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.