Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:01:55

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://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 ActsMatrix<3, 2> sphericalToFreeDirectionJacobian(
0027     const Vector3& direction) {
0028   auto [cosPhi, sinPhi, cosTheta, sinTheta] =
0029       VectorHelpers::evaluateTrigonomics(direction);
0030 
0031   // clang-format off
0032   ActsMatrix<3, 2> jacobian;
0033   jacobian << 
0034     -direction.y(),  cosTheta * cosPhi,
0035      direction.x(),  cosTheta * sinPhi,
0036      0,             -sinTheta;
0037   // clang-format on
0038 
0039   return jacobian;
0040 }
0041 
0042 /// @brief Calculates the Jacobian for free to spherical
0043 ///        direction vector transformation
0044 ///
0045 /// @note We use the direction vector as an input because
0046 ///       the trigonometric simplify that way
0047 ///
0048 /// @param direction The normalised direction vector
0049 ///
0050 /// @return The Jacobian d(phi, theta) / d(dir_x, dir_y, dir_z)
0051 ///
0052 inline ActsMatrix<2, 3> freeToSphericalDirectionJacobian(
0053     const Vector3& direction) {
0054   auto [cosPhi, sinPhi, cosTheta, sinTheta] =
0055       VectorHelpers::evaluateTrigonomics(direction);
0056   ActsScalar invSinTheta = 1. / sinTheta;
0057 
0058   // clang-format off
0059   ActsMatrix<2, 3> jacobian;
0060   jacobian <<
0061     -sinPhi * invSinTheta, cosPhi * invSinTheta, 0,
0062      cosPhi * cosTheta,    sinPhi * cosTheta,    -sinTheta;
0063   // clang-format on
0064 
0065   return jacobian;
0066 }
0067 
0068 }  // namespace Acts