Analysis Software
Documentation for sPHENIX simulation 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 
17 #include "Acts/Geometry/Layer.hpp"
25 
26 #include <cstddef>
27 #include <memory>
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 using boost::test_tools::output_test_stream;
33 namespace utf = boost::unit_test;
34 
35 namespace Acts {
36 
37 namespace Test {
38 
39 // Create a test context
41 
42 namespace Layers {
43 BOOST_AUTO_TEST_SUITE(Layers)
44 
45 
46 BOOST_AUTO_TEST_CASE(PlaneLayerConstruction) {
47  // default constructor, copy and assignment are all deleted
48  // minimally need a Transform3 and a PlanarBounds object (e.g.
49  // RectangleBounds) to construct
50  Translation3 translation{0., 1., 2.};
51  auto pTransform = Transform3(translation);
52  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
53  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
54  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
55  BOOST_CHECK_EQUAL(pPlaneLayer->layerType(), LayerType::active);
56  // next level: need an array of Surfaces;
57  // bounds object, rectangle type
58  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
60  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
61  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
62  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
63  const double thickness(1.0);
65  size_t binsX(2), binsY(4);
66  auto pSurfaceArray = sac.surfaceArrayOnPlane(tgContext, aSurfaces, binsX,
67  binsY, BinningValue::binZ);
68  auto pPlaneLayerFromSurfaces =
69  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray));
70  BOOST_CHECK_EQUAL(pPlaneLayerFromSurfaces->layerType(), LayerType::active);
71  // construct with thickness:
72  auto pPlaneLayerWithThickness = PlaneLayer::create(
73  pTransform, pRectangle, std::move(pSurfaceArray), thickness);
74  BOOST_CHECK_EQUAL(pPlaneLayerWithThickness->thickness(), thickness);
75  // with an approach descriptor...
76  std::unique_ptr<ApproachDescriptor> ad(
77  new GenericApproachDescriptor(aSurfaces));
78  auto adPtr = ad.get();
79  auto pPlaneLayerWithApproachDescriptor =
80  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
81  thickness, std::move(ad));
82  BOOST_CHECK_EQUAL(pPlaneLayerWithApproachDescriptor->approachDescriptor(),
83  adPtr);
84  // with the layerType specified...
85  auto pPlaneLayerWithLayerType =
86  PlaneLayer::create(pTransform, pRectangle, std::move(pSurfaceArray),
87  thickness, std::move(ad), LayerType::passive);
88  BOOST_CHECK_EQUAL(pPlaneLayerWithLayerType->layerType(), LayerType::passive);
89 }
90 
92 BOOST_AUTO_TEST_CASE(PlaneLayerProperties) {
93  Translation3 translation{0., 1., 2.};
94  auto pTransform = Transform3(translation);
95  const double halfX(10.), halfY(5.); // 20 x 10 rectangle
96  auto pRectangle = std::make_shared<const RectangleBounds>(halfX, halfY);
97  auto pPlaneLayer = PlaneLayer::create(pTransform, pRectangle);
98  // auto planeSurface = pPlaneLayer->surfaceRepresentation();
99  BOOST_CHECK_EQUAL(pPlaneLayer->surfaceRepresentation().name(),
100  std::string("Acts::PlaneSurface"));
101 }
102 
103 BOOST_AUTO_TEST_SUITE_END()
104 } // namespace Layers
105 } // namespace Test
106 
107 } // namespace Acts