9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
21 namespace tt = boost::test_tools;
22 using boost::test_tools::output_test_stream;
23 namespace utf = boost::unit_test;
32 BOOST_AUTO_TEST_SUITE(CylinderSurfaces)
38 double radius(1.0), halfZ(10.), halfPhiSector(
M_PI / 8.);
40 auto pTransform = std::make_shared<const Transform3D>(translation);
41 std::shared_ptr<const Transform3D> pNullTransform{};
43 Surface::makeShared<CylinderSurface>(pNullTransform,
radius, halfZ)
47 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ)->type(),
51 BOOST_CHECK_EQUAL(Surface::makeShared<CylinderSurface>(pTransform,
radius,
57 auto pCylinderBounds = std::make_shared<const CylinderBounds>(
radius, halfZ);
59 Surface::makeShared<CylinderSurface>(pTransform, pCylinderBounds)->type(),
64 auto cylinderSurfaceObject =
65 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
66 auto copiedCylinderSurface =
67 Surface::makeShared<CylinderSurface>(*cylinderSurfaceObject);
69 BOOST_CHECK(*copiedCylinderSurface == *cylinderSurfaceObject);
72 auto copiedTransformedCylinderSurface = Surface::makeShared<CylinderSurface>(
74 BOOST_CHECK_EQUAL(copiedTransformedCylinderSurface->type(),
79 auto nullBounds = Surface::makeShared<CylinderSurface>(
nullptr,
nullptr),
86 double radius(1.0), halfZ(10.);
88 auto pTransform = std::make_shared<const Transform3D>(translation);
89 auto cylinderSurfaceObject =
90 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
96 Vector3D binningPosition{0., 1., 2.};
99 binningPosition, 1
e-9);
102 double rootHalf = std::sqrt(0.5);
103 Vector3D globalPosition{rootHalf, 1. - rootHalf, 0.};
104 Vector3D globalPositionZ{rootHalf, 1. - rootHalf, 2.0};
108 expectedFrame << rootHalf, 0., rootHalf, rootHalf, 0., -rootHalf, 0., 1., 0.;
112 expectedFrame, 1
e-6, 1e-9);
116 expectedFrame, 1e-6, 1e-9);
124 Vector3D pos45deg = {rootHalf, 1 + rootHalf, 0.};
125 Vector3D pos45degZ = {rootHalf, 1 + rootHalf, 4.};
126 Vector3D normal45deg = {rootHalf, rootHalf, 0.};
129 normal45deg, 1e-6 * rootHalf);
132 normal45deg, 1e-6 * rootHalf);
136 Vector3D normalAtPiBy2{std::cos(1.), std::sin(1.), 0.};
138 normalAtPiBy2, 1e-9);
147 BOOST_CHECK_EQUAL(cylinderSurfaceObject->bounds().type(),
155 BOOST_CHECK_EQUAL(globalPosition, expectedPosition);
160 Vector2D expectedLocalPosition{0., 0.};
161 BOOST_CHECK_EQUAL(localPosition, expectedLocalPosition);
165 BOOST_CHECK(cylinderSurfaceObject->isOnSurface(
testContext, globalPosition,
167 BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(
testContext, offSurface,
172 auto intersect = cylinderSurfaceObject->intersectionEstimate(
175 Intersection::Status::reachable};
177 BOOST_CHECK(
bool(intersect));
179 CHECK_CLOSE_ABS(intersect.pathLength, expectedIntersect.pathLength, 1e-9);
182 auto surfaceIntersect = cylinderSurfaceObject->intersect(
184 BOOST_CHECK(
bool(surfaceIntersect));
186 BOOST_CHECK(surfaceIntersect.alternative);
188 double pn = surfaceIntersect.intersection.pathLength;
189 double pa = surfaceIntersect.alternative.pathLength;
190 BOOST_CHECK(pn * pn < pa * pa);
195 std::sqrt(3.), 0.01);
198 BOOST_CHECK_EQUAL(cylinderSurfaceObject->name(),
199 std::string(
"Acts::CylinderSurface"));
202 boost::test_tools::output_test_stream dumpOuput;
203 cylinderSurfaceObject->toStream(
testContext, dumpOuput);
205 dumpOuput.is_equal(
"Acts::CylinderSurface\n\
206 Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
207 Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
208 colY = (0.000000, 1.000000, 0.000000)\n\
209 colZ = (0.000000, 0.000000, 1.000000)\n\
210 Bounds : Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, averagePhi) = (1.0000000, 10.0000000, 3.1415927, 0.0000000)"));
214 double radius(1.0), halfZ(10.);
216 auto pTransform = std::make_shared<const Transform3D>(translation);
217 auto cylinderSurfaceObject =
218 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
220 auto cylinderSurfaceObject2 =
221 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
224 BOOST_CHECK(*cylinderSurfaceObject == *cylinderSurfaceObject2);
226 BOOST_TEST_CHECKPOINT(
227 "Create and then assign a CylinderSurface object to the existing one");
229 auto assignedCylinderSurface =
230 Surface::makeShared<CylinderSurface>(
nullptr, 6.6, 5.4);
231 *assignedCylinderSurface = *cylinderSurfaceObject;
233 BOOST_CHECK(*assignedCylinderSurface == *cylinderSurfaceObject);
236 BOOST_AUTO_TEST_SUITE_END()