Back to home page

EIC code displayed by LXR

 
 

    


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

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