Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2024, Sylvester Joosten, Chao Peng, Wouter Deconinck, David Lawrence, Derek Anderson
0003 
0004 /*
0005  *  Reconstruct the cluster/layer info for imaging calorimeter
0006  *  Logarithmic weighting is used to describe energy deposit in transverse direction
0007  *
0008  *  Author: Chao Peng (ANL), 06/02/2021
0009  */
0010 
0011 #pragma once
0012 
0013 #include <algorithms/algorithm.h>
0014 #include <edm4hep/CaloHitContribution.h>
0015 // Event Model related classes
0016 #include <edm4hep/MCParticleCollection.h>
0017 #include <edm4eic/EDM4eicVersion.h>
0018 #if EDM4EIC_VERSION_MAJOR >= 7
0019 #include <edm4eic/MCRecoCalorimeterHitAssociationCollection.h>
0020 #else
0021 #include <edm4hep/SimCalorimeterHitCollection.h>
0022 #endif
0023 #include <edm4eic/CalorimeterHitCollection.h>
0024 #include <edm4eic/ClusterCollection.h>
0025 #include <edm4eic/MCRecoClusterParticleAssociationCollection.h>
0026 #include <edm4eic/ProtoClusterCollection.h>
0027 #include <string>
0028 #include <string_view>
0029 #include <utility>
0030 #include <vector>
0031 
0032 #include "ImagingClusterRecoConfig.h"
0033 #include "algorithms/interfaces/WithPodConfig.h"
0034 
0035 namespace eicrecon {
0036 
0037 using ImagingClusterRecoAlgorithm =
0038     algorithms::Algorithm<algorithms::Input<edm4eic::ProtoClusterCollection,
0039 #if EDM4EIC_VERSION_MAJOR >= 7
0040                                             edm4eic::MCRecoCalorimeterHitAssociationCollection
0041 #else
0042                                             edm4hep::SimCalorimeterHitCollection
0043 #endif
0044                                             >,
0045                           algorithms::Output<edm4eic::ClusterCollection,
0046                                              edm4eic::MCRecoClusterParticleAssociationCollection,
0047                                              edm4eic::ClusterCollection>>;
0048 
0049 /** Imaging cluster reconstruction.
0050    *
0051    *  Reconstruct the cluster/layer info for imaging calorimeter
0052    *  Logarithmic weighting is used to describe energy deposit in transverse direction
0053    *
0054    *  \ingroup reco
0055    */
0056 class ImagingClusterReco : public ImagingClusterRecoAlgorithm,
0057                            public WithPodConfig<ImagingClusterRecoConfig> {
0058 
0059 public:
0060   ImagingClusterReco(std::string_view name) : ImagingClusterRecoAlgorithm {
0061     name,
0062 #if EDM4EIC_VERSION_MAJOR >= 7
0063         {"inputProtoClusterCollection", "mcRawHitAssocations"},
0064 #else
0065         {"inputProtoClusterCollection", "mcHits"},
0066 #endif
0067         {"outputClusterCollection", "outputClusterAssociations", "outputLayerCollection"},
0068         "Reconstruct the cluster/layer info for imaging calorimeter."
0069   }
0070   {}
0071 
0072 public:
0073   void init() {}
0074 
0075   void process(const Input& input, const Output& output) const final;
0076 
0077 private:
0078   std::vector<edm4eic::MutableCluster>
0079   reconstruct_cluster_layers(const edm4eic::ProtoCluster& pcl) const;
0080 
0081   edm4eic::MutableCluster
0082   reconstruct_layer(const std::vector<std::pair<const edm4eic::CalorimeterHit, float>>& hits) const;
0083 
0084   edm4eic::MutableCluster reconstruct_cluster(const edm4eic::ProtoCluster& pcl) const;
0085 
0086   std::pair<double /* polar */, double /* azimuthal */>
0087   fit_track(const std::vector<edm4eic::MutableCluster>& layers) const;
0088 
0089   void associate_mc_particles(
0090       const edm4eic::Cluster& cl,
0091 #if EDM4EIC_VERSION_MAJOR >= 7
0092       const edm4eic::MCRecoCalorimeterHitAssociationCollection* mchitassociations,
0093 #else
0094       const edm4hep::SimCalorimeterHitCollection* mchits,
0095 #endif
0096       edm4eic::MCRecoClusterParticleAssociationCollection* assocs) const;
0097 
0098   edm4hep::MCParticle get_primary(const edm4hep::CaloHitContribution& contrib) const;
0099 };
0100 
0101 } // namespace eicrecon