Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 07:56:23

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Sylvester Joosten
0003 
0004 #pragma once
0005 
0006 #include <algorithms/algorithm.h>
0007 #include <edm4eic/ClusterCollection.h>
0008 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0009 #include <edm4hep/MCParticleCollection.h>
0010 #include <map>
0011 #include <string>
0012 #include <string_view>
0013 
0014 namespace eicrecon {
0015 
0016 using TruthEnergyPositionClusterMergerAlgorithm = algorithms::Algorithm<
0017     algorithms::Input<edm4hep::MCParticleCollection, edm4eic::ClusterCollection,
0018                       edm4eic::MCRecoClusterParticleAssociationCollection,
0019                       edm4eic::ClusterCollection,
0020                       edm4eic::MCRecoClusterParticleAssociationCollection>,
0021     algorithms::Output<edm4eic::ClusterCollection,
0022                        edm4eic::MCRecoClusterParticleAssociationCollection>>;
0023 
0024 /** Simple algorithm to merge the energy measurement from cluster1 with the position
0025    * measurement of cluster2 (in case matching clusters are found). If not, it will
0026    * propagate the raw cluster from cluster1 or cluster2
0027    *
0028    * Matching occurs based on the mc truth information of the clusters.
0029    *
0030    * \ingroup reco
0031    */
0032 class TruthEnergyPositionClusterMerger : public TruthEnergyPositionClusterMergerAlgorithm {
0033 
0034 public:
0035   TruthEnergyPositionClusterMerger(std::string_view name)
0036       : TruthEnergyPositionClusterMergerAlgorithm{
0037             name,
0038             {"mcParticles", "energyClusterCollection", "energyClusterAssociations",
0039              "positionClusterCollection", "positionClusterAssociations"},
0040             {"outputClusterCollection", "outputClusterAssociations"},
0041             "Merge energy and position clusters based on truth."} {}
0042 
0043 public:
0044   void init() {}
0045 
0046   void process(const Input& input, const Output& output) const final;
0047 
0048   // get a map of MCParticle index --> cluster
0049   // input: cluster_collections --> list of handles to all cluster collections
0050   std::map<int, edm4eic::Cluster>
0051   indexedClusters(const edm4eic::ClusterCollection& clusters,
0052                   const edm4eic::MCRecoClusterParticleAssociationCollection& associations) const;
0053 };
0054 
0055 } // namespace eicrecon