Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConeVolumeBoundsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConeVolumeBoundsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 <memory>
19 #include <utility>
20 #include <vector>
21 
22 namespace tt = boost::test_tools;
23 
24 namespace Acts {
25 
26 using namespace UnitLiterals;
27 
28 // Create a test context
30 
31 namespace Test {
32 
33 BOOST_AUTO_TEST_SUITE(VolumeBounds)
34 
35 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) {
36  // Single solid Cone
37  ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., M_PI);
38 
39  // Test correct parameter return
40  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerAlpha), 0.);
41  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerOffsetZ), 0.);
42  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterAlpha), 0.45);
43  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterOffsetZ), 50.);
44  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfLengthZ), 50.);
45  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eAveragePhi), 0.);
46  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector), M_PI);
47  // Derived quantities
48  BOOST_CHECK_EQUAL(solidCone.innerTanAlpha(), 0.);
49  BOOST_CHECK_EQUAL(solidCone.innerRmin(), 0.);
50  BOOST_CHECK_EQUAL(solidCone.innerRmax(), 0.);
51  BOOST_CHECK_EQUAL(solidCone.outerTanAlpha(), std::tan(0.45));
52 
53  double outerRmax = 100_mm * solidCone.outerTanAlpha();
54  BOOST_CHECK_EQUAL(solidCone.outerRmin(), 0.);
55  BOOST_CHECK_EQUAL(solidCone.outerRmax(), outerRmax);
56 
57  auto solidConeSurfaces = solidCone.orientedSurfaces();
58  BOOST_CHECK_EQUAL(solidConeSurfaces.size(), 2);
59 
60  // Single solid Cone - with cut off
61  ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., M_PI);
62  auto cutOffConeSurfaces = cutOffCone.orientedSurfaces();
63  BOOST_CHECK_EQUAL(cutOffConeSurfaces.size(), 3);
64 
65  // Cone - Cone inlay
66  ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
67  auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces();
68  BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4);
69 
70  // Sectoral Cone - Cone inlay
71  ConeVolumeBounds cutOffHollowSectoralCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
72  0.456);
73  auto cutOffHollowSectoralConeSurfaces =
74  cutOffHollowSectoralCone.orientedSurfaces();
75  BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6);
76 
77  // Sectoral Cone - Hollow Cone
78  ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
79  auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces();
80  BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4);
81 
82  // Single Hollow Cylinder - Cone inlay
83  ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0., M_PI);
84  auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces();
85  BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4);
86 }
87 
88 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) {
90 
91  ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
92 
93  auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3::Identity());
94  BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
95 
96  auto geoCtx = GeometryContext();
97  Vector3 xaxis(1., 0., 0.);
98  Vector3 yaxis(0., 1., 0.);
99  Vector3 zaxis(0., 0., 1.);
100 
101  for (auto& os : cvbOrientedSurfaces) {
102  // Test the orientation of the boundary surfaces
103  auto rot = os.first->transform(geoCtx).rotation();
104  BOOST_CHECK(rot.col(0).isApprox(xaxis));
105  BOOST_CHECK(rot.col(1).isApprox(yaxis));
106  BOOST_CHECK(rot.col(2).isApprox(zaxis));
107  }
108 }
109 
110 BOOST_AUTO_TEST_SUITE_END()
111 
112 } // namespace Test
113 
114 } // namespace Acts