EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RadialBoundsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RadialBoundsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
16 
17 #include <limits>
18 
19 namespace Acts {
20 
21 namespace Test {
22 BOOST_AUTO_TEST_SUITE(Surfaces)
23 
24 
25 BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) {
26  double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
27  // test default construction
28  // RadialBounds defaultConstructedRadialBounds; should be deleted
29  //
31  BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius).type(),
33  //
35  BOOST_CHECK_EQUAL(RadialBounds(minRadius, maxRadius, halfPhiSector).type(),
37  //
39  RadialBounds original(minRadius, maxRadius);
40  RadialBounds copied(original);
41  BOOST_CHECK_EQUAL(copied, original);
42 }
43 
44 // Streaning and recreation test
45 BOOST_AUTO_TEST_CASE(RadialBoundsRecreation) {
46  double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1);
47  RadialBounds original(minRadius, maxRadius, halfPhiSector, avgPhi);
48  // const bool symmetric(false);
49  auto valvector = original.values();
50  std::array<double, RadialBounds::eSize> values;
51  std::copy_n(valvector.begin(), RadialBounds::eSize, values.begin());
52  RadialBounds recreated(values);
53  BOOST_CHECK_EQUAL(original, recreated);
54 }
55 
56 // Streaning and recreation test
57 BOOST_AUTO_TEST_CASE(RadialBoundsException) {
58  double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0), avgPhi(0.1);
59 
60  // Negative inner radius
61  BOOST_CHECK_THROW(RadialBounds(-minRadius, maxRadius, halfPhiSector, avgPhi),
62  std::logic_error);
63 
64  // Negative outer radius
65  BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, avgPhi),
66  std::logic_error);
67 
68  // Negative inner and outer radius
69  BOOST_CHECK_THROW(RadialBounds(-minRadius, -maxRadius, halfPhiSector, avgPhi),
70  std::logic_error);
71 
72  // Swapped radii
73  BOOST_CHECK_THROW(RadialBounds(maxRadius, minRadius, halfPhiSector, avgPhi),
74  std::logic_error);
75 
76  // Out of bound phi sector
77  BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, -5., avgPhi),
78  std::logic_error);
79 
80  // Out of bound phi position
81  BOOST_CHECK_THROW(RadialBounds(minRadius, -maxRadius, halfPhiSector, 5.),
82  std::logic_error);
83 }
84 
86 BOOST_AUTO_TEST_CASE(RadialBoundsProperties) {
87  double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
89  RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector);
90  BOOST_CHECK_EQUAL(radialBoundsObject.type(), SurfaceBounds::eDisc);
91  //
93  Vector2D outside(30., 0.);
94  Vector2D inSurface(2., 0.0);
95 
97  boost::test_tools::output_test_stream dumpOuput;
98  radialBoundsObject.toStream(dumpOuput);
99  BOOST_CHECK(
100  dumpOuput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, "
101  "hPhiSector, averagePhi) = (1.0000000, "
102  "5.0000000, 0.3926991, 0.0000000)"));
103  //
105  BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryCheck(true)));
106  BOOST_CHECK(!radialBoundsObject.inside(outside, BoundaryCheck(true)));
107  //
109  BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMinR), minRadius);
110  //
112  BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), maxRadius);
113  //
115  BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.0);
116  //
118  BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector),
119  halfPhiSector);
120 }
122 BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) {
123  double minRadius(1.0), maxRadius(5.0), halfPhiSector(M_PI / 8.0);
124  RadialBounds radialBoundsObject(minRadius, maxRadius, halfPhiSector);
125  // operator == not implemented in this class
126  //
128  RadialBounds assignedRadialBoundsObject(10.1, 123.);
129  assignedRadialBoundsObject = radialBoundsObject;
130  BOOST_CHECK_EQUAL(assignedRadialBoundsObject, radialBoundsObject);
131 }
132 
133 BOOST_AUTO_TEST_SUITE_END()
134 
135 } // namespace Test
136 
137 } // namespace Acts