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 "traccc/definitions/common.hpp"
0010 #include "traccc/edm/measurement_collection.hpp"
0011 #include "traccc/edm/spacepoint_collection.hpp"
0012 #include "traccc/seeding/seeding_algorithm.hpp"
0013 #include "traccc/seeding/track_params_estimation.hpp"
0014 #include "traccc/utils/detray_conversion.hpp"
0015 
0016 // Detray include(s).
0017 #include <detray/tracks/helix.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 using namespace traccc;
0026 
0027 namespace {
0028 
0029 // Memory resource used by the EDM.
0030 vecmem::host_memory_resource host_mr;
0031 
0032 }  // namespace
0033 
0034 TEST(track_params_estimation, helix_negative_charge) {
0035   // Set B field
0036   const vector3 B{0.f * unit<scalar>::T, 0.f * unit<scalar>::T,
0037                   2.f * unit<scalar>::T};
0038 
0039   // Track property
0040   const scalar q{-1.f * unit<scalar>::e};
0041   const point3 pos{0.f, 0.f, 0.f};
0042   const scalar time{0.f};
0043   const vector3 mom{1.f * unit<scalar>::GeV, 0.f, 1.f * unit<scalar>::GeV};
0044 
0045   // Make a helix
0046   detray::detail::helix<traccc::default_algebra> hlx(
0047       pos, time, vector::normalize(mom), q / vector::norm(mom), B);
0048 
0049   // Make three spacepoints with the helix
0050   edm::measurement_collection::host measurements(host_mr);
0051   edm::spacepoint_collection::host spacepoints{host_mr};
0052   measurements.resize(3);
0053   spacepoints.reserve(3);
0054   spacepoints.push_back(
0055       {0, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0056        traccc::utils::to_float_array<traccc::default_algebra>(
0057            hlx(50 * unit<scalar>::mm)),
0058        0.f, 0.f});
0059   spacepoints.push_back(
0060       {1, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0061        traccc::utils::to_float_array<traccc::default_algebra>(
0062            hlx(100 * unit<scalar>::mm)),
0063        0.f, 0.f});
0064   spacepoints.push_back(
0065       {2, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0066        traccc::utils::to_float_array<traccc::default_algebra>(
0067            hlx(150 * unit<scalar>::mm)),
0068        0.f, 0.f});
0069 
0070   // Make a seed from the three spacepoints
0071   edm::seed_collection::host seeds{host_mr};
0072   seeds.push_back({0, 1, 2, 0.0f});
0073 
0074   // Run track parameter estimation
0075   traccc::track_params_estimation_config track_params_estimation_config;
0076   traccc::host::track_params_estimation tp(track_params_estimation_config,
0077                                            host_mr);
0078   auto bound_params =
0079       tp(vecmem::get_data(measurements), vecmem::get_data(spacepoints),
0080          vecmem::get_data(seeds), B);
0081 
0082   // Make sure that the reconstructed momentum is equal to the original
0083   // momentum
0084   ASSERT_EQ(bound_params.size(), 1u);
0085   ASSERT_NEAR(bound_params[0].p(q), vector::norm(mom), 2.f * 1e-4);
0086   ASSERT_TRUE(bound_params[0].qop() < 0.f);
0087 }
0088 
0089 TEST(track_params_estimation, helix_positive_charge) {
0090   // Set B field
0091   const vector3 B{0.f * unit<scalar>::T, 0.f * unit<scalar>::T,
0092                   2.f * unit<scalar>::T};
0093 
0094   // Track property
0095   const scalar q{1.f * unit<scalar>::e};
0096   const point3 pos{0.f, 0.f, 0.f};
0097   const scalar time{0.f};
0098   const vector3 mom{1.f * unit<scalar>::GeV, 0.f, 1.f * unit<scalar>::GeV};
0099 
0100   // Make a helix
0101   detray::detail::helix<traccc::default_algebra> hlx(
0102       pos, time, vector::normalize(mom), q / vector::norm(mom), B);
0103 
0104   // Make three spacepoints with the helix
0105   edm::measurement_collection::host measurements(host_mr);
0106   edm::spacepoint_collection::host spacepoints{host_mr};
0107   measurements.resize(3);
0108   spacepoints.reserve(3);
0109   spacepoints.push_back(
0110       {0, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0111        traccc::utils::to_float_array<traccc::default_algebra>(
0112            hlx(50 * unit<scalar>::mm)),
0113        0.f, 0.f});
0114   spacepoints.push_back(
0115       {1, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0116        traccc::utils::to_float_array<traccc::default_algebra>(
0117            hlx(100 * unit<scalar>::mm)),
0118        0.f, 0.f});
0119   spacepoints.push_back(
0120       {2, traccc::edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX,
0121        traccc::utils::to_float_array<traccc::default_algebra>(
0122            hlx(150 * unit<scalar>::mm)),
0123        0.f, 0.f});
0124 
0125   // Make a seed from the three spacepoints
0126   edm::seed_collection::host seeds{host_mr};
0127   seeds.push_back({0, 1, 2, 0.0f});
0128 
0129   // Run track parameter estimation
0130   traccc::track_params_estimation_config track_params_estimation_config;
0131   traccc::host::track_params_estimation tp(track_params_estimation_config,
0132                                            host_mr);
0133   auto bound_params =
0134       tp(vecmem::get_data(measurements), vecmem::get_data(spacepoints),
0135          vecmem::get_data(seeds), B);
0136 
0137   // Make sure that the reconstructed momentum is equal to the original
0138   // momentum
0139   ASSERT_EQ(bound_params.size(), 1u);
0140   ASSERT_NEAR(bound_params[0].p(q), vector::norm(mom), 2.f * 1e-4);
0141   ASSERT_TRUE(bound_params[0].qop() > 0.f);
0142 }