18 namespace ActsFatras {
29 template <
typename signal_t,
size_t kSize>
33 using ChannelKey = std::array<unsigned int, kSize>;
36 auto extractChannelKey = [&](
const Channel& ch) -> ChannelKey {
38 for (
unsigned int ik = 0; ik < kSize; ++ik) {
39 cKey[ik] = ch.
cellId[ik].first;
44 std::map<ChannelKey, Channel> channelMap;
45 for (
const auto& ch : channels) {
46 ChannelKey key = extractChannelKey(ch);
47 auto chItr = channelMap.find(key);
48 if (chItr != channelMap.end()) {
49 chItr->second.value += ch.value;
50 chItr->second.links.insert(ch.links.begin(), ch.links.end());
52 channelMap.insert(std::pair<ChannelKey, Channel>(key, ch));
56 std::vector<Channel> mergedChannels;
57 mergedChannels.reserve(channelMap.size());
58 for (
auto& [key,
value] : channelMap) {
59 mergedChannels.push_back(
value);
61 return mergedChannels;