Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GridAxisGeneratorsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GridAxisGeneratorsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
16 
17 #include <cmath>
18 #include <tuple>
19 #include <utility>
20 
21 using namespace Acts;
22 using namespace Acts::detail;
23 using namespace Acts::Experimental;
24 using namespace Acts::Experimental::detail::GridAxisGenerators;
25 
26 BOOST_AUTO_TEST_SUITE(Detector)
27 
29  EqBound eqb{{-10, 10}, 10};
30  auto axisTupleB = eqb();
31  BOOST_CHECK(std::tuple_size<decltype(axisTupleB)>{} == 1u);
32  auto axisB = std::get<0u>(axisTupleB);
33  BOOST_CHECK(axisB.getBoundaryType() == AxisBoundaryType::Bound);
34 
35  EqOpen eqo{{-10, 10}, 10};
36  auto axisTupleO = eqo();
37  BOOST_CHECK(std::tuple_size<decltype(axisTupleO)>{} == 1u);
38  auto axisO = std::get<0u>(axisTupleO);
39  BOOST_CHECK(axisO.getBoundaryType() == AxisBoundaryType::Open);
40 
41  EqClosed eqc{{-10, 10}, 10};
42  auto axisTupleC = eqc();
43  BOOST_CHECK(std::tuple_size<decltype(axisTupleC)>{} == 1u);
44  auto axisC = std::get<0u>(axisTupleC);
45  BOOST_CHECK(axisC.getBoundaryType() == AxisBoundaryType::Closed);
46 
47  // Test that we can make a grid out of this
48  EqBound::grid_type<bool> eqbGrid(std::move(axisTupleB));
49 }
50 
52  EqOpenEqClosed eoec{{0, 10}, 10u, {-M_PI, M_PI}, 16u};
53  auto axisTuple = eoec();
54  BOOST_CHECK(std::tuple_size<decltype(axisTuple)>{} == 2u);
55  auto axisVar = std::get<0u>(axisTuple);
56  BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Open);
57  BOOST_CHECK(axisVar.isEquidistant());
58  auto axisEq = std::get<1u>(axisTuple);
59  BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed);
60  BOOST_CHECK(axisEq.isEquidistant());
61  // Test that we can make a grid out of this
62  EqOpenEqClosed::grid_type<bool> eoecGrid(std::move(axisTuple));
63 }
64 
66  EqBoundVarOpen ebvo{{0, 10}, 10u, {10., 20, 30, 40}};
67  auto axisTuple = ebvo();
68  BOOST_CHECK(std::tuple_size<decltype(axisTuple)>{} == 2u);
69  auto axisVar = std::get<0u>(axisTuple);
70  BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
71  BOOST_CHECK(axisVar.isEquidistant());
72  auto axisEq = std::get<1u>(axisTuple);
73  BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Open);
74  BOOST_CHECK(axisEq.isVariable());
75  // Test that we can make a grid out of this
76  EqBoundVarOpen::grid_type<bool> ebvoGrid(std::move(axisTuple));
77 }
78 
80  VarBoundEqClosed vbec{{10., 20, 30, 40}, {-M_PI, M_PI}, 12u};
81  auto axisTuple = vbec();
82  BOOST_CHECK(std::tuple_size<decltype(axisTuple)>{} == 2u);
83  auto axisVar = std::get<0u>(axisTuple);
84  BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
85  BOOST_CHECK(axisVar.isVariable());
86  auto axisEq = std::get<1u>(axisTuple);
87  BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Closed);
88  BOOST_CHECK(axisEq.isEquidistant());
89  // Test that we can make a grid out of this
90  VarBoundEqClosed::grid_type<bool> vbecGrid(std::move(axisTuple));
91 }
92 
94  VarBoundVarBound vbvb{{10., 20, 30, 40}, {10., 20, 30, 40}};
95  auto axisTuple = vbvb();
96  BOOST_CHECK(std::tuple_size<decltype(axisTuple)>{} == 2u);
97  auto axisVar = std::get<0u>(axisTuple);
98  BOOST_CHECK(axisVar.getBoundaryType() == AxisBoundaryType::Bound);
99  BOOST_CHECK(axisVar.isVariable());
100  auto axisEq = std::get<1u>(axisTuple);
101  BOOST_CHECK(axisEq.getBoundaryType() == AxisBoundaryType::Bound);
102  BOOST_CHECK(axisEq.isVariable());
103  // Test that we can make a grid out of this
104  VarBoundVarBound::grid_type<bool> vbvbGrid(std::move(axisTuple));
105 }
106 
107 BOOST_AUTO_TEST_SUITE_END()