ATLAS Offline Software
SeedToTrackCnvAlg.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 <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 
17 
18 #include "SeedToTrackCnvAlg.h"
19 
20 namespace ActsTrk {
21 
22 SeedToTrackCnvAlg::SeedToTrackCnvAlg(const std::string& name, ISvcLocator* pSvcLocator) :
23  AthReentrantAlgorithm(name, pSvcLocator)
24 {
25 }
26 
28 {
29  ATH_CHECK(m_seedContainerKey.initialize());
32  ATH_CHECK(m_actsTrackParamsKey.initialize());
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 
40 StatusCode SeedToTrackCnvAlg::execute(const EventContext& context) const
41 {
42  ActsTrk::MutableTrackContainer tracksContainer;
43 
44  Acts::GeometryContext gctx = m_trackingGeometryTool->getGeometryContext(context).context();
45  std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry = m_trackingGeometryTool->trackingGeometry();
46  ATH_CHECK(trackingGeometry.get() != nullptr);
47 
50 
52  detectorElementToGeometryIdMap{m_detectorElementToGeometryIdMapKey, context};
53  ATH_CHECK(detectorElementToGeometryIdMap.isValid());
54 
55  ATH_CHECK(seedsHandle.isValid());
56  ATH_CHECK(parameterHandle.isValid());
57  for (std::size_t seedIndex = 0 ; seedIndex < seedsHandle->size() ;++seedIndex){
58  const ActsTrk::Seed* seedPointer = seedsHandle->at(seedIndex);
59  const Acts::BoundTrackParameters* paramsPointer = parameterHandle->at(seedIndex);
60 
61  auto actsTrack = tracksContainer.makeTrack();
62  ActsTrk::MutableMultiTrajectory& trackStateContainer = tracksContainer.trackStateContainer();
63 
64  actsTrack.parameters() = paramsPointer->parameters();
65  actsTrack.covariance() = (*paramsPointer->covariance());
66  actsTrack.setReferenceSurface(paramsPointer->referenceSurface().getSharedPtr());
67  size_t tsosPreviousIndex = Acts::MultiTrajectoryTraits::kInvalid;
68  for (const xAOD::SpacePoint_v1* spacepoint: seedPointer->sp()) {
69  const auto& measurements = spacepoint->measurements();
70  for (const xAOD::UncalibratedMeasurement *umeas : measurements) {
72  const Acts::Surface *surf = ActsTrk::getSurfaceOfMeasurement(*trackingGeometry,**detectorElementToGeometryIdMap,*umeas);
73  ATH_CHECK( surf && surf->getSharedPtr().get() != nullptr);
74  auto actsTSOS = trackStateContainer.getTrackState(trackStateContainer.addTrackState(Acts::TrackStatePropMask::None, tsosPreviousIndex));
75  actsTSOS.setReferenceSurface(surf->getSharedPtr());
76  actsTSOS.setUncalibratedSourceLink(Acts::SourceLink(el));
77  actsTrack.tipIndex() = actsTSOS.index();
78  tsosPreviousIndex = actsTrack.tipIndex();
79  }
80  }
81  }
82 
83  std::unique_ptr<ActsTrk::TrackContainer> constTracksContainer = m_tracksBackendHandlesHelper.moveToConst(std::move(tracksContainer),
84  m_trackingGeometryTool->getGeometryContext(context).context(), context);
85 
87  ATH_MSG_DEBUG("Tracks Container `" << m_trackContainerKey.key() << "` created ...");
88  ATH_MSG_DEBUG("Created container with size: " << constTracksContainer->size());
89  ATH_CHECK(trackContainerHandle.record(std::move(constTracksContainer)));
90  if (!trackContainerHandle.isValid())
91  {
92  ATH_MSG_FATAL("Failed to write TrackContainer with key " << m_trackContainerKey.key());
93  return StatusCode::FAILURE;
94  }
95  return StatusCode::SUCCESS;
96 }
97 
98 } // namespace ActsTrk
99 
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:40
ActsTrk::MutableTrackContainerHandlesHelper::moveToConst
std::unique_ptr< ActsTrk::TrackContainer > moveToConst(ActsTrk::MutableTrackContainer &&tc, const Acts::GeometryContext &geoContext, const EventContext &evtContext) const
produces ActsTrk::ConstTrackContainer with all backends stored in SG
Definition: TrackContainerHandlesHelper.cxx:130
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
AthMsgStreamMacros.h
ActsTrk::SeedToTrackCnvAlg::m_trackContainerKey
SG::WriteHandleKey< ActsTrk::TrackContainer > m_trackContainerKey
Definition: SeedToTrackCnvAlg.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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:18
HitType::spacepoint
@ spacepoint
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::SeedToTrackCnvAlg::m_detectorElementToGeometryIdMapKey
SG::ReadCondHandleKey< ActsTrk::DetectorElementToActsGeometryIdMap > m_detectorElementToGeometryIdMapKey
Definition: SeedToTrackCnvAlg.h:45
ActsTrk::MutableTrackContainerHandlesHelper::initialize
StatusCode initialize(const std::string &prefix)
Sets up the handles.
Definition: TrackContainerHandlesHelper.cxx:51
ActsTrk::getSurfaceOfMeasurement
const Acts::Surface * getSurfaceOfMeasurement(const Acts::TrackingGeometry &tracking_geometry, const DetectorElementToActsGeometryIdMap &detector_element_to_geoid, const xAOD::UncalibratedMeasurement &measurement)
Definition: SurfaceOfMeasurementUtil.h:13
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ActsTrk::SeedToTrackCnvAlg::SeedToTrackCnvAlg
SeedToTrackCnvAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SeedToTrackCnvAlg.cxx:22
ActsTrk::MutableMultiTrajectory
Athena implementation of ACTS::MultiTrajectory (ReadWrite version) The data is stored in 4 external b...
Definition: MultiTrajectory.h:81
WriteHandle.h
Handle class for recording to StoreGate.
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
ActsTrk::makeATLASUncalibSourceLink
ATLASUncalibSourceLink makeATLASUncalibSourceLink(const xAOD::UncalibratedMeasurementContainer *container, std::size_t index, [[maybe_unused]] const EventContext &ctx)
Definition: ATLASSourceLink.h:30
ActsTrk::SeedToTrackCnvAlg::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: SeedToTrackCnvAlg.h:49
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
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::Seed
Acts::Seed< xAOD::SpacePoint, 3ul > Seed
Definition: Seed.h:12
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::m_actsTrackParamsKey
SG::ReadHandleKey< ActsTrk::BoundTrackParametersContainer > m_actsTrackParamsKey
Definition: SeedToTrackCnvAlg.h:43
ActsTrk::SeedToTrackCnvAlg::initialize
virtual StatusCode initialize() override
Definition: SeedToTrackCnvAlg.cxx:27
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::SeedToTrackCnvAlg::m_tracksBackendHandlesHelper
ActsTrk::MutableTrackContainerHandlesHelper m_tracksBackendHandlesHelper
Definition: SeedToTrackCnvAlg.h:41
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SurfaceOfMeasurementUtil.h
ActsTrk::SeedToTrackCnvAlg::m_seedContainerKey
SG::ReadHandleKey< ActsTrk::SeedContainer > m_seedContainerKey
Definition: SeedToTrackCnvAlg.h:42
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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: MuonDetectorBuilderTool.cxx:54
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.