Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CylinderLayerTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CylinderLayerTests.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 
18 #include "Acts/Geometry/Layer.hpp"
26 
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(CylinderLayerConstruction) {
47  // default constructor, copy and assignment are all deleted
48  // minimally need a Transform3 and a PlanarBounds object (e.g.
49  // CylinderBounds) to construct
50  Translation3 translation{0., 1., 2.};
51  auto pTransform = Transform3(translation);
52  double radius(0.5), halfz(10.);
53  auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
54  auto pCylinderLayer =
55  CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
56  BOOST_CHECK_EQUAL(pCylinderLayer->layerType(), LayerType::passive);
57  // next level: need an array of Surfaces;
58  // bounds object, rectangle type
59  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
61  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
62  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds),
63  Surface::makeShared<PlaneSurface>(Transform3::Identity(), rBounds)};
64  const double thickness(1.0);
65  auto pCylinderLayerFromSurfaces =
66  CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
67  BOOST_CHECK_EQUAL(pCylinderLayerFromSurfaces->layerType(),
69  // construct with thickness:
70  auto pCylinderLayerWithThickness =
71  CylinderLayer::create(pTransform, pCylinder, nullptr, thickness);
72  CHECK_CLOSE_REL(pCylinderLayerWithThickness->thickness(), thickness, 1e-6);
73  // with an approach descriptor...
74  std::unique_ptr<ApproachDescriptor> ad(
75  new GenericApproachDescriptor(aSurfaces));
76  auto adPtr = ad.get();
77  auto pCylinderLayerWithApproachDescriptor = CylinderLayer::create(
78  pTransform, pCylinder, nullptr, thickness, std::move(ad));
79  BOOST_CHECK_EQUAL(pCylinderLayerWithApproachDescriptor->approachDescriptor(),
80  adPtr);
81  // with the layerType specified...
82  auto pCylinderLayerWithLayerType =
83  CylinderLayer::create(pTransform, pCylinder, nullptr, thickness,
85  BOOST_CHECK_EQUAL(pCylinderLayerWithLayerType->layerType(),
87 }
88 
90 BOOST_AUTO_TEST_CASE(CylinderLayerProperties) {
91  Translation3 translation{0., 1., 2.};
92  auto pTransform = Transform3(translation);
93  double radius(0.5), halfz(10.);
94  auto pCylinder = std::make_shared<const CylinderBounds>(radius, halfz);
95  auto pCylinderLayer =
96  CylinderLayer::create(pTransform, pCylinder, nullptr, 1.);
97  // auto planeSurface = pCylinderLayer->surfaceRepresentation();
98  BOOST_CHECK_EQUAL(pCylinderLayer->surfaceRepresentation().name(),
99  std::string("Acts::CylinderSurface"));
100 }
101 
102 BOOST_AUTO_TEST_SUITE_END()
103 } // namespace Layers
104 } // namespace Test
105 
106 } // namespace Acts