Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-12 08:02: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/Geometry/ApproachDescriptor.hpp"
0013 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/Layer.hpp"
0016 #include "Acts/Geometry/PlaneLayer.hpp"
0017 #include "Acts/Geometry/SurfaceArrayCreator.hpp"
0018 #include "Acts/Surfaces/PlaneSurface.hpp"
0019 #include "Acts/Surfaces/RectangleBounds.hpp"
0020 #include "Acts/Surfaces/Surface.hpp"
0021 
0022 #include <cstddef>
0023 #include <memory>
0024 #include <string>
0025 #include <utility>
0026 #include <vector>
0027 
0028 using namespace Acts;
0029 
0030 GeometryContext tgContext = GeometryContext::dangerouslyDefaultConstruct();
0031 
0032 namespace ActsTests {
0033 
0034 BOOST_AUTO_TEST_SUITE(GeometrySuite)
0035 
0036 /// Unit test for creating compliant/non-compliant PlaneLayer object
0037 BOOST_AUTO_TEST_CASE(PlaneLayerConstruction) {
0038   // default constructor, copy and assignment are all deleted
0039   // minimally need a Transform3 and a PlanarBounds object (e.g.
0040   // RectangleBounds) to construct
0041   Translation3 translation{0., 1., 2.};
0042   auto pTransform = Transform3(translation);
0043   const double halfX(10.), halfY(5.);  // 20 x 10 rectangle
0044   auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
0045   auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle, nullptr);
0046   BOOST_CHECK_EQUAL(pPlaneLayer->layerType(), LayerType::active);
0047   // next level: need an array of Surfaces;
0048   // bounds object, rectangle type
0049   auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
0050   /// Constructor with transform pointer
0051   const std::vector<std::shared_ptr<const Surface>> aSurfaces{
0052       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
0053       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
0054   const double thickness(1.0);
0055   SurfaceArrayCreator sac;
0056   std::size_t binsX(2), binsY(4);
0057   auto pSurfaceArray = sac.surfaceArrayOnPlane(tgContext, aSurfaces, binsX,
0058                                                binsY, AxisDirection::AxisZ);
0059   auto pPlaneLayerFromSurfaces =
0060       PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray));
0061   BOOST_CHECK_EQUAL(pPlaneLayerFromSurfaces->layerType(), LayerType::active);
0062   // construct with thickness:
0063   auto pPlaneLayerWithThickness = PlaneLayer::create(
0064       pTransform, pRectangle, std::move(pSurfaceArray), thickness);
0065   BOOST_CHECK_EQUAL(pPlaneLayerWithThickness->layerThickness(), thickness);
0066   // with an approach descriptor...
0067   auto ad(std::make_unique<GenericApproachDescriptor>(aSurfaces));
0068   auto adPtr = ad.get();
0069   auto pPlaneLayerWithApproachDescriptor =
0070       PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
0071                          thickness, std::move(ad));
0072   BOOST_CHECK_EQUAL(pPlaneLayerWithApproachDescriptor->approachDescriptor(),
0073                     adPtr);
0074   // with the layerType specified...
0075   auto pPlaneLayerWithLayerType =
0076       PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
0077                          thickness, std::move(ad), LayerType::passive);
0078   BOOST_CHECK_EQUAL(pPlaneLayerWithLayerType->layerType(), LayerType::passive);
0079 }
0080 
0081 /// Unit test for testing Layer properties
0082 BOOST_AUTO_TEST_CASE(PlaneLayerProperties) {
0083   Translation3 translation{0., 1., 2.};
0084   auto pTransform = Transform3(translation);
0085   const double halfX(10.), halfY(5.);  // 20 x 10 rectangle
0086   auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
0087   auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle, nullptr);
0088   // auto planeSurface = pPlaneLayer->surfaceRepresentation();
0089   BOOST_CHECK_EQUAL(pPlaneLayer->surfaceRepresentation().name(),
0090                     std::string("Acts::PlaneSurface"));
0091 }
0092 
0093 BOOST_AUTO_TEST_SUITE_END()
0094 
0095 }  // namespace ActsTests