File indexing completed on 2025-07-05 08:52:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #pragma once
0022
0023 #include <algorithms/algorithm.h>
0024
0025 #include <edm4eic/CalorimeterHitCollection.h>
0026 #include <edm4eic/ProtoClusterCollection.h>
0027 #include <array>
0028 #include <cstddef>
0029 #include <list>
0030 #include <set>
0031 #include <string>
0032 #include <string_view>
0033
0034 #include "ImagingTopoClusterConfig.h"
0035 #include "algorithms/interfaces/WithPodConfig.h"
0036
0037 namespace eicrecon {
0038
0039 using ImagingTopoClusterAlgorithm =
0040 algorithms::Algorithm<algorithms::Input<edm4eic::CalorimeterHitCollection>,
0041 algorithms::Output<edm4eic::ProtoClusterCollection>>;
0042
0043 class ImagingTopoCluster : public ImagingTopoClusterAlgorithm,
0044 public WithPodConfig<ImagingTopoClusterConfig> {
0045
0046 public:
0047 ImagingTopoCluster(std::string_view name)
0048 : ImagingTopoClusterAlgorithm{
0049 name,
0050 {"inputHitCollection"},
0051 {"outputProtoClusterCollection"},
0052 "Topological cell clustering algorithm for imaging calorimetry."} {}
0053
0054 private:
0055
0056 std::array<double, 2> localDistXY{0, 0};
0057 std::array<double, 2> layerDistEtaPhi{0, 0};
0058 std::array<double, 2> layerDistXY{0, 0};
0059 double sectorDist{0};
0060 double minClusterHitEdep{0};
0061 double minClusterCenterEdep{0};
0062 double minClusterEdep{0};
0063
0064 public:
0065 void init();
0066 void process(const Input& input, const Output& output) const final;
0067
0068 private:
0069
0070 bool is_neighbour(const edm4eic::CalorimeterHit& h1, const edm4eic::CalorimeterHit& h2) const;
0071
0072
0073
0074 template <typename Compare>
0075 void bfs_group(const edm4eic::CalorimeterHitCollection& hits,
0076 std::set<std::size_t, Compare>& indices, std::list<std::size_t>& group,
0077 const std::size_t idx) const {
0078
0079
0080 for (auto idx1 = group.begin(); idx1 != group.end(); ++idx1) {
0081
0082 for (auto idx2 = indices.begin(); idx2 != indices.end();
0083 indices.empty() ? idx2 = indices.end() : idx2) {
0084
0085
0086
0087 if (*idx2 == *idx1 || *idx2 == idx) {
0088 idx2++;
0089 continue;
0090 }
0091
0092
0093
0094
0095
0096
0097
0098 if (hits[*idx2].getEnergy() < m_cfg.minClusterHitEdep) {
0099 idx2 = indices.erase(idx2);
0100 continue;
0101 }
0102
0103 if (is_neighbour(hits[*idx1], hits[*idx2])) {
0104 group.push_back(*idx2);
0105 idx2 = indices.erase(idx2);
0106 } else {
0107 idx2++;
0108 }
0109 }
0110 }
0111 }
0112 };
0113
0114 }