File indexing completed on 2025-08-06 08:11:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/ProtoLayer.hpp"
0016 #include "Acts/Surfaces/PlaneSurface.hpp"
0017 #include "Acts/Surfaces/RectangleBounds.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0020 #include "Acts/Utilities/BinningType.hpp"
0021 #include "Acts/Utilities/RangeXD.hpp"
0022
0023 #include <array>
0024 #include <cmath>
0025 #include <memory>
0026 #include <sstream>
0027 #include <string>
0028 #include <utility>
0029 #include <vector>
0030
0031 namespace Acts {
0032
0033 namespace Test {
0034 namespace Layers {
0035
0036 BOOST_AUTO_TEST_SUITE(Geometry)
0037
0038 BOOST_AUTO_TEST_CASE(ProtoLayerTests) {
0039 GeometryContext tgContext = GeometryContext();
0040
0041
0042 auto recBounds = std::make_shared<RectangleBounds>(3., 6.);
0043
0044
0045 static const Transform3 planeYZ = AngleAxis3(0.5 * M_PI, Vector3::UnitY()) *
0046 AngleAxis3(0.5 * M_PI, Vector3::UnitZ()) *
0047 Transform3::Identity();
0048 static const Transform3 planeZX = AngleAxis3(-0.5 * M_PI, Vector3::UnitX()) *
0049 AngleAxis3(-0.5 * M_PI, Vector3::UnitZ()) *
0050 Transform3::Identity();
0051
0052 std::vector<std::shared_ptr<const Surface>> surfaceStore;
0053 surfaceStore.reserve(100);
0054
0055 auto createProtoLayer = [&](const Transform3& trf,
0056 bool shared = false) -> ProtoLayer {
0057 auto atNegX = Surface::makeShared<PlaneSurface>(
0058 Transform3(trf * Translation3(Vector3(-3., 0., 0.)) * planeYZ),
0059 recBounds);
0060
0061 auto atPosX = Surface::makeShared<PlaneSurface>(
0062 Transform3(trf * Translation3(Vector3(3., 0., 0.)) * planeYZ),
0063 recBounds);
0064
0065 auto atNegY = Surface::makeShared<PlaneSurface>(
0066 Transform3(trf * Translation3(Vector3(0., -3, 0.)) * planeZX),
0067 recBounds);
0068
0069 auto atPosY = Surface::makeShared<PlaneSurface>(
0070 Transform3(trf * Translation3(Vector3(0., 3., 0.)) * planeZX),
0071 recBounds);
0072
0073 std::vector<std::shared_ptr<const Surface>> sharedSurfaces = {
0074 atNegX, atNegY, atPosX, atPosY};
0075 surfaceStore.insert(surfaceStore.begin(), sharedSurfaces.begin(),
0076 sharedSurfaces.end());
0077 if (!shared) {
0078 std::vector<const Surface*> surfaces = {atNegX.get(), atNegY.get(),
0079 atPosX.get(), atPosY.get()};
0080
0081 return ProtoLayer(tgContext, surfaces);
0082 }
0083 return ProtoLayer(tgContext, sharedSurfaces);
0084 };
0085
0086
0087 auto pLayerSf = createProtoLayer(Transform3::Identity());
0088 auto pLayerSfShared = createProtoLayer(Transform3::Identity());
0089
0090 BOOST_CHECK(pLayerSf.extent.range() == pLayerSfShared.extent.range());
0091 BOOST_CHECK(pLayerSf.envelope == pLayerSfShared.envelope);
0092
0093
0094 BOOST_CHECK_EQUAL(pLayerSf.surfaces().size(), 4);
0095
0096 auto rB = std::make_shared<RectangleBounds>(30., 60.);
0097
0098
0099 auto addSurface =
0100 Surface::makeShared<PlaneSurface>(Transform3::Identity(), rB);
0101
0102 pLayerSf.add(tgContext, *addSurface.get());
0103
0104 BOOST_CHECK_EQUAL(pLayerSf.surfaces().size(), 5);
0105
0106
0107 BOOST_CHECK(!(pLayerSf.extent.range() == pLayerSfShared.extent.range()));
0108
0109
0110 auto protoLayer = createProtoLayer(Transform3::Identity());
0111
0112 CHECK_CLOSE_ABS(protoLayer.range(binX), 12., 1e-8);
0113 CHECK_CLOSE_ABS(protoLayer.medium(binX), 0., 1e-8);
0114 CHECK_CLOSE_ABS(protoLayer.min(binX), -6., 1e-8);
0115 CHECK_CLOSE_ABS(protoLayer.max(binX), 6., 1e-8);
0116 CHECK_CLOSE_ABS(protoLayer.range(binY), 6., 1e-8);
0117 CHECK_CLOSE_ABS(protoLayer.medium(binY), 0., 1e-8);
0118 CHECK_CLOSE_ABS(protoLayer.min(binY), -3., 1e-8);
0119 CHECK_CLOSE_ABS(protoLayer.max(binY), 3., 1e-8);
0120 CHECK_CLOSE_ABS(protoLayer.range(binZ), 12., 1e-8);
0121 CHECK_CLOSE_ABS(protoLayer.medium(binZ), 0., 1e-8);
0122 CHECK_CLOSE_ABS(protoLayer.min(binZ), -6., 1e-8);
0123 CHECK_CLOSE_ABS(protoLayer.max(binZ), 6., 1e-8);
0124 CHECK_CLOSE_ABS(protoLayer.max(binR), std::hypot(3, 6), 1e-8);
0125 CHECK_CLOSE_ABS(protoLayer.min(binR), 3., 1e-8);
0126
0127
0128
0129
0130
0131 auto protoLayerRot = createProtoLayer(AngleAxis3(-0.345, Vector3::UnitZ()) *
0132 Transform3::Identity());
0133
0134 BOOST_CHECK_NE(protoLayer.min(binX), -6.);
0135 CHECK_CLOSE_ABS(protoLayerRot.medium(binX), 0., 1e-8);
0136 CHECK_CLOSE_ABS(protoLayerRot.medium(binY), 0., 1e-8);
0137 CHECK_CLOSE_ABS(protoLayerRot.range(binZ), 12., 1e-8);
0138 CHECK_CLOSE_ABS(protoLayerRot.medium(binZ), 0., 1e-8);
0139 CHECK_CLOSE_ABS(protoLayerRot.min(binZ), -6., 1e-8);
0140 CHECK_CLOSE_ABS(protoLayerRot.max(binZ), 6., 1e-8);
0141 CHECK_CLOSE_ABS(protoLayerRot.min(binR), 3., 1e-8);
0142 CHECK_CLOSE_ABS(protoLayerRot.max(binR), std::hypot(3, 6), 1e-8);
0143
0144 std::stringstream sstream;
0145 protoLayerRot.toStream(sstream);
0146 std::string oString = R"(ProtoLayer with dimensions (min/max)
0147 Extent in space :
0148 - value : binX | range = [-6.66104, 6.66104]
0149 - value : binY | range = [-4.85241, 4.85241]
0150 - value : binZ | range = [-6, 6]
0151 - value : binR | range = [3, 6.7082]
0152 - value : binPhi | range = [-3.02295, 2.33295]
0153 - value : binRPhi | range = [-20.2785, 15.6499]
0154 - value : binH | range = [0.61548, 2.52611]
0155 - value : binEta | range = [-1.14622, 1.14622]
0156 - value : binMag | range = [7.34847, 7.34847]
0157 )";
0158 BOOST_CHECK_EQUAL(sstream.str(), oString);
0159 }
0160
0161 BOOST_AUTO_TEST_SUITE_END()
0162 }
0163 }
0164
0165 }