File indexing completed on 2026-05-27 07:24:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/utils/curvilinear_frame.hpp"
0011
0012
0013 #include "detray/test/framework/types.hpp"
0014
0015
0016 #include <gtest/gtest.h>
0017
0018 using namespace detray;
0019
0020 using test_algebra = test::algebra;
0021 using transform3 = test::transform3;
0022 using vector3 = typename transform3::vector3;
0023 using point3 = test::point3;
0024 using scalar = test::scalar;
0025
0026 GTEST_TEST(detray_utils, curvilinear_frame) {
0027 constexpr const scalar tolerance = 1e-5f;
0028
0029 point3 pos = {4.f, 10.f, 2.f};
0030 scalar time = 0.1f;
0031 vector3 mom = {10.f, 20.f, 30.f};
0032 constexpr scalar charge = -1.f;
0033
0034 free_track_parameters<test_algebra> free_params(pos, time, mom, charge);
0035
0036 curvilinear_frame<test_algebra> cf(free_params);
0037
0038 const auto bound_vec = cf.m_bound_vec;
0039
0040 const scalar phi = vector::phi(mom);
0041 const scalar theta = vector::theta(mom);
0042
0043 EXPECT_NEAR(getter::element(bound_vec.bound_local(), e_bound_loc0), 0.f,
0044 tolerance);
0045 EXPECT_NEAR(getter::element(bound_vec.bound_local(), e_bound_loc1), 0.f,
0046 tolerance);
0047 EXPECT_NEAR(bound_vec.phi(), phi, tolerance);
0048 EXPECT_NEAR(bound_vec.theta(), theta, tolerance);
0049 EXPECT_NEAR(bound_vec.qop(), charge / vector::norm(mom), tolerance);
0050
0051 const vector3 unit_p = vector::normalize(mom);
0052 const vector3 trf_x = cf.m_trf.x();
0053 const vector3 trf_y = cf.m_trf.y();
0054 const vector3 trf_z = cf.m_trf.z();
0055 const vector3 trf_t = cf.m_trf.translation();
0056
0057
0058 EXPECT_NEAR(trf_x[2], 0.f, tolerance);
0059
0060
0061 EXPECT_NEAR(unit_p[0], trf_z[0], tolerance);
0062 EXPECT_NEAR(unit_p[1], trf_z[1], tolerance);
0063 EXPECT_NEAR(unit_p[2], trf_z[2], tolerance);
0064
0065
0066 EXPECT_NEAR(pos[0], trf_t[0], tolerance);
0067 EXPECT_NEAR(pos[1], trf_t[1], tolerance);
0068 EXPECT_NEAR(pos[2], trf_t[2], tolerance);
0069
0070
0071 const auto jac = cf.bound_to_free_jacobian();
0072 EXPECT_NEAR(getter::element(jac, 0u, 0u), trf_x[0u], tolerance);
0073 EXPECT_NEAR(getter::element(jac, 1u, 0u), trf_x[1u], tolerance);
0074 EXPECT_NEAR(getter::element(jac, 2u, 0u), trf_x[2u], tolerance);
0075 EXPECT_NEAR(getter::element(jac, 0u, 1u), trf_y[0u], tolerance);
0076 EXPECT_NEAR(getter::element(jac, 1u, 1u), trf_y[1u], tolerance);
0077 EXPECT_NEAR(getter::element(jac, 2u, 1u), trf_y[2u], tolerance);
0078
0079 EXPECT_NEAR(getter::element(jac, e_free_dir0, e_bound_phi),
0080 -math::sin(phi) * math::sin(theta), tolerance);
0081 EXPECT_NEAR(getter::element(jac, e_free_dir0, e_bound_theta),
0082 math::cos(phi) * math::cos(theta), tolerance);
0083 EXPECT_NEAR(getter::element(jac, e_free_dir1, e_bound_phi),
0084 math::cos(phi) * math::sin(theta), tolerance);
0085 EXPECT_NEAR(getter::element(jac, e_free_dir1, e_bound_theta),
0086 math::sin(phi) * math::cos(theta), tolerance);
0087 EXPECT_NEAR(getter::element(jac, e_free_dir2, e_bound_phi), 0, tolerance);
0088 EXPECT_NEAR(getter::element(jac, e_free_dir2, e_bound_theta),
0089 -math::sin(theta), tolerance);
0090 }