Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-23 08:24:31

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