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