Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:13

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/EventData/TrackParameters.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0015 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0016 #include "Acts/MagneticField/NullBField.hpp"
0017 #include "Acts/Propagator/EigenStepper.hpp"
0018 #include "Acts/Propagator/Propagator.hpp"
0019 #include "Acts/Utilities/Result.hpp"
0020 #include "Acts/Vertexing/LinearizedTrack.hpp"
0021 
0022 namespace Acts {
0023 
0024 /// @class NumericalTrackLinearizer
0025 /// Linearizes the track parameters at the PCA to a user-provided
0026 /// point (linPoint). The track parameters are written as a function
0027 /// of the global 4D PCA position and the momentum of the particle at
0028 /// the PCA (i.e., (phi, theta, q/p)). The linearization then reads
0029 /// (see Eq. 5.7 in Ref(1)):
0030 ///
0031 /// q = A (r - r_0) + B (p - p_0) + c,
0032 ///
0033 /// where q are the Perigee parameters wrt linPoint, {r_0} r is the {initial}
0034 /// 4D PCA position, {p_0} p is the {initial} momentum at the PCA, and c is
0035 /// the constant term of the expansion. A and B are matrices of derivatives,
0036 /// denoted hereafter as "positionJacobian" and "momentumJacobian" respectively.
0037 /// Note that, unlike in Ref. (1), we add the time to the parametrization, which
0038 /// adds a row and a column to A and a row to B.
0039 ///
0040 /// This class computes A and B by wiggling one of the 7 parameters
0041 /// at the PCA and computing the new PCA wrt linPoint. The derivatives wrt
0042 /// the k-th parameter pk are then calculated via
0043 ///
0044 /// (q(p1, p2, ..., pk+delta, ... p7) - q(p1, p2, ..., pk, ... p7))/delta,
0045 ///
0046 /// where q(p1, p2, ..., pk+delta, ... p7) are the new Perigee parameters
0047 /// (corresponding to the new PCA to linPoint). Note that p1 corresponds to
0048 /// the x-position of the PCA, p2 corresponds to the y-position of the PCA, etc.
0049 ///
0050 /// @note Connection to RiddersPropagator: The RiddersPropagator does a very
0051 /// similar thing to what this class does, but it wiggles BoundTrackParameters
0052 /// (FreeTrackParameters could also be used if Propagator.hpp and Propagator.ipp
0053 /// were adapted to accommodate them). Here, we wiggle neither
0054 /// BoundTrackParameters nor FreeTrackParameters, but rather the parameters
0055 /// described above.
0056 ///
0057 /// Ref.(1) - CERN-THESIS-2010-027, Giacinto Piacquadio (Freiburg U.)
0058 class NumericalTrackLinearizer {
0059  public:
0060   /// @brief Configuration struct
0061   struct Config {
0062     /// @ Config constructor if magnetic field is present
0063     ///
0064     /// @param bIn The magnetic field
0065     /// @param prop The propagator
0066     Config(std::shared_ptr<const MagneticFieldProvider> bIn,
0067            std::shared_ptr<const BasePropagator> prop)
0068         : bField(std::move(bIn)), propagator(std::move(prop)) {}
0069 
0070     /// @brief Config constructor without B field -> uses NullBField
0071     ///
0072     /// @param prop Propagator
0073     Config(std::shared_ptr<const BasePropagator> prop)
0074         : bField{std::make_shared<NullBField>()}, propagator(std::move(prop)) {}
0075 
0076     std::shared_ptr<const MagneticFieldProvider> bField;
0077 
0078     std::shared_ptr<const BasePropagator> propagator;
0079 
0080     /// Tolerance determining how close we need to get to a surface to
0081     /// reach it during propagation
0082     double targetTolerance = 1e-12;
0083 
0084     /// Setting size of the perturbation delta for calculation of numerical
0085     /// derivatives (i.e., f'(x) ~ (f(x+delta) - f(x)) / delta)
0086     double delta = 1e-8;
0087   };
0088 
0089   /// @brief Constructor
0090   ///
0091   /// @param config Configuration object
0092   /// @param _logger Logger instance
0093   NumericalTrackLinearizer(const Config& config,
0094                            std::unique_ptr<const Logger> _logger =
0095                                getDefaultLogger("NumTrkLinProp", Logging::INFO))
0096       : m_cfg(config), m_logger{std::move(_logger)} {}
0097 
0098   /// @brief Function that linearizes BoundTrackParameters at
0099   /// the PCA to a given Perigee surface
0100   ///
0101   /// @param params Parameters to linearize
0102   /// @param linPointTime Time associated to the linearization point
0103   /// @note Transverse plane of the Perigee corresponding to @p linPoint is
0104   /// parallel to the global x-y plane
0105   /// @param perigeeSurface Perigee surface belonging to @p linPoint
0106   /// @param gctx Geometry context
0107   /// @param mctx Magnetic field context
0108   ///
0109   /// @return Linearized track
0110   Result<LinearizedTrack> linearizeTrack(
0111       const BoundTrackParameters& params, double linPointTime,
0112       const Surface& perigeeSurface, const Acts::GeometryContext& gctx,
0113       const Acts::MagneticFieldContext& mctx,
0114       MagneticFieldProvider::Cache& /*fieldCache*/) const;
0115 
0116  private:
0117   const Config m_cfg;
0118 
0119   std::unique_ptr<const Logger> m_logger;
0120 
0121   const Logger& logger() const { return *m_logger; }
0122 };
0123 
0124 }  // namespace Acts