Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:14:01

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