Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-06 09:23:52

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/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/IndexGrid.hpp"
0014 
0015 #include <vector>
0016 
0017 using namespace Acts;
0018 
0019 GeometryContext tContext;
0020 Logging::Level logLevel = Logging::VERBOSE;
0021 
0022 namespace {
0023 
0024 /// Helper method to count how many bins are not empty
0025 template <typename indexed_surface_grid>
0026 std::size_t countBins(const indexed_surface_grid& isGrid) {
0027   std::size_t nonEmptyBins = 0u;
0028   for (std::size_t igb = 0u; igb < isGrid.grid.size(); ++igb) {
0029     const auto& gb = isGrid.grid.at(igb);
0030     if (!gb.empty()) {
0031       ++nonEmptyBins;
0032     }
0033   }
0034   return nonEmptyBins;
0035 }
0036 
0037 }  // namespace
0038 
0039 namespace ActsTests {
0040 
0041 BOOST_AUTO_TEST_SUITE(DetectorSuite)
0042 
0043 BOOST_AUTO_TEST_CASE(BinSequence) {
0044   ACTS_LOCAL_LOGGER(getDefaultLogger("*** Pre-Test", logLevel));
0045   ACTS_INFO("Testing bin sequence generators.");
0046 
0047   // Test standard bound local bin sequence
0048   auto seq48e0b10B = binSequence({4u, 8u}, 0u, 10u, AxisBoundaryType::Bound);
0049   std::vector<std::size_t> reference = {4u, 5u, 6u, 7u, 8u};
0050   BOOST_CHECK(seq48e0b10B == reference);
0051 
0052   // Test bound local bin sequence with expansion 1u
0053   auto seq48e1b10B = binSequence({4u, 8u}, 1u, 10u, AxisBoundaryType::Bound);
0054   reference = {3u, 4u, 5u, 6u, 7u, 8u, 9u};
0055   BOOST_CHECK(seq48e1b10B == reference);
0056 
0057   // Test bound local bin sequence with expansion 3u - clipped to max bin 10u
0058   auto seq48e3b10B = binSequence({4u, 8u}, 3u, 10u, AxisBoundaryType::Bound);
0059   reference = {1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u};
0060   BOOST_CHECK(seq48e3b10B == reference);
0061 
0062   // Test open bin sequence with overflow filling
0063   auto seq48e3b10O = binSequence({4u, 8u}, 3u, 10u, AxisBoundaryType::Open);
0064   reference = {1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u};
0065   BOOST_CHECK(seq48e3b10O == reference);
0066 
0067   // Test standard closed local bins
0068   auto seq48e0b10C = binSequence({4u, 8u}, 0u, 20u, AxisBoundaryType::Closed);
0069   reference = {4u, 5u, 6u, 7u, 8u};
0070   BOOST_CHECK(seq48e0b10C == reference);
0071 
0072   // Test closed local bins with expansion
0073   auto seq48e1b10C = binSequence({4u, 8u}, 1u, 20u, AxisBoundaryType::Closed);
0074   reference = {3u, 4u, 5u, 6u, 7u, 8u, 9u};
0075   BOOST_CHECK(seq48e1b10C == reference);
0076 
0077   // Test closed local bins with expansion over bin boundary
0078   auto seq1029e1b20C =
0079       binSequence({19u, 20u}, 1u, 20u, AxisBoundaryType::Closed);
0080   reference = {1u, 18u, 19u, 20u};
0081   BOOST_CHECK(seq1029e1b20C == reference);
0082 
0083   // Test closed local bins with bin boundary jump
0084   auto seq218e0b20C = binSequence({2u, 18u}, 0u, 20u, AxisBoundaryType::Closed);
0085   reference = {1u, 2u, 18u, 19u, 20u};
0086   BOOST_CHECK(seq218e0b20C == reference);
0087 
0088   // Test closed local bins with bin boundary jump with extension
0089   auto seq218e2b20C = binSequence({2u, 18u}, 2u, 20u, AxisBoundaryType::Closed);
0090   reference = {1u, 2u, 3u, 4u, 16u, 17u, 18u, 19u, 20u};
0091   BOOST_CHECK(seq218e2b20C == reference);
0092 }
0093 
0094 BOOST_AUTO_TEST_SUITE_END()
0095 
0096 }  // namespace ActsTests