Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:04

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/SpacePointContainer2.hpp"
0012 #include "Acts/EventData/Types.hpp"
0013 #include "Acts/Seeding2/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(SpacePointIndex2 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<SpacePointIndex2>& 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   class Proxy {
0075    public:
0076     Proxy(const TripletTopCandidates* container, Index index)
0077         : m_container(container), m_index(index) {}
0078 
0079     SpacePointIndex2 spacePoint() const {
0080       return m_container->m_topSpacePoints[m_index];
0081     }
0082 
0083     float curvature() const { return m_container->m_curvatures[m_index]; }
0084 
0085     float impactParameter() const {
0086       return m_container->m_impactParameters[m_index];
0087     }
0088 
0089    private:
0090     const TripletTopCandidates* m_container{};
0091     Index m_index{};
0092   };
0093 
0094   /// @brief Provides access to a triplet candidate via proxy object
0095   /// @param index Index of the candidate to access
0096   /// @return Proxy object providing structured access to candidate data
0097   Proxy operator[](Index index) const { return Proxy(this, index); }
0098 
0099   /// Type alias for const iterator over triplet candidates
0100   using const_iterator =
0101       Acts::detail::ContainerIterator<TripletTopCandidates, Proxy, Index, true>;
0102 
0103   /// @brief Returns iterator to the beginning of the candidate collection
0104   /// @return Const iterator pointing to the first triplet candidate
0105   const_iterator begin() const { return const_iterator(*this, 0); }
0106   /// @brief Returns iterator to the end of the candidate collection
0107   /// @return Const iterator pointing past the last triplet candidate
0108   const_iterator end() const { return const_iterator(*this, size()); }
0109 
0110  private:
0111   std::vector<SpacePointIndex2> m_topSpacePoints;
0112   std::vector<float> m_curvatures;
0113   std::vector<float> m_impactParameters;
0114 };
0115 
0116 /// Interface and a collection of standard implementations for a triplet seed
0117 /// finder.
0118 ///
0119 /// @note The standard implementations rely on virtual function dispatch which
0120 /// did not turn out to affect the performance after measurement.
0121 class TripletSeedFinder {
0122  public:
0123   /// Collection of configuration parameters for the triplet seed finder. This
0124   /// includes triplet cuts, steering switches, and assumptions about the space
0125   /// points.
0126   struct Config {
0127     /// Delegates for accessors to detailed information on double strip
0128     /// measurement that produced the space point. This is mainly referring to
0129     /// space points produced when combining measurement from strips on
0130     /// back-to-back modules. Enables setting of the following delegates.
0131     bool useStripInfo = false;
0132 
0133     /// Whether the input doublets are sorted by cotTheta
0134     bool sortedByCotTheta = true;
0135 
0136     /// Minimum transverse momentum (pT) used to check the r-z slope
0137     /// compatibility of triplets with maximum multiple scattering effect
0138     /// (produced by the minimum allowed pT particle) + a certain uncertainty
0139     /// term. Check the documentation for more information
0140     /// https://acts.readthedocs.io/en/latest/core/reconstruction/pattern_recognition/seeding.html
0141     float minPt = 400 * UnitConstants::MeV;
0142     /// Number of sigmas of scattering angle to be considered in the minimum pT
0143     /// scattering term
0144     float sigmaScattering = 5;
0145     /// Term that accounts for the thickness of scattering medium in radiation
0146     /// lengths in the Lynch & Dahl correction to the Highland equation default
0147     /// is 5%
0148     float radLengthPerSeed = 0.05;
0149     /// Maximum value of impact parameter estimation of the seed candidates
0150     float impactMax = 20 * UnitConstants::mm;
0151     /// Parameter which can loosen the tolerance of the track seed to form a
0152     /// helix. This is useful for e.g. misaligned seeding.
0153     float helixCutTolerance = 1;
0154 
0155     /// Tolerance parameter used to check the compatibility of space-point
0156     /// coordinates in xyz. This is only used in a detector specific check for
0157     /// strip modules
0158     float toleranceParam = 1.1 * UnitConstants::mm;
0159   };
0160 
0161   /// Derived configuration for the triplet seed finder using a magnetic field.
0162   struct DerivedConfig : public Config {
0163     /// @brief Constructor for derived configuration with magnetic field
0164     /// @param config Base configuration parameters to inherit
0165     /// @param bFieldInZ Magnetic field strength in Z direction [T]
0166     DerivedConfig(const Config& config, float bFieldInZ);
0167 
0168     /// Magnetic field strength in Z direction
0169     float bFieldInZ = std::numeric_limits<float>::quiet_NaN();
0170     /// Highland term for multiple scattering calculations
0171     float highland = std::numeric_limits<float>::quiet_NaN();
0172     /// Conversion factor from pT to helix radius in magnetic field
0173     float pTPerHelixRadius = std::numeric_limits<float>::quiet_NaN();
0174     /// Minimum squared helix diameter for track candidates
0175     float minHelixDiameter2 = std::numeric_limits<float>::quiet_NaN();
0176     /// Squared pT uncertainty per unit radius for helix fitting
0177     float sigmapT2perRadius = std::numeric_limits<float>::quiet_NaN();
0178     /// Squared multiple scattering angle for uncertainty calculations
0179     float multipleScattering2 = std::numeric_limits<float>::quiet_NaN();
0180   };
0181 
0182   /// Creates a new triplet seed finder instance given the configuration.
0183   /// @param config Configuration for the triplet seed finder
0184   /// @return Unique pointer to new TripletSeedFinder instance
0185   static std::unique_ptr<TripletSeedFinder> create(const DerivedConfig& config);
0186 
0187   virtual ~TripletSeedFinder() = default;
0188 
0189   /// Returns the configuration of the triplet seed finder.
0190   /// @return Reference to the configuration object
0191   virtual const DerivedConfig& config() const = 0;
0192 
0193   /// Create triplets from the bottom, middle, and top space points.
0194   ///
0195   /// @param spacePoints Space point container
0196   /// @param spM Space point candidate to be used as middle SP in a seed
0197   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0198   /// @param topDoublets Top doublets to be used for triplet creation
0199   /// @param tripletTopCandidates Cache for triplet top candidates
0200   virtual void createTripletTopCandidates(
0201       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0202       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0203       DoubletsForMiddleSp::Range& topDoublets,
0204       TripletTopCandidates& tripletTopCandidates) const = 0;
0205 
0206   /// Create triplets from the bottom, middle, and top space points.
0207   ///
0208   /// @param spacePoints Space point container
0209   /// @param spM Space point candidate to be used as middle SP in a seed
0210   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0211   /// @param topDoublets Top doublets to be used for triplet creation
0212   /// @param tripletTopCandidates Cache for triplet top candidates
0213   virtual void createTripletTopCandidates(
0214       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0215       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0216       DoubletsForMiddleSp::Subset& topDoublets,
0217       TripletTopCandidates& tripletTopCandidates) const = 0;
0218 
0219   /// Create triplets from the bottom, middle, and top space points.
0220   ///
0221   /// @param spacePoints Space point container
0222   /// @param spM Space point candidate to be used as middle SP in a seed
0223   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0224   /// @param topDoublets Top doublets to be used for triplet creation
0225   /// @param tripletTopCandidates Cache for triplet top candidates
0226   virtual void createTripletTopCandidates(
0227       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0228       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0229       DoubletsForMiddleSp::Subset2& topDoublets,
0230       TripletTopCandidates& tripletTopCandidates) const = 0;
0231 };
0232 
0233 }  // namespace Acts