Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:32

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2017-2018 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0013 #include "Acts/Geometry/CutoutCylinderVolumeBounds.hpp"
0014 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0015 #include "Acts/Utilities/BinAdjustmentVolume.hpp"
0016 #include "Acts/Utilities/BinUtility.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018 
0019 #include <cmath>
0020 #include <memory>
0021 #include <vector>
0022 
0023 namespace Acts::Test {
0024 
0025 // Test Cylinder
0026 BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cylinder) {
0027   CylinderVolumeBounds bound(10, 50, 150, M_PI / 2, 0);
0028   BinUtility bu;
0029   bu += BinUtility(1, 0, 1, Acts::open, Acts::binR);
0030   bu += BinUtility(1, 0, 1, Acts::open, Acts::binPhi);
0031   bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ);
0032 
0033   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0034 
0035   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 10);
0036   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 50);
0037   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float(-M_PI / 2));
0038   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float(M_PI / 2));
0039   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].min, -150);
0040   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].max, 150);
0041 }
0042 
0043 // Test Cutout Cylinder
0044 BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_CutoutCylinder) {
0045   CutoutCylinderVolumeBounds bound(10, 20, 50, 100, 15);
0046   BinUtility bu;
0047   bu += BinUtility(1, 0, 1, Acts::open, Acts::binR);
0048   bu += BinUtility(1, 0, 1, Acts::closed, Acts::binPhi);
0049   bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ);
0050 
0051   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0052 
0053   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 10);
0054   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 50);
0055   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float(-M_PI));
0056   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float(M_PI));
0057   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].min, -100);
0058   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].max, 100);
0059 }
0060 
0061 // Test Cuboid
0062 BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cuboid) {
0063   CuboidVolumeBounds bound(13, 23, 42);
0064   BinUtility bu;
0065   bu += BinUtility(1, 0, 1, Acts::open, Acts::binX);
0066   bu += BinUtility(1, 0, 1, Acts::open, Acts::binY);
0067   bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ);
0068 
0069   BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
0070 
0071   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -13);
0072   BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 13);
0073   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -23);
0074   BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 23);
0075   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].min, -42);
0076   BOOST_CHECK_EQUAL(buAdjust.binningData()[2].max, 42);
0077 }
0078 
0079 }  // namespace Acts::Test