Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-23 22:40:21

0001 // Original Author: Leonardo Cristella
0002 
0003 #include <vector>
0004 #include <map>
0005 #include <unordered_map>
0006 #include <memory>  // shared_ptr
0007 
0008 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0009 #include "DataFormats/HGCRecHit/interface/HGCRecHit.h"
0010 #include "SimDataFormats/Associations/interface/MultiClusterToCaloParticleAssociator.h"
0011 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0012 
0013 namespace edm {
0014   class EDProductGetter;
0015 }
0016 
0017 namespace hgcal {
0018   struct detIdInfoInCluster {
0019     bool operator==(const detIdInfoInCluster &o) const { return clusterId == o.clusterId; };
0020     long unsigned int clusterId;
0021     float fraction;
0022     detIdInfoInCluster(long unsigned int cId, float fr) {
0023       clusterId = cId;
0024       fraction = fr;
0025     }
0026   };
0027 
0028   struct detIdInfoInMultiCluster {
0029     bool operator==(const detIdInfoInMultiCluster &o) const { return multiclusterId == o.multiclusterId; };
0030     unsigned int multiclusterId;
0031     long unsigned int clusterId;
0032     float fraction;
0033   };
0034 
0035   struct caloParticleOnALayer {
0036     unsigned int caloParticleId;
0037     float energy = 0;
0038     std::vector<std::pair<DetId, float>> hits_and_fractions;
0039     std::unordered_map<int, std::pair<float, float>> multiClusterIdToEnergyAndScore;
0040   };
0041 
0042   typedef std::vector<std::vector<std::pair<unsigned int, float>>> multiClusterToCaloParticle;
0043   typedef std::vector<std::vector<hgcal::caloParticleOnALayer>> caloParticleToMultiCluster;
0044   typedef std::tuple<multiClusterToCaloParticle, caloParticleToMultiCluster> association;
0045 }  // namespace hgcal
0046 
0047 class MultiClusterAssociatorByEnergyScoreImpl : public hgcal::MultiClusterToCaloParticleAssociatorBaseImpl {
0048 public:
0049   explicit MultiClusterAssociatorByEnergyScoreImpl(edm::EDProductGetter const &,
0050                                                    bool,
0051                                                    std::shared_ptr<hgcal::RecHitTools>,
0052                                                    const std::unordered_map<DetId, const HGCRecHit *> *&);
0053 
0054   hgcal::RecoToSimCollectionWithMultiClusters associateRecoToSim(
0055       const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0056       const edm::Handle<CaloParticleCollection> &cPCH) const override;
0057 
0058   hgcal::SimToRecoCollectionWithMultiClusters associateSimToReco(
0059       const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0060       const edm::Handle<CaloParticleCollection> &cPCH) const override;
0061 
0062 private:
0063   const bool hardScatterOnly_;
0064   std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0065   const std::unordered_map<DetId, const HGCRecHit *> *hitMap_;
0066   unsigned layers_;
0067   edm::EDProductGetter const *productGetter_;
0068   hgcal::association makeConnections(const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0069                                      const edm::Handle<CaloParticleCollection> &cPCH) const;
0070 };