Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:56

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/CylinderBounds.hpp"
0013 #include "Acts/Surfaces/RadialBounds.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0016 #include "Acts/Utilities/BinAdjustment.hpp"
0017 #include "Acts/Utilities/BinUtility.hpp"
0018 #include "Acts/Utilities/BinningType.hpp"
0019 
0020 #include <cmath>
0021 #include <memory>
0022 #include <numbers>
0023 #include <vector>
0024 
0025 namespace Acts::Test {
0026 
0027 // Test Radial
0028 BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) {
0029   RadialBounds bound(50, 75, std::numbers::pi, 0);
0030   BinUtility bu;
0031   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisR);
0032   bu += BinUtility(1, 0, 1, Acts::closed, Acts::AxisDirection::AxisPhi);
0033 
0034   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0035 
0036   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 50);
0037   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 75);
0038   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -std::numbers::pi_v<float>);
0039   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, std::numbers::pi_v<float>);
0040 }
0041 
0042 // Test Cylinder
0043 BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) {
0044   CylinderBounds bound(25, 50, std::numbers::pi / 4, 0);
0045   BinUtility bu;
0046   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisPhi);
0047   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisZ);
0048 
0049   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0050 
0051   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min,
0052                     -static_cast<float>(std::numbers::pi / 4.));
0053   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max,
0054                     static_cast<float>(std::numbers::pi / 4.));
0055   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -50);
0056   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 50);
0057 }
0058 
0059 // Test Rectangule
0060 BOOST_AUTO_TEST_CASE(BinAdjustment_Rectangle) {
0061   RectangleBounds bound(20, 30);
0062   BinUtility bu;
0063   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisX);
0064   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisY);
0065 
0066   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0067 
0068   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -20);
0069   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 20);
0070   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
0071   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
0072 }
0073 
0074 // Test Trapezoid
0075 BOOST_AUTO_TEST_CASE(BinAdjustment_Trapezoid) {
0076   TrapezoidBounds bound(5, 15, 30);
0077   BinUtility bu;
0078   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisX);
0079   bu += BinUtility(1, 0, 1, Acts::open, Acts::AxisDirection::AxisY);
0080 
0081   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0082 
0083   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -15);
0084   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 15);
0085   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
0086   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
0087 }
0088 
0089 }  // namespace Acts::Test