Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-08 09:20:10

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();
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);
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->thickness(), thickness);
0066   // with an approach descriptor...
0067   std::unique_ptr<ApproachDescriptor> ad(
0068       new GenericApproachDescriptor(aSurfaces));
0069   auto adPtr = ad.get();
0070   auto pPlaneLayerWithApproachDescriptor =
0071       PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
0072                          thickness, std::move(ad));
0073   BOOST_CHECK_EQUAL(pPlaneLayerWithApproachDescriptor->approachDescriptor(),
0074                     adPtr);
0075   // with the layerType specified...
0076   auto pPlaneLayerWithLayerType =
0077       PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
0078                          thickness, std::move(ad), LayerType::passive);
0079   BOOST_CHECK_EQUAL(pPlaneLayerWithLayerType->layerType(), LayerType::passive);
0080 }
0081 
0082 /// Unit test for testing Layer properties
0083 BOOST_AUTO_TEST_CASE(PlaneLayerProperties) {
0084   Translation3 translation{0., 1., 2.};
0085   auto pTransform = Transform3(translation);
0086   const double halfX(10.), halfY(5.);  // 20 x 10 rectangle
0087   auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
0088   auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
0089   // auto planeSurface = pPlaneLayer->surfaceRepresentation();
0090   BOOST_CHECK_EQUAL(pPlaneLayer->surfaceRepresentation().name(),
0091                     std::string("Acts::PlaneSurface"));
0092 }
0093 
0094 BOOST_AUTO_TEST_SUITE_END()
0095 
0096 }  // namespace ActsTests