Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-31 08:18:41

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Seeding/detail/SpacePointGridPhiBinning.hpp"
0013 
0014 #include <stdexcept>
0015 
0016 using namespace Acts::UnitLiterals;
0017 
0018 namespace Acts::Test {
0019 
0020 namespace {
0021 
0022 // A physically sensible baseline: the minimum-pT helix radius is well above
0023 // rMax / 2, so the phi bin count is driven by the helix deflection.
0024 detail::SpacePointGridPhiBinningConfig makeConfig() {
0025   detail::SpacePointGridPhiBinningConfig config;
0026   config.minPt = 500_MeV;
0027   config.bFieldInZ = 2_T;
0028   config.rMax = 200_mm;
0029   config.deltaRMax = 100_mm;
0030   config.impactMax = 10_mm;
0031   config.phiBinDeflectionCoverage = 1;
0032   config.maxPhiBins = 10000;
0033   return config;
0034 }
0035 
0036 }  // namespace
0037 
0038 BOOST_AUTO_TEST_SUITE(SpacePointGridPhiBinningTests)
0039 
0040 BOOST_AUTO_TEST_CASE(ZeroFieldUsesMaxPhiBins) {
0041   auto config = makeConfig();
0042   config.bFieldInZ = 0;
0043   config.maxPhiBins = 42;
0044   BOOST_CHECK_EQUAL(detail::computeSpacePointGridPhiBins(config), 42);
0045 }
0046 
0047 BOOST_AUTO_TEST_CASE(BaselineGivesFinitePositiveBinCount) {
0048   const auto config = makeConfig();
0049   const int phiBins = detail::computeSpacePointGridPhiBins(config);
0050   BOOST_CHECK_GT(phiBins, 1);
0051   BOOST_CHECK_LE(phiBins, config.maxPhiBins);
0052 }
0053 
0054 BOOST_AUTO_TEST_CASE(MaxPhiBinsCapsResult) {
0055   auto config = makeConfig();
0056   const int uncapped = detail::computeSpacePointGridPhiBins(config);
0057   config.maxPhiBins = uncapped - 1;
0058   BOOST_CHECK_EQUAL(detail::computeSpacePointGridPhiBins(config),
0059                     config.maxPhiBins);
0060 }
0061 
0062 BOOST_AUTO_TEST_CASE(DeflectionCoverageIncreasesBinCount) {
0063   auto config = makeConfig();
0064   const int singleCoverage = detail::computeSpacePointGridPhiBins(config);
0065   config.phiBinDeflectionCoverage = 2;
0066   const int doubleCoverage = detail::computeSpacePointGridPhiBins(config);
0067   BOOST_CHECK_GT(doubleCoverage, singleCoverage);
0068 }
0069 
0070 // Regression for the robustness fix of PR 5696: an impact parameter at or
0071 // beyond rMax - deltaRMax must fall back to a coarse binning instead of
0072 // producing a NaN and an invalid (zero) bin count.
0073 BOOST_AUTO_TEST_CASE(LargeImpactParameterStaysFinite) {
0074   auto config = makeConfig();
0075   config.impactMax = config.rMax;
0076   const int phiBins = detail::computeSpacePointGridPhiBins(config);
0077   BOOST_CHECK_GT(phiBins, 0);
0078   BOOST_CHECK_LE(phiBins, config.maxPhiBins);
0079 }
0080 
0081 BOOST_AUTO_TEST_CASE(TooSmallHelixRadiusThrows) {
0082   auto config = makeConfig();
0083   // minHelixRadius = minPt / bFieldInZ falls below rMax / 2
0084   config.minPt = 10_MeV;
0085   BOOST_CHECK_THROW(detail::computeSpacePointGridPhiBins(config),
0086                     std::domain_error);
0087 }
0088 
0089 BOOST_AUTO_TEST_SUITE_END()
0090 
0091 }  // namespace Acts::Test