Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:13:06

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