9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
35 #include <initializer_list>
41 namespace utf = boost::unit_test;
42 namespace tt = boost::test_tools;
45 class AssertionFailureException;
52 BOOST_AUTO_TEST_SUITE(Surfaces)
57 double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.);
61 Surface::makeShared<DiscSurface>(Transform3::Identity(), rMin, rMax));
67 Surface::makeShared<DiscSurface>(pTransform, rMin, rMax, halfPhiSector));
70 auto anotherDiscSurface =
71 Surface::makeShared<DiscSurface>(pTransform, rMin, rMax, halfPhiSector);
76 auto copiedSurface = Surface::makeShared<DiscSurface>(*anotherDiscSurface);
77 BOOST_TEST_MESSAGE(
"Copy constructed DiscSurface ok");
80 BOOST_CHECK_NO_THROW(Surface::makeShared<DiscSurface>(
81 tgContext, *anotherDiscSurface, pTransform));
86 auto nullBounds = Surface::makeShared<DiscSurface>(
nullptr, detElem),
93 double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.);
94 auto discSurfaceObject = Surface::makeShared<DiscSurface>(
95 Transform3::Identity(), rMin, rMax, halfPhiSector);
102 BOOST_CHECK_EQUAL(discSurfaceObject->normal(
tgContext), zAxis);
106 BOOST_CHECK_EQUAL(discSurfaceObject->normal(
tgContext, lpos), zAxis);
119 Vector3 ignoredMomentum{0., 0., 0.};
121 Vector3 point3DNotInSector{0.0, 1.2, 0};
122 Vector3 point3DOnSurface{1.2, 0.0, 0};
123 BOOST_CHECK(!discSurfaceObject->isOnSurface(
124 tgContext, point3DNotInSector, ignoredMomentum,
true));
125 BOOST_CHECK(discSurfaceObject->isOnSurface(
tgContext, point3DOnSurface,
126 ignoredMomentum,
true));
129 Vector3 returnedPosition{10.9, 8.7, 6.5};
130 Vector3 expectedPosition{1.2, 0, 0};
132 Vector2 rPhiNotInSector{1.2, M_PI};
134 discSurfaceObject->localToGlobal(
tgContext, rPhiOnDisc, ignoredMomentum);
137 returnedPosition = discSurfaceObject->localToGlobal(
138 tgContext, rPhiNotInSector, ignoredMomentum);
139 Vector3 expectedNonPosition{-1.2, 0, 0};
143 Vector2 returnedLocalPosition{33., 44.};
144 Vector2 expectedLocalPosition{1.2, 0.0};
145 returnedLocalPosition =
147 ->globalToLocal(
tgContext, point3DOnSurface, ignoredMomentum)
152 returnedLocalPosition =
154 ->globalToLocal(
tgContext, point3DNotInSector, ignoredMomentum)
157 Vector3 pointOutsideR{0.0, 100., 0};
158 returnedLocalPosition =
160 ->globalToLocal(
tgContext, pointOutsideR, ignoredMomentum)
164 Vector2 rPhi1_1{std::sqrt(2.), M_PI / 4.};
170 CHECK_CLOSE_REL(discSurfaceObject->localCartesianToPolar(cartesian1_1),
174 CHECK_CLOSE_REL(discSurfaceObject->localPolarToLocalCartesian(rPhi1_1),
178 Vector3 cartesian3D1_1{1., 1., 0.};
180 discSurfaceObject->localCartesianToGlobal(
tgContext, cartesian1_1),
181 cartesian3D1_1, 1
e-6);
185 discSurfaceObject->globalToLocalCartesian(
tgContext, cartesian3D1_1),
189 double projected3DMomentum = std::sqrt(3.) * 1.e6;
191 projected3DMomentum};
192 Vector3 ignoredPosition{1.1, 2.2, 3.3};
198 Vector3 globalPosition{1.2, 0.0, -10.};
200 Vector3 expected{1.2, 0.0, 0.0};
204 auto sfIntersection =
205 discSurfaceObject->intersect(
tgContext, globalPosition, direction,
false)
208 Intersection3D::Status::reachable};
209 BOOST_CHECK(
bool(sfIntersection));
210 CHECK_CLOSE_ABS(sfIntersection.position(), expectedIntersect.position(),
212 CHECK_CLOSE_ABS(sfIntersection.pathLength(), expectedIntersect.pathLength(),
214 BOOST_CHECK_EQUAL(sfIntersection.object(), discSurfaceObject.get());
218 boost::test_tools::output_test_stream nameOuput;
219 nameOuput << discSurfaceObject->name();
220 BOOST_CHECK(nameOuput.is_equal(
"Acts::DiscSurface"));
226 double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.);
227 auto discSurfaceObject = Surface::makeShared<DiscSurface>(
228 Transform3::Identity(), rMin, rMax, halfPhiSector);
230 Surface::makeShared<DiscSurface>(Transform3::Identity(), 2.2, 4.4, 0.07);
232 BOOST_CHECK_NO_THROW(*assignedDisc = *discSurfaceObject);
233 BOOST_CHECK((*assignedDisc) == (*discSurfaceObject));
238 double rMin(1.0), rMax(5.0);
241 Surface::makeShared<DiscSurface>(Transform3::Identity(), 0., rMax);
242 auto pDiscExtent = pDisc->polyhedronRepresentation(
tgContext, 1).extent();
256 Surface::makeShared<DiscSurface>(Transform3::Identity(), rMin, rMax);
257 auto pRingExtent = pRing->polyhedronRepresentation(
tgContext, 1).extent();
273 double rMin(1.0), rMax(5.0), halfPhiSector(M_PI / 8.);
274 auto discSurfaceObject =
275 Surface::makeShared<DiscSurface>(
transform, rMin, rMax, halfPhiSector);
277 const auto& rotation = transform.rotation();
279 const Vector3 localZAxis = rotation.col(2);
284 Vector3 globalPosition{0, 4, 2};
289 parameters.head<3>() = globalPosition;
290 parameters.segment<3>(
eFreeDir0) = direction;
294 discSurfaceObject->alignmentToPathDerivative(
tgContext, parameters);
297 expAlignToPath << 0, 0, 1, 3, 0, 0;
303 const auto& loc3DToLocBound =
304 discSurfaceObject->localCartesianToBoundLocalDerivative(
tgContext,
308 expLoc3DToLocBound << 0, 1, 0, -1.0 / 3, 0, 0;
313 using namespace Acts::UnitLiterals;
323 auto bounds = std::make_shared<RadialBounds>(
minR,
maxR, M_PI / 8, 0.1);
324 auto disc = Acts::Surface::makeShared<Acts::DiscSurface>(trf,
bounds);
332 BOOST_CHECK_EQUAL(bp, exp);
333 BOOST_CHECK_EQUAL(disc->binningPositionValue(
tgContext,
binR),
337 BOOST_CHECK_EQUAL(bp, exp);
342 BOOST_TEST_CONTEXT(
"binValue: " <<
b) {
343 BOOST_CHECK_EQUAL(disc->binningPosition(
tgContext,
b),
351 double minPhiRel = -0.3;
352 double maxPhiRel = 0.2;
354 auto bounds = std::make_shared<AnnulusBounds>(
minR,
maxR, minPhiRel,
357 auto disc = Acts::Surface::makeShared<Acts::DiscSurface>(trf,
bounds);
365 BOOST_CHECK_EQUAL(bp, exp);
368 BOOST_CHECK_EQUAL(bp, exp);
371 BOOST_TEST_CONTEXT(
"binValue: " <<
b) {
372 BOOST_CHECK_EQUAL(disc->binningPosition(
tgContext,
b),
379 BOOST_AUTO_TEST_SUITE_END()