Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 08:26:23

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Derek Anderson, Dmitry Kalinkin
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 //! Track-Based Cluster Merger/Splitter
0032 // ==========================================================================
0033 /*! An algorithm which takes a collection of clusters, matches
0034  *  track projections, and then decides to merge or split those
0035  *  clusters based on average E/p from simulations.
0036  *
0037  *  Heavily inspired by Eur. Phys. J. C (2017) 77:466
0038  */
0039 class TrackClusterMergeSplitter : public TrackClusterMergeSplitterAlgorithm,
0040                                   public WithPodConfig<TrackClusterMergeSplitterConfig> {
0041 
0042 public:
0043   ///! Algorithm constructor
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   ///! Alias for vectors of track segments
0055   using segment_vector = std::vector<edm4eic::TrackSegment>;
0056 
0057   ///! Alias for vectors of mutable protoclusters
0058   using protocluster_vector = std::vector<edm4eic::MutableProtoCluster>;
0059 
0060   ///! Alias for vectors of clusters
0061   using cluster_vector = std::vector<edm4eic::Cluster>;
0062 
0063   ///! Alias for a map of hits onto their splitting weights
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 }; // end TrackClusterMergeSplitter
0074 } // namespace eicrecon