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