ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlaneLayerTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PlaneLayerTests.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 
20 
21 #include "LayerStub.hpp"
22 
23 using boost::test_tools::output_test_stream;
24 namespace utf = boost::unit_test;
25 
26 namespace Acts {
27 
28 namespace Test {
29 
30 // Create a test context
32 
33 namespace Layers {
34 BOOST_AUTO_TEST_SUITE(Layers)
35 
36 
37 BOOST_AUTO_TEST_CASE(PlaneLayerConstruction) {
38  // default constructor, copy and assignment are all deleted
39  // minimally need a Transform3D and a PlanarBounds object (e.g.
40  // RectangleBounds) to construct
41  Translation3D translation{0., 1., 2.};
42  auto pTransform = std::make_shared<const Transform3D>(translation);
43  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
44  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
45  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
46  BOOST_CHECK_EQUAL(pPlaneLayer->layerType(), LayerType::active);
47  // next level: need an array of Surfaces;
48  // bounds object, rectangle type
49  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
51  std::shared_ptr<const Transform3D> pNullTransform{};
52  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
53  Surface::makeShared<PlaneSurface>(pNullTransform, rBounds),
54  Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)};
55  const double thickness(1.0);
57  size_t binsX(2), binsY(4);
58  auto pSurfaceArray = sac.surfaceArrayOnPlane(tgContext, aSurfaces, binsX,
59  binsY, BinningValue::binZ);
60  auto pPlaneLayerFromSurfaces =
61  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray));
62  BOOST_CHECK_EQUAL(pPlaneLayerFromSurfaces->layerType(), LayerType::active);
63  // construct with thickness:
64  auto pPlaneLayerWithThickness = PlaneLayer::create(
65  pTransform, pRectangle, std::move(pSurfaceArray), thickness);
66  BOOST_CHECK_EQUAL(pPlaneLayerWithThickness->thickness(), thickness);
67  // with an approach descriptor...
68  std::unique_ptr<ApproachDescriptor> ad(
69  new GenericApproachDescriptor(aSurfaces));
70  auto adPtr = ad.get();
71  auto pPlaneLayerWithApproachDescriptor =
72  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
73  thickness, std::move(ad));
74  BOOST_CHECK_EQUAL(pPlaneLayerWithApproachDescriptor->approachDescriptor(),
75  adPtr);
76  // with the layerType specified...
77  auto pPlaneLayerWithLayerType =
78  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
79  thickness, std::move(ad), LayerType::passive);
80  BOOST_CHECK_EQUAL(pPlaneLayerWithLayerType->layerType(), LayerType::passive);
81 }
82 
84 BOOST_AUTO_TEST_CASE(PlaneLayerProperties /*, *utf::expected_failures(1)*/) {
85  Translation3D translation{0., 1., 2.};
86  auto pTransform = std::make_shared<const Transform3D>(translation);
87  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
88  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
89  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
90  // auto planeSurface = pPlaneLayer->surfaceRepresentation();
91  BOOST_CHECK_EQUAL(pPlaneLayer->surfaceRepresentation().name(),
92  std::string("Acts::PlaneSurface"));
93 }
94 
95 BOOST_AUTO_TEST_SUITE_END()
96 } // namespace Layers
97 } // namespace Test
98 
99 } // namespace Acts