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/LayerClusterToSimClusterAssociator.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 struct simClusterOnCLayer {
0045 unsigned int simClusterId;
0046 float energy = 0;
0047 std::vector<std::pair<DetId, float>> hits_and_fractions;
0048 std::unordered_map<int, std::pair<float, float>> layerClusterIdToEnergyAndScore;
0049 };
0050
0051
0052
0053
0054 typedef std::vector<std::vector<std::pair<unsigned int, float>>> layerClusterToSimCluster;
0055
0056
0057 typedef std::vector<std::vector<ticl::simClusterOnCLayer>> simClusterToLayerCluster;
0058
0059
0060
0061 typedef std::tuple<layerClusterToSimCluster, simClusterToLayerCluster> association;
0062 }
0063
0064 template <typename HIT>
0065 class LCToSCAssociatorByEnergyScoreImpl : public ticl::LayerClusterToSimClusterAssociatorBaseImpl {
0066 public:
0067 explicit LCToSCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &,
0068 bool,
0069 std::shared_ptr<hgcal::RecHitTools>,
0070 const std::unordered_map<DetId, const unsigned int> *,
0071 std::vector<const HIT *> &hits);
0072
0073 ticl::RecoToSimCollectionWithSimClusters associateRecoToSim(
0074 const edm::Handle<reco::CaloClusterCollection> &cCH,
0075 const edm::Handle<SimClusterCollection> &sCCH) const override;
0076
0077 ticl::SimToRecoCollectionWithSimClusters associateSimToReco(
0078 const edm::Handle<reco::CaloClusterCollection> &cCH,
0079 const edm::Handle<SimClusterCollection> &sCCH) const override;
0080
0081 private:
0082 const bool hardScatterOnly_;
0083 std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0084 const std::unordered_map<DetId, const unsigned int> *hitMap_;
0085 unsigned layers_;
0086 edm::EDProductGetter const *productGetter_;
0087 ticl::association makeConnections(const edm::Handle<reco::CaloClusterCollection> &cCH,
0088 const edm::Handle<SimClusterCollection> &sCCH) const;
0089 std::vector<const HIT *> hits_;
0090 };
0091
0092 extern template class LCToSCAssociatorByEnergyScoreImpl<HGCRecHit>;
0093 extern template class LCToSCAssociatorByEnergyScoreImpl<reco::PFRecHit>;
0094
0095 using HGCalLCToSCAssociatorByEnergyScoreImpl = LCToSCAssociatorByEnergyScoreImpl<HGCRecHit>;
0096 using BarrelLCToSCAssociatorByEnergyScoreImpl = LCToSCAssociatorByEnergyScoreImpl<reco::PFRecHit>;