Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:11:38

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/ContainerIterator.hpp"
0015 
0016 #include <vector>
0017 
0018 namespace Acts::Experimental {
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   using Index = std::uint32_t;
0027 
0028   Index size() const { return static_cast<Index>(m_topSpacePoints.size()); }
0029 
0030   void reserve(Index size) {
0031     m_topSpacePoints.reserve(size);
0032     m_curvatures.reserve(size);
0033     m_impactParameters.reserve(size);
0034   }
0035 
0036   void clear() {
0037     m_topSpacePoints.clear();
0038     m_curvatures.clear();
0039     m_impactParameters.clear();
0040   }
0041 
0042   void emplace_back(SpacePointIndex2 spT, float curvature,
0043                     float impactParameter) {
0044     m_topSpacePoints.emplace_back(spT);
0045     m_curvatures.emplace_back(curvature);
0046     m_impactParameters.emplace_back(impactParameter);
0047   }
0048 
0049   const std::vector<SpacePointIndex2>& topSpacePoints() const {
0050     return m_topSpacePoints;
0051   }
0052   const std::vector<float>& curvatures() const { return m_curvatures; }
0053   const std::vector<float>& impactParameters() const {
0054     return m_impactParameters;
0055   }
0056 
0057   class Proxy {
0058    public:
0059     Proxy(const TripletTopCandidates* container, Index index)
0060         : m_container(container), m_index(index) {}
0061 
0062     SpacePointIndex2 spacePoint() const {
0063       return m_container->m_topSpacePoints[m_index];
0064     }
0065 
0066     float curvature() const { return m_container->m_curvatures[m_index]; }
0067 
0068     float impactParameter() const {
0069       return m_container->m_impactParameters[m_index];
0070     }
0071 
0072    private:
0073     const TripletTopCandidates* m_container{};
0074     Index m_index{};
0075   };
0076 
0077   Proxy operator[](Index index) const { return Proxy(this, index); }
0078 
0079   using const_iterator =
0080       ContainerIterator<TripletTopCandidates, Proxy, Index, true>;
0081 
0082   const_iterator begin() const { return const_iterator(*this, 0); }
0083   const_iterator end() const { return const_iterator(*this, size()); }
0084 
0085  private:
0086   std::vector<SpacePointIndex2> m_topSpacePoints;
0087   std::vector<float> m_curvatures;
0088   std::vector<float> m_impactParameters;
0089 };
0090 
0091 /// Interface and a collection of standard implementations for a triplet seed
0092 /// finder.
0093 ///
0094 /// @note The standard implementations rely on virtual function dispatch which
0095 /// did not turn out to affect the performance after measurement.
0096 class TripletSeedFinder {
0097  public:
0098   /// Collection of configuration parameters for the triplet seed finder. This
0099   /// includes triplet cuts, steering switches, and assumptions about the space
0100   /// points.
0101   struct Config {
0102     /// Delegates for accessors to detailed information on double strip
0103     /// measurement that produced the space point. This is mainly referring to
0104     /// space points produced when combining measurement from strips on
0105     /// back-to-back modules. Enables setting of the following delegates.
0106     bool useStripInfo = false;
0107 
0108     /// Whether the input doublets are sorted by cotTheta
0109     bool sortedByCotTheta = true;
0110 
0111     /// Minimum transverse momentum (pT) used to check the r-z slope
0112     /// compatibility of triplets with maximum multiple scattering effect
0113     /// (produced by the minimum allowed pT particle) + a certain uncertainty
0114     /// term. Check the documentation for more information
0115     /// https://acts.readthedocs.io/en/latest/core/reconstruction/pattern_recognition/seeding.html
0116     float minPt = 400 * UnitConstants::MeV;
0117     /// Number of sigmas of scattering angle to be considered in the minimum pT
0118     /// scattering term
0119     float sigmaScattering = 5;
0120     /// Term that accounts for the thickness of scattering medium in radiation
0121     /// lengths in the Lynch & Dahl correction to the Highland equation default
0122     /// is 5%
0123     float radLengthPerSeed = 0.05;
0124     /// Maximum transverse momentum for scattering calculation
0125     float maxPtScattering = 10 * UnitConstants::GeV;
0126     /// Maximum value of impact parameter estimation of the seed candidates
0127     float impactMax = 20 * UnitConstants::mm;
0128     /// Parameter which can loosen the tolerance of the track seed to form a
0129     /// helix. This is useful for e.g. misaligned seeding.
0130     float helixCutTolerance = 1;
0131 
0132     /// Tolerance parameter used to check the compatibility of space-point
0133     /// coordinates in xyz. This is only used in a detector specific check for
0134     /// strip modules
0135     float toleranceParam = 1.1 * UnitConstants::mm;
0136   };
0137 
0138   /// Derived configuration for the triplet seed finder using a magnetic field.
0139   struct DerivedConfig : public Config {
0140     DerivedConfig(const Config& config, float bFieldInZ);
0141 
0142     float bFieldInZ = std::numeric_limits<float>::quiet_NaN();
0143     float highland = std::numeric_limits<float>::quiet_NaN();
0144     float pTPerHelixRadius = std::numeric_limits<float>::quiet_NaN();
0145     float minHelixDiameter2 = std::numeric_limits<float>::quiet_NaN();
0146     float sigmapT2perRadius = std::numeric_limits<float>::quiet_NaN();
0147     float multipleScattering2 = std::numeric_limits<float>::quiet_NaN();
0148   };
0149 
0150   /// Creates a new triplet seed finder instance given the configuration.
0151   static std::unique_ptr<TripletSeedFinder> create(const DerivedConfig& config);
0152 
0153   virtual ~TripletSeedFinder() = default;
0154 
0155   /// Returns the configuration of the triplet seed finder.
0156   virtual const DerivedConfig& config() const = 0;
0157 
0158   /// Create triplets from the bottom, middle, and top space points.
0159   ///
0160   /// @param spacePoints Space point container
0161   /// @param spM Space point candidate to be used as middle SP in a seed
0162   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0163   /// @param topDoublets Top doublets to be used for triplet creation
0164   /// @param tripletTopCandidates Cache for triplet top candidates
0165   virtual void createTripletTopCandidates(
0166       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0167       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0168       DoubletsForMiddleSp::Range& topDoublets,
0169       TripletTopCandidates& tripletTopCandidates) const = 0;
0170 
0171   /// Create triplets from the bottom, middle, and top space points.
0172   ///
0173   /// @param spacePoints Space point container
0174   /// @param spM Space point candidate to be used as middle SP in a seed
0175   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0176   /// @param topDoublets Top doublets to be used for triplet creation
0177   /// @param tripletTopCandidates Cache for triplet top candidates
0178   virtual void createTripletTopCandidates(
0179       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0180       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0181       DoubletsForMiddleSp::Subset& topDoublets,
0182       TripletTopCandidates& tripletTopCandidates) const = 0;
0183 
0184   /// Create triplets from the bottom, middle, and top space points.
0185   ///
0186   /// @param spacePoints Space point container
0187   /// @param spM Space point candidate to be used as middle SP in a seed
0188   /// @param bottomDoublet Bottom doublet to be used for triplet creation
0189   /// @param topDoublets Top doublets to be used for triplet creation
0190   /// @param tripletTopCandidates Cache for triplet top candidates
0191   virtual void createTripletTopCandidates(
0192       const SpacePointContainer2& spacePoints, const ConstSpacePointProxy2& spM,
0193       const DoubletsForMiddleSp::Proxy& bottomDoublet,
0194       DoubletsForMiddleSp::Subset2& topDoublets,
0195       TripletTopCandidates& tripletTopCandidates) const = 0;
0196 };
0197 
0198 }  // namespace Acts::Experimental