Back to home page

sPhenix code displayed by LXR

 
 

    


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

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/GenericApproachDescriptor.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/Layer.hpp"
0017 #include "Acts/Surfaces/PlaneSurface.hpp"
0018 #include "Acts/Surfaces/RectangleBounds.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceArray.hpp"
0021 
0022 #include <cmath>
0023 #include <memory>
0024 #include <utility>
0025 #include <vector>
0026 
0027 #include "../Surfaces/SurfaceStub.hpp"
0028 #include "LayerStub.hpp"
0029 
0030 namespace Acts::Test {
0031 
0032 // Create a test context
0033 GeometryContext tgContext = GeometryContext();
0034 
0035 namespace Layers {
0036 
0037 BOOST_AUTO_TEST_SUITE(Layers)
0038 
0039 /// Unit test for creating compliant/non-compliant Layer object
0040 BOOST_AUTO_TEST_CASE(LayerConstruction) {
0041   // Descendant Layer objects also inherit from Surface objects, which
0042   // delete the default constructor
0043   //
0044   /// Minimum possible construction (default constructor is deleted)
0045   LayerStub minallyConstructed(nullptr);
0046   BOOST_CHECK(minallyConstructed.constructedOk());
0047   /// Need an approach descriptor for the next level of complexity:
0048   std::vector<std::shared_ptr<const Surface>> aSurfaces{
0049       Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
0050   std::unique_ptr<ApproachDescriptor> ad(
0051       new GenericApproachDescriptor(aSurfaces));
0052   const double thickness(1.0);
0053   LayerStub approachDescriptorConstructed(nullptr, thickness, std::move(ad));
0054   /// Construction with (minimal) approach descriptor
0055   BOOST_CHECK(approachDescriptorConstructed.constructedOk());
0056   // Copy construction is deleted
0057 }
0058 
0059 /// Unit test for testing Layer properties
0060 BOOST_AUTO_TEST_CASE(LayerProperties) {
0061   // Make a dummy layer to play with
0062   // bounds object, rectangle type
0063   auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
0064   /// Constructor
0065   const std::vector<std::shared_ptr<const Surface>> aSurfaces{
0066       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
0067       Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
0068   std::unique_ptr<ApproachDescriptor> ad(
0069       new GenericApproachDescriptor(aSurfaces));
0070   auto adPtr = ad.get();
0071   const double thickness(1.0);
0072   LayerStub layerStub(nullptr, thickness, std::move(ad));
0073   //
0074   /// surfaceArray()
0075   BOOST_CHECK_EQUAL(layerStub.surfaceArray(), nullptr);
0076   /// thickness()
0077   BOOST_CHECK_EQUAL(layerStub.thickness(), thickness);
0078   // onLayer() is templated; can't find implementation!
0079   /// isOnLayer() (delegates to the Surface 'isOnSurface()')
0080   const Vector3 pos{0.0, 0.0, 0.0};
0081   const Vector3 pos2{100., 100., std::nan("")};
0082   BOOST_CHECK(layerStub.isOnLayer(tgContext, pos));
0083   // this should fail, but globalToLocal has hard-coded return values, so it
0084   // succeeds
0085   BOOST_CHECK(layerStub.isOnLayer(tgContext, pos2));
0086   /// approachDescriptor(), retrieved as a pointer.
0087   BOOST_CHECK_EQUAL(layerStub.approachDescriptor(), adPtr);
0088   const Vector3 gpos{0., 0., 1.0};
0089   const Vector3 direction{0., 0., -1.};
0090   /// nextLayer()
0091   BOOST_CHECK(!(layerStub.nextLayer(tgContext, gpos, direction)));
0092   /// trackingVolume()
0093   BOOST_CHECK(!layerStub.trackingVolume());
0094   // BOOST_TEST_CHECKPOINT("Before ending test");
0095   // deletion results in "memory access violation at address: 0x00000071: no
0096   // mapping at fault address"
0097   // delete abstractVolumePtr;
0098   /// layerType()
0099   BOOST_CHECK_EQUAL(layerStub.layerType(), LayerType::passive);
0100 }
0101 
0102 BOOST_AUTO_TEST_SUITE_END()
0103 }  // namespace Layers
0104 }  // namespace Acts::Test