Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/include/Acts/Vertexing/HoughVertexFinder.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Seeding/HoughTransformUtils.hpp"
0014 #include "Acts/Utilities/Axis.hpp"
0015 #include "Acts/Utilities/Grid.hpp"
0016 #include "Acts/Utilities/Logger.hpp"
0017 #include "Acts/Utilities/Result.hpp"
0018 #include "Acts/Vertexing/Vertex.hpp"
0019 
0020 #include <algorithm>
0021 #include <cmath>
0022 #include <functional>
0023 #include <iterator>
0024 #include <numeric>
0025 #include <stdexcept>
0026 #include <string>
0027 #include <system_error>
0028 #include <utility>
0029 #include <vector>
0030 
0031 namespace Acts {
0032 
0033 /// @class HoughVertexFinder
0034 ///
0035 /// @brief Implements the vertex finder based on the spacepoints using Hough transform
0036 /// For more information, see arXiv:2410.14494
0037 /// 0. Assumes there is only 1 vertex and that it has a high multiplicity
0038 /// 1. Estimates what eta range is really necessary
0039 /// 2. Creates Hough space (z_vtx - cot(theta)) from spacepoints within that eta
0040 /// range
0041 /// 3. Subtracts the coincidentally crossed lines in the Hough space
0042 /// 4. Makes a projection to the Z axis and finds a peak - that is the vertex
0043 /// position
0044 /// 5. Repeats 2-4 if necessary
0045 ///
0046 template <typename spacepoint_t>
0047 class HoughVertexFinder {
0048  public:
0049   /// Configuration struct
0050   struct Config {
0051     /// Ideal amount of spacepoints; |eta| range will be limited to
0052     /// contain approximately this amount of SPs
0053     std::uint32_t targetSPs = 10000;
0054 
0055     /// Minimum and maximum ranges in |eta|; the |eta| will not be
0056     /// set outside these bounds even if targetSPs is not reached
0057     double minAbsEta = 0.3f;
0058     double maxAbsEta = 4.0f;
0059 
0060     /// Minimum number of hits in Hough plane to consider
0061     /// the cell to contain a track
0062     std::uint32_t minHits = 4;
0063 
0064     /// Number of neighbouring bins in Hough plane
0065     /// to fill in the cot(theta) direction
0066     std::uint32_t fillNeighbours = 0;
0067 
0068     /// The algorithm dynamically choose |eta| range necessary to
0069     /// have a reasonable precision, based on the distribution
0070     /// of the measurements.
0071     /// The first |eta| range starts at 0., the others start at
0072     /// the endpoint of the previous range.
0073     std::vector<double> absEtaRanges{2., 4.};
0074     /// The amount of measurements in the |eta| range expressed
0075     /// as a fraction of all measurements within the whole |eta| range.
0076     /// Measurements are assumed to be distributed uniformly with
0077     /// the |eta| range.
0078     std::vector<double> absEtaFractions{0.4f, 0.6f};
0079 
0080     /// The algorithm starts peak searching considering wide range
0081     /// in Z and then iteratively constrain itself to narrower ranges
0082     /// around previously found peak. At the same time it may adapt
0083     /// other Hough-image parameters in each step.
0084     std::vector<double> rangeIterZ{200. * UnitConstants::mm,
0085                                    30. * UnitConstants::mm,
0086                                    16. * UnitConstants::mm};
0087     /// Number of bins along z-axis of the Hough image for each iteration
0088     std::vector<std::uint32_t> nBinsZIterZ{800, 180, 80};
0089     /// Number of bins along cot(theta)-axis of the Hough image for
0090     /// each iteration
0091     std::vector<std::uint32_t> nBinsCotThetaIterZ{8000, 8000, 8000};
0092 
0093     /// If the actual number of measurements is below "targetSPs", then
0094     /// the number of bins along cot(theta)-axis decreases. Thus, the actual
0095     /// number of bins can be smaller than stated in "nBinsCotThetaIterZ".
0096     /// For every magnitude (in natural logarithm) below targetSPs, the number
0097     /// of bins in cot(theta) will decrease by this factor.
0098     double binsCotThetaDecrease = 1.35f;
0099 
0100     /// Width of the peak when estimating vertex position
0101     std::uint32_t peakWidth = 3;
0102 
0103     /// Default position of the vertex in X, Y, and Z coordinates
0104     Vector3 defVtxPosition{0. * UnitConstants::mm, 0. * UnitConstants::mm,
0105                            0. * UnitConstants::mm};
0106   };
0107 
0108   /// Const access to the config
0109   const Config& config() const { return m_cfg; }
0110 
0111   /// @brief Constructor
0112   /// @param cfg Configuration object
0113   /// @param lgr Logging instance
0114   explicit HoughVertexFinder(
0115       Config cfg,
0116       std::unique_ptr<const Logger> lgr = getDefaultLogger("HoughVertexFinder",
0117                                                            Logging::INFO));
0118 
0119   using HoughCount_t = std::uint16_t;
0120   using HoughAxis = Axis<AxisType::Equidistant, AxisBoundaryType::Open>;
0121   using HoughHist = Grid<HoughCount_t, HoughAxis, HoughAxis>;
0122 
0123   /// @brief Finds the vertex based on the provided spacepoints
0124   /// @param spacepoints Vector of the input spacepoints; they do not need to be sorted anyhow
0125   /// @return Position of the vertex
0126   Acts::Result<Acts::Vector3> find(
0127       const std::vector<spacepoint_t>& spacepoints) const;
0128 
0129  private:
0130   /// Configuration instance
0131   const Config m_cfg;
0132 
0133   /// @brief Returns the positions of the peak along Z axis in the pojection of the Hough plane
0134   /// @param spacepoints Set of all spacepoints within the event
0135   /// @param vtxOld Previous position of the vertex
0136   /// @param rangeZ Range in along Z around vtxOld_z to consider when looking for the new vertex
0137   /// @param numZBins Number of bins along Z axis
0138   /// @param minCotTheta Minimum theta to consider for the spacepoint
0139   /// @param maxCotTheta Maximum theta to consider for the spacepoint
0140   /// @param numCotThetaBins Number of bins along cot(theta) axis
0141   /// @return Position of the vertex in (X,Y,Z)
0142   Acts::Result<Acts::Vector3> findHoughVertex(
0143       const std::vector<spacepoint_t>& spacepoints, const Acts::Vector3& vtxOld,
0144       double rangeZ, std::uint32_t numZBins, double minCotTheta,
0145       double maxCotTheta, std::uint32_t numCotThetaBins) const;
0146 
0147   /// @brief Finds the peak in the Z axis projection of the Hough space
0148   /// @param houghZProjection Hough space projection after the cleaning procedure
0149   /// @param vtxZPositions Bins position in the Hough space projection
0150   /// @return Position of the peak
0151   Acts::Result<double> findHoughPeak(
0152       const std::vector<std::uint32_t>& houghZProjection,
0153       const std::vector<double>& vtxZPositions) const;
0154 
0155   /// Logging instance
0156   std::unique_ptr<const Logger> m_logger;
0157 
0158   /// Private access to logging instance
0159   const Logger& logger() const { return *m_logger; }
0160 };
0161 
0162 }  // namespace Acts
0163 
0164 #include "HoughVertexFinder.ipp"