Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayerTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LayerTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
17 #include "Acts/Geometry/Layer.hpp"
22 
23 #include <cmath>
24 #include <memory>
25 #include <utility>
26 #include <vector>
27 
28 #include "../Surfaces/SurfaceStub.hpp"
29 #include "LayerStub.hpp"
30 
31 using boost::test_tools::output_test_stream;
32 namespace utf = boost::unit_test;
33 
34 namespace Acts {
35 
36 namespace Test {
37 
38 // Create a test context
40 
41 namespace Layers {
42 
43 BOOST_AUTO_TEST_SUITE(Layers)
44 
45 
46 BOOST_AUTO_TEST_CASE(LayerConstruction) {
47  // Descendant Layer objects also inherit from Surface objects, which
48  // delete the default constructor
49  //
51  LayerStub minallyConstructed(nullptr);
52  BOOST_CHECK(minallyConstructed.constructedOk());
54  std::vector<std::shared_ptr<const Surface>> aSurfaces{
55  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
56  std::unique_ptr<ApproachDescriptor> ad(
57  new GenericApproachDescriptor(aSurfaces));
58  const double thickness(1.0);
59  LayerStub approachDescriptorConstructed(nullptr, thickness, std::move(ad));
61  BOOST_CHECK(approachDescriptorConstructed.constructedOk());
62  // Copy construction is deleted
63 }
64 
66 BOOST_AUTO_TEST_CASE(LayerProperties) {
67  // Make a dummy layer to play with
68  // bounds object, rectangle type
69  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
71  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
72  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
73  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
74  std::unique_ptr<ApproachDescriptor> ad(
75  new GenericApproachDescriptor(aSurfaces));
76  auto adPtr = ad.get();
77  const double thickness(1.0);
78  LayerStub layerStub(nullptr, thickness, std::move(ad));
79  //
81  BOOST_CHECK_EQUAL(layerStub.surfaceArray(), nullptr);
83  BOOST_CHECK_EQUAL(layerStub.thickness(), thickness);
84  // onLayer() is templated; can't find implementation!
86  const Vector3 pos{0.0, 0.0, 0.0};
87  const Vector3 pos2{100., 100., std::nan("")};
88  BOOST_CHECK(layerStub.isOnLayer(tgContext, pos));
89  // this should fail, but globalToLocal has hard-coded return values, so it
90  // succeeds
91  BOOST_CHECK(layerStub.isOnLayer(tgContext, pos2));
93  BOOST_CHECK_EQUAL(layerStub.approachDescriptor(), adPtr);
94  const Vector3 gpos{0., 0., 1.0};
95  const Vector3 direction{0., 0., -1.};
97  BOOST_CHECK(!(layerStub.nextLayer(tgContext, gpos, direction)));
99  BOOST_CHECK(!layerStub.trackingVolume());
100  // BOOST_TEST_CHECKPOINT("Before ending test");
101  // deletion results in "memory access violation at address: 0x00000071: no
102  // mapping at fault address"
103  // delete abstractVolumePtr;
105  BOOST_CHECK_EQUAL(layerStub.layerType(), LayerType::passive);
106 }
107 
108 BOOST_AUTO_TEST_SUITE_END()
109 } // namespace Layers
110 } // namespace Test
111 
112 } // namespace Acts