EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GenericApproachDescriptorTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GenericApproachDescriptorTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2020 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 
18 #include "../Surfaces/SurfaceStub.hpp"
19 #include "LayerStub.hpp"
20 
21 using boost::test_tools::output_test_stream;
22 namespace utf = boost::unit_test;
23 
24 namespace Acts {
25 
26 namespace Test {
27 namespace Layers {
28 
29 // Build a default context for testing
31 
32 BOOST_AUTO_TEST_SUITE(Layers)
33 
34 
35 
36 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorConstruction) {
37  std::vector<std::shared_ptr<const Surface>> someSurfaces{
38  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
39  BOOST_CHECK_NO_THROW(
40  GenericApproachDescriptor minimallyConstructedApproachDescriptor(
41  someSurfaces));
42  //
43  std::vector<std::shared_ptr<const Layer>> sharedLayers{
44  std::make_shared<LayerStub>(nullptr),
45  std::make_shared<LayerStub>(nullptr)};
46  BOOST_CHECK_NO_THROW(GenericApproachDescriptor sharedLayerApproachDescriptor(
47  {sharedLayers.at(0)->surfaceRepresentation().getSharedPtr(),
48  sharedLayers.at(1)->surfaceRepresentation().getSharedPtr()}));
49 }
50 
52 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorProperties,
53  *utf::expected_failures(1)) {
55  0.,
56  0.,
57  0.,
58  };
59  Vector3D zDir{0., 0., 1.};
60  BoundaryCheck bcheck{true};
61  //
62  std::vector<std::shared_ptr<const Surface>> someSurfaces{
63  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
64  GenericApproachDescriptor approachDescriptor(someSurfaces);
65  LayerStub aLayer(nullptr);
66  // registerLayer()
67  BOOST_CHECK_NO_THROW(approachDescriptor.registerLayer(aLayer));
68  // approachSurface
69  SurfaceIntersection surfIntersection =
70  approachDescriptor.approachSurface(tgContext, origin, zDir, bcheck);
71  double expectedIntersection = 20.0; // property of SurfaceStub
72  CHECK_CLOSE_REL(surfIntersection.intersection.pathLength,
73  expectedIntersection, 1e-6);
74  // containedSurfaces()
75  BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().size(),
76  someSurfaces.size());
77 
78  for (size_t i = 0; i < someSurfaces.size(); i++) {
79  BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().at(i),
80  someSurfaces.at(i).get());
81  }
82 }
83 
87 BOOST_AUTO_TEST_CASE(GenericApproachNoOverstepping) {
88  Vector3D origin{0., -0.5, 1.};
89  Vector3D direction{0., 1., 0.};
90  BoundaryCheck bcheck{true};
91 
92  auto conCyl =
93  Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 10., 20.);
94 
95  std::vector<std::shared_ptr<const Surface>> approachSurface = {conCyl};
96 
97  GenericApproachDescriptor gad(approachSurface);
98 
99  auto sfIntersection =
100  gad.approachSurface(GeometryContext(), origin, direction, bcheck);
101 
102  // No overstepping allowed, the preferred solution should be the forward one
103  CHECK_CLOSE_ABS(sfIntersection.intersection.pathLength, 10.5, s_epsilon);
104  CHECK_CLOSE_ABS(sfIntersection.intersection.position.x(), 0., s_epsilon);
105  CHECK_CLOSE_ABS(sfIntersection.intersection.position.y(), 10., s_epsilon);
106  CHECK_CLOSE_ABS(sfIntersection.intersection.position.z(), 1., s_epsilon);
107 
108  CHECK_CLOSE_ABS(sfIntersection.alternative.pathLength, -9.5, s_epsilon);
109  CHECK_CLOSE_ABS(sfIntersection.alternative.position.x(), 0., s_epsilon);
110  CHECK_CLOSE_ABS(sfIntersection.alternative.position.y(), -10., s_epsilon);
111  CHECK_CLOSE_ABS(sfIntersection.alternative.position.z(), 1., s_epsilon);
112 }
113 
114 BOOST_AUTO_TEST_SUITE_END()
115 } // namespace Layers
116 } // namespace Test
117 
118 } // namespace Acts