Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:23

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 // Project include(s).
0010 #include "detray/propagator/detail/jacobian_cartesian.hpp"
0011 
0012 #include "detray/geometry/mask.hpp"
0013 #include "detray/geometry/shapes/rectangle2D.hpp"
0014 #include "detray/propagator/detail/jacobian_engine.hpp"
0015 #include "detray/tracks/tracks.hpp"
0016 
0017 // Detray test include(s)
0018 #include "detray/test/framework/types.hpp"
0019 
0020 // GTest include(s).
0021 #include <gtest/gtest.h>
0022 
0023 using namespace detray;
0024 
0025 using test_algebra = test::algebra;
0026 using scalar = test::scalar;
0027 using point3 = test::point3;
0028 using vector3 = test::vector3;
0029 using transform3 = test::transform3;
0030 
0031 const scalar isclose{1e-5f};
0032 
0033 // This test cartesian2D coordinate
0034 GTEST_TEST(detray_propagator, jacobian_cartesian2D) {
0035   using jac_engine = detail::jacobian_engine<test_algebra>;
0036   using frame_type = cartesian2D<test_algebra>;
0037 
0038   // Preparation work
0039   const vector3 z = {0.f, 0.f, 1.f};
0040   const vector3 x = {1.f, 0.f, 0.f};
0041   const point3 t = {2.f, 3.f, 4.f};
0042   const transform3 trf(t, z, x);
0043   const point3 global1 = {4.f, 7.f, 4.f};
0044   const vector3 mom = {1.f, 2.f, 3.f};
0045   const scalar time{0.1f};
0046   const scalar charge{-1.f};
0047 
0048   const scalar h{2.f};
0049   mask<rectangle2D, test_algebra> rect{0u, h, h};
0050 
0051   // Free track parameter
0052   const free_track_parameters<test_algebra> free_params(global1, time, mom,
0053                                                         charge);
0054 
0055   const auto bound_vec =
0056       detail::free_to_bound_vector<cartesian2D<test_algebra>>(trf, free_params);
0057   const auto free_params2 = detail::bound_to_free_vector(trf, rect, bound_vec);
0058 
0059   // Check if the bound vector is correct
0060   ASSERT_NEAR(getter::element(bound_vec.bound_local(), e_bound_loc0), 2.f,
0061               isclose);
0062   ASSERT_NEAR(getter::element(bound_vec.bound_local(), e_bound_loc1), 4.f,
0063               isclose);
0064   ASSERT_NEAR(bound_vec.phi(), 1.1071487f, isclose);     // atan(2)
0065   ASSERT_NEAR(bound_vec.theta(), 0.64052231f, isclose);  // atan(sqrt(5)/3)
0066   ASSERT_NEAR(bound_vec.qop(), -1.f / 3.7416574f, isclose);
0067   ASSERT_NEAR(bound_vec.time(), 0.1f, isclose);
0068 
0069   // Check if the same free vector is obtained
0070   for (unsigned int i = 0u; i < 8u; i++) {
0071     ASSERT_NEAR(free_params[i], free_params2[i], isclose);
0072   }
0073 
0074   // Test Jacobian transformation
0075   const bound_matrix<test_algebra> J =
0076       jac_engine::free_to_bound_jacobian<frame_type>(trf, free_params) *
0077       jac_engine::bound_to_free_jacobian<frame_type>(trf, rect, bound_vec);
0078 
0079   for (unsigned int i = 0u; i < 6u; i++) {
0080     for (unsigned int j = 0u; j < 6u; j++) {
0081       if (i == j) {
0082         EXPECT_NEAR(getter::element(J, i, j), 1.f, isclose);
0083       } else {
0084         EXPECT_NEAR(getter::element(J, i, j), 0.f, isclose);
0085       }
0086     }
0087   }
0088 }