File indexing completed on 2026-05-27 07:24:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
0018 #include "detray/test/framework/types.hpp"
0019
0020
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
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
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
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
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);
0065 ASSERT_NEAR(bound_vec.theta(), 0.64052231f, isclose);
0066 ASSERT_NEAR(bound_vec.qop(), -1.f / 3.7416574f, isclose);
0067 ASSERT_NEAR(bound_vec.time(), 0.1f, isclose);
0068
0069
0070 for (unsigned int i = 0u; i < 8u; i++) {
0071 ASSERT_NEAR(free_params[i], free_params2[i], isclose);
0072 }
0073
0074
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 }