Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-05 08:55:24

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/SurfaceBinningMatcher.hpp"
0014 #include "Acts/Surfaces/DiscSurface.hpp"
0015 #include "Acts/Surfaces/RadialBounds.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018 
0019 #include <cmath>
0020 #include <memory>
0021 #include <numbers>
0022 #include <vector>
0023 
0024 #include <boost/format.hpp>
0025 
0026 using namespace Acts;
0027 
0028 namespace ActsTests {
0029 
0030 // Create a test context
0031 GeometryContext tgContext = GeometryContext();
0032 
0033 BOOST_AUTO_TEST_SUITE(GeometrySuite)
0034 
0035 BOOST_AUTO_TEST_CASE(PlaneSurfaceMatcher) {
0036   auto identity = Transform3::Identity();
0037 
0038   double rMin = 5.;
0039   double rMax = 10.;
0040   double rMinTol = 0.1;
0041   double rMaxTol = 0.5;
0042 
0043   double phiTol = 0.1;
0044 
0045   auto oneBounds =
0046       std::make_shared<RadialBounds>(rMin, rMax, std::numbers::pi / 16., 0.);
0047   auto oneSurface = Surface::makeShared<DiscSurface>(identity, oneBounds);
0048 
0049   auto otherBounds = std::make_shared<RadialBounds>(
0050       2 * rMax, 4 * rMax, std::numbers::pi / 16., std::numbers::pi / 2.);
0051   auto otherSurface = Surface::makeShared<DiscSurface>(identity, otherBounds);
0052 
0053   auto similarRbounds = std::make_shared<RadialBounds>(
0054       rMin - 0.5 * rMinTol, rMax + 0.5 * rMaxTol, std::numbers::pi / 1.,
0055       std::numbers::pi / 2.);
0056   auto similarRSurface =
0057       Surface::makeShared<DiscSurface>(identity, similarRbounds);
0058 
0059   auto similarPhiBounds = std::make_shared<RadialBounds>(
0060       0.25 * rMin, 0.5 * rMin, std::numbers::pi / 16., 0.);
0061   auto similarPhiSurface =
0062       Surface::makeShared<DiscSurface>(identity, similarPhiBounds);
0063 
0064   SurfaceBinningMatcher sbm;
0065   sbm.tolerances[toUnderlying(AxisDirection::AxisR)] = {rMinTol, rMaxTol};
0066   sbm.tolerances[toUnderlying(AxisDirection::AxisPhi)] = {phiTol, phiTol};
0067 
0068   // Always true
0069   for (AxisDirection ib : allAxisDirections()) {
0070     BOOST_CHECK(sbm(tgContext, ib, oneSurface.get(), oneSurface.get()));
0071   }
0072   // Not matching in R
0073   BOOST_CHECK(!sbm(tgContext, AxisDirection::AxisR, oneSurface.get(),
0074                    otherSurface.get()));
0075   // Not matching in phi
0076   BOOST_CHECK(!sbm(tgContext, AxisDirection::AxisPhi, oneSurface.get(),
0077                    otherSurface.get()));
0078 
0079   // Good enough matching in R
0080   BOOST_CHECK(sbm(tgContext, AxisDirection::AxisR, oneSurface.get(),
0081                   similarRSurface.get()));
0082   // Good enough matching in phi
0083   BOOST_CHECK(sbm(tgContext, AxisDirection::AxisPhi, oneSurface.get(),
0084                   similarPhiSurface.get()));
0085 }
0086 
0087 BOOST_AUTO_TEST_SUITE_END()
0088 
0089 }  // namespace ActsTests