Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-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 "traccc/clusterization/clusterization_algorithm.hpp"
0010 #include "traccc/geometry/detector.hpp"
0011 #include "traccc/geometry/detector_design_description.hpp"
0012 #include "traccc/io/read_cells.hpp"
0013 #include "traccc/io/read_detector.hpp"
0014 #include "traccc/io/read_detector_description.hpp"
0015 #include "traccc/io/read_spacepoints.hpp"
0016 #include "traccc/performance/details/is_same_object.hpp"
0017 #include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
0018 
0019 // VecMem include(s).
0020 #include <vecmem/memory/host_memory_resource.hpp>
0021 
0022 // GTest include(s).
0023 #include <gtest/gtest.h>
0024 
0025 class SurfaceBinningTests
0026     : public ::testing::TestWithParam<
0027           std::tuple<std::string, std::string, std::string, unsigned int>> {};
0028 
0029 // This defines the local frame test suite
0030 TEST_P(SurfaceBinningTests, Run) {
0031   std::string detector_file = std::get<0>(GetParam());
0032   std::string digi_config_file = std::get<1>(GetParam());
0033   std::string det_cond_file = std::get<1>(GetParam());
0034   std::string data_dir = std::get<2>(GetParam());
0035   unsigned int event = std::get<3>(GetParam());
0036 
0037   // Memory resource used by the EDM.
0038   vecmem::host_memory_resource host_mr;
0039 
0040   // Read the detector description.
0041   traccc::detector_design_description::host det_desc{host_mr};
0042   traccc::detector_conditions_description::host det_cond{host_mr};
0043   traccc::io::read_detector_description(det_desc, det_cond, detector_file,
0044                                         digi_config_file, det_cond_file,
0045                                         traccc::json);
0046   const traccc::detector_design_description::data det_desc_data =
0047       vecmem::get_data(det_desc);
0048   const traccc::detector_conditions_description::data det_cond_data =
0049       vecmem::get_data(det_cond);
0050 
0051   // Read the detector
0052   traccc::host_detector detector;
0053   traccc::io::read_detector(detector, host_mr, detector_file);
0054 
0055   // Algorithms
0056   traccc::host::clusterization_algorithm ca(host_mr);
0057   traccc::host::silicon_pixel_spacepoint_formation_algorithm sf(host_mr);
0058 
0059   // Read the cells from the relevant event file
0060   traccc::edm::silicon_cell_collection::host cells_truth{host_mr};
0061   traccc::io::read_cells(cells_truth, event, data_dir,
0062                          traccc::getDummyLogger().clone(), &det_cond);
0063 
0064   // Get Reconstructed Spacepoints
0065   auto measurements_recon =
0066       ca(vecmem::get_data(cells_truth), det_desc_data, det_cond_data);
0067   auto spacepoints_recon = sf(detector, vecmem::get_data(measurements_recon));
0068 
0069   // Read the hits from the relevant event file
0070   traccc::edm::spacepoint_collection::host spacepoints_truth{host_mr};
0071   traccc::edm::measurement_collection::host measurements_truth{host_mr};
0072   traccc::io::read_spacepoints(spacepoints_truth, measurements_truth, event,
0073                                data_dir, &detector);
0074 
0075   // Check the size of spacepoints
0076   EXPECT_TRUE(spacepoints_recon.size() > 0);
0077 
0078   for (traccc::edm::spacepoint_collection::host::size_type i = 0u;
0079        i < spacepoints_recon.size(); ++i) {
0080     const auto sp_recon = spacepoints_recon.at(i);
0081 
0082     bool found_match = false;
0083 
0084     // 20% resolution (Should be improved)
0085     auto iso = traccc::details::is_same_object(sp_recon, 0.2f);
0086 
0087     for (traccc::edm::spacepoint_collection::host::size_type j = 0u;
0088          j < spacepoints_truth.size(); ++j) {
0089       const auto sp_truth = spacepoints_truth.at(j);
0090 
0091       // Do not include the comparison of the measurement of spacepoint
0092       found_match = iso(sp_truth);
0093 
0094       if (found_match) {
0095         break;
0096       }
0097     }
0098 
0099     EXPECT_EQ(found_match, true);
0100   }
0101 }
0102 
0103 INSTANTIATE_TEST_SUITE_P(
0104     SurfaceBinningValidation, SurfaceBinningTests,
0105     ::testing::Values(
0106         std::make_tuple("geometries/odd/odd-detray_geometry_detray.json",
0107                         "geometries/odd/odd-digi-geometric-config.json",
0108                         "odd/geant4_1muon_100GeV", 0),
0109         /* The commented event files does not pass the test
0110                 std::make_tuple("geometries/odd/odd-detray_geometry_detray.json",
0111                                 "geometries/odd/odd-digi-geometric-config.json",
0112                                 "geometries/odd/odd-digi-geometric-config.json",
0113                                 "odd/geant4_1muon_100GeV", 1),
0114                 std::make_tuple("geometries/odd/odd-detray_geometry_detray.json",
0115                                 "geometries/odd/odd-digi-geometric-config.json",
0116                                 "geometries/odd/odd-digi-geometric-config.json",
0117                                 "odd/geant4_1muon_100GeV", 2),
0118         */
0119         std::make_tuple("geometries/odd/odd-detray_geometry_detray.json",
0120                         "geometries/odd/odd-digi-geometric-config.json",
0121                         "odd/geant4_1muon_100GeV", 3),
0122         std::make_tuple("geometries/odd/odd-detray_geometry_detray.json",
0123                         "geometries/odd/odd-digi-geometric-config.json",
0124                         "odd/geant4_1muon_100GeV", 4)));