Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:26:58

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022, 2024 Sylvester Joosten, Dmitry Romanov, Wouter Deconinck
0003 
0004 // Takes a list of particles (presumed to be from tracking), and all available clusters.
0005 // 1. Match clusters to their tracks using the mcID field
0006 // 2. For unmatched clusters create neutrals and add to the particle list
0007 
0008 #pragma once
0009 
0010 #include <algorithms/algorithm.h>
0011 #include <edm4eic/ClusterCollection.h>
0012 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0013 #include <edm4eic/MCRecoParticleAssociationCollection.h>
0014 #include <edm4eic/MCRecoParticleLinkCollection.h>
0015 #include <edm4eic/ReconstructedParticleCollection.h>
0016 #include <edm4hep/MCParticleCollection.h>
0017 #include <stdint.h>
0018 #include <map>
0019 #include <string>
0020 #include <string_view>
0021 
0022 #include "algorithms/interfaces/WithPodConfig.h"
0023 
0024 namespace eicrecon {
0025 
0026 using MatchClustersAlgorithm = algorithms::Algorithm<
0027     algorithms::Input<edm4hep::MCParticleCollection, edm4eic::ReconstructedParticleCollection,
0028                       edm4eic::MCRecoParticleAssociationCollection, edm4eic::ClusterCollection,
0029                       edm4eic::MCRecoClusterParticleAssociationCollection>,
0030     algorithms::Output<edm4eic::ReconstructedParticleCollection,
0031                        edm4eic::MCRecoParticleLinkCollection,
0032                        edm4eic::MCRecoParticleAssociationCollection>>;
0033 
0034 class MatchClusters : public MatchClustersAlgorithm, public WithPodConfig<NoConfig> {
0035 
0036 public:
0037   MatchClusters(std::string_view name)
0038       : MatchClustersAlgorithm{name,
0039                                {"MCParticles", "CentralTracks", "CentralTrackAssociations",
0040                                 "EcalClusters", "EcalClusterAssociations"},
0041                                {"ReconstructedParticles", "ReconstructedParticleLinks",
0042                                 "ReconstructedParticleAssociations"},
0043                                "Match tracks with clusters, and assign associations."} {}
0044 
0045   void init() final {};
0046   void process(const Input&, const Output&) const final;
0047 
0048 private:
0049   // get a map of mcID --> cluster
0050   // input: clusters --> all clusters
0051   std::map<int, edm4eic::Cluster>
0052   indexedClusters(const edm4eic::ClusterCollection* clusters,
0053                   const edm4eic::MCRecoClusterParticleAssociationCollection* associations) const;
0054 
0055   // reconstruct a neutral cluster
0056   // (for now assuming the vertex is at (0,0,0))
0057   static edm4eic::MutableReconstructedParticle
0058   reconstruct_neutral(const edm4eic::Cluster* cluster, const double mass, const int32_t pdg);
0059 };
0060 
0061 } // namespace eicrecon