File indexing completed on 2024-05-29 23:13:09
0001
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 }
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 unsigned int> *&,
0053 std::vector<const HGCRecHit *> &hits);
0054
0055 hgcal::RecoToSimCollectionWithMultiClusters associateRecoToSim(
0056 const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0057 const edm::Handle<CaloParticleCollection> &cPCH) const override;
0058
0059 hgcal::SimToRecoCollectionWithMultiClusters associateSimToReco(
0060 const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0061 const edm::Handle<CaloParticleCollection> &cPCH) const override;
0062
0063 private:
0064 const bool hardScatterOnly_;
0065 std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0066 const std::unordered_map<DetId, const unsigned int> *hitMap_;
0067 std::vector<const HGCRecHit *> hits_;
0068 unsigned layers_;
0069 edm::EDProductGetter const *productGetter_;
0070 hgcal::association makeConnections(const edm::Handle<reco::HGCalMultiClusterCollection> &mCCH,
0071 const edm::Handle<CaloParticleCollection> &cPCH) const;
0072 };