File indexing completed on 2026-07-26 08:22:21
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "traccc/edm/particle.hpp"
0011
0012 namespace traccc {
0013
0014 struct particle_hit_count {
0015 particle ptc;
0016 std::size_t hit_counts;
0017 };
0018
0019 inline bool operator==(const particle_hit_count& lhs, const particle& rhs) {
0020 if (lhs.ptc.particle_id == rhs.particle_id) {
0021 return true;
0022 }
0023 return false;
0024 }
0025
0026 inline bool operator<(const particle_hit_count& lhs,
0027 const particle_hit_count& rhs) {
0028 if (lhs.hit_counts < rhs.hit_counts) {
0029 return true;
0030 }
0031 return false;
0032 }
0033
0034 template <typename measurements_t, typename map_t>
0035 std::vector<particle_hit_count> identify_contributing_particles(
0036 const measurements_t& measurements, const map_t& m_p_map) {
0037 std::vector<particle_hit_count> result;
0038
0039 for (const auto& meas : measurements) {
0040 const auto mp_it = m_p_map.find(meas);
0041 if (mp_it == m_p_map.end()) {
0042 continue;
0043 }
0044 const auto& ptcs = mp_it->second;
0045
0046 for (auto const& [ptc, count] : ptcs) {
0047 auto it = std::find(result.begin(), result.end(), ptc);
0048
0049
0050 if (it != result.end()) {
0051 it->hit_counts++;
0052 }
0053
0054 else {
0055 result.push_back({ptc, 1u});
0056 }
0057 }
0058 }
0059
0060 std::sort(result.rbegin(), result.rend());
0061
0062 return result;
0063 }
0064
0065 }