File indexing completed on 2026-07-27 08:58:02
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Surfaces/Surface.hpp"
0012 #include "Acts/Surfaces/SurfaceError.hpp"
0013 #include "ActsFatras/Digitization/DigitizationData.hpp"
0014
0015 #include <array>
0016 #include <map>
0017 #include <utility>
0018
0019 namespace ActsFatras {
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 template <typename signal_t, std::size_t kSize>
0031 const std::vector<Channel<signal_t, kSize>> mergeChannels(
0032 const std::vector<Channel<signal_t, kSize>>& channels) {
0033 using Channel = Channel<signal_t, kSize>;
0034 using ChannelKey = std::array<unsigned int, kSize>;
0035
0036
0037 auto extractChannelKey = [&](const Channel& ch) -> ChannelKey {
0038 ChannelKey cKey;
0039 for (unsigned int ik = 0; ik < kSize; ++ik) {
0040 cKey[ik] = ch.cellId[ik].first;
0041 }
0042 return cKey;
0043 };
0044
0045 std::map<ChannelKey, Channel> channelMap;
0046 for (const auto& ch : channels) {
0047 ChannelKey key = extractChannelKey(ch);
0048 auto chItr = channelMap.find(key);
0049 if (chItr != channelMap.end()) {
0050 chItr->second.value += ch.value;
0051 chItr->second.links.insert(ch.links.begin(), ch.links.end());
0052 } else {
0053 channelMap.insert(std::pair<ChannelKey, Channel>(key, ch));
0054 }
0055 }
0056
0057 std::vector<Channel> mergedChannels;
0058 mergedChannels.reserve(channelMap.size());
0059 for (auto& [key, value] : channelMap) {
0060 mergedChannels.push_back(value);
0061 }
0062 return mergedChannels;
0063 }
0064
0065 }