File indexing completed on 2026-09-23 08:26:23
0001
0002
0003
0004 #pragma once
0005
0006 #include <algorithms/algorithm.h>
0007 #include <edm4eic/CalorimeterHit.h>
0008 #include <edm4eic/ClusterCollection.h>
0009 #include <edm4eic/ProtoClusterCollection.h>
0010 #include <edm4eic/TrackClusterMatchCollection.h>
0011 #include <edm4eic/TrackProtoClusterLinkCollection.h>
0012 #include <edm4eic/TrackSegmentCollection.h>
0013 #include <map>
0014 #include <optional>
0015 #include <string>
0016 #include <string_view>
0017 #include <vector>
0018
0019 #include "TrackClusterMergeSplitterConfig.h"
0020 #include "algorithms/interfaces/CompareObjectID.h"
0021 #include "algorithms/interfaces/WithPodConfig.h"
0022
0023 namespace eicrecon {
0024
0025 using TrackClusterMergeSplitterAlgorithm = algorithms::Algorithm<
0026 algorithms::Input<edm4eic::TrackClusterMatchCollection, edm4eic::ClusterCollection,
0027 edm4eic::TrackSegmentCollection>,
0028 algorithms::Output<edm4eic::ProtoClusterCollection, edm4eic::TrackProtoClusterLinkCollection>>;
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 class TrackClusterMergeSplitter : public TrackClusterMergeSplitterAlgorithm,
0040 public WithPodConfig<TrackClusterMergeSplitterConfig> {
0041
0042 public:
0043
0044 TrackClusterMergeSplitter(std::string_view name)
0045 : TrackClusterMergeSplitterAlgorithm{
0046 name,
0047 {"InputTrackClusterMatches", "InputClusterCollection", "InputTrackProjections"},
0048 {"OutputProtoClusterCollection", "OutputTrackProtoClusterLinks"},
0049 "Merges or splits clusters based on tracks matched to them."} {}
0050
0051 void process(const Input&, const Output&) const final;
0052
0053 private:
0054
0055 using segment_vector = std::vector<edm4eic::TrackSegment>;
0056
0057
0058 using protocluster_vector = std::vector<edm4eic::MutableProtoCluster>;
0059
0060
0061 using cluster_vector = std::vector<edm4eic::Cluster>;
0062
0063
0064 using hit_to_weight_map =
0065 std::map<edm4eic::CalorimeterHit, double, CompareObjectID<edm4eic::CalorimeterHit>>;
0066
0067 void merge_and_split_clusters(const cluster_vector& to_merge, const segment_vector& to_split,
0068 protocluster_vector& new_protos) const;
0069 static void add_cluster_to_proto(const edm4eic::Cluster& clust,
0070 edm4eic::MutableProtoCluster& proto,
0071 std::optional<hit_to_weight_map> split_weights = std::nullopt);
0072
0073 };
0074 }