Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TrackParamsEstimationTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp"
8 #include "Acts/EventData/TransformationHelpers.hpp"
9 
10 namespace ActsTrk {
12  const std::string& name,
13  const IInterface* parent)
14  : base_class(type, name, parent)
15  {}
16 
18  {
19  ATH_MSG_INFO( "Initializing " << name() << "..." );
20 
21  ATH_MSG_DEBUG( "Properties Summary:" );
22  ATH_MSG_DEBUG( " " << m_sigmaLoc0 );
23  ATH_MSG_DEBUG( " " << m_sigmaLoc1 );
24  ATH_MSG_DEBUG( " " << m_sigmaPhi );
25  ATH_MSG_DEBUG( " " << m_sigmaTheta );
26  ATH_MSG_DEBUG( " " << m_sigmaQOverP );
27  ATH_MSG_DEBUG( " " << m_sigmaT0 );
29 
30  m_logger = makeActsAthenaLogger(this, "Acts");
31 
32  m_extrapolator = Extrapolator(Stepper(std::make_shared<ATLASMagneticFieldWrapper>()), Navigator(), logger().cloneWithSuffix("Prop"));
33 
34  return StatusCode::SUCCESS;
35  }
36 
37  std::optional<Acts::BoundTrackParameters>
39  const ActsTrk::Seed& seed,
40  bool useTopSp,
41  const Acts::GeometryContext& geoContext,
42  const Acts::MagneticFieldContext& magFieldContext,
43  std::function<const Acts::Surface&(const ActsTrk::Seed& seed, bool useTopSp)> retrieveSurface) const
44  {
45  const auto& sp_collection = seed.sp();
46  if ( sp_collection.size() < 3 ) return std::nullopt;
47  const auto& bottom_sp = useTopSp ? sp_collection.back() : sp_collection.front();
48 
49  // Magnetic Field
50  ATLASMagneticFieldWrapper magneticField;
51  Acts::MagneticFieldProvider::Cache magFieldCache = magneticField.makeCache( magFieldContext );
52  Acts::Vector3 bField = *magneticField.getField( Acts::Vector3(bottom_sp->x(), bottom_sp->y(), bottom_sp->z()),
53  magFieldCache );
54 
55  // Get the surface
56  const Acts::Surface& surface = retrieveSurface(seed, useTopSp);
57 
59  seed,
60  useTopSp,
61  geoContext,
62  magFieldContext,
63  surface,
64  bField);
65  }
66 
67  std::optional<Acts::BoundTrackParameters>
69  const ActsTrk::Seed& seed,
70  bool useTopSp,
71  const Acts::GeometryContext& geoContext,
72  const Acts::MagneticFieldContext& magFieldContext,
73  const Acts::Surface& surface,
74  const Acts::Vector3& bField) const
75  {
76  // Get SPs
77  const auto& sp_collection = seed.sp();
78  if ( sp_collection.size() < 3 ) return std::nullopt;
79 
80  // Compute free parameters
81  Acts::FreeVector freeParams = useTopSp ?
82  Acts::estimateTrackParamsFromSeed(std::ranges::views::reverse(sp_collection),
83  bField) :
84  Acts::estimateTrackParamsFromSeed(sp_collection,
85  bField);
86 
87  if (useTopSp) {
88  // reverse direction so momentum vector pointing outwards
89  freeParams = Acts::reflectFreeParameters(freeParams);
90  }
91 
92  // Convert free params to curvilinear params for extrapolation
93  Acts::BoundTrackParameters curvilinearParams = Acts::BoundTrackParameters::createCurvilinear(
94  freeParams.segment<4>(Acts::eFreePos0),
95  freeParams.segment<3>(Acts::eFreeDir0),
96  freeParams[Acts::eFreeQOverP],
97  std::nullopt,
99 
100  // Extrapolate to surface
101  Acts::PropagatorPlainOptions propOptions(geoContext, magFieldContext);
102  propOptions.direction = Acts::Direction::fromScalarZeroAsPositive(
103  surface.intersect(
104  geoContext,
105  freeParams.segment<3>(Acts::eFreePos0),
106  freeParams.segment<3>(Acts::eFreeDir0)
107  ).closest().pathLength());
108  auto boundParamsResult = m_extrapolator->propagateToSurface(curvilinearParams, surface, propOptions);
109  if (!boundParamsResult.ok()) {
110  ATH_MSG_DEBUG("Extrapolation failed");
111  return std::nullopt;
112  }
113 
114  // Get extrapolated parameters
115  Acts::BoundTrackParameters boundParams = *boundParamsResult;
116 
117  // Estimate covariance
118  Acts::EstimateTrackParamCovarianceConfig covarianceEstimationConfig = {
120  .initialSigmaPtRel = m_initialSigmaPtRel,
121  .initialVarInflation = Eigen::Map<const Acts::BoundVector>(m_initialVarInflation.value().data()),
122  .noTimeVarInflation = 1.0,
123  };
124  boundParams.covariance() = Acts::estimateTrackParamCovariance(
125  covarianceEstimationConfig,
126  boundParams.parameters(),
127  false);
128 
129  return boundParams;
130  }
131 
132 }
133 // namespace ActsTrk
ActsTrk::TrackParamsEstimationTool::m_sigmaLoc0
Gaudi::Property< double > m_sigmaLoc0
Definition: TrackParamsEstimationTool.h:52
ActsTrk::TrackParamsEstimationTool::m_extrapolator
std::optional< Extrapolator > m_extrapolator
Definition: TrackParamsEstimationTool.h:73
ATLASMagneticFieldWrapper
Definition: ATLASMagneticFieldWrapper.h:15
ActsTrk::TrackParamsEstimationTool::m_initialSigmaPtRel
Gaudi::Property< double > m_initialSigmaPtRel
Definition: TrackParamsEstimationTool.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ActsTrk::TrackParamsEstimationTool::m_initialVarInflation
Gaudi::Property< std::vector< double > > m_initialVarInflation
Definition: TrackParamsEstimationTool.h:66
ActsTrk::TrackParamsEstimationTool::Extrapolator
Acts::Propagator< Stepper > Extrapolator
Definition: TrackParamsEstimationTool.h:71
ActsTrk::TrackParamsEstimationTool::m_sigmaTheta
Gaudi::Property< double > m_sigmaTheta
Definition: TrackParamsEstimationTool.h:58
ATLASMagneticFieldWrapper.h
xAOD::pion
@ pion
Definition: TrackingPrimitives.h:197
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ATLASMagneticFieldWrapper::makeCache
MagneticFieldProvider::Cache makeCache(const Acts::MagneticFieldContext &mctx) const override
Definition: ATLASMagneticFieldWrapper.h:34
ActsTrk::TrackParamsEstimationTool::estimateTrackParameters
virtual std::optional< Acts::BoundTrackParameters > estimateTrackParameters(const ActsTrk::Seed &seed, bool useTopSp, const Acts::GeometryContext &geoContext, const Acts::MagneticFieldContext &magFieldContext, std::function< const Acts::Surface &(const ActsTrk::Seed &seed, bool useTopSp)> retrieveSurface) const override
Definition: TrackParamsEstimationTool.cxx:38
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
ActsTrk::TrackParamsEstimationTool::m_sigmaLoc1
Gaudi::Property< double > m_sigmaLoc1
Definition: TrackParamsEstimationTool.h:54
ActsTrk::TrackParamsEstimationTool::Navigator
Acts::VoidNavigator Navigator
Definition: TrackParamsEstimationTool.h:70
makeActsAthenaLogger
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition: Tracking/Acts/ActsInterop/src/Logger.cxx:64
ActsTrk::TrackParamsEstimationTool::m_sigmaPhi
Gaudi::Property< double > m_sigmaPhi
Definition: TrackParamsEstimationTool.h:56
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::Seed
Acts::Seed< xAOD::SpacePoint, 3ul > Seed
Definition: Seed.h:12
ActsTrk::TrackParamsEstimationTool::Stepper
Acts::SympyStepper Stepper
Definition: TrackParamsEstimationTool.h:69
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::TrackParamsEstimationTool::TrackParamsEstimationTool
TrackParamsEstimationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrackParamsEstimationTool.cxx:11
ActsTrk::TrackParamsEstimationTool::m_logger
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Definition: TrackParamsEstimationTool.h:82
TrackParamsEstimationTool.h
ATLASMagneticFieldWrapper::getField
Acts::Result< Acts::Vector3 > getField(const Acts::Vector3 &position, Acts::MagneticFieldProvider::Cache &gcache) const override
Definition: ATLASMagneticFieldWrapper.h:39
ActsTrk::TrackParamsEstimationTool::m_sigmaT0
Gaudi::Property< double > m_sigmaT0
Definition: TrackParamsEstimationTool.h:62
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:55
ActsTrk::TrackParamsEstimationTool::logger
const Acts::Logger & logger() const
Private access to the logger.
Definition: TrackParamsEstimationTool.h:76
ActsTrk::TrackParamsEstimationTool::initialize
virtual StatusCode initialize() override
Definition: TrackParamsEstimationTool.cxx:17
ActsTrk::TrackParamsEstimationTool::m_sigmaQOverP
Gaudi::Property< double > m_sigmaQOverP
Definition: TrackParamsEstimationTool.h:60