Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:18:26

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/EventData/SpacePointContainer.hpp"
0012 #include "Acts/EventData/Types.hpp"
0013 #include "Acts/Seeding/DoubletSeedFinder.hpp"
0014 #include "Acts/Utilities/detail/ContainerIterator.hpp"
0015 
0016 #include <vector>
0017 
0018 namespace Acts {
0019 
0020 /// Container for triplet candidates found by the triplet seed finder.
0021 ///
0022 /// This implementation uses partial AoS/SoA depending on the access pattern in
0023 /// the triplet finding process.
0024 class TripletTopCandidates {
0025  public:
0026   /// Type alias for candidate index type
0027   using Index = std::uint32_t;
0028 
0029   /// @brief Returns the number of triplet candidates stored
0030   /// @return Number of triplet candidates in the container
0031   Index size() const { return static_cast<Index>(m_topSpacePoints.size()); }
0032 
0033   /// @brief Reserves storage space for the specified number of candidates
0034   /// @param size Number of candidates to reserve space for
0035   void reserve(Index size) {
0036     m_topSpacePoints.reserve(size);
0037     m_curvatures.reserve(size);
0038     m_impactParameters.reserve(size);
0039   }
0040 
0041   /// @brief Clears all stored triplet candidates
0042   /// Removes all candidates from the container and frees memory
0043   void clear() {
0044     m_topSpacePoints.clear();
0045     m_curvatures.clear();
0046     m_impactParameters.clear();
0047   }
0048 
0049   /// @brief Adds a new triplet candidate to the container
0050   /// @param spT Space point index for the top space point of the triplet
0051   /// @param curvature Track curvature estimation for the triplet
0052   /// @param impactParameter Impact parameter estimation for the triplet
0053   void emplace_back(SpacePointIndex spT, float curvature,
0054                     float impactParameter) {
0055     m_topSpacePoints.emplace_back(spT);
0056     m_curvatures.emplace_back(curvature);
0057     m_impactParameters.emplace_back(impactParameter);
0058   }
0059 
0060   /// @brief Returns the vector of top space point indices
0061   /// @return Const reference to vector containing all top space point indices
0062   const std::vector<SpacePointIndex>& topSpacePoints() const {
0063     return m_topSpacePoints;
0064   }
0065   /// @brief Returns the vector of track curvature estimations
0066   /// @return Const reference to vector containing curvature values for all candidates
0067   const std::vector<float>& curvatures() const { return m_curvatures; }
0068   /// @brief Returns the vector of impact parameter estimations
0069   /// @return Const reference to vector containing impact parameter values for all candidates
0070   const std::vector<float>& impactParameters() const {
0071     return m_impactParameters;
0072   }
0073 
0074   /// Proxy providing access to a triplet candidate.
0075   class Proxy {
0076    public:
0077     /// Constructor
0078     /// @param container The container to proxy
0079     /// @param index The index of the candidate in the container
0080     Proxy(const TripletTopCandidates* container, Index index)
0081         : m_container(container), m_index(index) {}
0082 
0083     /// Get the space point index
0084     /// @return The space point index
0085     SpacePointIndex spacePoint() const {
0086       return m_container->m_topSpacePoints[m_index];
0087     }
0088 
0089     /// Get the curvature estimation
0090     /// @return The curvature value
0091     float curvature() const { return m_container->m_curvatures[m_index]; }
0092 
0093     /// Get the impact parameter estimation
0094     /// @return The impact parameter value
0095     float impactParameter() const {
0096       return m_container->m_impactParameters[m_index];
0097     }
0098 
0099    private:
0100     const TripletTopCandidates* m_container{};
0101     Index m_index{};
0102   };
0103 
0104   /// @brief Provides access to a triplet candidate via proxy object
0105   /// @param index Index of the candidate to access
0106   /// @return Proxy object providing structured access to candidate data
0107   Proxy operator[](Index index) const { return Proxy(this, index); }
0108 
0109   /// Type alias for const iterator over triplet candidates
0110   using const_iterator =
0111       Acts::detail::ContainerIterator<TripletTopCandidates, Proxy, Index, true>;
0112 
0113   /// @brief Returns iterator to the beginning of the candidate collection
0114   /// @return Const iterator pointing to the first triplet candidate
0115   const_iterator begin() const { return const_iterator(*this, 0); }
0116   /// @brief Returns iterator to the end of the candidate collection
0117   /// @return Const iterator pointing past the last triplet candidate
0118   const_iterator end() const { return const_iterator(*this, size()); }
0119 
0120  private:
0121   std::vector<SpacePointIndex> m_topSpacePoints;
0122   std::vector<float> m_curvatures;
0123   std::vector<float> m_impactParameters;
0124 };
0125 
0126 /// Interface and a collection of standard implementations for a triplet seed
0127 /// finder.
0128 ///
0129 /// @note The standard implementations rely on virtual function dispatch which
0130 /// did not turn out to affect the performance after measurement.
0131 class TripletSeedFinder {
0132  public:
0133   /// Collection of configuration parameters for the triplet seed finder. This
0134   /// includes triplet cuts, steering switches, and assumptions about the space
0135   /// points.
0136   struct Config {
0137     /// Delegates for accessors to detailed information on double strip
0138     /// measurement that produced the space point. This is mainly referring to
0139     /// space points produced when combining measurement from strips on
0140     /// back-to-back modules. Enables setting of the following delegates.
0141     bool useStripInfo = false;
0142 
0143     /// Whether the input doublets are sorted by cotTheta
0144     bool sortedByCotTheta = true;
0145 
0146     /// Minimum transverse momentum (pT) used to check the r-z slope
0147     /// compatibility of triplets with maximum multiple scattering effect
0148     /// (produced by the minimum allowed pT particle) + a certain uncertainty
0149     /// term. Check the documentation for more information
0150     /// https://acts.readthedocs.io/en/latest/core/reconstruction/pattern_recognition/seeding.html
0151     float minPt = 400 * UnitConstants::MeV;
0152     /// Number of sigmas of scattering angle to be considered in the minimum pT
0153     /// scattering term
0154     float sigmaScattering = 5;
0155     /// Term that accounts for the thickness of scattering medium in radiation
0156     /// lengths in the Lynch & Dahl correction to the Highland equation default
0157     /// is 5%
0158     float radLengthPerSeed = 0.05;
0159     /// Maximum value of impact parameter estimation of the seed candidates
0160     float impactMax = 20 * UnitConstants::mm;
0161     /// Parameter which can loosen the tolerance of the track seed to form a
0162     /// helix. This is useful for e.g. misaligned seeding.
0163     float helixCutTolerance = 1;
0164 
0165     /// Tolerance parameter used to check the compatibility of space-point
0166     /// coordinates in xyz. This is only used in a detector specific check for
0167     /// strip modules.
0168     float toleranceParam = 1.1;
0169 
0170     /// Maximum allowed difference in cot(theta) between the bottom and top
0171     /// doublets, applied as a pre-filter before the expensive strip
0172     /// coordinate transformation. Only active when useStripInfo is true.
0173     /// Set to infinity (default) to disable.
0174     float cotThetaDiffMax = std::numeric_limits<float>::infinity();
0175   };
0176 
0177   /// Derived configuration for the triplet seed finder using a magnetic field.
0178   struct DerivedConfig : public Config {
0179     /// @brief Constructor for derived configuration with magnetic field
0180     /// @param config Base configuration parameters to inherit
0181     /// @param bFieldInZ Magnetic field strength in Z direction [T]
0182     DerivedConfig(const Config& config, float bFieldInZ);
0183 
0184     /// Magnetic field strength in Z direction
0185     float bFieldInZ = std::numeric_limits<float>::quiet_NaN();
0186     /// Highland term for multiple scattering calculations
0187     float highland = std::numeric_limits<float>::quiet_NaN();
0188     /// Conversion factor from pT to helix radius in magnetic field
0189     float pTPerHelixRadius = std::numeric_limits<float>::quiet_NaN();
0190     /// Minimum squared helix diameter for track candidates
0191     float minHelixDiameter2 = std::numeric_limits<float>::quiet_NaN();
0192     /// Squared pT uncertainty per unit radius for helix fitting
0193     float sigmapT2perRadius = std::numeric_limits<float>::quiet_NaN();
0194     /// Squared multiple scattering angle for uncertainty calculations
0195     float multipleScattering2 = std::numeric_limits<float>::quiet_NaN();
0196   };
0197 
0198   /// Creates a new triplet seed finder instance given the configuration.
0199   /// @param config Configuration for the triplet seed finder
0200   /// @return Unique pointer to new TripletSeedFinder instance
0201   static std::unique_ptr<TripletSeedFinder> create(const DerivedConfig& config);
0202 
0203   virtual ~TripletSeedFinder() = default;
0204 
0205   /// Returns the configuration of the triplet seed finder.
0206   /// @return Reference to the configuration object
0207   virtual const DerivedConfig& config() const = 0;
0208 
0209   /// Create triplets from the bottom, middle, and top space points.
0210   ///
0211   /// @param spacePoints Space point container
0212   /// @param spM Space point candidate to be used as middle SP in a seed
0213   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0214   /// @param topDoublets Top doublets to be used for triplet creation
0215   /// @param tripletTopCandidates Cache for triplet top candidates
0216   virtual void createTripletTopCandidates(
0217       const SpacePointContainer& spacePoints, const ConstSpacePointProxy& spM,
0218       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0219       DoubletsForMiddleSp::Range& topDoublets,
0220       TripletTopCandidates& tripletTopCandidates) const = 0;
0221 
0222   /// Create triplets from the bottom, middle, and top space points.
0223   ///
0224   /// @param spacePoints Space point container
0225   /// @param spM Space point candidate to be used as middle SP in a seed
0226   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0227   /// @param topDoublets Top doublets to be used for triplet creation
0228   /// @param tripletTopCandidates Cache for triplet top candidates
0229   virtual void createTripletTopCandidates(
0230       const SpacePointContainer& spacePoints, const ConstSpacePointProxy& spM,
0231       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0232       DoubletsForMiddleSp::Subset& topDoublets,
0233       TripletTopCandidates& tripletTopCandidates) const = 0;
0234 
0235   /// Create triplets from the bottom, middle, and top space points.
0236   ///
0237   /// @param spacePoints Space point container
0238   /// @param spM Space point candidate to be used as middle SP in a seed
0239   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0240   /// @param topDoublets Top doublets to be used for triplet creation
0241   /// @param tripletTopCandidates Cache for triplet top candidates
0242   virtual void createTripletTopCandidates(
0243       const SpacePointContainer& spacePoints, const ConstSpacePointProxy& spM,
0244       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0245       DoubletsForMiddleSp::Subset2& topDoublets,
0246       TripletTopCandidates& tripletTopCandidates) const = 0;
0247 };
0248 
0249 }  // namespace Acts