Analysis Software
Documentation for sPHENIX simulation 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 
18 #include "Acts/Geometry/Layer.hpp"
25 
26 #include <cstddef>
27 #include <limits>
28 #include <memory>
29 #include <vector>
30 
31 #include "../Surfaces/SurfaceStub.hpp"
32 #include "LayerStub.hpp"
33 
34 using boost::test_tools::output_test_stream;
35 namespace utf = boost::unit_test;
36 
37 namespace Acts {
38 
39 namespace Test {
40 namespace Layers {
41 
42 // Build a default context for testing
44 
45 BOOST_AUTO_TEST_SUITE(Layers)
46 
47 
48 
49 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorConstruction) {
50  std::vector<std::shared_ptr<const Surface>> someSurfaces{
51  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
52  BOOST_CHECK_NO_THROW(
53  GenericApproachDescriptor minimallyConstructedApproachDescriptor(
54  someSurfaces));
55  //
56  std::vector<std::shared_ptr<const Layer>> sharedLayers{
57  std::make_shared<LayerStub>(nullptr),
58  std::make_shared<LayerStub>(nullptr)};
59  BOOST_CHECK_NO_THROW(GenericApproachDescriptor sharedLayerApproachDescriptor(
60  {sharedLayers.at(0)->surfaceRepresentation().getSharedPtr(),
61  sharedLayers.at(1)->surfaceRepresentation().getSharedPtr()}));
62 }
63 
65 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorProperties) {
67  0.,
68  0.,
69  0.,
70  };
71  Vector3 zDir{0., 0., 1.};
72  BoundaryCheck bcheck{true};
73  double pLimit = std::numeric_limits<double>::max();
74  double oLimit = -100 * UnitConstants::um;
76  //
77  std::vector<std::shared_ptr<const Surface>> someSurfaces{
78  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
79  GenericApproachDescriptor approachDescriptor(someSurfaces);
80  LayerStub aLayer(nullptr);
81  // registerLayer()
82  BOOST_CHECK_NO_THROW(approachDescriptor.registerLayer(aLayer));
83  // approachSurface
84  SurfaceIntersection surfIntersection = approachDescriptor.approachSurface(
85  tgContext, origin, zDir, bcheck, pLimit, oLimit, tolerance);
86  double expectedIntersection = 20.0; // property of SurfaceStub
87  CHECK_CLOSE_REL(surfIntersection.pathLength(), expectedIntersection, 1e-6);
88  // containedSurfaces()
89  BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().size(),
90  someSurfaces.size());
91 
92  for (size_t i = 0; i < someSurfaces.size(); i++) {
93  BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().at(i),
94  someSurfaces.at(i).get());
95  }
96 }
97 
101 BOOST_AUTO_TEST_CASE(GenericApproachNoOverstepping) {
102  Vector3 origin{0., -0.5, 1.};
103  Vector3 direction{0., 1., 0.};
104  BoundaryCheck bcheck{true};
105  double pLimit = std::numeric_limits<double>::max();
106  double oLimit = -100 * UnitConstants::um;
108 
109  auto conCyl =
110  Surface::makeShared<CylinderSurface>(Transform3::Identity(), 10., 20.);
111 
112  std::vector<std::shared_ptr<const Surface>> approachSurface = {conCyl};
113 
114  GenericApproachDescriptor gad(approachSurface);
115 
116  auto sfIntersection = gad.approachSurface(
117  GeometryContext(), origin, direction, bcheck, pLimit, oLimit, tolerance);
118 
119  // No overstepping allowed, the preferred solution should be the forward one
120  CHECK_CLOSE_ABS(sfIntersection.pathLength(), 10.5, s_epsilon);
121  CHECK_CLOSE_ABS(sfIntersection.position().x(), 0., s_epsilon);
122  CHECK_CLOSE_ABS(sfIntersection.position().y(), 10., s_epsilon);
123  CHECK_CLOSE_ABS(sfIntersection.position().z(), 1., s_epsilon);
124 }
125 
126 BOOST_AUTO_TEST_SUITE_END()
127 } // namespace Layers
128 } // namespace Test
129 
130 } // namespace Acts