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