Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 09:39:03

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/Types.hpp"
0012 
0013 #include <limits>
0014 #include <vector>
0015 
0016 namespace Acts {
0017 
0018 /// @brief A description of a triplet candidate.
0019 struct TripletCandidate2 {
0020   /// @brief Default Constructor
0021   TripletCandidate2() = default;
0022 
0023   /// @brief constructor
0024   /// @param b The bottom space point
0025   /// @param m The middle space point
0026   /// @param t The top space point
0027   /// @param w The quality of the candidate
0028   /// @param z The z coordinate of the origin
0029   /// @param q Whether the candidate is high or low quality
0030   TripletCandidate2(SpacePointIndex2 b, SpacePointIndex2 m, SpacePointIndex2 t,
0031                     float w, float z, bool q)
0032       : bottom(b), middle(m), top(t), weight(w), zOrigin(z), isQuality(q) {}
0033 
0034   SpacePointIndex2 bottom{};
0035   SpacePointIndex2 middle{};
0036   SpacePointIndex2 top{};
0037   float weight{};
0038   float zOrigin{};
0039   bool isQuality{};
0040 };
0041 
0042 class CandidatesForMiddleSp2 {
0043  public:
0044   using Index = std::uint32_t;
0045   using Size = std::uint32_t;
0046 
0047   static constexpr Size kNoSize = std::numeric_limits<Size>::max();
0048 
0049   CandidatesForMiddleSp2();
0050 
0051   /// @brief Setting maximum number of candidates to keep
0052   /// @param nLow Maximum number of candidates in the low-quality collection
0053   /// @param nHigh Maximum number of candidates in the high-quality collection
0054   CandidatesForMiddleSp2(Size nLow, Size nHigh);
0055 
0056   Size size() const { return m_storage.size(); }
0057 
0058   /// @brief Clear the internal storage
0059   void clear();
0060 
0061   /// @brief Retrieve the number of Low quality candidates
0062   /// @returns The number of Low quality candidates
0063   Size nLowQualityCandidates() const {
0064     return static_cast<Size>(m_indicesLow.size());
0065   }
0066 
0067   /// @brief Retrieve the number of High quality candidates
0068   /// @returns The number of High quality candidates
0069   Size nHighQualityCandidates() const {
0070     return static_cast<Size>(m_indicesHigh.size());
0071   }
0072 
0073   /// @brief Adding a new triplet candidate to the collection, should it satisfy the
0074   /// selection criteria
0075   /// @param spB Bottom space point
0076   /// @param spM Medium space point
0077   /// @param spT Top space point
0078   /// @param weight The quality of the triplet candidate
0079   /// @param zOrigin The z-coordinate of the origin
0080   /// @param isQuality Whether the triplet candidate is high or low quality
0081   /// @returns whether the triplet candidate has been added or not to the collection
0082   bool push(SpacePointIndex2 spB, SpacePointIndex2 spM, SpacePointIndex2 spT,
0083             float weight, float zOrigin, bool isQuality);
0084 
0085   /// @brief Retrieve the triplet candidates, the resulting vector is already sorted,
0086   /// elements with higher quality first
0087   void toSortedCandidates(std::vector<TripletCandidate2>& output);
0088 
0089  private:
0090   using WeightIndex = std::pair<float, Index>;
0091   using Container = std::vector<WeightIndex>;
0092 
0093   static constexpr bool comparator(const WeightIndex& a, const WeightIndex& b) {
0094     return a.first > b.first;
0095   }
0096 
0097   // sizes
0098   // m_maxSize* is the maximum size of the indices collections. These values
0099   // are set by the user once
0100   Size m_maxSizeLow{kNoSize};
0101   Size m_maxSizeHigh{kNoSize};
0102 
0103   // storage contains the collection of the candidates
0104   std::vector<TripletCandidate2> m_storage;
0105 
0106   Container m_indicesLow;
0107   Container m_indicesHigh;
0108 
0109   bool push(Container& container, Size nMax, SpacePointIndex2 spB,
0110             SpacePointIndex2 spM, SpacePointIndex2 spT, float weight,
0111             float zOrigin, bool isQuality);
0112 };
0113 
0114 }  // namespace Acts