ATLAS Offline Software
DuplicateSeedDetector.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "src/detail/MeasurementIndex.h"
6 
7 namespace ActsTrk::detail {
8 
9  inline void DuplicateSeedDetector::newTrajectory() {
10  if (m_disabled || m_foundSeeds == 0 || m_nextSeed == m_nUsedMeasurements.size())
11  return;
12 
13  auto beg = m_nUsedMeasurements.begin();
14  if (m_nextSeed < m_nUsedMeasurements.size()) {
15  std::advance(beg, m_nextSeed);
16  }
17 
18  std::fill(beg, m_nUsedMeasurements.end(), 0ul);
19  }
20 
21  inline void DuplicateSeedDetector::addMeasurement(const ActsTrk::ATLASUncalibSourceLink &sl, const MeasurementIndex& measurementIndex) {
22  if (m_disabled || m_nextSeed == m_nUsedMeasurements.size())
23  return;
24 
25  std::size_t hitIndex = measurementIndex.index(ActsTrk::getUncalibratedMeasurement(sl));
26  if (!(hitIndex < m_seedIndex.size()))
27  return;
28 
29  for (index_t iseed : m_seedIndex[hitIndex]) {
30  assert(iseed < m_nUsedMeasurements.size());
31 
32  if (iseed < m_nextSeed || m_isDuplicateSeed[iseed])
33  continue;
34 
35 
36  // Here is to decide how many hits need to be on the seed to mark it as duplicate
37  if (++m_nUsedMeasurements[iseed] >= std::max(1ul, m_nSeedMeasurements[iseed] - m_measOffset)) {
38  assert(m_nUsedMeasurements[iseed] <= m_nSeedMeasurements[iseed]); // shouldn't ever find more
39  m_isDuplicateSeed[iseed] = true;
40  }
41  ++m_foundSeeds;
42  }
43  }
44 
45  // For complete removal of duplicate seeds, assumes isDuplicate(iseed) is called for monotonically increasing typeIndex,iseed.
46  inline bool DuplicateSeedDetector::isDuplicate(std::size_t typeIndex, index_t iseed) {
47  if (m_disabled)
48  return false;
49 
50  if (typeIndex < m_seedOffset.size()) {
51  iseed += m_seedOffset[typeIndex];
52  }
53 
54  assert(iseed < m_isDuplicateSeed.size());
55  // If iseed not increasing, we will miss some duplicate seeds, but won't exclude needed seeds.
56  if (iseed >= m_nextSeed) {
57  m_nextSeed = iseed + 1;
58  }
59 
60  return m_isDuplicateSeed[iseed];
61  }
62 
63 } // namespace ActsTrk::detail