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.);
42 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ)->type(),
46 BOOST_CHECK_EQUAL(Surface::makeShared<CylinderSurface>(pTransform,
radius,
52 auto pCylinderBounds = std::make_shared<const CylinderBounds>(
radius, halfZ);
54 Surface::makeShared<CylinderSurface>(pTransform, pCylinderBounds)->type(),
59 auto cylinderSurfaceObject =
60 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
61 auto copiedCylinderSurface =
62 Surface::makeShared<CylinderSurface>(*cylinderSurfaceObject);
64 BOOST_CHECK(*copiedCylinderSurface == *cylinderSurfaceObject);
67 auto copiedTransformedCylinderSurface = Surface::makeShared<CylinderSurface>(
69 BOOST_CHECK_EQUAL(copiedTransformedCylinderSurface->type(),
73 BOOST_CHECK_THROW(
auto nullBounds = Surface::makeShared<CylinderSurface>(
74 Transform3D::Identity(),
nullptr),
81 double radius(1.0), halfZ(10.);
84 auto cylinderSurfaceObject =
85 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
91 Vector3D binningPosition{0., 1., 2.};
94 binningPosition, 1
e-9);
97 double rootHalf = std::sqrt(0.5);
98 Vector3D globalPosition{rootHalf, 1. - rootHalf, 0.};
99 Vector3D globalPositionZ{rootHalf, 1. - rootHalf, 2.0};
103 expectedFrame << rootHalf, 0., rootHalf, rootHalf, 0., -rootHalf, 0., 1., 0.;
107 expectedFrame, 1
e-6, 1e-9);
111 expectedFrame, 1e-6, 1e-9);
119 Vector3D pos45deg = {rootHalf, 1 + rootHalf, 0.};
120 Vector3D pos45degZ = {rootHalf, 1 + rootHalf, 4.};
121 Vector3D normal45deg = {rootHalf, rootHalf, 0.};
124 normal45deg, 1e-6 * rootHalf);
127 normal45deg, 1e-6 * rootHalf);
133 normalAtPiBy2, 1e-9);
142 BOOST_CHECK_EQUAL(cylinderSurfaceObject->bounds().type(),
147 globalPosition = cylinderSurfaceObject->localToGlobal(
150 BOOST_CHECK_EQUAL(globalPosition, expectedPosition);
153 localPosition = cylinderSurfaceObject
156 Vector2D expectedLocalPosition{0., 0.};
157 BOOST_CHECK_EQUAL(localPosition, expectedLocalPosition);
161 BOOST_CHECK(cylinderSurfaceObject->isOnSurface(
testContext, globalPosition,
163 BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(
testContext, offSurface,
168 auto sfIntersection = cylinderSurfaceObject->intersect(
171 Intersection3D::Status::reachable};
172 BOOST_CHECK(
bool(sfIntersection));
174 expectedIntersect.position, 1e-9);
176 expectedIntersect.pathLength, 1e-9);
178 BOOST_CHECK(sfIntersection.alternative);
180 double pn = sfIntersection.intersection.pathLength;
181 double pa = sfIntersection.alternative.pathLength;
182 BOOST_CHECK(pn * pn < pa * pa);
183 BOOST_CHECK_EQUAL(sfIntersection.object, cylinderSurfaceObject.get());
189 std::sqrt(3.), 0.01);
192 BOOST_CHECK_EQUAL(cylinderSurfaceObject->name(),
193 std::string(
"Acts::CylinderSurface"));
196 boost::test_tools::output_test_stream dumpOuput;
197 cylinderSurfaceObject->toStream(
testContext, dumpOuput);
199 dumpOuput.is_equal(
"Acts::CylinderSurface\n\
200 Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
201 Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
202 colY = (0.000000, 1.000000, 0.000000)\n\
203 colZ = (0.000000, 0.000000, 1.000000)\n\
204 Bounds : Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, averagePhi) = (1.0000000, 10.0000000, 3.1415927, 0.0000000)"));
208 double radius(1.0), halfZ(10.);
211 auto cylinderSurfaceObject =
212 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
214 auto cylinderSurfaceObject2 =
215 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
218 BOOST_CHECK(*cylinderSurfaceObject == *cylinderSurfaceObject2);
220 BOOST_TEST_CHECKPOINT(
221 "Create and then assign a CylinderSurface object to the existing one");
223 auto assignedCylinderSurface =
224 Surface::makeShared<CylinderSurface>(Transform3D::Identity(), 6.6, 5.4);
225 *assignedCylinderSurface = *cylinderSurfaceObject;
227 BOOST_CHECK(*assignedCylinderSurface == *cylinderSurfaceObject);
233 double radius(1.0), halfZ(10.);
236 auto cylinderSurface =
237 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
239 auto cylinderExtent =
240 cylinderSurface->polyhedronRepresentation(
testContext, 1).extent();
254 double radius(1.0), halfZ(10.);
257 auto cylinderSurfaceObject =
258 Surface::makeShared<CylinderSurface>(pTransform,
radius, halfZ);
260 const auto& rotation = pTransform.rotation();
262 const Vector3D localZAxis = rotation.col(2);
271 const auto& loc3DToLocBound =
272 cylinderSurfaceObject->localCartesianToBoundLocalDerivative(
276 LocalCartesianToBoundLocalMatrix::Zero();
277 expLoc3DToLocBound << -1, 0, 0, 0, 0, 1;
281 BOOST_AUTO_TEST_SUITE_END()