Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-25 07:57:09

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 using namespace Acts;
0026 
0027 namespace ActsTests {
0028 
0029 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0030 
0031 // Test Radial
0032 BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) {
0033   RadialBounds bound(50, 75, std::numbers::pi, 0);
0034   BinUtility bu;
0035   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisR);
0036   bu += BinUtility(1, 0, 1, closed, AxisDirection::AxisPhi);
0037 
0038   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0039 
0040   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 50);
0041   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 75);
0042   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -std::numbers::pi_v<float>);
0043   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, std::numbers::pi_v<float>);
0044 }
0045 
0046 // Test Cylinder
0047 BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) {
0048   CylinderBounds bound(25, 50, std::numbers::pi / 4, 0);
0049   BinUtility bu;
0050   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisPhi);
0051   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisZ);
0052 
0053   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0054 
0055   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min,
0056                     -static_cast<float>(std::numbers::pi / 4.));
0057   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max,
0058                     static_cast<float>(std::numbers::pi / 4.));
0059   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -50);
0060   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 50);
0061 }
0062 
0063 // Test Rectangule
0064 BOOST_AUTO_TEST_CASE(BinAdjustment_Rectangle) {
0065   RectangleBounds bound(20, 30);
0066   BinUtility bu;
0067   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisX);
0068   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisY);
0069 
0070   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0071 
0072   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -20);
0073   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 20);
0074   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
0075   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
0076 }
0077 
0078 // Test Trapezoid
0079 BOOST_AUTO_TEST_CASE(BinAdjustment_Trapezoid) {
0080   TrapezoidBounds bound(5, 15, 30);
0081   BinUtility bu;
0082   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisX);
0083   bu += BinUtility(1, 0, 1, open, AxisDirection::AxisY);
0084 
0085   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0086 
0087   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -15);
0088   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 15);
0089   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
0090   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
0091 }
0092 
0093 BOOST_AUTO_TEST_SUITE_END()
0094 
0095 }  // namespace ActsTests