Analysis Software
Documentation for sPHENIX simulation 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 
20 
21 #include <memory>
22 #include <string>
23 
24 namespace Acts {
25 class PlanarBounds;
26 } // namespace Acts
27 
28 using boost::test_tools::output_test_stream;
29 namespace utf = boost::unit_test;
30 
31 namespace Acts {
32 
33 namespace Test {
34 
35 // Create a test context
37 
38 BOOST_AUTO_TEST_SUITE(StrawSurfaces)
40 BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) {
41  // StrawSurface default constructor is deleted
42  //
44  double radius(1.0), halfZ(10.);
45  Translation3 translation{0., 1., 2.};
46  auto pTransform = Transform3(translation);
47  BOOST_CHECK_EQUAL(
48  Surface::makeShared<StrawSurface>(Transform3::Identity(), radius, halfZ)
49  ->type(),
51  BOOST_CHECK_EQUAL(
52  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ)->type(),
54  //
56  auto pLineBounds = std::make_shared<const LineBounds>(radius, halfZ);
57  BOOST_CHECK_EQUAL(
58  Surface::makeShared<StrawSurface>(pTransform, pLineBounds)->type(),
60  //
62  std::shared_ptr<const Acts::PlanarBounds> p =
63  std::make_shared<const RectangleBounds>(1., 10.);
64  DetectorElementStub detElement{pTransform, p, 1.0, nullptr};
65  BOOST_CHECK_EQUAL(
66  Surface::makeShared<StrawSurface>(pLineBounds, detElement)->type(),
68  //
70  auto strawSurfaceObject =
71  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
72  auto copiedStrawSurface =
73  Surface::makeShared<StrawSurface>(*strawSurfaceObject);
74  BOOST_CHECK_EQUAL(copiedStrawSurface->type(), Surface::Straw);
75  BOOST_CHECK(*copiedStrawSurface == *strawSurfaceObject);
76  //
78  auto copiedTransformedStrawSurface = Surface::makeShared<StrawSurface>(
79  tgContext, *strawSurfaceObject, pTransform);
80  BOOST_CHECK_EQUAL(copiedTransformedStrawSurface->type(), Surface::Straw);
81 }
82 //
84 BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) {
86  double radius(1.0), halfZ(10.);
87  Translation3 translation{0., 1., 2.};
88  auto pTransform = Transform3(translation);
89  auto strawSurfaceObject =
90  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
91  //
93  BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw);
94  //
96  BOOST_CHECK_EQUAL(strawSurfaceObject->name(),
97  std::string("Acts::StrawSurface"));
98  //
100  boost::test_tools::output_test_stream dumpOuput;
101  strawSurfaceObject->toStream(tgContext, dumpOuput);
102  BOOST_CHECK(
103  dumpOuput.is_equal("Acts::StrawSurface\n\
104  Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
105  Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
106  colY = (0.000000, 1.000000, 0.000000)\n\
107  colZ = (0.000000, 0.000000, 1.000000)\n\
108  Bounds : Acts::LineBounds: (radius, halflengthInZ) = (1.0000000, 10.0000000)"));
109 }
110 
111 BOOST_AUTO_TEST_CASE(EqualityOperators) {
112  double radius(1.0), halfZ(10.);
113  Translation3 translation{0., 1., 2.};
114  auto pTransform = Transform3(translation);
115  auto strawSurfaceObject =
116  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
117  //
118  auto strawSurfaceObject2 =
119  Surface::makeShared<StrawSurface>(pTransform, radius, halfZ);
120  //
122  BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2);
123  //
124  BOOST_TEST_CHECKPOINT(
125  "Create and then assign a StrawSurface object to the existing one");
127  auto assignedStrawSurface =
128  Surface::makeShared<StrawSurface>(Transform3::Identity(), 6.6, 33.33);
129  *assignedStrawSurface = *strawSurfaceObject;
131  BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject);
132 }
133 
134 BOOST_AUTO_TEST_SUITE_END()
135 
136 } // namespace Test
137 
138 } // namespace Acts