File indexing completed on 2026-05-27 07:24:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/propagator/line_stepper.hpp"
0011
0012 #include "detray/definitions/units.hpp"
0013 #include "detray/tracks/tracks.hpp"
0014
0015
0016 #include "detray/test/framework/types.hpp"
0017
0018
0019 #include <gtest/gtest.h>
0020
0021 using namespace detray;
0022
0023 using test_algebra = test::algebra;
0024 using scalar = test::scalar;
0025 using vector3 = test::vector3;
0026 using point3 = test::point3;
0027 using transform3 = test::transform3;
0028
0029 namespace {
0030
0031 constexpr scalar tol{1e-3f};
0032 constexpr scalar step_size{1.f * unit<scalar>::mm};
0033 constexpr stepping::config step_cfg{};
0034
0035 }
0036
0037
0038 GTEST_TEST(detray_propagator, line_stepper) {
0039 using namespace step;
0040
0041
0042 using line_stepper_t = line_stepper<test_algebra>;
0043 using cline_stepper_t = line_stepper<test_algebra, constrained_step<scalar>>;
0044
0045 point3 pos{0.f, 0.f, 0.f};
0046 vector3 mom{1.f, 1.f, 0.f};
0047 free_track_parameters<test_algebra> track(pos, 0.f, mom, -1.f);
0048 free_track_parameters<test_algebra> c_track(pos, 0.f, mom, -1.f);
0049
0050 line_stepper_t l_stepper;
0051 cline_stepper_t cl_stepper;
0052
0053 line_stepper_t::state l_state{track};
0054 cline_stepper_t::state cl_state{c_track};
0055
0056
0057 cl_state.template set_constraint<constraint::e_accuracy>(10.f *
0058 unit<scalar>::mm);
0059 cl_state.template set_constraint<constraint::e_actor>(2.f * unit<scalar>::mm);
0060 cl_state.template set_constraint<constraint::e_aborter>(5.f *
0061 unit<scalar>::mm);
0062 cl_state.template set_constraint<constraint::e_user>(0.5f * unit<scalar>::mm);
0063 ASSERT_NEAR(cl_state.constraints().template size<>(), 0.5f * unit<scalar>::mm,
0064 tol);
0065
0066
0067 cl_state.template release_step<constraint::e_accuracy>();
0068 cl_state.template release_step<constraint::e_aborter>();
0069 cl_state.template release_step<constraint::e_user>();
0070 ASSERT_NEAR(cl_state.constraints().template size<>(), 2.f * unit<scalar>::mm,
0071 tol);
0072
0073 cl_state.template set_constraint<constraint::e_user>(0.5f * unit<scalar>::mm);
0074 ASSERT_NEAR(cl_state.constraints().template size<>(), 0.5f * unit<scalar>::mm,
0075 tol);
0076
0077
0078 ASSERT_TRUE(l_stepper.step(step_size, l_state, step_cfg));
0079
0080 ASSERT_TRUE(cl_stepper.step(step_size, cl_state, step_cfg));
0081 ASSERT_TRUE(cl_stepper.step(step_size, cl_state, step_cfg));
0082
0083 track = l_state();
0084 ASSERT_NEAR(track.pos()[0], constant<scalar>::inv_sqrt2, tol);
0085 ASSERT_NEAR(track.pos()[1], constant<scalar>::inv_sqrt2, tol);
0086 ASSERT_NEAR(track.pos()[2], 0.f, tol);
0087
0088 c_track = cl_state();
0089 ASSERT_NEAR(c_track.pos()[0], constant<scalar>::inv_sqrt2, tol);
0090 ASSERT_NEAR(c_track.pos()[1], constant<scalar>::inv_sqrt2, tol);
0091 ASSERT_NEAR(c_track.pos()[2], 0.f, tol);
0092
0093 ASSERT_TRUE(l_stepper.step(step_size, l_state, step_cfg));
0094
0095 track = l_state();
0096 ASSERT_NEAR(track.pos()[0], constant<scalar>::sqrt2, tol);
0097 ASSERT_NEAR(track.pos()[1], constant<scalar>::sqrt2, tol);
0098 ASSERT_NEAR(track.pos()[2], 0.f, tol);
0099 }