Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-03 08:58:42

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://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 <numbers>
0020 #include <utility>
0021 #include <vector>
0022 
0023 using namespace Acts;
0024 using namespace Acts::UnitLiterals;
0025 
0026 namespace ActsTests {
0027 
0028 BOOST_AUTO_TEST_SUITE(GeometrySuite)
0029 
0030 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) {
0031   // Single solid Cone
0032   ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., std::numbers::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),
0042                     std::numbers::pi);
0043   // Derived quantities
0044   BOOST_CHECK_EQUAL(solidCone.innerTanAlpha(), 0.);
0045   BOOST_CHECK_EQUAL(solidCone.innerRmin(), 0.);
0046   BOOST_CHECK_EQUAL(solidCone.innerRmax(), 0.);
0047   BOOST_CHECK_EQUAL(solidCone.outerTanAlpha(), std::tan(0.45));
0048 
0049   double outerRmax = 100_mm * solidCone.outerTanAlpha();
0050   BOOST_CHECK_EQUAL(solidCone.outerRmin(), 0.);
0051   BOOST_CHECK_EQUAL(solidCone.outerRmax(), outerRmax);
0052 
0053   auto solidConeSurfaces = solidCone.orientedSurfaces();
0054   BOOST_CHECK_EQUAL(solidConeSurfaces.size(), 2);
0055 
0056   // Single solid Cone - with cut off
0057   ConeVolumeBounds cutOffCone(0., 0., 0.45, 80_mm, 50_mm, 0., std::numbers::pi);
0058   auto cutOffConeSurfaces = cutOffCone.orientedSurfaces();
0059   BOOST_CHECK_EQUAL(cutOffConeSurfaces.size(), 3);
0060 
0061   // Cone - Cone inlay
0062   ConeVolumeBounds cutOffHollowCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
0063                                     std::numbers::pi);
0064   auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces();
0065   BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4);
0066 
0067   // Sectoral Cone - Cone inlay
0068   ConeVolumeBounds cutOffHollowSectoralCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
0069                                             0.456);
0070   auto cutOffHollowSectoralConeSurfaces =
0071       cutOffHollowSectoralCone.orientedSurfaces();
0072   BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6);
0073 
0074   // Sectoral Cone - Hollow Cone
0075   ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0.,
0076                                        std::numbers::pi);
0077   auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces();
0078   BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4);
0079 
0080   // Single Hollow Cylinder - Cone inlay
0081   ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0.,
0082                                        std::numbers::pi);
0083   auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces();
0084   BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4);
0085 }
0086 
0087 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) {
0088   ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., std::numbers::pi);
0089 
0090   auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3::Identity());
0091   BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
0092 
0093   auto geoCtx = GeometryContext();
0094   Vector3 xaxis(1., 0., 0.);
0095   Vector3 yaxis(0., 1., 0.);
0096   Vector3 zaxis(0., 0., 1.);
0097 
0098   for (auto& os : cvbOrientedSurfaces) {
0099     // Test the orientation of the boundary surfaces
0100     auto rot = os.surface->transform(geoCtx).rotation();
0101     BOOST_CHECK(rot.col(0).isApprox(xaxis));
0102     BOOST_CHECK(rot.col(1).isApprox(yaxis));
0103     BOOST_CHECK(rot.col(2).isApprox(zaxis));
0104   }
0105 }
0106 
0107 BOOST_AUTO_TEST_SUITE_END()
0108 
0109 }  // namespace ActsTests