Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-28 07:02:57

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