Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-14 08:14:37

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/ReconstructedParticleCollection.h>
0015 #include <edm4hep/MCParticleCollection.h>
0016 #include <stdint.h>
0017 #include <map>
0018 #include <string>
0019 #include <string_view>
0020 
0021 namespace eicrecon {
0022 
0023 using MatchClustersAlgorithm = algorithms::Algorithm<
0024     algorithms::Input<edm4hep::MCParticleCollection, edm4eic::ReconstructedParticleCollection,
0025                       edm4eic::MCRecoParticleAssociationCollection, edm4eic::ClusterCollection,
0026                       edm4eic::MCRecoClusterParticleAssociationCollection>,
0027     algorithms::Output<edm4eic::ReconstructedParticleCollection,
0028                        edm4eic::MCRecoParticleAssociationCollection>>;
0029 
0030 class MatchClusters : public MatchClustersAlgorithm {
0031 
0032 public:
0033   MatchClusters(std::string_view name)
0034       : MatchClustersAlgorithm{name,
0035                                {"MCParticles", "CentralTracks", "CentralTrackAssociations",
0036                                 "EcalClusters", "EcalClusterAssociations"},
0037                                {"ReconstructedParticles", "ReconstructedParticleAssociations"},
0038                                "Match tracks with clusters, and assign associations."} {}
0039 
0040   void init() final{};
0041   void process(const Input&, const Output&) const final;
0042 
0043 private:
0044   // get a map of mcID --> cluster
0045   // input: clusters --> all clusters
0046   std::map<int, edm4eic::Cluster>
0047   indexedClusters(const edm4eic::ClusterCollection* clusters,
0048                   const edm4eic::MCRecoClusterParticleAssociationCollection* associations) const;
0049 
0050   // reconstruct a neutral cluster
0051   // (for now assuming the vertex is at (0,0,0))
0052   static edm4eic::MutableReconstructedParticle
0053   reconstruct_neutral(const edm4eic::Cluster* cluster, const double mass, const int32_t pdg);
0054 };
0055 
0056 } // namespace eicrecon