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/KdtSurfacesProvider.hpp"
0013 #include "Acts/Geometry/Extent.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/LayerCreator.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp"
0018 #include "Acts/Utilities/BinningType.hpp"
0019 #include "Acts/Utilities/Enumerate.hpp"
0020 #include "Acts/Utilities/GridAxisGenerators.hpp"
0021
0022 #include <algorithm>
0023 #include <cstddef>
0024 #include <iterator>
0025 #include <memory>
0026 #include <utility>
0027 #include <vector>
0028
0029 using namespace Acts;
0030 using namespace Acts::Test;
0031 using namespace Acts::Experimental;
0032
0033 GeometryContext tContext;
0034 CylindricalTrackingGeometry cGeometry = CylindricalTrackingGeometry(tContext);
0035
0036 namespace {
0037
0038
0039
0040 std::vector<std::shared_ptr<Acts::Surface>> unpackSurfaces(
0041 const std::vector<const Acts::Surface*>& surfaces) {
0042 std::vector<std::shared_ptr<Acts::Surface>> uSurfaces;
0043 uSurfaces.reserve(surfaces.size());
0044 for (const auto& s : surfaces) {
0045 Surface* ncs = const_cast<Surface*>(s);
0046 uSurfaces.push_back(ncs->getSharedPtr());
0047 }
0048 return uSurfaces;
0049 }
0050
0051 std::vector<std::shared_ptr<Acts::Surface>> pixelSurfaces(
0052 CylindricalTrackingGeometry::DetectorStore& dStore) {
0053
0054 std::vector<std::shared_ptr<Acts::Surface>> pixelSurfaces;
0055
0056 std::vector<double> pixelDiscs = {-800., -700., -600., 600., 700., 800.};
0057 for (const auto& z : pixelDiscs) {
0058 auto rSurfaces = cGeometry.surfacesRing(dStore, 6.4, 12.4, 36., 0.125, 0.,
0059 55., z, 2., 22u);
0060 auto urSurfaces = unpackSurfaces(rSurfaces);
0061 pixelSurfaces.insert(pixelSurfaces.end(), urSurfaces.begin(),
0062 urSurfaces.end());
0063 }
0064
0065 std::vector<double> pixelBarrels = {32., 72., 116., 172.};
0066 std::vector<std::pair<int, int>> pixelBinning = {
0067 {16, 14}, {32, 14}, {52, 14}, {78, 14}};
0068 for (auto [ir, r] : enumerate(pixelBarrels)) {
0069 auto cSurfaces = cGeometry.surfacesCylinder(dStore, 8.4, 36., 0.15, 0.145,
0070 r, 3., 2., pixelBinning[ir]);
0071
0072 auto ucSurfaces = unpackSurfaces(cSurfaces);
0073 pixelSurfaces.insert(pixelSurfaces.end(), ucSurfaces.begin(),
0074 ucSurfaces.end());
0075 }
0076 return pixelSurfaces;
0077 }
0078
0079 }
0080
0081 BOOST_AUTO_TEST_SUITE(Detector)
0082
0083
0084 BOOST_AUTO_TEST_CASE(KdtSurfacesProvider_misconfigured) {
0085 Acts::Extent region;
0086 BOOST_CHECK_THROW(
0087 Acts::Experimental::KdtSurfacesProvider<> end3(nullptr, region),
0088 std::invalid_argument);
0089 }
0090
0091
0092 BOOST_AUTO_TEST_CASE(KdtSurfacesProvider) {
0093
0094 CylindricalTrackingGeometry::DetectorStore dStore;
0095 auto pSurfaces = pixelSurfaces(dStore);
0096
0097 std::size_t refNumber = 6u * 22u + 14u * (16u + 32u + 52u + 78u);
0098 BOOST_CHECK_EQUAL(pSurfaces.size(), refNumber);
0099
0100 using KDTS = Acts::Experimental::KdtSurfaces<>;
0101 auto skdt = std::make_shared<KDTS>(
0102 KDTS(tContext, pSurfaces, {AxisDirection::AxisZ, AxisDirection::AxisR}));
0103
0104
0105 Acts::Extent regionND3;
0106 regionND3.set(AxisDirection::AxisZ, -820, -780);
0107 regionND3.set(AxisDirection::AxisR, 0., 200.);
0108 Acts::Experimental::KdtSurfacesProvider<> end3(skdt, regionND3);
0109
0110 auto nd3 = end3.surfaces(tContext);
0111 BOOST_CHECK_EQUAL(nd3.size(), 22u);
0112
0113
0114 Acts::Extent regionB1;
0115 regionB1.set(AxisDirection::AxisZ, -580, 580);
0116 regionB1.set(AxisDirection::AxisR, 60., 80.);
0117
0118 Acts::Experimental::KdtSurfacesProvider<> ba1(skdt, regionB1);
0119
0120 auto b1 = ba1.surfaces(tContext);
0121 refNumber = 32u * 14u;
0122 BOOST_CHECK_EQUAL(b1.size(), refNumber);
0123 }
0124
0125 BOOST_AUTO_TEST_SUITE_END()