Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:25

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2023-2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Project include(s).
0009 #include "tests/test_detectors.hpp"
0010 #include "traccc/definitions/common.hpp"
0011 #include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
0012 
0013 // VecMem include(s).
0014 #include <vecmem/memory/host_memory_resource.hpp>
0015 
0016 // GTest include(s).
0017 #include <gtest/gtest.h>
0018 
0019 using namespace traccc;
0020 
0021 TEST(spacepoint_formation, cpu) {
0022   // Memory resource used by the EDM.
0023   vecmem::host_memory_resource host_mr;
0024 
0025   // Use rectangle surfaces
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   // Plane alignment direction (aligned to x-axis)
0031   detray::detail::ray<traccc::default_algebra> traj{
0032       {0, 0, 0}, 0, {1, 0, 0}, -1};
0033   // Position of planes (in mm unit)
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   // Create telescope geometry
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   // Surface lookup
0050 
0051   // Prepare measurement collection
0052   edm::measurement_collection::host measurements{host_mr};
0053 
0054   // Add a measurement at the first plane
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   // Add a measurement at the last plane
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   // Run spacepoint formation
0077   host::silicon_pixel_spacepoint_formation_algorithm sp_formation(host_mr);
0078   auto spacepoints = sp_formation(host_det, vecmem::get_data(measurements));
0079 
0080   // Check the results
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 }