9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
31 #include <initializer_list>
38 class AssertionFailureException;
41 namespace tt = boost::test_tools;
42 using boost::test_tools::output_test_stream;
43 namespace utf = boost::unit_test;
52 BOOST_AUTO_TEST_SUITE(CylinderSurfaces)
58 double radius(1.0), halfZ(10.), halfPhiSector(M_PI / 8.);
62 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ)->
type(),
66 BOOST_CHECK_EQUAL(Surface::makeShared<CylinderSurface>(pTransform, radius,
72 auto pCylinderBounds = std::make_shared<const CylinderBounds>(radius, halfZ);
74 Surface::makeShared<CylinderSurface>(pTransform, pCylinderBounds)->
type(),
79 auto cylinderSurfaceObject =
80 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
81 auto copiedCylinderSurface =
82 Surface::makeShared<CylinderSurface>(*cylinderSurfaceObject);
84 BOOST_CHECK(*copiedCylinderSurface == *cylinderSurfaceObject);
87 auto copiedTransformedCylinderSurface = Surface::makeShared<CylinderSurface>(
89 BOOST_CHECK_EQUAL(copiedTransformedCylinderSurface->type(),
93 BOOST_CHECK_THROW(
auto nullBounds = Surface::makeShared<CylinderSurface>(
94 Transform3::Identity(),
nullptr),
101 double radius(1.0), halfZ(10.);
104 auto cylinderSurfaceObject =
105 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
111 Vector3 binningPosition{0., 1., 2.};
114 binningPosition, 1
e-9);
117 double rootHalf = std::sqrt(0.5);
118 Vector3 globalPosition{rootHalf, 1. - rootHalf, 0.};
119 Vector3 globalPositionZ{rootHalf, 1. - rootHalf, 2.0};
121 Vector3 momentum2{6.6, -3., 2.};
123 expectedFrame << rootHalf, 0., rootHalf, rootHalf, 0., -rootHalf, 0., 1., 0.;
127 expectedFrame, 1
e-6, 1e-9);
131 expectedFrame, 1e-6, 1e-9);
135 Vector3 normal3D = {0., -1., 0.};
139 Vector3 pos45deg = {rootHalf, 1 + rootHalf, 0.};
140 Vector3 pos45degZ = {rootHalf, 1 + rootHalf, 4.};
141 Vector3 normal45deg = {rootHalf, rootHalf, 0.};
144 normal45deg, 1e-6 * rootHalf);
147 normal45deg, 1e-6 * rootHalf);
150 Vector2 positionPiBy2(1.0, 0.);
151 Vector3 normalAtPiBy2{std::cos(1.), std::sin(1.), 0.};
153 normalAtPiBy2, 1e-9);
157 Vector3 symmetryAxis{0., 0., 1.};
162 BOOST_CHECK_EQUAL(cylinderSurfaceObject->bounds().type(),
167 globalPosition = cylinderSurfaceObject->localToGlobal(
169 Vector3 expectedPosition{1, 1, 2};
170 BOOST_CHECK_EQUAL(globalPosition, expectedPosition);
173 localPosition = cylinderSurfaceObject
176 Vector2 expectedLocalPosition{0., 0.};
177 BOOST_CHECK_EQUAL(localPosition, expectedLocalPosition);
181 BOOST_CHECK(cylinderSurfaceObject->isOnSurface(
testContext, globalPosition,
183 BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(
testContext, offSurface,
188 auto sfIntersection = cylinderSurfaceObject->intersect(
191 Intersection3D::Status::reachable};
192 BOOST_CHECK(sfIntersection[0]);
196 expectedIntersect.pathLength(), 1e-9);
198 BOOST_CHECK(sfIntersection[1]);
200 double pn = sfIntersection[0].pathLength();
201 double pa = sfIntersection[1].pathLength();
202 BOOST_CHECK(std::abs(pn) < std::abs(pa));
203 BOOST_CHECK_EQUAL(sfIntersection.object(), cylinderSurfaceObject.get());
209 std::sqrt(3.), 0.01);
212 BOOST_CHECK_EQUAL(cylinderSurfaceObject->name(),
216 boost::test_tools::output_test_stream dumpOuput;
217 cylinderSurfaceObject->toStream(
testContext, dumpOuput);
219 dumpOuput.is_equal(
"Acts::CylinderSurface\n\
220 Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\
221 Rotation: colX = (1.000000, 0.000000, 0.000000)\n\
222 colY = (0.000000, 1.000000, 0.000000)\n\
223 colZ = (0.000000, 0.000000, 1.000000)\n\
224 Bounds : Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, averagePhi, bevelMinZ, bevelMaxZ) = (1.0000000, 10.0000000, 3.1415927, 0.0000000, 0.0000000, 0.0000000)"));
228 double radius(1.0), halfZ(10.);
231 auto cylinderSurfaceObject =
232 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
234 auto cylinderSurfaceObject2 =
235 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
238 BOOST_CHECK(*cylinderSurfaceObject == *cylinderSurfaceObject2);
240 BOOST_TEST_CHECKPOINT(
241 "Create and then assign a CylinderSurface object to the existing one");
243 auto assignedCylinderSurface =
244 Surface::makeShared<CylinderSurface>(Transform3::Identity(), 6.6, 5.4);
245 *assignedCylinderSurface = *cylinderSurfaceObject;
247 BOOST_CHECK(*assignedCylinderSurface == *cylinderSurfaceObject);
253 double radius(1.0), halfZ(10.);
256 auto cylinderSurface =
257 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
259 auto cylinderExtent =
260 cylinderSurface->polyhedronRepresentation(
testContext, 1).extent();
274 double radius(1.0), halfZ(10.);
277 auto cylinderSurfaceObject =
278 Surface::makeShared<CylinderSurface>(pTransform, radius, halfZ);
280 const auto& rotation = pTransform.rotation();
282 const Vector3 localZAxis = rotation.col(2);
287 Vector3 globalPosition{0, 2, 2};
291 const auto& loc3DToLocBound =
292 cylinderSurfaceObject->localCartesianToBoundLocalDerivative(
296 expLoc3DToLocBound << -1, 0, 0, 0, 0, 1;
301 using namespace Acts::UnitLiterals;
308 double averagePhi = 0.1;
311 std::make_shared<CylinderBounds>(
r, halfZ, M_PI / 8, averagePhi);
312 auto cylinder = Acts::Surface::makeShared<CylinderSurface>(trf,
bounds);
314 Vector3 exp =
Vector3{
r * std::cos(averagePhi),
r * std::sin(averagePhi), 0};
328 BOOST_TEST_CONTEXT(
"binValue: " <<
b) {
329 BOOST_CHECK_EQUAL(cylinder->binningPosition(
testContext,
b),
335 BOOST_AUTO_TEST_SUITE_END()