ATLAS Offline Software
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"
15 #include "StoreGate/WriteHandle.h"
16 
18 
19 
20 #include "SeedToTrackCnvAlg.h"
21 
22 namespace ActsTrk {
23 
25 {
26  ATH_CHECK(m_seedContainerKey.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 
44 StatusCode 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  const ActsTrk::Seed* seedPointer = seedsHandle->at(seedIndex);
63  const Acts::BoundTrackParameters* paramsPointer = parameterHandle->at(seedIndex);
64 
65  if (seedPointer == nullptr || paramsPointer == nullptr) {
66  ATH_MSG_DEBUG("Seed or 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: seedPointer->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 
ActsTrk::detail::xAODUncalibMeasSurfAcc::get
const Acts::Surface * get(const xAOD::UncalibratedMeasurement *meas) const
Operator.
Definition: xAODUncalibMeasSurfAcc.cxx:19
ActsTrk::ActsSeed::sp
const container_type & sp() const
Definition: Seed.h:73
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ActsTrk::SeedToTrackCnvAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: SeedToTrackCnvAlg.cxx:44
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
AthMsgStreamMacros.h
ActsTrk::SeedToTrackCnvAlg::m_trackContainerKey
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
Definition: SeedToTrackCnvAlg.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
ActsTrk::MutableTrackContainer
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Definition: TrackContainer.h:26
ActsTrk::SeedToTrackCnvAlg::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: SeedToTrackCnvAlg.h:49
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
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
HitType::spacepoint
@ spacepoint
xAODUncalibMeasCalibrator.h
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SeedToTrackCnvAlg.h
ActsTrk::detail::xAODUncalibMeasCalibrator::pack
static Acts::SourceLink pack(const xAOD::UncalibratedMeasurement *meas)
Helper method to pack an uncalibrated measurement to an Acts source link.
Definition: xAODUncalibMeasCalibrator.cxx:9
ActsTrk::SeedToTrackCnvAlg::m_surfAcc
detail::xAODUncalibMeasSurfAcc m_surfAcc
Definition: SeedToTrackCnvAlg.h:43
ActsTrk::MutableTrackContainerHandlesHelper::initialize
StatusCode initialize(const std::string &prefix)
Sets up the handles.
Definition: TrackContainerHandlesHelper.cxx:47
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
WriteHandle.h
Handle class for recording to StoreGate.
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
ActsTrk::SeedToTrackCnvAlg::m_actsTrackParamsKey
SG::ReadHandleKeyArray< ActsTrk::BoundTrackParametersContainer > m_actsTrackParamsKey
Definition: SeedToTrackCnvAlg.h:46
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
MeasurementDefs.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ActsTrk::SeedToTrackCnvAlg::initialize
virtual StatusCode initialize() override
Definition: SeedToTrackCnvAlg.cxx:24
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ActsTrk::SeedToTrackCnvAlg::m_tracksBackendHandlesHelper
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
Definition: SeedToTrackCnvAlg.h:44
SurfaceOfMeasurementUtil.h
ActsTrk::ActsSeed
Definition: Seed.h:18
ActsTrk::SeedToTrackCnvAlg::m_seedContainerKey
SG::ReadHandleKeyArray< ActsTrk::SeedContainer > m_seedContainerKey
Definition: SeedToTrackCnvAlg.h:45
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
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
ActsTrk::detail::xAODUncalibMeasSurfAcc
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
Definition: xAODUncalibMeasSurfAcc.h:22
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.