File indexing completed on 2025-09-18 08:17:42
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> sameLayerDistXY{0, 0};
0057 std::array<double, 2> diffLayerDistXY{0, 0};
0058 std::array<double, 2> sameLayerDistEtaPhi{0, 0};
0059 std::array<double, 2> diffLayerDistEtaPhi{0, 0};
0060 std::array<double, 2> sameLayerDistTZ{0, 0};
0061 std::array<double, 2> diffLayerDistTZ{0, 0};
0062 double sectorDist{0};
0063 double minClusterHitEdep{0};
0064 double minClusterCenterEdep{0};
0065 double minClusterEdep{0};
0066
0067 public:
0068 void init();
0069 void process(const Input& input, const Output& output) const final;
0070
0071 private:
0072
0073 bool is_neighbour(const edm4eic::CalorimeterHit& h1, const edm4eic::CalorimeterHit& h2) const;
0074
0075
0076
0077 template <typename Compare>
0078 void bfs_group(const edm4eic::CalorimeterHitCollection& hits,
0079 std::set<std::size_t, Compare>& indices, std::list<std::size_t>& group,
0080 const std::size_t idx) const {
0081
0082
0083 for (auto idx1 = group.begin(); idx1 != group.end(); ++idx1) {
0084
0085 for (auto idx2 = indices.begin(); idx2 != indices.end();
0086 indices.empty() ? idx2 = indices.end() : idx2) {
0087
0088
0089
0090 if (*idx2 == *idx1 || *idx2 == idx) {
0091 idx2++;
0092 continue;
0093 }
0094
0095
0096
0097
0098
0099
0100
0101 if (hits[*idx2].getEnergy() < m_cfg.minClusterHitEdep) {
0102 idx2 = indices.erase(idx2);
0103 continue;
0104 }
0105
0106 if (is_neighbour(hits[*idx1], hits[*idx2])) {
0107 group.push_back(*idx2);
0108 idx2 = indices.erase(idx2);
0109 } else {
0110 idx2++;
0111 }
0112 }
0113 }
0114 }
0115 };
0116
0117 }