Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:20

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