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/Utilities/detail/Line3DWithPartialDerivatives.hpp"
0012 
0013 #include "Acts/Definitions/Common.hpp"
0014 #include "Acts/Utilities/UnitVectors.hpp"
0015 
0016 namespace Acts::detail {
0017 
0018 template <std::floating_point T>
0019 void Line3DWithPartialDerivatives<T>::updateParameters(
0020     const ParamVector& newPars) {
0021   constexpr auto x0 = static_cast<std::uint8_t>(ParIndex::x0);
0022   constexpr auto y0 = static_cast<std::uint8_t>(ParIndex::y0);
0023   constexpr auto theta = static_cast<std::uint8_t>(ParIndex::theta);
0024   constexpr auto phi = static_cast<std::uint8_t>(ParIndex::phi);
0025 
0026   m_pos[Acts::eX] = newPars[x0];
0027   m_pos[Acts::eY] = newPars[y0];
0028 
0029   const T cosTheta = std::cos(newPars[theta]);
0030   const T sinTheta = std::sin(newPars[theta]);
0031   const T cosPhi = std::cos(newPars[phi]);
0032   const T sinPhi = std::sin(newPars[phi]);
0033 
0034   m_dir = Vector{cosPhi * sinTheta, sinPhi * sinTheta, cosTheta};
0035 
0036   m_gradient[y0] = Vector::UnitY();
0037   m_gradient[x0] = Vector::UnitX();
0038   /**            x_{0}                cos (phi) sin (theta)
0039    *  position = y_{0}  , Direction = sin (phi) sin (theta)
0040    *             0                         cos theta
0041    *
0042    *
0043    *   d Direction     cos (phi) cos(theta)     d Direction     -sin(phi) sin
0044    *(theta)
0045    *  -------------=   sin (phi) cos(theta)     ------------ =   cos(phi) sin
0046    *(theta) dTheta         - sin (theta)             dPhi                 0
0047    *
0048    *******************************************************************************/
0049   m_gradient[theta] = Vector{cosPhi * cosTheta, sinPhi * cosTheta, -sinTheta};
0050   m_gradient[phi] = Vector{-sinTheta * sinPhi, sinTheta * cosPhi, 0};
0051   /*********************************************************************************
0052    *   Non-vanishing second order derivatives
0053    *
0054    *    d^{2} Direction                 d^{2} Direction                     cos
0055    *phi
0056    *    ------------- = - Direction ,   ------------      = - sin(theta)    sin
0057    *phi d^{2} theta                      d^{2} phi                             0
0058    *
0059    *   d^{2} Direction                 -sin phi
0060    *   -------------     = cos(theta)   cos phi
0061    *    d theta dPhi                       0
0062    ************************************************************************************/
0063   constexpr auto idxThetaSq = vecIdxFromSymMat<s_nPars>(theta, theta);
0064   constexpr auto idxPhiSq = vecIdxFromSymMat<s_nPars>(phi, phi);
0065   constexpr auto idxPhiTheta = vecIdxFromSymMat<s_nPars>(theta, phi);
0066   m_hessian[idxThetaSq] = -m_dir;
0067   m_hessian[idxPhiSq] = -sinTheta * Vector{cosPhi, sinPhi, 0.};
0068   m_hessian[idxPhiTheta] = cosTheta * Vector{-sinPhi, cosPhi, 0.};
0069 }
0070 
0071 template <std::floating_point T>
0072 const Line3DWithPartialDerivatives<T>::Vector&
0073 Line3DWithPartialDerivatives<T>::position() const {
0074   return m_pos;
0075 }
0076 template <std::floating_point T>
0077 const Line3DWithPartialDerivatives<T>::Vector&
0078 Line3DWithPartialDerivatives<T>::direction() const {
0079   return m_dir;
0080 }
0081 template <std::floating_point T>
0082 const Line3DWithPartialDerivatives<T>::Vector&
0083 Line3DWithPartialDerivatives<T>::gradient(const ParIndex par) const {
0084   const auto param = static_cast<std::uint8_t>(par);
0085   assert(param < m_gradient.size());
0086   return m_gradient[param];
0087 }
0088 template <std::floating_point T>
0089 const Line3DWithPartialDerivatives<T>::Vector&
0090 Line3DWithPartialDerivatives<T>::hessian(const ParIndex param1,
0091                                          const ParIndex param2) const {
0092   const auto idx{vecIdxFromSymMat<s_nPars>(static_cast<std::size_t>(param1),
0093                                            static_cast<std::size_t>(param2))};
0094   assert(idx < m_hessian.size());
0095   return m_hessian[idx];
0096 }
0097 
0098 template <std::floating_point T>
0099 Line3DWithPartialDerivatives<T>::Vector Line3DWithPartialDerivatives<T>::point(
0100     const double lambda) const {
0101   return position() + lambda * direction();
0102 }
0103 }  // namespace Acts::detail