Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BinAdjustmentTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BinAdjustmentTests.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/unit_test.hpp>
10 
19 
20 #include <cmath>
21 #include <memory>
22 #include <vector>
23 
24 namespace Acts {
25 namespace Test {
26 
27 namespace tt = boost::test_tools;
28 
29 // Test Radial
30 BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) {
31  RadialBounds bound(50, 75, M_PI, 0);
32  BinUtility bu;
33  bu += BinUtility(1, 0, 1, Acts::open, Acts::binR);
34  bu += BinUtility(1, 0, 1, Acts::closed, Acts::binPhi);
35 
36  BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
37 
38  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, 50);
39  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 75);
40  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, float(-M_PI));
41  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, float(M_PI));
42 }
43 
44 // Test Cylinder
45 BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) {
46  CylinderBounds bound(25, 50, M_PI / 4, 0);
47  BinUtility bu;
48  bu += BinUtility(1, 0, 1, Acts::open, Acts::binPhi);
49  bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ);
50 
51  BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
52 
53  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, float(-M_PI / 4));
54  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, float(M_PI / 4));
55  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -50);
56  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 50);
57 }
58 
59 // Test Rectangule
60 BOOST_AUTO_TEST_CASE(BinAdjustment_Rectangle) {
61  RectangleBounds bound(20, 30);
62  BinUtility bu;
63  bu += BinUtility(1, 0, 1, Acts::open, Acts::binX);
64  bu += BinUtility(1, 0, 1, Acts::open, Acts::binY);
65 
66  BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
67 
68  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -20);
69  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 20);
70  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
71  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
72 }
73 
74 // Test Trapezoid
75 BOOST_AUTO_TEST_CASE(BinAdjustment_Trapezoid) {
76  TrapezoidBounds bound(5, 15, 30);
77  BinUtility bu;
78  bu += BinUtility(1, 0, 1, Acts::open, Acts::binX);
79  bu += BinUtility(1, 0, 1, Acts::open, Acts::binY);
80 
81  BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity());
82 
83  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].min, -15);
84  BOOST_CHECK_EQUAL(buAdjust.binningData()[0].max, 15);
85  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].min, -30);
86  BOOST_CHECK_EQUAL(buAdjust.binningData()[1].max, 30);
87 }
88 
89 } // namespace Test
90 } // namespace Acts