File indexing completed on 2026-10-17 08:32:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifdef DETRAY_LOG_LVL
0011 #undef DETRAY_LOG_LVL
0012 #endif
0013 #define DETRAY_LOG_LVL 1
0014
0015
0016 #include "detray/propagator/perigee_extrapolator.hpp"
0017
0018 #include "detray/definitions/units.hpp"
0019 #include "detray/navigation/caching_navigator.hpp"
0020 #include "detray/propagator/base_actor.hpp"
0021 #include "detray/propagator/line_stepper.hpp"
0022 #include "detray/propagator/propagator.hpp"
0023 #include "detray/propagator/rk_stepper.hpp"
0024 #include "detray/tracks/tracks.hpp"
0025
0026
0027 #include "detray/test/common/bfield.hpp"
0028 #include "detray/test/common/build_toy_detector.hpp"
0029 #include "detray/test/common/track_generators.hpp"
0030 #include "detray/test/framework/types.hpp"
0031
0032
0033 #include <vecmem/memory/host_memory_resource.hpp>
0034
0035
0036 #include <gtest/gtest.h>
0037
0038 using namespace detray;
0039
0040 using test_algebra = test::algebra;
0041 using scalar = test::scalar;
0042 using point3 = test::point3;
0043
0044 constexpr scalar tol{1.1e-3f};
0045
0046 namespace detray::test {
0047
0048 struct portal_aborter : public base_actor {
0049
0050
0051 template <typename propagator_state_t>
0052 DETRAY_HOST_DEVICE void operator()(propagator_state_t &prop_state) const {
0053 DETRAY_VERBOSE_HOST("Aborter: Check target surface");
0054
0055 auto &navigation = prop_state.navigation();
0056 if (navigation.is_on_portal()) {
0057 navigation.exit();
0058 prop_state.heartbeat(false);
0059 }
0060 }
0061 };
0062
0063 }
0064
0065
0066 GTEST_TEST(detray_propagator, perigee_extrapolator) {
0067 vecmem::host_memory_resource host_mr;
0068
0069 toy_det_config<scalar> toy_cfg{};
0070 toy_cfg.use_material_maps(false);
0071 const auto [d, names] = build_toy_detector<test_algebra>(host_mr, toy_cfg);
0072
0073 using detector_t = decltype(d);
0074 using stepper_t = line_stepper<test_algebra>;
0075 using actor_chain_t = actor_chain<test::portal_aborter>;
0076
0077 using propagator_t =
0078 propagator<stepper_t, caching_navigator<detector_t>, actor_chain_t>;
0079 using extrapolator_t = perigee_extrapolator<detector_t, stepper_t>;
0080
0081
0082 using generator_t =
0083 uniform_track_generator<free_track_parameters<test_algebra>>;
0084
0085
0086 generator_t::configuration trk_gen_cfg{};
0087 trk_gen_cfg.eta_range(-3.f, 3.f);
0088 trk_gen_cfg.phi_steps(50u).eta_steps(50u);
0089 trk_gen_cfg.p_tot(10.f * unit<scalar>::GeV);
0090
0091 propagation::config prop_cfg{};
0092
0093 propagator_t p{prop_cfg};
0094 const extrapolator_t pe{prop_cfg};
0095
0096
0097 for (auto track : generator_t{trk_gen_cfg}) {
0098
0099 propagator_t::state prop_state{track, d, prop_cfg.context};
0100 ASSERT_TRUE(p.propagate(prop_state));
0101 ASSERT_TRUE(prop_state.stepping().path_length() >= 25.f * unit<scalar>::mm);
0102 ASSERT_NEAR(vector::perp(prop_state.stepping()().pos()),
0103 25.f * unit<scalar>::mm, tol);
0104
0105
0106 extrapolator_t::state extrapolator_state =
0107 pe.create_state(prop_state.stepping()(), d);
0108
0109
0110 ASSERT_NEAR(vector::perp(extrapolator_state.stepping()().pos()),
0111 25.f * unit<scalar>::mm, tol);
0112
0113
0114 const auto bound_params = pe.extrapolate(extrapolator_state);
0115 ASSERT_TRUE(pe.finished(extrapolator_state));
0116
0117 EXPECT_TRUE(extrapolator_state.stepping().abs_path_length() >=
0118 25.f * unit<scalar>::mm);
0119
0120
0121 EXPECT_NEAR(vector::norm(extrapolator_state.stepping()().pos() -
0122 point3{0.f, 0.f, 0.f}),
0123 0.f, tol);
0124
0125 const scalar d0{bound_params[e_bound_loc0]};
0126 const scalar z0{bound_params[e_bound_loc1]};
0127
0128 EXPECT_NEAR(d0, 0.f, tol);
0129 EXPECT_NEAR(z0, 0.f, tol);
0130 }
0131 }