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