File indexing completed on 2025-10-22 07:53:24
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/Geometry/GeometryIdentifier.hpp"
0013 #include "Acts/Seeding/HoughTransformUtils.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015
0016 #include <array>
0017 #include <memory>
0018 #include <vector>
0019
0020 using namespace Acts;
0021
0022 namespace ActsTests {
0023
0024 auto logger = getDefaultLogger("UnitTests", Logging::VERBOSE);
0025
0026 struct DriftCircle {
0027 double y{0.};
0028 double z{0.};
0029 double rDrift{0.};
0030 double rDriftError{0.};
0031
0032 DriftCircle(const double _y, const double _z, const double _r,
0033 const double _rUncert)
0034 : y{_y}, z{_z}, rDrift{_r}, rDriftError{_rUncert} {}
0035 };
0036
0037 BOOST_AUTO_TEST_SUITE(SeedingSuite)
0038
0039 BOOST_AUTO_TEST_CASE(hough_transform_seeder) {
0040 Logging::ScopedFailureThreshold ft{Logging::FATAL};
0041
0042
0043
0044 std::vector<std::pair<double, double>> simHits = {
0045 {-0.0401472 / 0.994974, -422.612}};
0046
0047
0048 constexpr double uncert{0.3};
0049 std::array<DriftCircle, 6> driftCircles{
0050 DriftCircle{-427.981, -225.541, 14.5202, uncert},
0051 DriftCircle{-412.964, -199.53, 1.66237, uncert},
0052 DriftCircle{-427.981, -173.519, 12.3176, uncert},
0053 DriftCircle{-427.981, 173.519, 1.5412, uncert},
0054 DriftCircle{-442.999, 199.53, 12.3937, uncert},
0055 DriftCircle{-427.981, 225.541, 3.77967, uncert}
0056
0057 };
0058
0059
0060 HoughTransformUtils::HoughPlaneConfig planeCfg;
0061 planeCfg.nBinsX = 1000;
0062 planeCfg.nBinsY = 1000;
0063
0064
0065 HoughTransformUtils::PeakFinders::IslandsAroundMaxConfig peakFinderCfg;
0066 peakFinderCfg.fractionCutoff = 0.7;
0067 peakFinderCfg.threshold = 3.;
0068 peakFinderCfg.minSpacingBetweenPeaks = {0., 30.};
0069
0070
0071
0072 HoughTransformUtils::HoughAxisRanges axisRanges{-3., 3., -2000., 2000.};
0073
0074
0075
0076
0077
0078 auto houghParamFromDCleft = [](double tanTheta, const DriftCircle& DC) {
0079 return DC.y - tanTheta * DC.z - DC.rDrift / std::cos(std::atan(tanTheta));
0080 };
0081
0082 auto houghParamFromDCright = [](double tanTheta, const DriftCircle& DC) {
0083 return DC.y - tanTheta * DC.z + DC.rDrift / std::cos(std::atan(tanTheta));
0084 };
0085
0086
0087 auto houghWidthFromDC = [](double, const DriftCircle& DC) {
0088 return std::min(DC.rDriftError * 3.,
0089 1.0);
0090
0091
0092 };
0093
0094
0095 HoughTransformUtils::HoughPlane<GeometryIdentifier::Value> houghPlane(
0096 planeCfg);
0097
0098
0099 HoughTransformUtils::PeakFinders::IslandsAroundMax<GeometryIdentifier::Value>
0100 peakFinder(peakFinderCfg);
0101
0102
0103 for (auto& sh : simHits) {
0104 houghPlane.reset();
0105
0106 for (std::size_t k = 0; k < driftCircles.size(); ++k) {
0107 auto dc = driftCircles[k];
0108
0109 houghPlane.fill<DriftCircle>(dc, axisRanges, houghParamFromDCleft,
0110 houghWidthFromDC, k);
0111 houghPlane.fill<DriftCircle>(dc, axisRanges, houghParamFromDCright,
0112 houghWidthFromDC, k);
0113 }
0114
0115
0116 auto maxima = peakFinder.findPeaks(houghPlane, axisRanges);
0117 for (auto& max : maxima) {
0118
0119 BOOST_CHECK_CLOSE(max.x, sh.first, 4.);
0120 BOOST_CHECK_CLOSE(max.y, sh.second, 0.2);
0121 }
0122 }
0123 }
0124
0125 BOOST_AUTO_TEST_SUITE_END()
0126
0127 }