Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProtoBinningTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ProtoBinningTests.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/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
11 
13 
14 using namespace Acts::Experimental;
15 
16 BOOST_AUTO_TEST_SUITE(Detector)
17 
18 BOOST_AUTO_TEST_CASE(ProtoBinningEquidistant) {
19  // An invalid binning, 0 bins given
20  BOOST_CHECK_THROW(
21  ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound, 15., 20.,
22  0),
23  std::invalid_argument);
24 
25  // Another invalid binning, min/max swapped
26  BOOST_CHECK_THROW(
27  ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound, 150., 20.,
28  10),
29  std::invalid_argument);
30 
31  // A valid binning
32  auto eq = ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound, 0.,
33  10., 5u);
34 
35  std::vector<Acts::ActsScalar> reference = {0., 2., 4., 6., 8., 10.};
36  BOOST_CHECK(eq.bins() == 5u);
37  BOOST_CHECK(eq.binValue == Acts::binX);
38  BOOST_CHECK(eq.axisType == Acts::detail::AxisType::Equidistant);
39  BOOST_CHECK(eq.boundaryType == Acts::detail::AxisBoundaryType::Bound);
40  BOOST_CHECK_EQUAL_COLLECTIONS(eq.edges.begin(), eq.edges.end(),
41  reference.begin(), reference.end());
42 }
43 
44 BOOST_AUTO_TEST_CASE(ProtoBinningVariable) {
45  // An invalid binning, edge size < 2u
46  BOOST_CHECK_THROW(
47  ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound, {12.}),
48  std::invalid_argument);
49 
50  // A valid binning
51  std::vector<Acts::ActsScalar> varEdges = {0., 12., 13., 15., 20.};
52  auto var =
53  ProtoBinning(Acts::binX, Acts::detail::AxisBoundaryType::Bound, varEdges);
54 
55  BOOST_CHECK(var.bins() == 4u);
56  BOOST_CHECK(var.binValue == Acts::binX);
57  BOOST_CHECK(var.axisType == Acts::detail::AxisType::Variable);
58  BOOST_CHECK(var.boundaryType == Acts::detail::AxisBoundaryType::Bound);
59  BOOST_CHECK_EQUAL_COLLECTIONS(var.edges.begin(), var.edges.end(),
60  varEdges.begin(), varEdges.end());
61 }
62 
63 BOOST_AUTO_TEST_SUITE_END()