ATLAS Offline Software
SeedsToTrackParamsAlg.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 #include "TrkSurfaces/Surface.h"
9 
10 namespace ActsTrk {
11 
13  ISvcLocator* pSvcLocator)
14  : AthReentrantAlgorithm(name, pSvcLocator)
15  {}
16 
18  ATH_MSG_INFO("Initializing " << name() << " ...");
19 
21  ATH_CHECK(m_extrapolationTool.retrieve());
22  ATH_CHECK(m_ATLASConverterTool.retrieve());
23  ATH_CHECK(m_paramEstimationTool.retrieve());
24 
26  ATH_CHECK(m_inputSeedContainerKey.initialize());
28 
30  }
31 
32  StatusCode SeedsToTrackParamsAlg::execute(const EventContext& ctx) const {
33  ATH_MSG_DEBUG("Executing " << name() << " ... ");
34 
35  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
36  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
37 
40 
41  ATH_CHECK(seedContainerHandle.isValid());
42  ATH_CHECK(detEleHandle.isValid());
43 
45  ATH_MSG_DEBUG(" \\__ Track Params Estimated `" << m_outputTrackParamsCollectionKey.key() << "` created ...");
46  ATH_CHECK(boundTrackParamsHandle.record(std::make_unique<ActsTrk::BoundTrackParametersContainer>()));
47  ActsTrk::BoundTrackParametersContainer *trackParams = boundTrackParamsHandle.ptr();
48 
49  const ActsTrk::SeedContainer &seeds = *seedContainerHandle;
50  const InDetDD::SiDetectorElementCollection &detElements = *detEleHandle.cptr();
51 
52  for (std::size_t iseed = 0; iseed < seeds.size(); ++iseed) {
53  const ActsTrk::Seed& seed = *seeds[iseed];
54 
55  const bool useTopSp = m_autoReverseSearch && shouldReverseSearch(seed);
56 
57  auto retrieveSurfaceFunction =
58  [this, &detElements] (const ActsTrk::Seed& seed, bool useTopSp) -> const Acts::Surface& {
59  const xAOD::SpacePoint* sp = useTopSp ? seed.sp().back() : seed.sp().front();
60  const InDetDD::SiDetectorElement* element = detElements.getDetectorElement(
61  useTopSp ? sp->elementIdList().back() : sp->elementIdList().front());
62  const Trk::Surface& atlas_surface = element->surface();
63  return this->m_ATLASConverterTool->trkSurfaceToActsSurface(atlas_surface);
64  };
65 
66  std::optional<Acts::BoundTrackParameters> optTrackParams =
67  m_paramEstimationTool->estimateTrackParameters(
68  seed,
69  useTopSp,
70  tgContext,
71  mfContext,
72  retrieveSurfaceFunction);
73 
74  if (!optTrackParams.has_value()) {
75  ATH_MSG_DEBUG("Failed to estimate track parameters for seed " << iseed);
76  trackParams->push_back(std::unique_ptr<Acts::BoundTrackParameters>());
77  continue;
78  }
79 
80  trackParams->push_back(std::make_unique<Acts::BoundTrackParameters>(std::move(*optTrackParams)));
81  }
82 
83  return StatusCode::SUCCESS;
84  }
85 
87  const auto& bottom_sp = seed.sp().front();
88 
89  const double r = bottom_sp->radius();
90  const double z = std::abs(bottom_sp->z());
91 
92  const double rBoundary = m_useTopSpRZboundary.value()[0];
93  const double zBoundary = m_useTopSpRZboundary.value()[1];
94 
95  return r > rBoundary || z > zBoundary;
96  }
97 
98 
99 }
beamspotman.r
def r
Definition: beamspotman.py:672
ActsTrk::SeedsToTrackParamsAlg::m_inputSeedContainerKey
SG::ReadHandleKey< ActsTrk::SeedContainer > m_inputSeedContainerKey
Definition: SeedsToTrackParamsAlg.h:42
ActsTrk::SeedsToTrackParamsAlg::m_paramEstimationTool
ToolHandle< ActsTrk::ITrackParamsEstimationTool > m_paramEstimationTool
Definition: SeedsToTrackParamsAlg.h:38
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:27
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Surface.h
xAOD::SpacePoint_v1::elementIdList
const std::vector< DetectorIDHashType > & elementIdList() const
Returns the IdentifierHash of the spacepoint (corresponds to the detector element IdentifierHash)
Definition: SpacePoint_v1.cxx:14
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
initialize
void initialize()
Definition: run_EoverP.cxx:894
InDetDD::SolidStateDetectorElementBase::surface
Trk::Surface & surface()
Element Surface.
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
ActsTrk::SeedsToTrackParamsAlg::m_useTopSpRZboundary
Gaudi::Property< std::vector< double > > m_useTopSpRZboundary
Definition: SeedsToTrackParamsAlg.h:46
ActsTrk::SeedsToTrackParamsAlg::SeedsToTrackParamsAlg
SeedsToTrackParamsAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SeedsToTrackParamsAlg.cxx:12
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
z
#define z
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ActsTrk::SeedsToTrackParamsAlg::m_detEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_detEleCollKey
Definition: SeedsToTrackParamsAlg.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::SeedsToTrackParamsAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: SeedsToTrackParamsAlg.cxx:32
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ActsTrk::SeedsToTrackParamsAlg::m_autoReverseSearch
Gaudi::Property< bool > m_autoReverseSearch
Definition: SeedsToTrackParamsAlg.h:45
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::SeedsToTrackParamsAlg::m_trackingGeometryTool
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Definition: SeedsToTrackParamsAlg.h:36
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ActsTrk::ActsSeed
Definition: Seed.h:18
SiDetectorElement.h
ActsTrk::SeedsToTrackParamsAlg::shouldReverseSearch
bool shouldReverseSearch(const ActsTrk::Seed &seed) const
Definition: SeedsToTrackParamsAlg.cxx:86
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
ActsTrk::SeedsToTrackParamsAlg::initialize
virtual StatusCode initialize() override
Definition: SeedsToTrackParamsAlg.cxx:17
ActsTrk::SeedsToTrackParamsAlg::m_outputTrackParamsCollectionKey
SG::WriteHandleKey< ActsTrk::BoundTrackParametersContainer > m_outputTrackParamsCollectionKey
Definition: SeedsToTrackParamsAlg.h:43
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ActsTrk::SeedsToTrackParamsAlg::m_extrapolationTool
ToolHandle< IActsExtrapolationTool > m_extrapolationTool
Definition: SeedsToTrackParamsAlg.h:35
ActsTrk::SeedsToTrackParamsAlg::m_ATLASConverterTool
ToolHandle< ActsTrk::IActsToTrkConverterTool > m_ATLASConverterTool
Definition: SeedsToTrackParamsAlg.h:37
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:25
SeedsToTrackParamsAlg.h
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:79
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:9
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:71