ATLAS Offline Software
Loading...
Searching...
No Matches
DuplicateSeedDetector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include <stdexcept>
9#include <array>
10
11namespace ActsTrk::detail {
12
14 unsigned int measOffset,
15 bool enabled)
16 : m_disabled(!enabled),
17 m_measOffset(measOffset),
18 m_nUsedMeasurements(enabled ? numSeeds : 0ul, 0u),
19 m_nSeedMeasurements(enabled ? numSeeds : 0ul, 0u),
20 m_isDuplicateSeed(enabled ? numSeeds : 0ul, false) {
21 if (m_disabled)
22 return;
23 m_seedOffset.reserve(2ul);
24 }
25
26 void DuplicateSeedDetector::addSeeds(std::size_t typeIndex,
27 const ActsTrk::SeedContainer &seeds,
28 const MeasurementIndex& measurementIndex) {
29 addSeeds(typeIndex, seeds, measurementIndex,
30 [](std::size_t) -> std::array<std::size_t, 3> { return {0, 1, 2}; },
31 [](const ActsTrk::Seed&) -> bool { return false; });
32 }
33
34 void DuplicateSeedDetector::addSeeds(std::size_t typeIndex,
35 const ActsTrk::SeedContainer &seeds,
36 const MeasurementIndex& measurementIndex,
37 SpacePointIndicesFun_t spacePointIndicesFun,
38 UseTopSpFun_t useTopSpFun) {
39 if (m_disabled)
40 return;
41 if (!(typeIndex < m_seedOffset.size()))
42 m_seedOffset.resize(typeIndex + 1);
43 m_seedOffset[typeIndex] = m_numSeeds;
44 m_seedIndex.resize(measurementIndex.size()); // will resize for each seed container, but always with the same space
45
46 for (const ActsTrk::Seed seed : seeds) {
47 std::size_t nSP = 0;
48 bool useTopSp = useTopSpFun(seed);
49 const auto& sps = seed.sp();
50 for (std::size_t isp : spacePointIndicesFun(sps.size())) {
51 const xAOD::SpacePoint *sp = sps.at(useTopSp ? sps.size() - isp - 1 : isp);
52 const std::vector<const xAOD::UncalibratedMeasurement *> &els = sp->measurements();
53 for (const xAOD::UncalibratedMeasurement *meas : els) {
54 std::size_t hitIndex = measurementIndex.index(*meas);
55 if (!(hitIndex < m_seedIndex.size())) {
56 // std::cout << "ERROR hit index " << hitIndex << " past end of " << m_seedIndex.size() << " hit indices\n";
57 continue;
58 }
59 m_seedIndex[hitIndex].push_back(m_numSeeds);
61 }
62 ++nSP;
63 if (nSP >= 3) break;
64 }
65 ++m_numSeeds;
66 }
67 }
68
69} // namespace ActsTrk::detail
DuplicateSeedDetector(std::size_t numSeeds, index_t measOffset, bool enabled)
std::function< std::array< std::size_t, 3 >(std::size_t)> SpacePointIndicesFun_t
std::vector< boost::container::small_vector< index_t, 2 > > m_seedIndex
void addSeeds(std::size_t typeIndex, const ActsTrk::SeedContainer &seeds, const MeasurementIndex &measurementIndex)
std::function< bool(const ActsTrk::Seed &)> UseTopSpFun_t
std::size_t index(const xAOD::UncalibratedMeasurement &hit) const
Athena definition of the Eigen plugin.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.