Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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/Utilities/Grid.hpp"
0013 #include "Acts/Utilities/GridAxisGenerators.hpp"
0014 #include "Acts/Utilities/detail/Axis.hpp"
0015 #include "Acts/Utilities/detail/AxisFwd.hpp"
0016 
0017 #include <cmath>
0018 #include <tuple>
0019 #include <utility>
0020 
0021 using namespace Acts;
0022 using namespace Acts::detail;
0023 using namespace Acts::GridAxisGenerators;
0024 
0025 BOOST_AUTO_TEST_SUITE(Detector)
0026 
0027 BOOST_AUTO_TEST_CASE(Eq1D) {
0028   EqBound eqb{{-10, 10}, 10};
0029   auto axisTupleB = eqb();
0030   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTupleB)>{}, 1u);
0031   auto axisB = std::get<0u>(axisTupleB);
0032   BOOST_CHECK(axisB.getBoundaryType() == AxisBoundaryType::Bound);
0033 
0034   EqOpen eqo{{-10, 10}, 10};
0035   auto axisTupleO = eqo();
0036   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTupleO)>{}, 1u);
0037   auto axisO = std::get<0u>(axisTupleO);
0038   BOOST_CHECK(axisO.getBoundaryType() == AxisBoundaryType::Open);
0039 
0040   EqClosed eqc{{-10, 10}, 10};
0041   auto axisTupleC = eqc();
0042   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTupleC)>{}, 1u);
0043   auto axisC = std::get<0u>(axisTupleC);
0044   BOOST_CHECK(axisC.getBoundaryType() == AxisBoundaryType::Closed);
0045 
0046   // Test that we can make a grid out of this
0047   EqBound::grid_type<bool> eqbGrid(std::move(axisTupleB));
0048 }
0049 
0050 BOOST_AUTO_TEST_CASE(EqEq2D) {
0051   EqOpenEqClosed eoec{{0, 10}, 10u, {-M_PI, M_PI}, 16u};
0052   auto axisTuple = eoec();
0053   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTuple)>{}, 2u);
0054   auto axisVar = std::get<0u>(axisTuple);
0055   BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Open);
0056   BOOST_CHECK(axisVar.isEquidistant());
0057   auto axisEq = std::get<1u>(axisTuple);
0058   BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed);
0059   BOOST_CHECK(axisEq.isEquidistant());
0060   // Test that we can make a grid out of this
0061   EqOpenEqClosed::grid_type<bool> eoecGrid(std::move(axisTuple));
0062 }
0063 
0064 BOOST_AUTO_TEST_CASE(EqVar2D) {
0065   EqBoundVarOpen ebvo{{0, 10}, 10u, {10., 20, 30, 40}};
0066   auto axisTuple = ebvo();
0067   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTuple)>{}, 2u);
0068   auto axisVar = std::get<0u>(axisTuple);
0069   BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
0070   BOOST_CHECK(axisVar.isEquidistant());
0071   auto axisEq = std::get<1u>(axisTuple);
0072   BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Open);
0073   BOOST_CHECK(axisEq.isVariable());
0074   // Test that we can make a grid out of this
0075   EqBoundVarOpen::grid_type<bool> ebvoGrid(std::move(axisTuple));
0076 }
0077 
0078 BOOST_AUTO_TEST_CASE(VarEq2D) {
0079   VarBoundEqClosed vbec{{10., 20, 30, 40}, {-M_PI, M_PI}, 12u};
0080   auto axisTuple = vbec();
0081   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTuple)>{}, 2u);
0082   auto axisVar = std::get<0u>(axisTuple);
0083   BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
0084   BOOST_CHECK(axisVar.isVariable());
0085   auto axisEq = std::get<1u>(axisTuple);
0086   BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed);
0087   BOOST_CHECK(axisEq.isEquidistant());
0088   // Test that we can make a grid out of this
0089   VarBoundEqClosed::grid_type<bool> vbecGrid(std::move(axisTuple));
0090 }
0091 
0092 BOOST_AUTO_TEST_CASE(VarVar2D) {
0093   VarBoundVarBound vbvb{{10., 20, 30, 40}, {10., 20, 30, 40}};
0094   auto axisTuple = vbvb();
0095   BOOST_CHECK_EQUAL(std::tuple_size<decltype(axisTuple)>{}, 2u);
0096   auto axisVar = std::get<0u>(axisTuple);
0097   BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
0098   BOOST_CHECK(axisVar.isVariable());
0099   auto axisEq = std::get<1u>(axisTuple);
0100   BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Bound);
0101   BOOST_CHECK(axisEq.isVariable());
0102   // Test that we can make a grid out of this
0103   VarBoundVarBound::grid_type<bool> vbvbGrid(std::move(axisTuple));
0104 }
0105 
0106 BOOST_AUTO_TEST_SUITE_END()