File indexing completed on 2025-01-18 09:12:33
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/Detector/detail/IndexedSurfacesGenerator.hpp"
0013 #include "Acts/Detector/detail/ReferenceGenerators.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/LayerCreator.hpp"
0016 #include "Acts/Navigation/InternalNavigation.hpp"
0017 #include "Acts/Navigation/NavigationDelegates.hpp"
0018 #include "Acts/Navigation/NavigationStateUpdaters.hpp"
0019 #include "Acts/Surfaces/DiscSurface.hpp"
0020 #include "Acts/Surfaces/RadialBounds.hpp"
0021 #include "Acts/Surfaces/Surface.hpp"
0022 #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0023 #include "Acts/Utilities/AxisDefinitions.hpp"
0024 #include "Acts/Utilities/BinningType.hpp"
0025 #include "Acts/Utilities/Delegate.hpp"
0026 #include "Acts/Utilities/Enumerate.hpp"
0027 #include "Acts/Utilities/Grid.hpp"
0028 #include "Acts/Utilities/GridAxisGenerators.hpp"
0029
0030 #include <array>
0031 #include <cmath>
0032 #include <cstddef>
0033 #include <memory>
0034 #include <numbers>
0035 #include <set>
0036 #include <tuple>
0037 #include <utility>
0038 #include <vector>
0039
0040 using namespace Acts;
0041 using namespace Acts::Test;
0042 using namespace Acts::Experimental;
0043 using namespace Acts::Experimental::detail;
0044
0045 GeometryContext tContext;
0046 CylindricalTrackingGeometry cGeometry = CylindricalTrackingGeometry(tContext);
0047
0048 BOOST_AUTO_TEST_SUITE(Detector)
0049
0050 BOOST_AUTO_TEST_CASE(RingDisc1D) {
0051
0052 CylindricalTrackingGeometry::DetectorStore dStore;
0053 auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
0054 55., 0., 2., 22u);
0055
0056 IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0057 irSurfaces{rSurfaces, {}, {AxisDirection::AxisPhi}};
0058
0059 GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi},
0060 44u};
0061 PolyhedronReferenceGenerator<1u, true> rGenerator;
0062
0063 auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0064
0065 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0066 using DelegateType =
0067 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0068
0069 const auto* instance = indexedRing.instance();
0070 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0071
0072 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0073
0074 const auto& chainedUpdaters = castedDelegate->updators;
0075 const auto& indexedSurfaces =
0076 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0077 const auto& grid = indexedSurfaces.grid;
0078
0079
0080 std::vector<std::size_t> reference = {10, 11, 12};
0081 GridType::point_t p = {0.05};
0082
0083 BOOST_CHECK(grid.atPosition(p) == reference);
0084
0085
0086 reference = {0, 1, 21};
0087 p = {-std::numbers::pi + 0.05};
0088 BOOST_CHECK(grid.atPosition(p) == reference);
0089 }
0090
0091 BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) {
0092
0093 CylindricalTrackingGeometry::DetectorStore dStore;
0094 auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
0095 55., 0., 2., 22u);
0096
0097 auto rBounds = std::make_shared<RadialBounds>(20., 20.);
0098 auto dSurface = Surface::makeShared<DiscSurface>(Transform3::Identity(),
0099 std::move(rBounds));
0100 rSurfaces.push_back(dSurface.get());
0101
0102 IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0103 irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {AxisDirection::AxisPhi}};
0104
0105 GridAxisGenerators::EqClosed aGenerator{{-std::numbers::pi, std::numbers::pi},
0106 44u};
0107 PolyhedronReferenceGenerator<1u, true> rGenerator;
0108
0109 auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0110
0111 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0112
0113 using DelegateType =
0114 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0115
0116 const auto* instance = indexedRing.instance();
0117 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0118
0119 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0120
0121 const auto& chainedUpdaters = castedDelegate->updators;
0122 const auto& indexedSurfaces =
0123 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0124 const auto& grid = indexedSurfaces.grid;
0125
0126
0127
0128 std::vector<std::size_t> reference = {10, 11, 12, 22};
0129 GridType::point_t p = {0.05};
0130 BOOST_CHECK(grid.atPosition(p) == reference);
0131
0132
0133 reference = {0, 1, 21, 22};
0134 p = {-std::numbers::pi + 0.05};
0135 BOOST_CHECK(grid.atPosition(p) == reference);
0136 }
0137
0138 BOOST_AUTO_TEST_CASE(RingDisc2D) {
0139
0140 CylindricalTrackingGeometry::DetectorStore dStore;
0141 auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0142 42., 0., 2., 22u);
0143
0144 auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0145 80., 0., 2., 22u);
0146
0147 decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0148 rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0149
0150 IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0151 irSurfaces{rSurfaces, {}, {AxisDirection::AxisR, AxisDirection::AxisPhi}};
0152
0153 GridAxisGenerators::VarBoundEqClosed aGenerator{
0154 {24., 74., 110.}, {-std::numbers::pi, std::numbers::pi}, 44u};
0155 PolyhedronReferenceGenerator<1u, true> rGenerator;
0156
0157 auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0158
0159 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0160
0161 using DelegateType =
0162 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0163
0164 const auto* instance = indexedRing.instance();
0165 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0166
0167 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0168
0169 const auto& chainedUpdaters = castedDelegate->updators;
0170 const auto& indexedSurfaces =
0171 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0172 const auto& grid = indexedSurfaces.grid;
0173
0174
0175 std::vector<std::size_t> reference = {16, 17, 38, 39};
0176 GridType::point_t p = {65., std::numbers::pi * 0.49};
0177 BOOST_CHECK(grid.atPosition(p) == reference);
0178 }
0179
0180 BOOST_AUTO_TEST_CASE(RingDisc2DFine) {
0181
0182 CylindricalTrackingGeometry::DetectorStore dStore;
0183 auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0184 42., 0., 2., 22u);
0185
0186 auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0187 80., 0., 2., 22u);
0188
0189 auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0190 122., 0., 2., 36u);
0191
0192 decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0193 rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0194 rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0195
0196 IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0197 irSurfaces{rSurfaces, {}, {AxisDirection::AxisR, AxisDirection::AxisPhi}};
0198
0199 GridAxisGenerators::EqBoundEqClosed aGenerator{
0200 {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u};
0201
0202 PolyhedronReferenceGenerator<1u, true> rGenerator;
0203
0204 auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0205
0206 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0207
0208 using DelegateType =
0209 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0210
0211 const auto* instance = indexedRing.instance();
0212 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0213
0214 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0215
0216 const auto& chainedUpdaters = castedDelegate->updators;
0217 const auto& indexedSurfaces =
0218 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0219 const auto& grid = indexedSurfaces.grid;
0220
0221
0222 std::vector<std::size_t> reference = {38, 39};
0223 GridType::point_t p = {80., std::numbers::pi * 0.49};
0224 BOOST_CHECK(grid.atPosition(p) == reference);
0225 }
0226
0227 BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) {
0228
0229 CylindricalTrackingGeometry::DetectorStore dStore;
0230 auto rSurfacesR0 = cGeometry.surfacesRing(dStore, 6.4, 12.4, 18., 0.125, 0.,
0231 42., 0., 2., 22u);
0232
0233 auto rSurfacesR1 = cGeometry.surfacesRing(dStore, 12.4, 20.4, 30., 0.125, 0.,
0234 80., 0., 2., 22u);
0235
0236 auto rSurfacesR2 = cGeometry.surfacesRing(dStore, 18.4, 28.4, 30., 0.125, 0.,
0237 122., 0., 2., 36u);
0238
0239 decltype(rSurfacesR0) rSurfaces = rSurfacesR0;
0240 rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end());
0241 rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end());
0242
0243 IndexedSurfacesGenerator<decltype(rSurfaces), IndexedSurfacesNavigation>
0244 irSurfaces{rSurfaces,
0245 {},
0246 {AxisDirection::AxisR, AxisDirection::AxisPhi},
0247 {2u, 4u}};
0248
0249 GridAxisGenerators::EqBoundEqClosed aGenerator{
0250 {24., 152}, 8u, {-std::numbers::pi, std::numbers::pi}, 88u};
0251 PolyhedronReferenceGenerator<1u, true> rGenerator;
0252
0253 auto indexedRing = irSurfaces(tContext, aGenerator, rGenerator);
0254
0255 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0256 using DelegateType =
0257 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0258
0259 const auto* instance = indexedRing.instance();
0260 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0261
0262 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0263
0264 const auto& chainedUpdaters = castedDelegate->updators;
0265 const auto& indexedSurfaces =
0266 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0267 const auto& grid = indexedSurfaces.grid;
0268
0269
0270 std::vector<std::size_t> reference = {38, 39};
0271 GridType::point_t p = {80., std::numbers::pi * 0.49};
0272 BOOST_CHECK_GT(grid.atPosition(p).size(), 2u);
0273 }
0274
0275 BOOST_AUTO_TEST_CASE(Cylinder2D) {
0276 CylindricalTrackingGeometry::DetectorStore dStore;
0277 auto surfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145,
0278 116., 3., 2., {52, 14});
0279
0280 IndexedSurfacesGenerator<decltype(surfaces), IndexedSurfacesNavigation>
0281 icSurfaces{surfaces,
0282 {},
0283 {AxisDirection::AxisZ, AxisDirection::AxisPhi},
0284 {1u, 1u}};
0285
0286 GridAxisGenerators::EqBoundEqClosed aGenerator{
0287 {-500., 500}, 28, {-std::numbers::pi, std::numbers::pi}, 52u};
0288 PolyhedronReferenceGenerator<1u, true> rGenerator;
0289
0290 auto indexedCylinder = icSurfaces(tContext, aGenerator, rGenerator);
0291
0292 using GridType = decltype(aGenerator)::grid_type<std::vector<std::size_t>>;
0293 using DelegateType =
0294 IndexedSurfacesAllPortalsNavigation<GridType, IndexedSurfacesNavigation>;
0295
0296 const auto* instance = indexedCylinder.instance();
0297 auto castedDelegate = dynamic_cast<const DelegateType*>(instance);
0298
0299 BOOST_REQUIRE_NE(castedDelegate, nullptr);
0300
0301 const auto& chainedUpdaters = castedDelegate->updators;
0302 const auto& indexedSurfaces =
0303 std::get<IndexedSurfacesNavigation<GridType>>(chainedUpdaters);
0304 const auto& grid = indexedSurfaces.grid;
0305
0306
0307 std::vector<std::size_t> reference = {676, 677, 725, 726, 727};
0308 GridType::point_t p = {490., std::numbers::pi * 0.99};
0309 BOOST_CHECK(grid.atPosition(p) == reference);
0310 }
0311
0312 BOOST_AUTO_TEST_SUITE_END()