Warning, file /acts/Core/src/Seeding2/detail/CandidatesForMiddleSp2.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Seeding2/detail/CandidatesForMiddleSp2.hpp"
0010
0011 #include <algorithm>
0012
0013 namespace Acts {
0014
0015 CandidatesForMiddleSp2::CandidatesForMiddleSp2()
0016 : CandidatesForMiddleSp2(kNoSize, kNoSize) {}
0017
0018 CandidatesForMiddleSp2::CandidatesForMiddleSp2(Size nLow, Size nHigh)
0019 : m_maxSizeLow(nLow), m_maxSizeHigh(nHigh) {
0020
0021 m_storage.reserve((nLow != kNoSize ? nLow : 0) +
0022 (nHigh != kNoSize ? nHigh : 0));
0023 }
0024
0025 void CandidatesForMiddleSp2::clear() {
0026 m_storage.clear();
0027 m_indicesLow.clear();
0028 m_indicesHigh.clear();
0029 }
0030
0031 bool CandidatesForMiddleSp2::push(SpacePointIndex2 spB, SpacePointIndex2 spM,
0032 SpacePointIndex2 spT, float weight,
0033 float zOrigin, bool isQuality) {
0034
0035
0036 if (isQuality) {
0037 return push(m_indicesHigh, m_maxSizeHigh, spB, spM, spT, weight, zOrigin,
0038 isQuality);
0039 }
0040 return push(m_indicesLow, m_maxSizeLow, spB, spM, spT, weight, zOrigin,
0041 isQuality);
0042 }
0043
0044 bool CandidatesForMiddleSp2::push(Container& container, Size nMax,
0045 SpacePointIndex2 spB, SpacePointIndex2 spM,
0046 SpacePointIndex2 spT, float weight,
0047 float zOrigin, bool isQuality) {
0048 if (nMax == 0) {
0049 return false;
0050 }
0051
0052 if (container.size() < nMax) {
0053
0054 m_storage.emplace_back(spB, spM, spT, weight, zOrigin, isQuality);
0055 container.emplace_back(weight, m_storage.size() - 1);
0056 std::ranges::push_heap(container, comparator);
0057 return true;
0058 }
0059
0060
0061
0062 const auto [smallestWeight, smallestIndex] = container.front();
0063 if (weight <= smallestWeight) {
0064 return false;
0065 }
0066
0067
0068 m_storage[smallestIndex] =
0069 TripletCandidate2(spB, spM, spT, weight, zOrigin, isQuality);
0070 std::ranges::pop_heap(container, comparator);
0071 container.back() = {weight, smallestIndex};
0072 std::ranges::push_heap(container, comparator);
0073
0074 return true;
0075 }
0076
0077 void CandidatesForMiddleSp2::toSortedCandidates(
0078 std::vector<TripletCandidate2>& output) {
0079 output.clear();
0080 output.reserve(size());
0081
0082 std::ranges::sort_heap(m_indicesHigh, comparator);
0083 std::ranges::sort_heap(m_indicesLow, comparator);
0084
0085 for (const auto& [weight, index] : m_indicesHigh) {
0086 output.emplace_back(m_storage[index]);
0087 }
0088 for (const auto& [weight, index] : m_indicesLow) {
0089 output.emplace_back(m_storage[index]);
0090 }
0091
0092 clear();
0093 }
0094
0095 }