Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:19:39

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/VectorHelpers.hpp"
0013 
0014 namespace Acts {
0015 
0016 /// @brief Calculates the Jacobian for spherical to free
0017 ///        direction vector transformation
0018 ///
0019 /// @note We use the direction vector as an input because
0020 ///       the trigonometric simplify that way
0021 ///
0022 /// @param direction The normalised direction vector
0023 ///
0024 /// @return The Jacobian d(dir_x, dir_y, dir_z) / d(phi, theta)
0025 ///
0026 inline Matrix<3, 2> sphericalToFreeDirectionJacobian(const Vector3& direction) {
0027   auto [cosPhi, sinPhi, cosTheta, sinTheta] =
0028       VectorHelpers::evaluateTrigonomics(direction);
0029 
0030   // clang-format off
0031   Matrix<3, 2> jacobian;
0032   jacobian <<
0033     -direction.y(),  cosTheta * cosPhi,
0034      direction.x(),  cosTheta * sinPhi,
0035      0,             -sinTheta;
0036   // clang-format on
0037 
0038   return jacobian;
0039 }
0040 
0041 /// @brief Calculates the Jacobian for free to spherical
0042 ///        direction vector transformation
0043 ///
0044 /// @note We use the direction vector as an input because
0045 ///       the trigonometric simplify that way
0046 ///
0047 /// @param direction The normalised direction vector
0048 ///
0049 /// @return The Jacobian d(phi, theta) / d(dir_x, dir_y, dir_z)
0050 ///
0051 inline Matrix<2, 3> freeToSphericalDirectionJacobian(const Vector3& direction) {
0052   auto [cosPhi, sinPhi, cosTheta, sinTheta] =
0053       VectorHelpers::evaluateTrigonomics(direction);
0054   double invSinTheta = 1. / sinTheta;
0055 
0056   // clang-format off
0057   Matrix<2, 3> jacobian;
0058   jacobian <<
0059     -sinPhi * invSinTheta, cosPhi * invSinTheta, 0,
0060      cosPhi * cosTheta,    sinPhi * cosTheta,    -sinTheta;
0061   // clang-format on
0062 
0063   return jacobian;
0064 }
0065 
0066 }  // namespace Acts