Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 08:47:43

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/EventData/TransformationHelpers.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/Zip.hpp"
0018 
0019 #include <array>
0020 #include <optional>
0021 #include <stdexcept>
0022 
0023 namespace Acts {
0024 
0025 /// @defgroup est_track_params Estimate track parameters from seed
0026 ///
0027 /// The implemented method is based on the conformal map transformation. It
0028 /// estimates the full free track parameters, i.e. (x, y, z, t, dx, dy, dz, q/p)
0029 /// at the bottom space point. The magnetic field (which can be along any
0030 /// direction) is also necessary for the momentum estimation.
0031 ///
0032 /// It resembles the method used in ATLAS for the track parameters estimated
0033 /// from seed, i.e. the function InDet::SiTrackMaker_xk::getAtaPlane here:
0034 /// https://acode-browser.usatlas.bnl.gov/lxr/source/athena/InnerGeometry/InDetRecTools/SiTrackMakerTool_xk/src/SiTrackMaker_xk.cxx
0035 ///
0036 /// @{
0037 
0038 /// Estimate free track parameters from three space points
0039 ///
0040 /// This is a purely spatial estimation, i.e. the time parameter will be set to
0041 /// 0.
0042 ///
0043 /// @param sp0 is the bottom space point
0044 /// @param sp1 is the middle space point
0045 /// @param sp2 is the top space point
0046 /// @param bField is the magnetic field vector
0047 ///
0048 /// @return the free parameters
0049 [[deprecated(
0050     "Use the version of estimateTrackParamsFromSeed with time information "
0051     "instead.")]]
0052 FreeVector estimateTrackParamsFromSeed(const Vector3& sp0, const Vector3& sp1,
0053                                        const Vector3& sp2,
0054                                        const Vector3& bField);
0055 
0056 /// Estimate free track parameters from three space points
0057 ///
0058 /// @param sp0 is the bottom space point
0059 /// @param t0 is the time of the bottom space point
0060 /// @param sp1 is the middle space point
0061 /// @param sp2 is the top space point
0062 /// @param bField is the magnetic field vector
0063 ///
0064 /// @return the free parameters
0065 FreeVector estimateTrackParamsFromSeed(const Vector3& sp0, double t0,
0066                                        const Vector3& sp1, const Vector3& sp2,
0067                                        const Vector3& bField);
0068 
0069 /// Estimate free track parameters from three space points
0070 ///
0071 /// @tparam space_point_range_t The type of space point range
0072 ///
0073 /// @param spRange is the range of space points
0074 /// @param bField is the magnetic field vector
0075 ///
0076 /// @return the free parameters
0077 template <std::ranges::range space_point_range_t>
0078 FreeVector estimateTrackParamsFromSeed(space_point_range_t spRange,
0079                                        const Vector3& bField) {
0080   // Check the number of provided space points
0081   if (spRange.size() != 3) {
0082     throw std::invalid_argument(
0083         "There should be exactly three space points provided.");
0084   }
0085 
0086   // The global positions of the bottom, middle and space points
0087   std::array<Vector3, 3> spPositions = {Vector3::Zero(), Vector3::Zero(),
0088                                         Vector3::Zero()};
0089   std::array<std::optional<double>, 3> spTimes = {std::nullopt, std::nullopt,
0090                                                   std::nullopt};
0091   // The first, second and third space point are assumed to be bottom, middle
0092   // and top space point, respectively
0093   for (auto [sp, spPosition, spTime] :
0094        Acts::zip(spRange, spPositions, spTimes)) {
0095     if (sp == nullptr) {
0096       throw std::invalid_argument("Empty space point found.");
0097     }
0098     spPosition = Vector3(sp->x(), sp->y(), sp->z());
0099     spTime = sp->t();
0100   }
0101 
0102   return estimateTrackParamsFromSeed(spPositions[0], spTimes[0].value_or(0),
0103                                      spPositions[1], spPositions[2], bField);
0104 }
0105 
0106 /// Estimate bound track parameters from three space points
0107 ///
0108 /// @param gctx is the geometry context
0109 /// @param surface is the surface of the bottom space point. The estimated bound
0110 ///                track parameters will be represented at this surface.
0111 /// @param sp0 is the bottom space point
0112 /// @param t0 is the time of the bottom space point
0113 /// @param sp1 is the middle space point
0114 /// @param sp2 is the top space point
0115 /// @param bField is the magnetic field vector
0116 ///
0117 /// @return bound parameters
0118 Result<BoundVector> estimateTrackParamsFromSeed(
0119     const GeometryContext& gctx, const Surface& surface, const Vector3& sp0,
0120     double t0, const Vector3& sp1, const Vector3& sp2, const Vector3& bField);
0121 
0122 /// Estimate bound track parameters from three space points
0123 ///
0124 /// @tparam space_point_range_t The type of space point range
0125 ///
0126 /// @param gctx is the geometry context
0127 /// @param spRange is the range of space points
0128 /// @param surface is the surface of the bottom space point. The estimated bound
0129 ///                track parameters will be represented at this surface.
0130 /// @param bField is the magnetic field vector
0131 ///
0132 /// @return bound parameters
0133 template <std::ranges::range space_point_range_t>
0134 Result<BoundVector> estimateTrackParamsFromSeed(const GeometryContext& gctx,
0135                                                 space_point_range_t spRange,
0136                                                 const Surface& surface,
0137                                                 const Vector3& bField) {
0138   const FreeVector freeParams = estimateTrackParamsFromSeed(spRange, bField);
0139   return transformFreeToBoundParameters(freeParams, surface, gctx);
0140 }
0141 
0142 /// Configuration for the estimation of the covariance matrix of the track
0143 /// parameters with `estimateTrackParamCovariance`.
0144 struct EstimateTrackParamCovarianceConfig {
0145   /// The initial sigmas for the track parameters
0146   BoundVector initialSigmas = {1. * UnitConstants::mm,
0147                                1. * UnitConstants::mm,
0148                                1. * UnitConstants::degree,
0149                                1. * UnitConstants::degree,
0150                                1. * UnitConstants::e / UnitConstants::GeV,
0151                                1. * UnitConstants::ns};
0152 
0153   /// The initial sigma for the q/pt
0154   /// @note The resulting q/p sigma is added to the one in `initialSigmas`
0155   double initialSigmaQoverPt = 0. * UnitConstants::e / UnitConstants::GeV;
0156 
0157   /// The initial relative uncertainty sigma(pt)/pt
0158   /// @note The resulting q/p sigma is added to the one in `initialSigmas`
0159   double initialSigmaPtRel = 0.1;
0160 
0161   /// The inflation factors for the variances of the track parameters
0162   BoundVector initialVarInflation = {1., 1., 1., 1., 1., 1.};
0163   /// The inflation factor for time uncertainty if the time parameter was not
0164   /// estimated
0165   double noTimeVarInflation = 100.;
0166 };
0167 
0168 /// Estimate the covariance matrix of the given track parameters based on the
0169 /// provided configuration. The assumption is that we can model the uncertainty
0170 /// of the track parameters as a diagonal matrix with the provided initial
0171 /// sigmas. The inflation factors are used to inflate the initial variances
0172 /// based on the provided configuration. The uncertainty of q/p is estimated
0173 /// based on the relative uncertainty of the q/pt and the theta uncertainty.
0174 ///
0175 /// @param config is the configuration for the estimation
0176 /// @param params is the track parameters
0177 /// @param hasTime is true if the track parameters have time
0178 ///
0179 /// @return the covariance matrix of the track parameters
0180 BoundMatrix estimateTrackParamCovariance(
0181     const EstimateTrackParamCovarianceConfig& config, const BoundVector& params,
0182     bool hasTime);
0183 
0184 /// @}
0185 
0186 }  // namespace Acts