Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:36

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::UnitLiterals;
0024 
0025 namespace Acts::Test {
0026 
0027 BOOST_AUTO_TEST_SUITE(VolumeBounds)
0028 
0029 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsTests) {
0030   // Single solid Cone
0031   ConeVolumeBounds solidCone(0., 0., 0.45, 50_mm, 50_mm, 0., std::numbers::pi);
0032 
0033   // Test correct parameter return
0034   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerAlpha), 0.);
0035   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eInnerOffsetZ), 0.);
0036   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterAlpha), 0.45);
0037   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eOuterOffsetZ), 50.);
0038   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfLengthZ), 50.);
0039   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eAveragePhi), 0.);
0040   BOOST_CHECK_EQUAL(solidCone.get(ConeVolumeBounds::eHalfPhiSector),
0041                     std::numbers::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., std::numbers::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.,
0062                                     std::numbers::pi);
0063   auto cutOffHollowConeSurfaces = cutOffHollowCone.orientedSurfaces();
0064   BOOST_CHECK_EQUAL(cutOffHollowConeSurfaces.size(), 4);
0065 
0066   // Sectoral Cone - Cone inlay
0067   ConeVolumeBounds cutOffHollowSectoralCone(0.35, 70_mm, 0.45, 80_mm, 50_mm, 0.,
0068                                             0.456);
0069   auto cutOffHollowSectoralConeSurfaces =
0070       cutOffHollowSectoralCone.orientedSurfaces();
0071   BOOST_CHECK_EQUAL(cutOffHollowSectoralConeSurfaces.size(), 6);
0072 
0073   // Sectoral Cone - Hollow Cone
0074   ConeVolumeBounds cutOffHollowCylCone(10_mm, 0.45, 80_mm, 50_mm, 0.,
0075                                        std::numbers::pi);
0076   auto cutOffHollowCylConeSurfaces = cutOffHollowCylCone.orientedSurfaces();
0077   BOOST_CHECK_EQUAL(cutOffHollowCylConeSurfaces.size(), 4);
0078 
0079   // Single Hollow Cylinder - Cone inlay
0080   ConeVolumeBounds cutOffHollowConeCyl(120_mm, 0.35, 70_mm, 50_mm, 0.,
0081                                        std::numbers::pi);
0082   auto cutOffHollowConeCylSurfaces = cutOffHollowConeCyl.orientedSurfaces();
0083   BOOST_CHECK_EQUAL(cutOffHollowConeCylSurfaces.size(), 4);
0084 }
0085 
0086 BOOST_AUTO_TEST_CASE(ConeVolumeBoundsSurfaceOrientation) {
0087   ConeVolumeBounds hcone(10_mm, 0.45, 80_mm, 50_mm, 0., std::numbers::pi);
0088 
0089   auto cvbOrientedSurfaces = hcone.orientedSurfaces(Transform3::Identity());
0090   BOOST_CHECK_EQUAL(cvbOrientedSurfaces.size(), 4);
0091 
0092   auto geoCtx = GeometryContext();
0093   Vector3 xaxis(1., 0., 0.);
0094   Vector3 yaxis(0., 1., 0.);
0095   Vector3 zaxis(0., 0., 1.);
0096 
0097   for (auto& os : cvbOrientedSurfaces) {
0098     // Test the orientation of the boundary surfaces
0099     auto rot = os.surface->transform(geoCtx).rotation();
0100     BOOST_CHECK(rot.col(0).isApprox(xaxis));
0101     BOOST_CHECK(rot.col(1).isApprox(yaxis));
0102     BOOST_CHECK(rot.col(2).isApprox(zaxis));
0103   }
0104 }
0105 
0106 BOOST_AUTO_TEST_SUITE_END()
0107 
0108 }  // namespace Acts::Test