Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:12:59

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/Utilities/AlgebraHelpers.hpp"
0013 #include "Acts/Utilities/ArrayHelpers.hpp"
0014 
0015 #include <cstdint>
0016 
0017 namespace Acts::detail {
0018 /// @brief Helper to describe a line in 3D space. The line is described
0019 ///        by a point on the line and a corresponding direction vector with unit
0020 ///        length. Additionally, the `Line3DWithPartialDerivatives` holds the
0021 ///        first and second derivative of the line with respect to the
0022 ///        parameters `x0`, `y0`, `theta`, and `phi` (the parameters are defined
0023 ///        in the enum `ParIndex`).
0024 template <std::floating_point T>
0025 class Line3DWithPartialDerivatives {
0026  public:
0027   /// @brief Abrivation of the Vector
0028   using Vector = Eigen::Matrix<T, 3, 1>;
0029   /// @brief Enum to map the indices of the parameter vector
0030   enum class ParIndex : std::uint8_t {
0031     x0 = 0,
0032     y0 = 1,
0033     theta = 2,
0034     phi = 3,
0035     nPars = 4
0036   };
0037   static constexpr std::uint8_t s_nPars =
0038       static_cast<std::uint8_t>(ParIndex::nPars);
0039   /// @brief Abrivation of the parameter vector type
0040   using ParamVector = std::array<T, s_nPars>;
0041 
0042   /// @brief Update the line & derivatives with the new parameters
0043   /// @param newPars The new parameters to update the line with
0044   void updateParameters(const ParamVector& newPars);
0045   /// @brief Returns a point on the line
0046   const Vector& position() const;
0047   /// @brief Returns the direction of the line
0048   const Vector& direction() const;
0049   /// @brief Returns the first derivative of the line with respect to the passed
0050   /// @param param: Index of the parameter to get the derivative for
0051   const Vector& gradient(const ParIndex param) const;
0052   /// @brief Returns the second derivative of the line with respect to the passed
0053   /// @param param1: Index of the first parameter to get the derivative for
0054   /// @param param2: Index of the second parameter to get the derivative for
0055   const Vector& hessian(const ParIndex param1, const ParIndex param2) const;
0056   /// @brief Returns a point along the line which is by lambda apart from
0057   ///        the line reference
0058   /// @param lambda: Separation from the reference
0059   Vector point(const double lambda) const;
0060 
0061  private:
0062   Vector m_pos{Vector::Zero()};
0063   Vector m_dir{Vector::Zero()};
0064   std::array<Vector, s_nPars> m_gradient{
0065       filledArray<Vector, s_nPars>(Vector::Zero())};
0066 
0067   std::array<Vector, sumUpToN(s_nPars)> m_hessian{
0068       filledArray<Vector, sumUpToN(s_nPars)>(Vector::Zero())};
0069 };
0070 }  // namespace Acts::detail
0071 #include "Acts/Utilities/detail/Line3DWithPartialDerivatives.ipp"