File indexing completed on 2026-12-04 09:48:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/output_test_stream.hpp>
0011 #include <boost/test/unit_test.hpp>
0012
0013 #include "Acts/Definitions/Algebra.hpp"
0014 #include "Acts/Definitions/Alignment.hpp"
0015 #include "Acts/Definitions/Tolerance.hpp"
0016 #include "Acts/Definitions/Units.hpp"
0017 #include "Acts/Geometry/Extent.hpp"
0018 #include "Acts/Geometry/GeometryContext.hpp"
0019 #include "Acts/Geometry/Polyhedron.hpp"
0020 #include "Acts/Material/BinnedSurfaceMaterial.hpp"
0021 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0022 #include "Acts/Material/Material.hpp"
0023 #include "Acts/Material/MaterialSlab.hpp"
0024 #include "Acts/Surfaces/AnnulusBounds.hpp"
0025 #include "Acts/Surfaces/DiscSurface.hpp"
0026 #include "Acts/Surfaces/DiscTrapezoidBounds.hpp"
0027 #include "Acts/Surfaces/RadialBounds.hpp"
0028 #include "Acts/Surfaces/Surface.hpp"
0029 #include "Acts/Surfaces/SurfaceBounds.hpp"
0030 #include "Acts/Surfaces/SurfaceMergingException.hpp"
0031 #include "Acts/Utilities/AxisDefinitions.hpp"
0032 #include "Acts/Utilities/BinUtility.hpp"
0033 #include "Acts/Utilities/BinningType.hpp"
0034 #include "Acts/Utilities/Diagnostics.hpp"
0035 #include "Acts/Utilities/Intersection.hpp"
0036 #include "Acts/Utilities/Result.hpp"
0037 #include "Acts/Utilities/ThrowAssert.hpp"
0038 #include "Acts/Utilities/detail/periodic.hpp"
0039 #include "ActsTests/CommonHelpers/DetectorElementStub.hpp"
0040 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0041 #include "ActsTests/CommonHelpers/SurfaceDerivatives.hpp"
0042
0043 #include <cmath>
0044 #include <memory>
0045 #include <numbers>
0046 #include <string>
0047 #include <vector>
0048
0049 using namespace Acts;
0050 using namespace Acts::UnitLiterals;
0051
0052 namespace ActsTests {
0053
0054 GeometryContext tgContext = GeometryContext::dangerouslyDefaultConstruct();
0055 auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE);
0056
0057 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0058
0059 BOOST_AUTO_TEST_CASE(DiscSurfaceConstruction) {
0060
0061
0062
0063 const double rMin = 1.;
0064 const double rMax = 5.;
0065 const double halfPhiSector = std::numbers::pi / 8.;
0066
0067
0068 BOOST_CHECK_NO_THROW(
0069 Surface::makeShared<DiscSurface>(Transform3::Identity(), rMin, rMax));
0070
0071
0072 Translation3 translation{0., 1., 2.};
0073 auto pTransform = Transform3(translation);
0074 BOOST_CHECK_NO_THROW(
0075 Surface::makeShared<DiscSurface>(pTransform, rMin, rMax, halfPhiSector));
0076
0077
0078 auto anotherDiscSurface =
0079 Surface::makeShared<DiscSurface>(pTransform, rMin, rMax, halfPhiSector);
0080
0081
0082
0083 auto copiedSurface = Surface::makeShared<DiscSurface>(*anotherDiscSurface);
0084 BOOST_TEST_MESSAGE("Copy constructed DiscSurface ok");
0085
0086
0087 BOOST_CHECK_NO_THROW(Surface::makeShared<DiscSurface>(
0088 tgContext, *anotherDiscSurface, pTransform));
0089
0090
0091 DetectorElementStub detElem;
0092 BOOST_CHECK_THROW(
0093 auto nullBounds = Surface::makeShared<DiscSurface>(nullptr, detElem),
0094 AssertionFailureException);
0095 }
0096
0097
0098 BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) {
0099 const double rMin = 1.;
0100 const double rMax = 5.;
0101 const double halfPhiSector = std::numbers::pi / 8.;
0102
0103 const Vector3 origin3D{0, 0, 0};
0104
0105 auto discSurfaceObject = Surface::makeShared<DiscSurface>(
0106 Transform3::Identity(), rMin, rMax, halfPhiSector);
0107
0108
0109 BOOST_CHECK_EQUAL(discSurfaceObject->type(), Surface::Disc);
0110
0111
0112 Vector3 zAxis{0, 0, 1};
0113 BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext), zAxis);
0114
0115
0116 Vector2 lpos(2., 0.05);
0117 BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext, lpos), zAxis);
0118
0119
0120 BOOST_CHECK_EQUAL(
0121 discSurfaceObject->referencePosition(tgContext, AxisDirection::AxisRPhi),
0122 origin3D);
0123
0124
0125 BOOST_CHECK_EQUAL(discSurfaceObject->bounds().type(), SurfaceBounds::eDisc);
0126
0127 Vector3 ignoredMomentum{0., 0., 0.};
0128
0129 Vector3 point3DNotInSector{0., 1.2, 0};
0130 Vector3 point3DOnSurface{1.2, 0., 0};
0131 BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector,
0132 ignoredMomentum,
0133 BoundaryTolerance::None()));
0134 BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector,
0135 BoundaryTolerance::None()));
0136 BOOST_CHECK(discSurfaceObject->isOnSurface(
0137 tgContext, point3DOnSurface, ignoredMomentum, BoundaryTolerance::None()));
0138 BOOST_CHECK(discSurfaceObject->isOnSurface(tgContext, point3DOnSurface,
0139 BoundaryTolerance::None()));
0140
0141
0142 Vector3 returnedPosition{10.9, 8.7, 6.5};
0143 Vector3 expectedPosition{1.2, 0, 0};
0144 Vector2 rPhiOnDisc{1.2, 0.};
0145 Vector2 rPhiNotInSector{
0146 1.2, std::numbers::pi};
0147 returnedPosition =
0148 discSurfaceObject->localToGlobal(tgContext, rPhiOnDisc, ignoredMomentum);
0149 CHECK_CLOSE_ABS(returnedPosition, expectedPosition, 1e-6);
0150
0151 returnedPosition = discSurfaceObject->localToGlobal(
0152 tgContext, rPhiNotInSector, ignoredMomentum);
0153 Vector3 expectedNonPosition{-1.2, 0, 0};
0154 CHECK_CLOSE_ABS(returnedPosition, expectedNonPosition, 1e-6);
0155
0156
0157 Vector2 returnedLocalPosition{33., 44.};
0158 Vector2 expectedLocalPosition{1.2, 0.};
0159 returnedLocalPosition =
0160 discSurfaceObject
0161 ->globalToLocal(tgContext, point3DOnSurface, ignoredMomentum)
0162 .value();
0163 CHECK_CLOSE_ABS(returnedLocalPosition, expectedLocalPosition, 1e-6);
0164
0165
0166 returnedLocalPosition =
0167 discSurfaceObject
0168 ->globalToLocal(tgContext, point3DNotInSector, ignoredMomentum)
0169 .value();
0170
0171 Vector3 pointOutsideR{0., 100., 0};
0172 returnedLocalPosition =
0173 discSurfaceObject
0174 ->globalToLocal(tgContext, pointOutsideR, ignoredMomentum)
0175 .value();
0176
0177
0178 Vector2 rPhi1_1{std::numbers::sqrt2, std::numbers::pi / 4.};
0179 Vector2 cartesian1_1{1., 1.};
0180 CHECK_CLOSE_REL(discSurfaceObject->localPolarToCartesian(rPhi1_1),
0181 cartesian1_1, 1e-6);
0182
0183
0184 CHECK_CLOSE_REL(discSurfaceObject->localCartesianToPolar(cartesian1_1),
0185 rPhi1_1, 1e-6);
0186
0187
0188 CHECK_CLOSE_REL(discSurfaceObject->localPolarToLocalCartesian(rPhi1_1),
0189 cartesian1_1, 1e-6);
0190
0191
0192 Vector3 cartesian3D1_1{1., 1., 0.};
0193 CHECK_CLOSE_ABS(
0194 discSurfaceObject->localCartesianToGlobal(tgContext, cartesian1_1),
0195 cartesian3D1_1, 1e-6);
0196
0197
0198 CHECK_CLOSE_REL(
0199 discSurfaceObject->globalToLocalCartesian(tgContext, cartesian3D1_1),
0200 cartesian1_1, 1e-6);
0201
0202
0203 double projected3DMomentum = std::numbers::sqrt3 * 1.e6;
0204 Vector3 momentum{projected3DMomentum, projected3DMomentum,
0205 projected3DMomentum};
0206 Vector3 ignoredPosition = discSurfaceObject->center(tgContext);
0207 CHECK_CLOSE_REL(discSurfaceObject->pathCorrection(tgContext, ignoredPosition,
0208 momentum.normalized()),
0209 std::numbers::sqrt3, 0.01);
0210
0211
0212 Vector3 globalPosition{1.2, 0., -10.};
0213 Vector3 direction{0., 0., 1.};
0214 Vector3 expected{1.2, 0., 0.};
0215
0216
0217
0218 Intersection3D sfIntersection =
0219 discSurfaceObject
0220 ->intersect(tgContext, globalPosition, direction,
0221 BoundaryTolerance::Infinite())
0222 .closest();
0223 Intersection3D expectedIntersect{Vector3{1.2, 0., 0.}, 10.,
0224 IntersectionStatus::reachable};
0225 BOOST_CHECK(sfIntersection.isValid());
0226 CHECK_CLOSE_ABS(sfIntersection.position(), expectedIntersect.position(),
0227 1e-9);
0228 CHECK_CLOSE_ABS(sfIntersection.pathLength(), expectedIntersect.pathLength(),
0229 1e-9);
0230
0231
0232 boost::test_tools::output_test_stream nameOuput;
0233 nameOuput << discSurfaceObject->name();
0234 BOOST_CHECK(nameOuput.is_equal("Acts::DiscSurface"));
0235 }
0236
0237
0238 BOOST_AUTO_TEST_CASE(DiscSurfaceAssignment) {
0239 const double rMin = 1.;
0240 const double rMax = 5.;
0241 const double halfPhiSector = std::numbers::pi / 8.;
0242
0243 auto discSurfaceObject = Surface::makeShared<DiscSurface>(
0244 Transform3::Identity(), rMin, rMax, halfPhiSector);
0245 auto assignedDisc =
0246 Surface::makeShared<DiscSurface>(Transform3::Identity(), 2.2, 4.4, 0.07);
0247
0248
0249
0250 ACTS_PUSH_IGNORE_DEPRECATED()
0251 BOOST_CHECK_NO_THROW(*assignedDisc = *discSurfaceObject);
0252 ACTS_POP_IGNORE_DEPRECATED()
0253 BOOST_CHECK((*assignedDisc) == (*discSurfaceObject));
0254 }
0255
0256
0257 BOOST_AUTO_TEST_CASE(DiscSurfaceExtent) {
0258 const double rMin = 1.;
0259 const double rMax = 5.;
0260
0261 auto pDisc =
0262 Surface::makeShared<DiscSurface>(Transform3::Identity(), 0., rMax);
0263 auto pDiscExtent = pDisc->polyhedronRepresentation(tgContext, 1).extent();
0264
0265 CHECK_CLOSE_ABS(0., pDiscExtent.min(AxisDirection::AxisZ),
0266 s_onSurfaceTolerance);
0267 CHECK_CLOSE_ABS(0., pDiscExtent.max(AxisDirection::AxisZ),
0268 s_onSurfaceTolerance);
0269 CHECK_CLOSE_ABS(0., pDiscExtent.min(AxisDirection::AxisR),
0270 s_onSurfaceTolerance);
0271 CHECK_CLOSE_ABS(rMax, pDiscExtent.max(AxisDirection::AxisR),
0272 s_onSurfaceTolerance);
0273 CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(AxisDirection::AxisX),
0274 s_onSurfaceTolerance);
0275 CHECK_CLOSE_ABS(rMax, pDiscExtent.max(AxisDirection::AxisX),
0276 s_onSurfaceTolerance);
0277 CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(AxisDirection::AxisY),
0278 s_onSurfaceTolerance);
0279 CHECK_CLOSE_ABS(rMax, pDiscExtent.max(AxisDirection::AxisY),
0280 s_onSurfaceTolerance);
0281 CHECK_CLOSE_ABS(-std::numbers::pi, pDiscExtent.min(AxisDirection::AxisPhi),
0282 s_onSurfaceTolerance);
0283 CHECK_CLOSE_ABS(std::numbers::pi, pDiscExtent.max(AxisDirection::AxisPhi),
0284 s_onSurfaceTolerance);
0285
0286 auto pRing =
0287 Surface::makeShared<DiscSurface>(Transform3::Identity(), rMin, rMax);
0288 auto pRingExtent = pRing->polyhedronRepresentation(tgContext, 1).extent();
0289
0290 CHECK_CLOSE_ABS(0., pRingExtent.min(AxisDirection::AxisZ),
0291 s_onSurfaceTolerance);
0292 CHECK_CLOSE_ABS(0., pRingExtent.max(AxisDirection::AxisZ),
0293 s_onSurfaceTolerance);
0294 CHECK_CLOSE_ABS(rMin, pRingExtent.min(AxisDirection::AxisR),
0295 s_onSurfaceTolerance);
0296 CHECK_CLOSE_ABS(rMax, pRingExtent.max(AxisDirection::AxisR),
0297 s_onSurfaceTolerance);
0298 CHECK_CLOSE_ABS(-rMax, pRingExtent.min(AxisDirection::AxisX),
0299 s_onSurfaceTolerance);
0300 CHECK_CLOSE_ABS(rMax, pRingExtent.max(AxisDirection::AxisX),
0301 s_onSurfaceTolerance);
0302 CHECK_CLOSE_ABS(-rMax, pRingExtent.min(AxisDirection::AxisY),
0303 s_onSurfaceTolerance);
0304 CHECK_CLOSE_ABS(rMax, pRingExtent.max(AxisDirection::AxisY),
0305 s_onSurfaceTolerance);
0306 }
0307
0308
0309 BOOST_AUTO_TEST_CASE(DiscSurfaceAlignment) {
0310 Translation3 translation{0., 1., 2.};
0311 Transform3 transform(translation);
0312 const double rMin = 1.;
0313 const double rMax = 5.;
0314 const double halfPhiSector = std::numbers::pi / 8.;
0315
0316 auto discSurfaceObject =
0317 Surface::makeShared<DiscSurface>(transform, rMin, rMax, halfPhiSector);
0318
0319 const auto& rotation = transform.rotation();
0320
0321 const Vector3 localZAxis = rotation.col(2);
0322
0323 CHECK_CLOSE_ABS(localZAxis, Vector3(0., 0., 1.), 1e-15);
0324
0325
0326 Vector3 globalPosition{0, 4, 2};
0327 Vector3 momentum{0, 0, 1};
0328 Vector3 direction = momentum.normalized();
0329
0330
0331 const AlignmentToPathMatrix& alignToPath =
0332 discSurfaceObject->alignmentToPathDerivative(tgContext, globalPosition,
0333 direction);
0334
0335 AlignmentToPathMatrix expAlignToPath = AlignmentToPathMatrix::Zero();
0336 expAlignToPath << 0, 0, 1, 3, 0, 0;
0337
0338 CHECK_CLOSE_ABS(alignToPath, expAlignToPath, 1e-10);
0339
0340
0341 const Vector3 tiltedDirection = Vector3(0.25, -0.2, 0.95).normalized();
0342 checkSurfaceDerivatives(
0343 tgContext, *discSurfaceObject, transform, globalPosition, tiltedDirection,
0344 [&](const Transform3& tf) {
0345 return Surface::makeShared<DiscSurface>(tf, rMin, rMax, halfPhiSector);
0346 });
0347
0348
0349
0350 const auto& loc3DToLocBound =
0351 discSurfaceObject->localCartesianToBoundLocalDerivative(
0352 tgContext, globalPosition, direction);
0353
0354 Matrix<2, 3> expLoc3DToLocBound = Matrix<2, 3>::Zero();
0355 expLoc3DToLocBound << 0, 1, 0, -1. / 3, 0, 0;
0356 CHECK_CLOSE_ABS(loc3DToLocBound, expLoc3DToLocBound, 1e-10);
0357 }
0358
0359 BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) {
0360 using namespace Acts::UnitLiterals;
0361 Vector3 s{5_mm, 7_mm, 10_cm};
0362 Transform3 trf;
0363 trf = Translation3(s) * AngleAxis3{0.5, Vector3::UnitZ()};
0364
0365 double minR = 300;
0366 double maxR = 330;
0367
0368 {
0369
0370 auto bounds =
0371 std::make_shared<RadialBounds>(minR, maxR, std::numbers::pi / 8, 0.1);
0372 auto disc = Acts::Surface::makeShared<Acts::DiscSurface>(trf, bounds);
0373
0374 Vector3 bp = disc->referencePosition(tgContext, AxisDirection::AxisR);
0375 double r = (bounds->rMax() + bounds->rMin()) / 2.0;
0376 double phi = bounds->get(RadialBounds::eAveragePhi);
0377 Vector3 exp = Vector3{r * std::cos(phi), r * std::sin(phi), 0};
0378 exp = trf * exp;
0379
0380 BOOST_CHECK_EQUAL(bp, exp);
0381 BOOST_CHECK_EQUAL(
0382 disc->referencePositionValue(tgContext, AxisDirection::AxisR),
0383 VectorHelpers::perp(exp));
0384
0385 bp = disc->referencePosition(tgContext, AxisDirection::AxisPhi);
0386 BOOST_CHECK_EQUAL(bp, exp);
0387 BOOST_CHECK_EQUAL(
0388 disc->referencePositionValue(tgContext, AxisDirection::AxisPhi),
0389 VectorHelpers::phi(exp));
0390
0391 for (auto b :
0392 {AxisDirection::AxisX, AxisDirection::AxisY, AxisDirection::AxisZ,
0393 AxisDirection::AxisEta, AxisDirection::AxisRPhi,
0394 AxisDirection::AxisTheta, AxisDirection::AxisMag}) {
0395 BOOST_TEST_CONTEXT("binValue: " << b) {
0396 BOOST_CHECK_EQUAL(disc->referencePosition(tgContext, b),
0397 disc->center(tgContext));
0398 }
0399 }
0400 }
0401
0402 {
0403
0404 double minPhiRel = -0.3;
0405 double maxPhiRel = 0.2;
0406 Vector2 origin{5_mm, 5_mm};
0407 auto bounds = std::make_shared<AnnulusBounds>(minR, maxR, minPhiRel,
0408 maxPhiRel, origin);
0409
0410 auto disc = Acts::Surface::makeShared<Acts::DiscSurface>(trf, bounds);
0411
0412 Vector3 bp = disc->referencePosition(tgContext, AxisDirection::AxisR);
0413 double r = (bounds->rMax() + bounds->rMin()) / 2.0;
0414 double phi = bounds->get(AnnulusBounds::eAveragePhi);
0415 Vector3 exp = Vector3{r * std::cos(phi), r * std::sin(phi), 0};
0416 exp = trf * exp;
0417
0418 BOOST_CHECK_EQUAL(bp, exp);
0419
0420 bp = disc->referencePosition(tgContext, AxisDirection::AxisPhi);
0421 BOOST_CHECK_EQUAL(bp, exp);
0422
0423 for (auto b :
0424 {AxisDirection::AxisX, AxisDirection::AxisY, AxisDirection::AxisZ,
0425 AxisDirection::AxisEta, AxisDirection::AxisRPhi,
0426 AxisDirection::AxisTheta, AxisDirection::AxisMag}) {
0427 BOOST_TEST_CONTEXT("binValue: " << b) {
0428 BOOST_CHECK_EQUAL(disc->referencePosition(tgContext, b),
0429 disc->center(tgContext));
0430 }
0431 }
0432 }
0433 }
0434
0435 BOOST_AUTO_TEST_SUITE(DiscSurfaceMerging)
0436
0437 namespace {
0438 std::shared_ptr<DiscSurface> makeDisc(const Transform3& transform, double rMin,
0439 double rMax,
0440 double halfPhi = std::numbers::pi,
0441 double avgPhi = 0) {
0442 return Surface::makeShared<DiscSurface>(
0443 transform, std::make_shared<RadialBounds>(rMin, rMax, halfPhi, avgPhi));
0444 }
0445
0446 }
0447
0448 BOOST_AUTO_TEST_CASE(IncompatibleBounds) {
0449 Logging::ScopedFailureThreshold ft{Logging::FATAL};
0450 Transform3 base = Transform3::Identity();
0451 auto discRadial = makeDisc(base, 30_mm, 100_mm);
0452 auto discTrap =
0453 Surface::makeShared<DiscSurface>(base, 20_mm, 40_mm, 100_mm, 150_mm);
0454 auto discTrap2 =
0455 Surface::makeShared<DiscSurface>(base, 20_mm, 40_mm, 30_mm, 100_mm);
0456
0457 BOOST_CHECK_THROW(
0458 discRadial->mergedWith(*discTrap, AxisDirection::AxisR, false, *logger),
0459
0460 SurfaceMergingException);
0461
0462 BOOST_CHECK_THROW(
0463 discTrap2->mergedWith(*discTrap, AxisDirection::AxisR, false, *logger),
0464 SurfaceMergingException);
0465 }
0466
0467 BOOST_AUTO_TEST_CASE(InvalidDetectorElement) {
0468 DetectorElementStub detElem;
0469
0470 auto bounds1 = std::make_shared<RadialBounds>(30_mm, 100_mm);
0471 auto disc1 = Surface::makeShared<DiscSurface>(bounds1, detElem);
0472
0473 auto bounds2 = std::make_shared<RadialBounds>(100_mm, 150_mm);
0474 auto disc2 = Surface::makeShared<DiscSurface>(bounds2, detElem);
0475
0476 BOOST_CHECK_THROW(
0477 disc1->mergedWith(*disc2, AxisDirection::AxisR, false, *logger),
0478 SurfaceMergingException);
0479 }
0480
0481 BOOST_DATA_TEST_CASE(IncompatibleRDirection,
0482 (boost::unit_test::data::xrange(-135, 180, 45) *
0483 boost::unit_test::data::make(Vector3{0_mm, 0_mm, 0_mm},
0484 Vector3{20_mm, 0_mm, 0_mm},
0485 Vector3{0_mm, 20_mm, 0_mm},
0486 Vector3{20_mm, 20_mm, 0_mm},
0487 Vector3{0_mm, 0_mm, 20_mm})),
0488 angle, offset) {
0489 Logging::ScopedFailureThreshold ft{Logging::FATAL};
0490
0491 Transform3 base =
0492 AngleAxis3(angle * 1_degree, Vector3::UnitX()) * Translation3(offset);
0493
0494 auto disc = makeDisc(base, 30_mm, 100_mm);
0495
0496
0497 auto discOverlap = makeDisc(base, 90_mm, 150_mm);
0498 BOOST_CHECK_THROW(disc->mergedWith(*discOverlap, Acts::AxisDirection::AxisR,
0499 false, *logger),
0500 SurfaceMergingException);
0501
0502
0503 auto discGap = makeDisc(base, 110_mm, 150_mm);
0504 BOOST_CHECK_THROW(
0505 disc->mergedWith(*discGap, Acts::AxisDirection::AxisR, false, *logger),
0506 SurfaceMergingException);
0507
0508 auto discShiftedZ = Surface::makeShared<DiscSurface>(
0509 base * Translation3{Vector3::UnitZ() * 10_mm}, 100_mm, 150_mm);
0510 BOOST_CHECK_THROW(disc->mergedWith(*discShiftedZ, Acts::AxisDirection::AxisR,
0511 false, *logger),
0512 SurfaceMergingException);
0513
0514 auto discShiftedXy = makeDisc(
0515 base * Translation3{Vector3{1_mm, 2_mm, 200_mm}}, 100_mm, 150_mm);
0516 BOOST_CHECK_THROW(disc->mergedWith(*discShiftedXy, Acts::AxisDirection::AxisZ,
0517 false, *logger),
0518 SurfaceMergingException);
0519
0520 auto discRotatedZ = makeDisc(base * AngleAxis3{10_degree, Vector3::UnitZ()},
0521 100_mm, 150_mm, 60_degree, 0_degree);
0522 BOOST_CHECK_THROW(disc->mergedWith(*discRotatedZ, Acts::AxisDirection::AxisR,
0523 false, *logger),
0524 SurfaceMergingException);
0525
0526 auto discRotatedX =
0527 makeDisc(base * AngleAxis3{10_degree, Vector3::UnitX()}, 100_mm, 150_mm);
0528 BOOST_CHECK_THROW(disc->mergedWith(*discRotatedX, Acts::AxisDirection::AxisR,
0529 false, *logger),
0530 SurfaceMergingException);
0531
0532
0533 auto discPhi1 = makeDisc(base, 30_mm, 100_mm, 10_degree, 40_degree);
0534 auto discPhi2 = makeDisc(base, 100_mm, 160_mm, 20_degree, 40_degree);
0535 auto discPhi3 = makeDisc(base, 100_mm, 160_mm, 10_degree, 50_degree);
0536 BOOST_CHECK_THROW(
0537 discPhi1->mergedWith(*discPhi2, AxisDirection::AxisR, false, *logger),
0538 SurfaceMergingException);
0539
0540 BOOST_CHECK_THROW(
0541 discPhi1->mergedWith(*discPhi3, AxisDirection::AxisR, false, *logger),
0542 SurfaceMergingException);
0543 }
0544
0545 BOOST_DATA_TEST_CASE(RDirection,
0546 (boost::unit_test::data::xrange(-135, 180, 45) *
0547 boost::unit_test::data::make(Vector3{0_mm, 0_mm, 0_mm},
0548 Vector3{20_mm, 0_mm, 0_mm},
0549 Vector3{0_mm, 20_mm, 0_mm},
0550 Vector3{20_mm, 20_mm, 0_mm},
0551 Vector3{0_mm, 0_mm, 20_mm})),
0552 angle, offset) {
0553 Transform3 base =
0554 AngleAxis3(angle * 1_degree, Vector3::UnitX()) * Translation3(offset);
0555
0556 auto disc = makeDisc(base, 30_mm, 100_mm);
0557
0558 auto disc2 =
0559 makeDisc(base * AngleAxis3(14_degree, Vector3::UnitZ()), 100_mm, 150_mm);
0560
0561 auto [disc3, reversed] =
0562 disc->mergedWith(*disc2, Acts::AxisDirection::AxisR, false, *logger);
0563 BOOST_REQUIRE_NE(disc3, nullptr);
0564 BOOST_CHECK(!reversed);
0565
0566 auto [disc3Reversed, reversed2] =
0567 disc2->mergedWith(*disc, Acts::AxisDirection::AxisR, false, *logger);
0568 BOOST_REQUIRE_NE(disc3Reversed, nullptr);
0569 BOOST_CHECK(disc3->bounds() == disc3Reversed->bounds());
0570 BOOST_CHECK(reversed2);
0571
0572 const auto* bounds = dynamic_cast<const RadialBounds*>(&disc3->bounds());
0573 BOOST_REQUIRE_NE(bounds, nullptr);
0574
0575 BOOST_CHECK_EQUAL(bounds->get(RadialBounds::eMinR), 30_mm);
0576 BOOST_CHECK_EQUAL(bounds->get(RadialBounds::eMaxR), 150_mm);
0577
0578
0579 BOOST_CHECK_EQUAL(base.matrix(),
0580 disc3->localToGlobalTransform(tgContext).matrix());
0581
0582
0583 Transform3 expected12 = base;
0584 BOOST_CHECK_EQUAL(expected12.matrix(),
0585 disc3->localToGlobalTransform(tgContext).matrix());
0586
0587 Transform3 expected21 = base * AngleAxis3(14_degree, Vector3::UnitZ());
0588 CHECK_CLOSE_OR_SMALL(
0589 disc3Reversed->localToGlobalTransform(tgContext).matrix(),
0590 expected21.matrix(), 1e-6, 1e-10);
0591
0592
0593 auto discPhi1 = makeDisc(base, 30_mm, 100_mm, 10_degree, 40_degree);
0594 auto discPhi2 = makeDisc(base, 100_mm, 160_mm, 10_degree, 40_degree);
0595 auto [discPhi12, reversedPhi12] =
0596 discPhi1->mergedWith(*discPhi2, AxisDirection::AxisR, false, *logger);
0597 BOOST_REQUIRE_NE(discPhi12, nullptr);
0598
0599 const auto* boundsPhi12 =
0600 dynamic_cast<const RadialBounds*>(&discPhi12->bounds());
0601 BOOST_REQUIRE_NE(boundsPhi12, nullptr);
0602
0603 BOOST_CHECK_EQUAL(boundsPhi12->get(RadialBounds::eMinR), 30_mm);
0604 BOOST_CHECK_EQUAL(boundsPhi12->get(RadialBounds::eMaxR), 160_mm);
0605 BOOST_CHECK_EQUAL(boundsPhi12->get(RadialBounds::eHalfPhiSector), 10_degree);
0606 }
0607
0608 BOOST_DATA_TEST_CASE(IncompatiblePhiDirection,
0609 (boost::unit_test::data::xrange(-135, 180, 45) *
0610 boost::unit_test::data::make(Vector3{0_mm, 0_mm, 0_mm},
0611 Vector3{20_mm, 0_mm, 0_mm},
0612 Vector3{0_mm, 20_mm, 0_mm},
0613 Vector3{20_mm, 20_mm, 0_mm},
0614 Vector3{0_mm, 0_mm, 20_mm}) *
0615 boost::unit_test::data::xrange(-1300, 1300, 104)),
0616 angle, offset, phiShift) {
0617 Logging::ScopedFailureThreshold ft{Logging::FATAL};
0618 Transform3 base =
0619 AngleAxis3(angle * 1_degree, Vector3::UnitX()) * Translation3(offset);
0620
0621 auto a = [phiShift](double v) {
0622 return detail::radian_sym(v + phiShift * 1_degree);
0623 };
0624
0625 auto discPhi = makeDisc(base, 30_mm, 100_mm, 10_degree, a(40_degree));
0626
0627
0628 auto discPhi2 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(85_degree));
0629 BOOST_CHECK_THROW(discPhi->mergedWith(*discPhi2, Acts::AxisDirection::AxisPhi,
0630 false, *logger),
0631 SurfaceMergingException);
0632
0633
0634 auto discPhi3 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(105_degree));
0635 BOOST_CHECK_THROW(discPhi->mergedWith(*discPhi3, Acts::AxisDirection::AxisPhi,
0636 false, *logger),
0637 SurfaceMergingException);
0638
0639
0640 auto discPhi4 = makeDisc(base * Translation3{Vector3::UnitZ() * 20_mm}, 30_mm,
0641 100_mm, 45_degree, a(95_degree));
0642 BOOST_CHECK_THROW(discPhi->mergedWith(*discPhi4, Acts::AxisDirection::AxisPhi,
0643 false, *logger),
0644 SurfaceMergingException);
0645
0646
0647 auto discPhi5 = makeDisc(base, 100_mm, 150_mm, 45_degree, a(95_degree));
0648 BOOST_CHECK_THROW(discPhi->mergedWith(*discPhi5, Acts::AxisDirection::AxisPhi,
0649 false, *logger),
0650 SurfaceMergingException);
0651 }
0652
0653 BOOST_DATA_TEST_CASE(PhiDirection,
0654 (boost::unit_test::data::xrange(-135, 180, 45) *
0655 boost::unit_test::data::make(Vector3{0_mm, 0_mm, 0_mm},
0656 Vector3{20_mm, 0_mm, 0_mm},
0657 Vector3{0_mm, 20_mm, 0_mm},
0658 Vector3{20_mm, 20_mm, 0_mm},
0659 Vector3{0_mm, 0_mm, 20_mm}) *
0660 boost::unit_test::data::xrange(-1300, 1300, 104)),
0661 angle, offset, phiShift) {
0662 Transform3 base =
0663 AngleAxis3(angle * 1_degree, Vector3::UnitX()) * Translation3(offset);
0664
0665 auto a = [phiShift](double v) {
0666 return detail::radian_sym(v + phiShift * 1_degree);
0667 };
0668
0669 BOOST_TEST_CONTEXT("Internal rotation") {
0670 auto disc = makeDisc(base, 30_mm, 100_mm, 10_degree, a(40_degree));
0671 auto disc2 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(95_degree));
0672
0673 auto [disc3, reversed] =
0674 disc->mergedWith(*disc2, Acts::AxisDirection::AxisPhi, false, *logger);
0675 BOOST_REQUIRE_NE(disc3, nullptr);
0676 BOOST_CHECK_EQUAL(base.matrix(),
0677 disc3->localToGlobalTransform(tgContext).matrix());
0678 BOOST_CHECK(reversed);
0679
0680 auto [disc3Reversed, reversed2] =
0681 disc2->mergedWith(*disc, Acts::AxisDirection::AxisPhi, false, *logger);
0682 BOOST_REQUIRE_NE(disc3Reversed, nullptr);
0683 BOOST_CHECK(*disc3 == *disc3Reversed);
0684 BOOST_CHECK(!reversed2);
0685
0686 const auto* bounds = dynamic_cast<const RadialBounds*>(&disc3->bounds());
0687 BOOST_REQUIRE_NE(bounds, nullptr);
0688
0689 BOOST_CHECK_SMALL(
0690 detail::difference_periodic(bounds->get(RadialBounds::eAveragePhi),
0691 a(85_degree), 2 * std::numbers::pi),
0692 1e-6);
0693 BOOST_CHECK_CLOSE(bounds->get(RadialBounds::eHalfPhiSector), 55_degree,
0694 1e-6);
0695
0696 auto disc4 = makeDisc(base, 30_mm, 100_mm, 20_degree, a(170_degree));
0697 auto disc5 = makeDisc(base, 30_mm, 100_mm, 10_degree, a(-160_degree));
0698 auto [disc45, reversed45] =
0699 disc4->mergedWith(*disc5, Acts::AxisDirection::AxisPhi, false, *logger);
0700 BOOST_REQUIRE_NE(disc45, nullptr);
0701 BOOST_CHECK_EQUAL(base.matrix(),
0702 disc45->localToGlobalTransform(tgContext).matrix());
0703 BOOST_CHECK(reversed45);
0704
0705 auto [disc54, reversed54] =
0706 disc5->mergedWith(*disc4, Acts::AxisDirection::AxisPhi, false, *logger);
0707 BOOST_REQUIRE_NE(disc54, nullptr);
0708 BOOST_CHECK(!reversed54);
0709
0710 BOOST_CHECK(*disc54 == *disc45);
0711
0712 const auto* bounds45 = dynamic_cast<const RadialBounds*>(&disc45->bounds());
0713 BOOST_REQUIRE_NE(bounds, nullptr);
0714
0715 BOOST_CHECK_SMALL(
0716 detail::difference_periodic(bounds45->get(RadialBounds::eAveragePhi),
0717 a(180_degree), 2 * std::numbers::pi),
0718 1e-6);
0719 BOOST_CHECK_CLOSE(bounds45->get(RadialBounds::eHalfPhiSector), 30_degree,
0720 1e-6);
0721
0722 auto disc6 = makeDisc(base, 30_mm, 100_mm, 90_degree, a(0_degree));
0723 auto disc7 = makeDisc(base, 30_mm, 100_mm, 90_degree, a(180_degree));
0724
0725 auto [disc67, reversed67] =
0726 disc6->mergedWith(*disc7, Acts::AxisDirection::AxisPhi, false, *logger);
0727 BOOST_REQUIRE_NE(disc67, nullptr);
0728 CHECK_CLOSE_OR_SMALL(disc67->localToGlobalTransform(tgContext).matrix(),
0729 base.matrix(), 1e-6, 1e-10);
0730 BOOST_CHECK(!reversed67);
0731
0732 auto [disc76, reversed76] =
0733 disc7->mergedWith(*disc6, Acts::AxisDirection::AxisPhi, false, *logger);
0734 BOOST_REQUIRE_NE(disc76, nullptr);
0735
0736 BOOST_CHECK(*disc76 != *disc67);
0737
0738 BOOST_CHECK_NE(disc76->bounds(), disc67->bounds());
0739
0740 BOOST_CHECK_EQUAL(disc76->localToGlobalTransform(tgContext).matrix(),
0741 disc67->localToGlobalTransform(tgContext).matrix());
0742
0743 BOOST_CHECK(!reversed76);
0744
0745 const auto* bounds67 = dynamic_cast<const RadialBounds*>(&disc67->bounds());
0746 BOOST_REQUIRE_NE(bounds67, nullptr);
0747 BOOST_CHECK_SMALL(
0748 detail::difference_periodic(bounds67->get(RadialBounds::eAveragePhi),
0749 a(90_degree), 2 * std::numbers::pi),
0750 1e-6);
0751 BOOST_CHECK_CLOSE(bounds67->get(RadialBounds::eHalfPhiSector), 180_degree,
0752 1e-6);
0753 }
0754
0755 BOOST_TEST_CONTEXT("External rotation") {
0756 Transform3 trf1 = base * AngleAxis3(a(40_degree), Vector3::UnitZ());
0757 auto disc = makeDisc(trf1, 30_mm, 100_mm, 10_degree, 0_degree);
0758 Transform3 trf2 = base * AngleAxis3(a(95_degree), Vector3::UnitZ());
0759 auto disc2 = makeDisc(trf2, 30_mm, 100_mm, 45_degree, 0_degree);
0760
0761 auto [disc3, reversed] =
0762 disc->mergedWith(*disc2, Acts::AxisDirection::AxisPhi, true, *logger);
0763 BOOST_REQUIRE_NE(disc3, nullptr);
0764 Transform3 trfExpected12 =
0765 base * AngleAxis3(a(85_degree), Vector3::UnitZ());
0766 CHECK_CLOSE_OR_SMALL(disc3->localToGlobalTransform(tgContext).matrix(),
0767 trfExpected12.matrix(), 1e-6, 1e-10);
0768 BOOST_CHECK(reversed);
0769
0770 auto [disc3Reversed, reversed2] =
0771 disc2->mergedWith(*disc, Acts::AxisDirection::AxisPhi, true, *logger);
0772 BOOST_REQUIRE_NE(disc3Reversed, nullptr);
0773 BOOST_CHECK(*disc3 == *disc3Reversed);
0774 BOOST_CHECK(!reversed2);
0775
0776 const auto* bounds = dynamic_cast<const RadialBounds*>(&disc3->bounds());
0777 BOOST_REQUIRE_NE(bounds, nullptr);
0778
0779 BOOST_CHECK_EQUAL(bounds->get(RadialBounds::eAveragePhi), 0);
0780 BOOST_CHECK_CLOSE(bounds->get(RadialBounds::eHalfPhiSector), 55_degree,
0781 1e-6);
0782
0783 Transform3 trf4 = base * AngleAxis3(a(170_degree), Vector3::UnitZ());
0784 auto disc4 = makeDisc(trf4, 30_mm, 100_mm, 20_degree, 0_degree);
0785 Transform3 trf5 = base * AngleAxis3(a(-160_degree), Vector3::UnitZ());
0786 auto disc5 = makeDisc(trf5, 30_mm, 100_mm, 10_degree, 0_degree);
0787 auto [disc45, reversed45] =
0788 disc4->mergedWith(*disc5, Acts::AxisDirection::AxisPhi, true, *logger);
0789 BOOST_REQUIRE_NE(disc45, nullptr);
0790 Transform3 trfExpected45 =
0791 base * AngleAxis3(a(180_degree), Vector3::UnitZ());
0792 CHECK_CLOSE_OR_SMALL(disc45->localToGlobalTransform(tgContext).matrix(),
0793 trfExpected45.matrix(), 1e-6, 1e-10);
0794 BOOST_CHECK(reversed45);
0795
0796 auto [disc54, reversed54] =
0797 disc5->mergedWith(*disc4, Acts::AxisDirection::AxisPhi, true, *logger);
0798 BOOST_REQUIRE_NE(disc54, nullptr);
0799 BOOST_CHECK(!reversed54);
0800
0801 BOOST_CHECK(*disc54 == *disc45);
0802
0803 const auto* bounds45 = dynamic_cast<const RadialBounds*>(&disc45->bounds());
0804 BOOST_REQUIRE_NE(bounds, nullptr);
0805
0806 BOOST_CHECK_EQUAL(bounds45->get(RadialBounds::eAveragePhi), 0);
0807 BOOST_CHECK_CLOSE(bounds45->get(RadialBounds::eHalfPhiSector), 30_degree,
0808 1e-6);
0809
0810 Transform3 trf6 = base * AngleAxis3(a(0_degree), Vector3::UnitZ());
0811 auto disc6 = makeDisc(trf6, 30_mm, 100_mm, 90_degree, 0_degree);
0812 Transform3 trf7 = base * AngleAxis3(a(180_degree), Vector3::UnitZ());
0813 auto disc7 = makeDisc(trf7, 30_mm, 100_mm, 90_degree, 0_degree);
0814 auto [disc67, reversed67] =
0815 disc6->mergedWith(*disc7, Acts::AxisDirection::AxisPhi, true, *logger);
0816 BOOST_REQUIRE_NE(disc67, nullptr);
0817 Transform3 trfExpected67 =
0818 base * AngleAxis3(a(90_degree), Vector3::UnitZ());
0819 CHECK_CLOSE_OR_SMALL(disc67->localToGlobalTransform(tgContext).matrix(),
0820 trfExpected67.matrix(), 1e-6, 1e-10);
0821 BOOST_CHECK(!reversed67);
0822
0823 auto [disc76, reversed76] =
0824 disc7->mergedWith(*disc6, Acts::AxisDirection::AxisPhi, true, *logger);
0825 BOOST_REQUIRE_NE(disc76, nullptr);
0826
0827 BOOST_CHECK(*disc76 != *disc67);
0828 BOOST_CHECK_NE(disc76->localToGlobalTransform(tgContext).matrix(),
0829 disc67->localToGlobalTransform(tgContext).matrix());
0830
0831 BOOST_CHECK_EQUAL(disc76->bounds(), disc67->bounds());
0832
0833
0834 BOOST_CHECK(!reversed76);
0835
0836 const auto* bounds67 = dynamic_cast<const RadialBounds*>(&disc67->bounds());
0837 BOOST_REQUIRE_NE(bounds67, nullptr);
0838 BOOST_CHECK_EQUAL(bounds67->get(RadialBounds::eAveragePhi), 0);
0839 BOOST_CHECK_CLOSE(bounds67->get(RadialBounds::eHalfPhiSector), 180_degree,
0840 1e-6);
0841 }
0842 }
0843
0844 BOOST_AUTO_TEST_SUITE_END()
0845
0846 BOOST_AUTO_TEST_CASE(DiscSurfaceMaterialAssignment) {
0847 auto surface =
0848 Surface::makeShared<DiscSurface>(Transform3::Identity(), 1., 100.);
0849 MaterialSlab slab(Material::fromMolarDensity(1., 2., 3., 4., 5.), 0.1);
0850
0851
0852 auto homMat = std::make_shared<HomogeneousSurfaceMaterial>(slab);
0853 BOOST_CHECK_NO_THROW(surface->assignSurfaceMaterial(homMat));
0854 BOOST_CHECK_NE(surface->surfaceMaterial(), nullptr);
0855
0856
0857 BOOST_CHECK_NO_THROW(surface->assignSurfaceMaterial(nullptr));
0858 BOOST_CHECK_EQUAL(surface->surfaceMaterial(), nullptr);
0859
0860
0861 BinUtility buR(10, 1.f, 100.f, Acts::open, AxisDirection::AxisR);
0862 auto matR = std::make_shared<BinnedSurfaceMaterial>(
0863 buR, MaterialSlabVector(10, slab));
0864 BOOST_CHECK_NO_THROW(surface->assignSurfaceMaterial(matR));
0865
0866
0867 BinUtility buPhi(10, -3.14f, 3.14f, Acts::closed, AxisDirection::AxisPhi);
0868 auto matPhi = std::make_shared<BinnedSurfaceMaterial>(
0869 buPhi, MaterialSlabVector(10, slab));
0870 BOOST_CHECK_NO_THROW(surface->assignSurfaceMaterial(matPhi));
0871
0872
0873 BinUtility bu2D(5, 1.f, 100.f, Acts::open, AxisDirection::AxisR);
0874 bu2D += BinUtility(3, -3.14f, 3.14f, Acts::closed, AxisDirection::AxisPhi);
0875 auto mat2D = std::make_shared<BinnedSurfaceMaterial>(
0876 bu2D, MaterialSlabMatrix(3, MaterialSlabVector(5, slab)));
0877 BOOST_CHECK_NO_THROW(surface->assignSurfaceMaterial(mat2D));
0878
0879
0880 for (auto badDir : {AxisDirection::AxisRPhi, AxisDirection::AxisZ,
0881 AxisDirection::AxisX, AxisDirection::AxisY}) {
0882 BinUtility buBad(10, 0.f, 10.f, Acts::open, badDir);
0883 auto matBad = std::make_shared<BinnedSurfaceMaterial>(
0884 buBad, MaterialSlabVector(10, slab));
0885 BOOST_CHECK_THROW(surface->assignSurfaceMaterial(matBad),
0886 std::invalid_argument);
0887 }
0888 }
0889
0890
0891
0892
0893
0894 BOOST_AUTO_TEST_CASE(DiscBoundToCartesianJacobianMatchesTheSurface) {
0895 const GeometryContext gctx = GeometryContext::dangerouslyDefaultConstruct();
0896 const double averagePhi = 0.7;
0897
0898 std::vector<std::shared_ptr<DiscBounds>> bounds;
0899 bounds.push_back(std::make_shared<RadialBounds>(20., 40., 0.4, averagePhi));
0900 bounds.push_back(
0901 std::make_shared<DiscTrapezoidBounds>(6., 10., 20., 40., averagePhi));
0902 bounds.push_back(std::make_shared<AnnulusBounds>(
0903 20., 40., -0.2, 0.2, Vector2(0., -5.), averagePhi));
0904
0905 Transform3 transform = Transform3::Identity();
0906 transform.translate(Vector3(0., 0., 300.));
0907 transform.rotate(Eigen::AngleAxisd(0.9, Vector3::UnitZ()));
0908
0909 for (const auto& b : bounds) {
0910 auto surface = Surface::makeShared<DiscSurface>(transform, b);
0911 const RotationMatrix3 rotation =
0912 surface->localToGlobalTransform(gctx).rotation();
0913
0914 for (const double r : {24., 30., 36.}) {
0915 const Vector2 lposition(r, averagePhi + 0.05);
0916
0917
0918
0919 constexpr double h = 1e-6;
0920 SquareMatrix2 numeric;
0921 for (int i = 0; i < 2; ++i) {
0922 Vector2 up = lposition;
0923 Vector2 down = lposition;
0924 up[i] += h;
0925 down[i] -= h;
0926 const Vector3 delta = (surface->localToGlobal(gctx, up) -
0927 surface->localToGlobal(gctx, down)) /
0928 (2 * h);
0929
0930 numeric.col(i) = (rotation.transpose() * delta).head<2>();
0931 }
0932
0933 CHECK_CLOSE_ABS(b->boundToCartesianJacobian(lposition), numeric, 1e-6);
0934 }
0935 }
0936 }
0937
0938
0939 BOOST_AUTO_TEST_CASE(DiscSurfaceContains) {
0940 using std::numbers::pi;
0941 auto disc = [](const Transform3& transform, double rMin, double rMax,
0942 double halfPhi = pi, double avgPhi = 0.) {
0943 return Surface::makeShared<DiscSurface>(
0944 transform,
0945 std::make_shared<const RadialBounds>(rMin, rMax, halfPhi, avgPhi));
0946 };
0947 const Transform3 identity = Transform3::Identity();
0948 auto rotatedZ = [](double angle) {
0949 return Transform3{AngleAxis3{angle, Vector3::UnitZ()}};
0950 };
0951 auto ring = disc(identity, 10_mm, 50_mm);
0952
0953 BOOST_CHECK(ring->contains(tgContext, *ring));
0954 BOOST_CHECK(ring->contains(tgContext, *disc(identity, 20_mm, 40_mm)));
0955 BOOST_CHECK(!ring->contains(tgContext, *disc(identity, 5_mm, 40_mm)));
0956 BOOST_CHECK(!ring->contains(tgContext, *disc(identity, 20_mm, 60_mm)));
0957 BOOST_CHECK(!disc(identity, 20_mm, 40_mm)->contains(tgContext, *ring));
0958
0959
0960 auto sector = disc(identity, 10_mm, 50_mm, pi / 4.);
0961 BOOST_CHECK(sector->contains(
0962 tgContext, *disc(identity, 20_mm, 40_mm, pi / 8., pi / 8.)));
0963 BOOST_CHECK(!sector->contains(
0964 tgContext, *disc(identity, 20_mm, 40_mm, pi / 8., pi / 4.)));
0965 BOOST_CHECK(sector->contains(
0966 tgContext, *disc(rotatedZ(pi / 8.), 20_mm, 40_mm, pi / 8.)));
0967 BOOST_CHECK(!sector->contains(
0968 tgContext, *disc(rotatedZ(pi / 4.), 20_mm, 40_mm, pi / 8.)));
0969 BOOST_CHECK(!sector->contains(tgContext, *ring));
0970
0971
0972 auto back = disc(identity, 10_mm, 50_mm, pi / 4., -pi);
0973 BOOST_CHECK(back->contains(
0974 tgContext, *disc(identity, 20_mm, 40_mm, pi / 16., 7. * pi / 8.)));
0975
0976
0977 auto upper = disc(identity, 10_mm, 50_mm, pi / 8., pi / 8.);
0978 const Transform3 flipped{AngleAxis3{pi, Vector3::UnitX()}};
0979 BOOST_CHECK(upper->contains(
0980 tgContext, *disc(identity, 20_mm, 40_mm, pi / 16., pi / 8.)));
0981 BOOST_CHECK(!upper->contains(
0982 tgContext, *disc(flipped, 20_mm, 40_mm, pi / 16., pi / 8.)));
0983 BOOST_CHECK(upper->contains(
0984 tgContext, *disc(flipped, 20_mm, 40_mm, pi / 16., -pi / 8.)));
0985
0986
0987 BOOST_CHECK(!ring->contains(
0988 tgContext, *disc(Transform3{Translation3{1_mm, 0, 0}}, 20_mm, 40_mm)));
0989 BOOST_CHECK(!ring->contains(
0990 tgContext, *disc(Transform3{Translation3{0, 0, 1_mm}}, 20_mm, 40_mm)));
0991
0992
0993 auto trapezoid = Surface::makeShared<DiscSurface>(
0994 identity,
0995 std::make_shared<const DiscTrapezoidBounds>(2_mm, 4_mm, 20_mm, 40_mm));
0996 BOOST_CHECK(!ring->contains(tgContext, *trapezoid));
0997 }
0998
0999 BOOST_AUTO_TEST_SUITE_END()
1000
1001 }