File indexing completed on 2026-07-26 08:22:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "tests/test_detectors.hpp"
0010 #include "traccc/definitions/common.hpp"
0011 #include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
0012
0013
0014 #include <vecmem/memory/host_memory_resource.hpp>
0015
0016
0017 #include <gtest/gtest.h>
0018
0019 using namespace traccc;
0020
0021 TEST(spacepoint_formation, cpu) {
0022
0023 vecmem::host_memory_resource host_mr;
0024
0025
0026 detray::mask<detray::rectangle2D, traccc::default_algebra> rectangle{
0027 0u, 10000.f * traccc::unit<scalar>::mm,
0028 10000.f * traccc::unit<scalar>::mm};
0029
0030
0031 detray::detail::ray<traccc::default_algebra> traj{
0032 {0, 0, 0}, 0, {1, 0, 0}, -1};
0033
0034 std::vector<scalar> plane_positions = {20.f, 40.f, 60.f, 80.f, 100.f,
0035 120.f, 140.f, 160.f, 180.f};
0036
0037 detray::tel_det_config tel_cfg{rectangle};
0038 tel_cfg.positions(plane_positions);
0039 tel_cfg.pilot_track(traj);
0040
0041
0042 auto [det, name_map] = build_telescope_detector(host_mr, tel_cfg);
0043
0044 auto surfaces = det.surfaces();
0045
0046 traccc::host_detector host_det;
0047 host_det.set<traccc::telescope_detector>(std::move(det));
0048
0049
0050
0051
0052 edm::measurement_collection::host measurements{host_mr};
0053
0054
0055 measurements.push_back({{7.f, 2.f},
0056 {0.f, 0.f},
0057 2,
0058 0.f,
0059 0.f,
0060 0u,
0061 surfaces[0].identifier(),
0062 {1u, 1u},
0063 0u});
0064
0065
0066 measurements.push_back({{10.f, 15.f},
0067 {0.f, 0.f},
0068 2u,
0069 0.f,
0070 0.f,
0071 0u,
0072 surfaces[8u].identifier(),
0073 {1u, 1u},
0074 1u});
0075
0076
0077 host::silicon_pixel_spacepoint_formation_algorithm sp_formation(host_mr);
0078 auto spacepoints = sp_formation(host_det, vecmem::get_data(measurements));
0079
0080
0081 EXPECT_EQ(spacepoints.size(), 2u);
0082 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[0].x()), 20.f);
0083 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[0].y()), 7.f);
0084 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[0].z()), 2.f);
0085 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[1].x()), 180.f);
0086 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[1].y()), 10.f);
0087 EXPECT_FLOAT_EQ(static_cast<float>(spacepoints[1].z()), 15.f);
0088 }