Back to home page

EIC code displayed by LXR

 
 

    


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

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/CylinderLayer.hpp"
0014 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0015 #include "Acts/Geometry/Layer.hpp"
0016 #include "Acts/Surfaces/CylinderBounds.hpp"
0017 #include "Acts/Surfaces/CylinderSurface.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/Tests/CommonHelpers/FloatComparisons.hpp"
0023 
0024 #include <memory>
0025 #include <string>
0026 #include <utility>
0027 #include <vector>
0028 
0029 namespace Acts::Test::Layers {
0030 
0031 BOOST_AUTO_TEST_SUITE(Layers)
0032 
0033 /// Unit test for creating compliant/non-compliant CylinderLayer object
0034 BOOST_AUTO_TEST_CASE(CylinderLayerConstruction) {
0035   // default constructor, copy and assignment are all deleted
0036   // minimally need a Transform3 and a PlanarBounds object (e.g.
0037   // CylinderBounds) to construct
0038   Translation3 translation{0., 1., 2.};
0039   auto pTransform = Transform3(translation);
0040   double radius(0.5), halfz(10.);
0041   auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
0042   auto pCylinderLayer =
0043       CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
0044   BOOST_CHECK_EQUAL(pCylinderLayer->layerType(), LayerType::passive);
0045   // next level: need an array of Surfaces;
0046   // bounds object, rectangle type
0047   auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
0048   /// Construction
0049   const std::vector<std::shared_ptr<const Surface>> aSurfaces{
0050       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
0051       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
0052   const double thickness(1.0);
0053   auto pCylinderLayerFromSurfaces =
0054       CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
0055   BOOST_CHECK_EQUAL(pCylinderLayerFromSurfaces->layerType(),
0056                     LayerType::passive);
0057   // construct with thickness:
0058   auto pCylinderLayerWithThickness =
0059       CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
0060   CHECK_CLOSE_REL(pCylinderLayerWithThickness->thickness(), thickness, 1e-6);
0061   // with an approach descriptor...
0062   std::unique_ptr<ApproachDescriptor> ad(
0063       new GenericApproachDescriptor(aSurfaces));
0064   auto adPtr = ad.get();
0065   auto pCylinderLayerWithApproachDescriptor = CylinderLayer::create(
0066       pTransform, pCylinder, nullptr, thickness, std::move(ad));
0067   BOOST_CHECK_EQUAL(pCylinderLayerWithApproachDescriptor->approachDescriptor(),
0068                     adPtr);
0069   // with the layerType specified...
0070   auto pCylinderLayerWithLayerType =
0071       CylinderLayer::create(pTransform, pCylinder, nullptr, thickness,
0072                             std::move(ad), LayerType::passive);
0073   BOOST_CHECK_EQUAL(pCylinderLayerWithLayerType->layerType(),
0074                     LayerType::passive);
0075 }
0076 
0077 /// Unit test for testing Layer properties
0078 BOOST_AUTO_TEST_CASE(CylinderLayerProperties) {
0079   Translation3 translation{0., 1., 2.};
0080   auto pTransform = Transform3(translation);
0081   double radius(0.5), halfz(10.);
0082   auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
0083   auto pCylinderLayer =
0084       CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
0085   // auto planeSurface = pCylinderLayer->surfaceRepresentation();
0086   BOOST_CHECK_EQUAL(pCylinderLayer->surfaceRepresentation().name(),
0087                     std::string("Acts::CylinderSurface"));
0088 }
0089 
0090 BOOST_AUTO_TEST_SUITE_END()
0091 
0092 }  // namespace Acts::Test::Layers