ECCE @ 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-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 
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 
84 BOOST_AUTO_TEST_SUITE_END()
85 } // namespace Layers
86 } // namespace Test
87 
88 } // namespace Acts