File indexing completed on 2026-05-27 07:24:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "detray/definitions/units.hpp"
0011
0012
0013 #include "detray/test/common/build_toy_detector.hpp"
0014 #include "detray/test/cpu/detector_consistency.hpp"
0015 #include "detray/test/cpu/detector_scan.hpp"
0016 #include "detray/test/cpu/material_scan.hpp"
0017 #include "detray/test/cpu/material_validation.hpp"
0018 #include "detray/test/cpu/navigation_validation.hpp"
0019 #include "detray/test/framework/register_checks.hpp"
0020 #include "detray/test/framework/types.hpp"
0021 #include "detray/test/framework/whiteboard.hpp"
0022
0023
0024 #include <vecmem/memory/host_memory_resource.hpp>
0025
0026
0027 #include <gtest/gtest.h>
0028
0029 int main(int argc, char **argv) {
0030 using namespace detray;
0031
0032
0033 ::testing::InitGoogleTest(&argc, argv);
0034
0035 using toy_detector_t = detector<test::toy_metadata>;
0036 using test_algebra = toy_detector_t::algebra_type;
0037 using scalar = dscalar<test_algebra>;
0038
0039
0040 const float min_stepsize{stepping::config{}.min_stepsize};
0041
0042
0043
0044
0045 toy_det_config<scalar> toy_cfg{};
0046 toy_cfg.n_brl_layers(4u).n_edc_layers(7u);
0047 toy_cfg.use_material_maps(true);
0048
0049 std::clog << toy_cfg << std::endl;
0050
0051
0052 vecmem::host_memory_resource host_mr;
0053 auto [toy_det, toy_names] =
0054 build_toy_detector<test_algebra>(host_mr, toy_cfg);
0055
0056 auto white_board = std::make_shared<test::whiteboard>();
0057 toy_detector_t::geometry_context ctx{};
0058
0059
0060 test::consistency_check<toy_detector_t>::config cfg_cons{};
0061 test::register_checks<test::consistency_check>(
0062 toy_det, toy_names, cfg_cons.name("toy_detector_consistency"), ctx);
0063
0064
0065 test::ray_scan<toy_detector_t>::config cfg_ray_scan{};
0066 cfg_ray_scan.name("toy_detector_ray_scan");
0067 cfg_ray_scan.overlaps_tol(min_stepsize);
0068 cfg_ray_scan.track_generator().n_tracks(10000u);
0069
0070 test::register_checks<test::ray_scan>(toy_det, toy_names, cfg_ray_scan, ctx,
0071 white_board);
0072
0073
0074 test::straight_line_navigation<toy_detector_t>::config cfg_str_nav{};
0075 cfg_str_nav.name("toy_detector_straight_line_navigation");
0076 cfg_str_nav.n_tracks(cfg_ray_scan.track_generator().n_tracks());
0077 cfg_str_nav.propagation().stepping.min_stepsize = min_stepsize;
0078 cfg_str_nav.propagation().navigation.estimate_scattering_noise = false;
0079 cfg_str_nav.propagation().navigation.search_window = {3u, 3u};
0080 cfg_str_nav.propagation().navigation.intersection.min_mask_tolerance =
0081 static_cast<float>(cfg_ray_scan.mask_tolerance());
0082 cfg_str_nav.propagation().navigation.intersection.max_mask_tolerance =
0083 static_cast<float>(cfg_ray_scan.mask_tolerance());
0084
0085 test::register_checks<test::straight_line_navigation>(
0086 toy_det, toy_names, cfg_str_nav, ctx, white_board);
0087
0088
0089 test::helix_scan<toy_detector_t>::config cfg_hel_scan{};
0090 cfg_hel_scan.name("toy_detector_helix_scan");
0091
0092 cfg_hel_scan.mask_tolerance(detray::detail::invalid_value<scalar>());
0093 cfg_hel_scan.track_generator().n_tracks(10000u);
0094 cfg_hel_scan.overlaps_tol(min_stepsize);
0095 cfg_hel_scan.track_generator().randomize_charge(true);
0096 cfg_hel_scan.track_generator().eta_range(-4.f, 4.f);
0097 cfg_hel_scan.track_generator().p_T(1.f * unit<scalar>::GeV);
0098
0099 test::register_checks<test::helix_scan>(toy_det, toy_names, cfg_hel_scan, ctx,
0100 white_board);
0101
0102
0103 test::helix_navigation<toy_detector_t>::config cfg_hel_nav{};
0104 cfg_hel_nav.name("toy_detector_helix_navigation");
0105 cfg_hel_nav.n_tracks(cfg_hel_scan.track_generator().n_tracks());
0106 cfg_hel_nav.propagation().stepping.min_stepsize = min_stepsize;
0107 cfg_hel_nav.propagation().navigation.estimate_scattering_noise = false;
0108 cfg_hel_nav.propagation().navigation.search_window = {3u, 3u};
0109
0110 test::register_checks<test::helix_navigation>(toy_det, toy_names, cfg_hel_nav,
0111 ctx, white_board);
0112
0113
0114 test::material_scan<toy_detector_t>::config mat_scan_cfg{};
0115 mat_scan_cfg.name("toy_detector_material_scan");
0116 mat_scan_cfg.track_generator().uniform_eta(true).eta_range(-4.f, 4.f);
0117 mat_scan_cfg.track_generator().phi_steps(100).eta_steps(100);
0118 mat_scan_cfg.overlaps_tol(min_stepsize);
0119
0120
0121 test::register_checks<test::material_scan>(toy_det, toy_names, mat_scan_cfg,
0122 ctx, white_board);
0123
0124
0125 test::material_validation<toy_detector_t>::config mat_val_cfg{};
0126 mat_val_cfg.name("toy_detector_material_validaiton");
0127
0128 if constexpr (std::is_same_v<scalar, float>) {
0129 mat_val_cfg.relative_error(1.e-4f);
0130 }
0131 mat_val_cfg.propagation() = cfg_str_nav.propagation();
0132 mat_val_cfg.propagation().stepping.min_stepsize = min_stepsize;
0133
0134
0135 test::register_checks<test::material_validation>(
0136 toy_det, toy_names, mat_val_cfg, ctx, white_board);
0137
0138
0139 toy_cfg.use_material_maps(false);
0140
0141 std::clog << toy_cfg << std::endl;
0142
0143 auto [toy_det_hom_mat, toy_names_hom_mat] =
0144 build_toy_detector<test_algebra>(host_mr, toy_cfg);
0145 toy_names_hom_mat.set_detector_name(toy_names_hom_mat.get_detector_name() +
0146 "_hom_material");
0147
0148
0149 test::register_checks<test::consistency_check>(
0150 toy_det_hom_mat, toy_names_hom_mat,
0151 cfg_cons.name("toy_detector_consistency_hom_mat"), ctx);
0152
0153
0154 mat_scan_cfg.name("toy_detector_hom_material_scan");
0155 test::register_checks<test::material_scan>(toy_det_hom_mat, toy_names_hom_mat,
0156 mat_scan_cfg, ctx, white_board);
0157
0158
0159 mat_val_cfg.name("toy_detector_hom_material_validaiton");
0160 test::register_checks<test::material_validation>(
0161 toy_det_hom_mat, toy_names_hom_mat, mat_val_cfg, ctx, white_board);
0162
0163
0164 return RUN_ALL_TESTS();
0165 }