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 
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 
28 // Create a test context
30 
31 namespace Layers {
32 BOOST_AUTO_TEST_SUITE(Layers)
33 
34 
35 BOOST_AUTO_TEST_CASE(PlaneLayerConstruction) {
36  // default constructor, copy and assignment are all deleted
37  // minimally need a Transform3D and a PlanarBounds object (e.g.
38  // RectangleBounds) to construct
39  Translation3D translation{0., 1., 2.};
40  auto pTransform = Transform3D(translation);
41  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
42  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
43  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
44  BOOST_CHECK_EQUAL(pPlaneLayer->layerType(), LayerType::active);
45  // next level: need an array of Surfaces;
46  // bounds object, rectangle type
47  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
49  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
50  Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds),
51  Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds)};
52  const double thickness(1.0);
54  size_t binsX(2), binsY(4);
55  auto pSurfaceArray = sac.surfaceArrayOnPlane(tgContext, aSurfaces, binsX,
56  binsY, BinningValue::binZ);
57  auto pPlaneLayerFromSurfaces =
58  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray));
59  BOOST_CHECK_EQUAL(pPlaneLayerFromSurfaces->layerType(), LayerType::active);
60  // construct with thickness:
61  auto pPlaneLayerWithThickness = PlaneLayer::create(
62  pTransform, pRectangle, std::move(pSurfaceArray), thickness);
63  BOOST_CHECK_EQUAL(pPlaneLayerWithThickness->thickness(), thickness);
64  // with an approach descriptor...
65  std::unique_ptr<ApproachDescriptor> ad(
66  new GenericApproachDescriptor(aSurfaces));
67  auto adPtr = ad.get();
68  auto pPlaneLayerWithApproachDescriptor =
69  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
70  thickness, std::move(ad));
71  BOOST_CHECK_EQUAL(pPlaneLayerWithApproachDescriptor->approachDescriptor(),
72  adPtr);
73  // with the layerType specified...
74  auto pPlaneLayerWithLayerType =
75  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
76  thickness, std::move(ad), LayerType::passive);
77  BOOST_CHECK_EQUAL(pPlaneLayerWithLayerType->layerType(), LayerType::passive);
78 }
79 
81 BOOST_AUTO_TEST_CASE(PlaneLayerProperties /*, *utf::expected_failures(1)*/) {
82  Translation3D translation{0., 1., 2.};
83  auto pTransform = Transform3D(translation);
84  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
85  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
86  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
87  // auto planeSurface = pPlaneLayer->surfaceRepresentation();
88  BOOST_CHECK_EQUAL(pPlaneLayer->surfaceRepresentation().name(),
89  std::string("Acts::PlaneSurface"));
90 }
91 
92 BOOST_AUTO_TEST_SUITE_END()
93 } // namespace Layers
94 } // namespace Test
95 
96 } // namespace Acts