File indexing completed on 2025-01-18 09:12:38
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/Geometry/GenericApproachDescriptor.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/Layer.hpp"
0017 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0018 #include "Acts/Surfaces/CylinderSurface.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceArray.hpp"
0021 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0022 #include "Acts/Utilities/Intersection.hpp"
0023
0024 #include <cstddef>
0025 #include <limits>
0026 #include <memory>
0027 #include <vector>
0028
0029 #include "../Surfaces/SurfaceStub.hpp"
0030 #include "LayerStub.hpp"
0031
0032 namespace Acts::Test::Layers {
0033
0034
0035 GeometryContext tgContext = GeometryContext();
0036
0037 BOOST_AUTO_TEST_SUITE(Layers)
0038
0039
0040
0041 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorConstruction) {
0042 std::vector<std::shared_ptr<const Surface>> someSurfaces{
0043 Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
0044 BOOST_CHECK_NO_THROW(
0045 GenericApproachDescriptor minimallyConstructedApproachDescriptor(
0046 someSurfaces));
0047
0048 std::vector<std::shared_ptr<const Layer>> sharedLayers{
0049 std::make_shared<LayerStub>(nullptr),
0050 std::make_shared<LayerStub>(nullptr)};
0051 BOOST_CHECK_NO_THROW(GenericApproachDescriptor sharedLayerApproachDescriptor(
0052 {sharedLayers.at(0)->surfaceRepresentation().getSharedPtr(),
0053 sharedLayers.at(1)->surfaceRepresentation().getSharedPtr()}));
0054 }
0055
0056
0057 BOOST_AUTO_TEST_CASE(GenericApproachDescriptorProperties) {
0058 Vector3 origin{
0059 0.,
0060 0.,
0061 0.,
0062 };
0063 Vector3 zDir{0., 0., 1.};
0064 BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
0065 double nearLimit = -100 * UnitConstants::um;
0066 double farLimit = std::numeric_limits<double>::max();
0067
0068 std::vector<std::shared_ptr<const Surface>> someSurfaces{
0069 Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
0070 GenericApproachDescriptor approachDescriptor(someSurfaces);
0071 LayerStub aLayer(nullptr);
0072
0073 BOOST_CHECK_NO_THROW(approachDescriptor.registerLayer(aLayer));
0074
0075 SurfaceIntersection surfIntersection = approachDescriptor.approachSurface(
0076 tgContext, origin, zDir, boundaryTolerance, nearLimit, farLimit);
0077 double expectedIntersection = 20.0;
0078 CHECK_CLOSE_REL(surfIntersection.pathLength(), expectedIntersection, 1e-6);
0079
0080 BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().size(),
0081 someSurfaces.size());
0082
0083 for (std::size_t i = 0; i < someSurfaces.size(); i++) {
0084 BOOST_CHECK_EQUAL(approachDescriptor.containedSurfaces().at(i),
0085 someSurfaces.at(i).get());
0086 }
0087 }
0088
0089
0090
0091
0092 BOOST_AUTO_TEST_CASE(GenericApproachNoOverstepping) {
0093 Vector3 origin{0., -0.5, 1.};
0094 Vector3 direction{0., 1., 0.};
0095 BoundaryTolerance boundaryTolerance = BoundaryTolerance::None();
0096 double nearLimit = -100 * UnitConstants::um;
0097 double farLimit = std::numeric_limits<double>::max();
0098
0099 auto conCyl =
0100 Surface::makeShared<CylinderSurface>(Transform3::Identity(), 10., 20.);
0101
0102 std::vector<std::shared_ptr<const Surface>> approachSurface = {conCyl};
0103
0104 GenericApproachDescriptor gad(approachSurface);
0105
0106 auto sfIntersection =
0107 gad.approachSurface(GeometryContext(), origin, direction,
0108 boundaryTolerance, nearLimit, farLimit);
0109
0110
0111 CHECK_CLOSE_ABS(sfIntersection.pathLength(), 10.5, s_epsilon);
0112 CHECK_CLOSE_ABS(sfIntersection.position().x(), 0., s_epsilon);
0113 CHECK_CLOSE_ABS(sfIntersection.position().y(), 10., s_epsilon);
0114 CHECK_CLOSE_ABS(sfIntersection.position().z(), 1., s_epsilon);
0115 }
0116
0117 BOOST_AUTO_TEST_SUITE_END()
0118 }