EIC 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 #include "Acts/Utilities/Units.hpp"
17 
18 namespace tt = boost::test_tools;
19 
20 namespace Acts {
21 
22 using namespace UnitLiterals;
23 
24 // Create a test context
26 
27 namespace Test {
28 
29 BOOST_AUTO_TEST_SUITE(VolumeBounds)
30 
31 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) {
32  // Single solid Cone
33  ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., M_PI);
34 
35  // Test correct parameter return
36  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerAlpha), 0.);
37  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerOffsetZ), 0.);
38  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterAlpha), 0.45);
39  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterOffsetZ), 50.);
40  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfLengthZ), 50.);
41  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eAveragePhi), 0.);
42  BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector), M_PI);
43  // Derived quantities
44  BOOST_CHECK_EQUAL(solidCone.innerTanAlpha(), 0.);
45  BOOST_CHECK_EQUAL(solidCone.innerRmin(), 0.);
46  BOOST_CHECK_EQUAL(solidCone.innerRmax(), 0.);
47  BOOST_CHECK_EQUAL(solidCone.outerTanAlpha(), std::tan(0.45));
48 
49  double outerRmax = 100_mm * solidCone.outerTanAlpha();
50  BOOST_CHECK_EQUAL(solidCone.outerRmin(), 0.);
51  BOOST_CHECK_EQUAL(solidCone.outerRmax(), outerRmax);
52 
53  auto solidConeSurfaces = solidCone.orientedSurfaces();
54  BOOST_CHECK_EQUAL(solidConeSurfaces.size(), 2);
55 
56  // Single solid Cone - with cut off
57  ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., M_PI);
58  auto cutOffConeSurfaces = cutOffCone.orientedSurfaces();
59  BOOST_CHECK_EQUAL(cutOffConeSurfaces.size(), 3);
60 
61  // Cone - Cone inlay
62  ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
63  auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces();
64  BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4);
65 
66  // Sectoral Cone - Cone inlay
67  ConeVolumeBounds cutOffHollowSectoralCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
68  0.456);
69  auto cutOffHollowSectoralConeSurfaces =
70  cutOffHollowSectoralCone.orientedSurfaces();
71  BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6);
72 
73  // Sectoral Cone - Hollow Cone
74  ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
75  auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces();
76  BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4);
77 
78  // Single Hollow Cylinder - Cone inlay
79  ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0., M_PI);
80  auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces();
81  BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4);
82 }
83 
84 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) {
86 
87  ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
88 
89  auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3D::Identity());
90  BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
91 
92  auto geoCtx = GeometryContext();
93  Vector3D xaxis(1., 0., 0.);
94  Vector3D yaxis(0., 1., 0.);
95  Vector3D zaxis(0., 0., 1.);
96 
97  for (auto& os : cvbOrientedSurfaces) {
98  // Test the orientation of the boundary surfaces
99  auto rot = os.first->transform(geoCtx).rotation();
100  BOOST_CHECK(rot.col(0).isApprox(xaxis));
101  BOOST_CHECK(rot.col(1).isApprox(yaxis));
102  BOOST_CHECK(rot.col(2).isApprox(zaxis));
103  }
104 }
105 
106 BOOST_AUTO_TEST_SUITE_END()
107 
108 } // namespace Test
109 
110 } // namespace Acts