ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StrawSurfaceTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StrawSurfaceTests.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 
13 #include <limits>
14 
21 
22 using boost::test_tools::output_test_stream;
23 namespace utf = boost::unit_test;
24 
25 namespace Acts {
26 
27 namespace Test {
28 
29 // Create a test context
31 
32 BOOST_AUTO_TEST_SUITE(StrawSurfaces)
34 BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) {
35  // StrawSurface default constructor is deleted
36  //
38  double radius(1.0), halfZ(10.);
39  Translation3D translation{0., 1., 2.};
40  auto pTransform = std::make_shared<const Transform3D>(translation);
41  std::shared_ptr<const Transform3D> pNullTransform{};
42  BOOST_CHECK_EQUAL(
43  Surface::makeShared<StrawSurface>(pNullTransform, radius, halfZ)->type(),
45  BOOST_CHECK_EQUAL(
46  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ)->type(),
48  //
50  auto pLineBounds = std::make_shared<const LineBounds>(radius, halfZ);
51  BOOST_CHECK_EQUAL(
52  Surface::makeShared<StrawSurface>(pTransform, pLineBounds)->type(),
54  //
56  std::shared_ptr<const Acts::PlanarBounds> p =
57  std::make_shared<const RectangleBounds>(1., 10.);
58  DetectorElementStub detElement{pTransform, p, 1.0, nullptr};
59  BOOST_CHECK_EQUAL(
60  Surface::makeShared<StrawSurface>(pLineBounds, detElement)->type(),
62  //
64  auto strawSurfaceObject =
65  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
66  auto copiedStrawSurface =
67  Surface::makeShared<StrawSurface>(*strawSurfaceObject);
68  BOOST_CHECK_EQUAL(copiedStrawSurface->type(), Surface::Straw);
69  BOOST_CHECK(*copiedStrawSurface == *strawSurfaceObject);
70  //
72  auto copiedTransformedStrawSurface = Surface::makeShared<StrawSurface>(
73  tgContext, *strawSurfaceObject, *pTransform);
74  BOOST_CHECK_EQUAL(copiedTransformedStrawSurface->type(), Surface::Straw);
75 }
76 //
78 BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) {
80  double radius(1.0), halfZ(10.);
81  Translation3D translation{0., 1., 2.};
82  auto pTransform = std::make_shared<const Transform3D>(translation);
83  auto strawSurfaceObject =
84  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
85  //
87  BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw);
88  //
90  BOOST_CHECK_EQUAL(strawSurfaceObject->name(),
91  std::string("Acts::StrawSurface"));
92  //
94  boost::test_tools::output_test_stream dumpOuput;
95  strawSurfaceObject->toStream(tgContext, dumpOuput);
96  BOOST_CHECK(
97  dumpOuput.is_equal("Acts::StrawSurface\n\
98  Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
99  Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
100  colY = (0.000000, 1.000000, 0.000000)\n\
101  colZ = (0.000000, 0.000000, 1.000000)\n\
102  Bounds : Acts::LineBounds: (radius, halflengthInZ) = (1.0000000, 10.0000000)"));
103 }
104 
105 BOOST_AUTO_TEST_CASE(EqualityOperators) {
106  double radius(1.0), halfZ(10.);
107  Translation3D translation{0., 1., 2.};
108  auto pTransform = std::make_shared<const Transform3D>(translation);
109  auto strawSurfaceObject =
110  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
111  //
112  auto strawSurfaceObject2 =
113  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
114  //
116  BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2);
117  //
118  BOOST_TEST_CHECKPOINT(
119  "Create and then assign a StrawSurface object to the existing one");
121  auto assignedStrawSurface =
122  Surface::makeShared<StrawSurface>(nullptr, 6.6, 33.33);
123  *assignedStrawSurface = *strawSurfaceObject;
125  BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject);
126 }
127 
128 BOOST_AUTO_TEST_SUITE_END()
129 
130 } // namespace Test
131 
132 } // namespace Acts