File indexing completed on 2024-05-29 23:13:08
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 "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h"
0011 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
0012 #include "SimDataFormats/Associations/interface/LayerClusterToCaloParticleAssociator.h"
0013 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0014
0015 namespace edm {
0016 class EDProductGetter;
0017 }
0018
0019 namespace ticl {
0020
0021
0022
0023
0024 struct detIdInfoInCluster {
0025 bool operator==(const detIdInfoInCluster &o) const { return clusterId == o.clusterId; };
0026 long unsigned int clusterId;
0027 float fraction;
0028 detIdInfoInCluster(long unsigned int cId, float fr) {
0029 clusterId = cId;
0030 fraction = fr;
0031 }
0032 };
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 struct caloParticleOnLayer {
0047 unsigned int caloParticleId;
0048 float energy = 0;
0049 std::vector<std::pair<DetId, float>> hits_and_fractions;
0050 std::unordered_map<int, std::pair<float, float>> layerClusterIdToEnergyAndScore;
0051 };
0052
0053
0054
0055
0056
0057 typedef std::vector<std::vector<std::pair<unsigned int, float>>> layerClusterToCaloParticle;
0058
0059
0060 typedef std::vector<std::vector<ticl::caloParticleOnLayer>> caloParticleToLayerCluster;
0061
0062
0063
0064 typedef std::tuple<layerClusterToCaloParticle, caloParticleToLayerCluster> association;
0065 }
0066
0067 template <typename HIT>
0068 class LCToCPAssociatorByEnergyScoreImpl : public ticl::LayerClusterToCaloParticleAssociatorBaseImpl {
0069 public:
0070 explicit LCToCPAssociatorByEnergyScoreImpl(edm::EDProductGetter const &,
0071 bool,
0072 std::shared_ptr<hgcal::RecHitTools>,
0073 const std::unordered_map<DetId, const unsigned int> *,
0074 const std::vector<const HIT *> &hits);
0075
0076 ticl::RecoToSimCollection associateRecoToSim(const edm::Handle<reco::CaloClusterCollection> &cCH,
0077 const edm::Handle<CaloParticleCollection> &cPCH) const override;
0078
0079 ticl::SimToRecoCollection associateSimToReco(const edm::Handle<reco::CaloClusterCollection> &cCH,
0080 const edm::Handle<CaloParticleCollection> &cPCH) const override;
0081
0082 private:
0083 const bool hardScatterOnly_;
0084 std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0085 const std::unordered_map<DetId, const unsigned int> *hitMap_;
0086 unsigned layers_;
0087 edm::EDProductGetter const *productGetter_;
0088 ticl::association makeConnections(const edm::Handle<reco::CaloClusterCollection> &cCH,
0089 const edm::Handle<CaloParticleCollection> &cPCH) const;
0090 std::vector<const HIT *> hits_;
0091 };
0092
0093 extern template class LCToCPAssociatorByEnergyScoreImpl<HGCRecHit>;
0094 extern template class LCToCPAssociatorByEnergyScoreImpl<reco::PFRecHit>;
0095
0096 using HGCalLCToCPAssociatorByEnergyScoreImpl = LCToCPAssociatorByEnergyScoreImpl<HGCRecHit>;
0097 using BarrelLCToCPAssociatorByEnergyScoreImpl = LCToCPAssociatorByEnergyScoreImpl<reco::PFRecHit>;