Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:08:08

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