ATLAS Offline Software
DuplicateSeedDetector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace ActsTrk::detail {
8 
10  bool enabled)
11  : m_disabled(!enabled),
12  m_nUsedMeasurements(enabled ? numSeeds : 0u, 0u),
13  m_nSeedMeasurements(enabled ? numSeeds : 0u, 0u),
14  m_isDuplicateSeeds(enabled ? numSeeds : 0u, false)
15  {
16  if (m_disabled)
17  return;
18  m_seedIndexes.reserve(6 * numSeeds); // 6 hits/seed for strips (3 for pixels)
19  m_seedOffsets.reserve(2);
20  }
21 
22  void DuplicateSeedDetector::addSeeds(std::size_t typeIndex,
23  const ActsTrk::SeedContainer &seeds)
24  {
25  if (m_disabled) return;
26  if (!(typeIndex < m_seedOffsets.size()))
27  m_seedOffsets.resize(typeIndex + 1);
28  m_seedOffsets[typeIndex] = m_numSeeds;
29 
30  for (const ActsTrk::Seed *seed : seeds) {
31  if (!seed) continue;
32 
33  for (const xAOD::SpacePoint *sp : seed->sp()) {
34  const std::vector< const xAOD::UncalibratedMeasurement* > &els = sp->measurements();
35  for (const xAOD::UncalibratedMeasurement *meas : els) {
36  m_seedIndexes.insert({meas, m_numSeeds});
38  }
39  }
40  ++m_numSeeds;
41  }
42  }
43 
45  if (m_disabled or m_foundSeeds == 0 or m_nextSeeds == m_nUsedMeasurements.size())
46  return;
47 
48  auto beg = m_nUsedMeasurements.begin();
49  if (m_nextSeeds < m_nUsedMeasurements.size()) {
50  std::advance(beg, m_nextSeeds);
51  }
52 
54  }
55 
57  if (m_disabled or m_nextSeeds == m_nUsedMeasurements.size()) return;
58 
59  for (auto [iiseed, eiseed] = m_seedIndexes.equal_range(&(ActsTrk::getUncalibratedMeasurement(sl)));
60  iiseed != eiseed; ++iiseed) {
61  std::size_t iseed = iiseed->second;
62  assert(iseed < m_nUsedMeasurements.size());
63 
64  if (iseed < m_nextSeeds or m_isDuplicateSeeds[iseed]) continue;
65 
66  if (++m_nUsedMeasurements[iseed] >= m_nSeedMeasurements[iseed]) {
67  assert(m_nUsedMeasurements[iseed] == m_nSeedMeasurements[iseed]); // shouldn't ever find more
68  m_isDuplicateSeeds[iseed] = true;
69  }
70  ++m_foundSeeds;
71  }
72  }
73 
74  // For complete removal of duplicate seeds, assumes isDuplicate(iseed) is called for monotonically increasing iseed.
75  bool DuplicateSeedDetector::isDuplicate(std::size_t typeIndex,
76  std::size_t iseed) {
77  if (m_disabled) return false;
78 
79  if (typeIndex < m_seedOffsets.size()) {
80  iseed += m_seedOffsets[typeIndex];
81  }
82 
83  assert(iseed < m_isDuplicateSeeds.size());
84  // If iseed not increasing, we will miss some duplicate seeds, but won't exclude needed seeds.
85  if (iseed >= m_nextSeeds) {
86  m_nextSeeds = iseed + 1;
87  }
88 
89  return m_isDuplicateSeeds[iseed];
90  }
91 
92 } // namespace ActsTrk::detail
ActsTrk::detail::DuplicateSeedDetector::m_foundSeeds
std::size_t m_foundSeeds
Definition: DuplicateSeedDetector.h:57
ActsTrk::detail::DuplicateSeedDetector::m_nUsedMeasurements
std::vector< std::size_t > m_nUsedMeasurements
Definition: DuplicateSeedDetector.h:51
ActsTrk::detail::DuplicateSeedDetector::addSeeds
void addSeeds(std::size_t typeIndex, const ActsTrk::SeedContainer &seeds)
Definition: DuplicateSeedDetector.cxx:22
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
ActsTrk::detail::DuplicateSeedDetector::DuplicateSeedDetector
DuplicateSeedDetector(std::size_t numSeeds, bool enabled)
Definition: DuplicateSeedDetector.cxx:9
xAOD::UncalibratedMeasurement_v1
Definition: UncalibratedMeasurement_v1.h:13
ActsTrk::detail::DuplicateSeedDetector::m_disabled
bool m_disabled
Definition: DuplicateSeedDetector.h:49
ActsTrk::Seed
Acts::Seed< xAOD::SpacePoint, 3ul > Seed
Definition: Seed.h:12
detail::ul
unsigned long ul
Definition: PrimitiveHelpers.h:46
ActsTrk::detail::DuplicateSeedDetector::m_seedOffsets
std::vector< std::size_t > m_seedOffsets
Definition: DuplicateSeedDetector.h:54
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsTrk::detail::DuplicateSeedDetector::addMeasurement
void addMeasurement(const ActsTrk::ATLASUncalibSourceLink &sl)
Definition: DuplicateSeedDetector.cxx:56
ActsTrk::detail::DuplicateSeedDetector::m_numSeeds
std::size_t m_numSeeds
Definition: DuplicateSeedDetector.h:55
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
ActsTrk::detail::DuplicateSeedDetector::newTrajectory
void newTrajectory()
Definition: DuplicateSeedDetector.cxx:44
ActsTrk::getUncalibratedMeasurement
const xAOD::UncalibratedMeasurement & getUncalibratedMeasurement(const ATLASUncalibSourceLink &source_link)
Definition: ATLASSourceLink.h:26
ActsTrk::detail::DuplicateSeedDetector::m_seedIndexes
std::unordered_multimap< const xAOD::UncalibratedMeasurement *, std::size_t > m_seedIndexes
Definition: DuplicateSeedDetector.h:50
ActsTrk::detail::DuplicateSeedDetector::m_isDuplicateSeeds
std::vector< bool > m_isDuplicateSeeds
Definition: DuplicateSeedDetector.h:53
ActsTrk::detail::DuplicateSeedDetector::isDuplicate
bool isDuplicate(std::size_t typeIndex, std::size_t iseed)
Definition: DuplicateSeedDetector.cxx:75
ActsTrk::detail::DuplicateSeedDetector::numSeeds
std::size_t numSeeds() const
ActsTrk::detail::DuplicateSeedDetector::m_nextSeeds
std::size_t m_nextSeeds
Definition: DuplicateSeedDetector.h:56
ActsTrk::detail::DuplicateSeedDetector::m_nSeedMeasurements
std::vector< std::size_t > m_nSeedMeasurements
Definition: DuplicateSeedDetector.h:52
DuplicateSeedDetector.h
ActsTrk::detail
Definition: Decoration.h:15