File indexing completed on 2025-01-18 09:12:12
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 <utility>
0017
0018 namespace ActsFatras {
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 template <typename signal_t, std::size_t kSize>
0030 const std::vector<Channel<signal_t, kSize>> mergeChannels(
0031 const std::vector<Channel<signal_t, kSize>>& channels) {
0032 using Channel = Channel<signal_t, kSize>;
0033 using ChannelKey = std::array<unsigned int, kSize>;
0034
0035
0036 auto extractChannelKey = [&](const Channel& ch) -> ChannelKey {
0037 ChannelKey cKey;
0038 for (unsigned int ik = 0; ik < kSize; ++ik) {
0039 cKey[ik] = ch.cellId[ik].first;
0040 }
0041 return cKey;
0042 };
0043
0044 std::map<ChannelKey, Channel> channelMap;
0045 for (const auto& ch : channels) {
0046 ChannelKey key = extractChannelKey(ch);
0047 auto chItr = channelMap.find(key);
0048 if (chItr != channelMap.end()) {
0049 chItr->second.value += ch.value;
0050 chItr->second.links.insert(ch.links.begin(), ch.links.end());
0051 } else {
0052 channelMap.insert(std::pair<ChannelKey, Channel>(key, ch));
0053 }
0054 }
0055
0056 std::vector<Channel> mergedChannels;
0057 mergedChannels.reserve(channelMap.size());
0058 for (auto& [key, value] : channelMap) {
0059 mergedChannels.push_back(value);
0060 }
0061 return mergedChannels;
0062 }
0063
0064 }