Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:20

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2020 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Geometry/ConeVolumeBounds.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 
0017 #include <cmath>
0018 #include <memory>
0019 #include <utility>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 using namespace UnitLiterals;
0025 
0026 namespace Test {
0027 
0028 BOOST_AUTO_TEST_SUITE(VolumeBounds)
0029 
0030 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) {
0031   // Single solid Cone
0032   ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., M_PI);
0033 
0034   // Test correct parameter return
0035   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerAlpha), 0.);
0036   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerOffsetZ), 0.);
0037   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterAlpha), 0.45);
0038   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterOffsetZ), 50.);
0039   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfLengthZ), 50.);
0040   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eAveragePhi), 0.);
0041   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector), M_PI);
0042   // Derived quantities
0043   BOOST_CHECK_EQUAL(solidCone.innerTanAlpha(), 0.);
0044   BOOST_CHECK_EQUAL(solidCone.innerRmin(), 0.);
0045   BOOST_CHECK_EQUAL(solidCone.innerRmax(), 0.);
0046   BOOST_CHECK_EQUAL(solidCone.outerTanAlpha(), std::tan(0.45));
0047 
0048   double outerRmax = 100_mm * solidCone.outerTanAlpha();
0049   BOOST_CHECK_EQUAL(solidCone.outerRmin(), 0.);
0050   BOOST_CHECK_EQUAL(solidCone.outerRmax(), outerRmax);
0051 
0052   auto solidConeSurfaces = solidCone.orientedSurfaces();
0053   BOOST_CHECK_EQUAL(solidConeSurfaces.size(), 2);
0054 
0055   // Single solid Cone - with cut off
0056   ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., M_PI);
0057   auto cutOffConeSurfaces = cutOffCone.orientedSurfaces();
0058   BOOST_CHECK_EQUAL(cutOffConeSurfaces.size(), 3);
0059 
0060   // Cone - Cone inlay
0061   ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
0062   auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces();
0063   BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4);
0064 
0065   // Sectoral Cone - Cone inlay
0066   ConeVolumeBounds cutOffHollowSectoralCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
0067                                             0.456);
0068   auto cutOffHollowSectoralConeSurfaces =
0069       cutOffHollowSectoralCone.orientedSurfaces();
0070   BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6);
0071 
0072   // Sectoral Cone - Hollow Cone
0073   ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
0074   auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces();
0075   BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4);
0076 
0077   // Single Hollow Cylinder - Cone inlay
0078   ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0., M_PI);
0079   auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces();
0080   BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4);
0081 }
0082 
0083 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) {
0084   ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., M_PI);
0085 
0086   auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3::Identity());
0087   BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
0088 
0089   auto geoCtx = GeometryContext();
0090   Vector3 xaxis(1., 0., 0.);
0091   Vector3 yaxis(0., 1., 0.);
0092   Vector3 zaxis(0., 0., 1.);
0093 
0094   for (auto& os : cvbOrientedSurfaces) {
0095     // Test the orientation of the boundary surfaces
0096     auto rot = os.surface->transform(geoCtx).rotation();
0097     BOOST_CHECK(rot.col(0).isApprox(xaxis));
0098     BOOST_CHECK(rot.col(1).isApprox(yaxis));
0099     BOOST_CHECK(rot.col(2).isApprox(zaxis));
0100   }
0101 }
0102 
0103 BOOST_AUTO_TEST_SUITE_END()
0104 
0105 }  // namespace Test
0106 
0107 }  // namespace Acts