Back to home page

EIC code displayed by LXR

 
 

    


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

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/Surfaces/PointBounds.hpp"
0013 #include "Acts/Surfaces/SurfaceBounds.hpp"
0014 
0015 #include <stdexcept>
0016 #include <vector>
0017 
0018 using namespace Acts;
0019 
0020 namespace ActsTests {
0021 
0022 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0023 
0024 /// Unit test for creating compliant/non-compliant PointBounds object
0025 BOOST_AUTO_TEST_CASE(PointBoundsConstruction) {
0026   double maxDistance = 3.;
0027   PointBounds pointBounds(maxDistance);
0028   BOOST_CHECK_EQUAL(pointBounds.type(), SurfaceBounds::ePoint);
0029 
0030   // Copy constructor
0031   PointBounds copied(pointBounds);
0032   BOOST_CHECK_EQUAL(copied.type(), SurfaceBounds::ePoint);
0033   BOOST_CHECK_EQUAL(copied.get(PointBounds::eR), maxDistance);
0034 }
0035 
0036 /// Unit test for PointBounds properties
0037 BOOST_AUTO_TEST_CASE(PointBoundsProperties) {
0038   double maxDistance = 3.;
0039   PointBounds pointBounds(maxDistance);
0040 
0041   BOOST_CHECK_EQUAL(pointBounds.get(PointBounds::eR), maxDistance);
0042   BOOST_CHECK(pointBounds.isCartesian());
0043 
0044   // values array
0045   std::vector<double> values = pointBounds.values();
0046   BOOST_CHECK_EQUAL(values.size(), 1u);
0047   BOOST_CHECK_EQUAL(values[0], maxDistance);
0048 
0049   // center is the origin
0050   BOOST_CHECK_EQUAL(pointBounds.center(), Vector2::Zero());
0051 }
0052 
0053 /// Unit test for the inside() disc semantics (Cartesian x^2 + y^2 <= R^2)
0054 BOOST_AUTO_TEST_CASE(PointBoundsInside) {
0055   double maxDistance = 3.;
0056   PointBounds pointBounds(maxDistance);
0057 
0058   BOOST_CHECK(pointBounds.inside(Vector2(0., 0.)));
0059   BOOST_CHECK(pointBounds.inside(Vector2(2., 2.)));      // r ~ 2.83 < 3
0060   BOOST_CHECK(pointBounds.inside(Vector2(3., 0.)));      // on boundary
0061   BOOST_CHECK(pointBounds.inside(Vector2(0., -3.)));     // on boundary
0062   BOOST_CHECK(!pointBounds.inside(Vector2(3., 3.)));     // r ~ 4.24 > 3
0063   BOOST_CHECK(!pointBounds.inside(Vector2(-2.5, -2.)));  // r ~ 3.2 > 3
0064 }
0065 
0066 /// Unit test for closestPoint (radial projection onto the boundary circle)
0067 BOOST_AUTO_TEST_CASE(PointBoundsClosestPoint) {
0068   double maxDistance = 3.;
0069   PointBounds pointBounds(maxDistance);
0070 
0071   Vector2 closest =
0072       pointBounds.closestPoint(Vector2(6., 0.), SquareMatrix2::Identity());
0073   BOOST_CHECK_CLOSE(closest.x(), 3., 1e-9);
0074   BOOST_CHECK_SMALL(closest.y(), 1e-9);
0075 
0076   // at the origin any boundary point is valid; norm must equal R
0077   Vector2 fromOrigin =
0078       pointBounds.closestPoint(Vector2(0., 0.), SquareMatrix2::Identity());
0079   BOOST_CHECK_CLOSE(fromOrigin.norm(), 3., 1e-9);
0080 }
0081 
0082 /// Negative radius must throw
0083 BOOST_AUTO_TEST_CASE(PointBoundsException) {
0084   BOOST_CHECK_THROW(PointBounds(-1.), std::invalid_argument);
0085 }
0086 
0087 BOOST_AUTO_TEST_SUITE_END()
0088 
0089 }  // namespace ActsTests