Back to home page

EIC code displayed by LXR

 
 

    


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

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/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/Layer.hpp"
0014 #include "Acts/Geometry/NavigationLayer.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "Acts/Utilities/BinningType.hpp"
0017 
0018 #include <cmath>
0019 #include <memory>
0020 #include <utility>
0021 
0022 #include "../Surfaces/SurfaceStub.hpp"
0023 
0024 namespace Acts::Test {
0025 // Create a test context
0026 GeometryContext tgContext = GeometryContext();
0027 }  // namespace Acts::Test
0028 
0029 namespace Acts::Test::Layers {
0030 
0031 BOOST_AUTO_TEST_SUITE(Layers)
0032 
0033 /// Unit test for creating compliant/non-compliant NavigationLayer object
0034 BOOST_AUTO_TEST_CASE(NavigationLayerConstruction) {
0035   // default constructor, copy and assignment are all deleted
0036   std::shared_ptr<const Surface> pSurface = Surface::makeShared<SurfaceStub>();
0037   auto pNavigationLayer = NavigationLayer::create(std::move(pSurface));
0038   BOOST_CHECK_EQUAL(pNavigationLayer->layerType(), LayerType::navigation);
0039   // next level: with thickness
0040   const double thickness = 0.1;
0041   auto pSurface2 = Surface::makeShared<SurfaceStub>();
0042   auto pThickNavigationLayer =
0043       NavigationLayer::create(std::move(pSurface2), thickness);
0044   BOOST_CHECK_EQUAL(pThickNavigationLayer->layerType(), LayerType::navigation);
0045 }
0046 
0047 /// Unit test for testing NavigationLayer properties
0048 BOOST_AUTO_TEST_CASE(NavigationLayerProperties) {
0049   const double thickness = 0.1;
0050   std::shared_ptr<const Surface> pSurface = Surface::makeShared<SurfaceStub>();
0051   auto rawSurfacePtr = pSurface.get();
0052   auto pNavigationLayer =
0053       NavigationLayer::create(std::move(pSurface), thickness);
0054   AxisDirection b{AxisDirection::AxisZ};
0055   Vector3 origin{0., 0., 0.};
0056   // referencePosition(), needs a better test
0057   BOOST_CHECK_EQUAL(pNavigationLayer->referencePosition(tgContext, b), origin);
0058   // surfaceRepresentation() [looks dangerous]
0059   BOOST_CHECK_EQUAL(rawSurfacePtr,
0060                     &(pNavigationLayer->surfaceRepresentation()));
0061   // isOnLayer()
0062   BOOST_CHECK(pNavigationLayer->isOnLayer(tgContext, origin,
0063                                           BoundaryTolerance::None()));
0064   // isOnLayer()
0065   Vector3 crazyPosition{1000., 10000., std::nan("")};
0066   // layer stub has hard-coded globalToLocal return value
0067   BOOST_CHECK(pNavigationLayer->isOnLayer(tgContext, crazyPosition,
0068                                           BoundaryTolerance::None()));
0069   // resolve()
0070   BOOST_CHECK(!pNavigationLayer->resolve(true, true, true));
0071 }
0072 
0073 BOOST_AUTO_TEST_SUITE_END()
0074 
0075 }  // namespace Acts::Test::Layers