Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:45:33

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/EventData/SpacePointContainer2.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 #include "Acts/Utilities/Result.hpp"
0016 
0017 #include <string>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 /// @brief Implements the vertex finder based on the space points using Hough transform
0023 /// For more information, see arXiv:2410.14494
0024 /// 0. Assumes there is only 1 vertex and that it has a high multiplicity
0025 /// 1. Estimates what eta range is really necessary
0026 /// 2. Creates Hough space (z_vtx - cot(theta)) from space points within that
0027 /// eta range
0028 /// 3. Subtracts the coincidentally crossed lines in the Hough space
0029 /// 4. Makes a projection to the Z axis and finds a peak - that is the vertex
0030 /// position
0031 /// 5. Repeats 2-4 if necessary
0032 ///
0033 class HoughVertexFinder2 {
0034  public:
0035   /// Configuration struct
0036   struct Config {
0037     /// Ideal amount of space points; |eta| range will be limited to
0038     /// contain approximately this amount of SPs
0039     std::uint32_t targetSPs = 10000;
0040 
0041     /// Minimum and maximum ranges in |eta|; the |eta| will not be
0042     /// set outside these bounds even if targetSPs is not reached
0043     double minAbsEta = 0.3f;
0044     /// Maximum absolute pseudorapidity for vertex finding
0045     double maxAbsEta = 4.0f;
0046 
0047     /// Minimum number of hits in Hough plane to consider
0048     /// the cell to contain a track
0049     std::uint32_t minHits = 4;
0050 
0051     /// Number of neighbouring bins in Hough plane
0052     /// to fill in the cot(theta) direction
0053     std::uint32_t fillNeighbours = 0;
0054 
0055     /// The algorithm dynamically choose |eta| range necessary to
0056     /// have a reasonable precision, based on the distribution
0057     /// of the measurements.
0058     /// The first |eta| range starts at 0., the others start at
0059     /// the endpoint of the previous range.
0060     std::vector<double> absEtaRanges{2., 4.};
0061     /// The amount of measurements in the |eta| range expressed
0062     /// as a fraction of all measurements within the whole |eta| range.
0063     /// Measurements are assumed to be distributed uniformly with
0064     /// the |eta| range.
0065     std::vector<double> absEtaFractions{0.4f, 0.6f};
0066 
0067     /// The algorithm starts peak searching considering wide range
0068     /// in Z and then iteratively constrain itself to narrower ranges
0069     /// around previously found peak. At the same time it may adapt
0070     /// other Hough-image parameters in each step.
0071     std::vector<double> rangeIterZ{200. * UnitConstants::mm,
0072                                    30. * UnitConstants::mm,
0073                                    16. * UnitConstants::mm};
0074     /// Number of bins along z-axis of the Hough image for each iteration
0075     std::vector<std::uint32_t> nBinsZIterZ{800, 180, 80};
0076     /// Number of bins along cot(theta)-axis of the Hough image for
0077     /// each iteration
0078     std::vector<std::uint32_t> nBinsCotThetaIterZ{8000, 8000, 8000};
0079 
0080     /// If the actual number of measurements is below "targetSPs", then
0081     /// the number of bins along cot(theta)-axis decreases. Thus, the actual
0082     /// number of bins can be smaller than stated in "nBinsCotThetaIterZ".
0083     /// For every magnitude (in natural logarithm) below targetSPs, the number
0084     /// of bins in cot(theta) will decrease by this factor.
0085     double binsCotThetaDecrease = 1.35f;
0086 
0087     /// Width of the peak when estimating vertex position
0088     std::uint32_t peakWidth = 3;
0089 
0090     /// Default position of the vertex in X, Y, and Z coordinates
0091     Vector3 defVtxPosition{0. * UnitConstants::mm, 0. * UnitConstants::mm,
0092                            0. * UnitConstants::mm};
0093   };
0094 
0095   /// @brief Constructor
0096   /// @param cfg Configuration object
0097   /// @param lgr Logging instance
0098   explicit HoughVertexFinder2(
0099       Config cfg,
0100       std::unique_ptr<const Logger> lgr = getDefaultLogger("HoughVertexFinder2",
0101                                                            Logging::INFO));
0102 
0103   /// Const access to the config
0104   /// @return Const reference to the configuration object
0105   const Config& config() const { return m_cfg; }
0106 
0107   /// @brief Finds the vertex based on the provided space points
0108   /// @param spacePoints Vector of the input space points; they do not need to be sorted anyhow
0109   /// @return Position of the vertex
0110   Acts::Result<Acts::Vector3> find(
0111       const SpacePointContainer2& spacePoints) const;
0112 
0113  private:
0114   /// Configuration instance
0115   const Config m_cfg;
0116 
0117   /// @brief Returns the positions of the peak along Z axis in the projection of the Hough plane
0118   /// @param spacePoints Set of all space points within the event
0119   /// @param vtxOld Previous position of the vertex
0120   /// @param rangeZ Range in along Z around vtxOld_z to consider when looking for the new vertex
0121   /// @param numZBins Number of bins along Z axis
0122   /// @param minCotTheta Minimum theta to consider for the space points
0123   /// @param maxCotTheta Maximum theta to consider for the space points
0124   /// @param numCotThetaBins Number of bins along cot(theta) axis
0125   /// @return Position of the vertex in (X,Y,Z)
0126   Acts::Result<Acts::Vector3> findHoughVertex(
0127       const SpacePointContainer2& spacePoints, const Acts::Vector3& vtxOld,
0128       double rangeZ, std::uint32_t numZBins, double minCotTheta,
0129       double maxCotTheta, std::uint32_t numCotThetaBins) const;
0130 
0131   /// @brief Finds the peak in the Z axis projection of the Hough space
0132   /// @param houghZProjection Hough space projection after the cleaning procedure
0133   /// @param vtxZPositions Bins position in the Hough space projection
0134   /// @return Position of the peak
0135   Acts::Result<double> findHoughPeak(
0136       const std::vector<std::uint32_t>& houghZProjection,
0137       const std::vector<double>& vtxZPositions) const;
0138 
0139   /// Logging instance
0140   std::unique_ptr<const Logger> m_logger;
0141 
0142   /// Private access to logging instance
0143   const Logger& logger() const { return *m_logger; }
0144 };
0145 
0146 }  // namespace Acts