Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-29 11:58:16

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/TracksterToSimTracksterHitLCAssociator.h"
0011 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0012 
0013 namespace edm {
0014   class EDProductGetter;
0015 }
0016 
0017 namespace hgcal {
0018 
0019   struct detIdInfoInCluster {
0020     bool operator==(const detIdInfoInCluster &o) const { return clusterId == o.clusterId; };
0021     long unsigned int clusterId;
0022     float fraction;
0023   };
0024 
0025   struct detIdInfoInTrackster {
0026     bool operator==(const detIdInfoInTrackster &o) const { return tracksterId == o.tracksterId; };
0027     unsigned int tracksterId;
0028     long unsigned int clusterId;
0029     float fraction;
0030   };
0031 
0032   struct caloParticleOnLayer {
0033     unsigned int caloParticleId;
0034     float energy = 0;
0035     std::vector<std::pair<DetId, float>> hits_and_fractions;
0036     std::unordered_map<unsigned int, std::pair<float, float>> layerClusterIdToEnergyAndScore;
0037   };
0038 
0039   // This object connects a Trackster, identified through its id (tsId), with a vector of pairs containing all
0040   // the SimTracksters (via their ids (stIds)) that share at least one LayerCluster. In that pair
0041   // it stores the score (tsId->(stId,score)). Keep in mind that the association is not unique, since there could be
0042   // several instances of the same SimTrackster from several related SimClusters that each contributed to the same Trackster.
0043 }  // namespace hgcal
0044 
0045 class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public hgcal::TracksterToSimTracksterHitLCAssociatorBaseImpl {
0046 public:
0047   explicit TSToSimTSHitLCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &,
0048                                                      bool,
0049                                                      std::shared_ptr<hgcal::RecHitTools>,
0050                                                      const std::unordered_map<DetId, const HGCRecHit *> *);
0051 
0052   hgcal::association_t makeConnections(const edm::Handle<ticl::TracksterCollection> &tCH,
0053                                        const edm::Handle<reco::CaloClusterCollection> &lCCH,
0054                                        const edm::Handle<SimClusterCollection> &sCCH,
0055                                        const edm::Handle<CaloParticleCollection> &cPCH,
0056                                        const edm::Handle<ticl::TracksterCollection> &sTCH) const;
0057 
0058   hgcal::RecoToSimCollectionSimTracksters associateRecoToSim(
0059       const edm::Handle<ticl::TracksterCollection> &tCH,
0060       const edm::Handle<reco::CaloClusterCollection> &lCCH,
0061       const edm::Handle<SimClusterCollection> &sCCH,
0062       const edm::Handle<CaloParticleCollection> &cPCH,
0063       const edm::Handle<ticl::TracksterCollection> &sTCH) const override;
0064 
0065   hgcal::SimToRecoCollectionSimTracksters associateSimToReco(
0066       const edm::Handle<ticl::TracksterCollection> &tCH,
0067       const edm::Handle<reco::CaloClusterCollection> &lCCH,
0068       const edm::Handle<SimClusterCollection> &sCCH,
0069       const edm::Handle<CaloParticleCollection> &cPCH,
0070       const edm::Handle<ticl::TracksterCollection> &sTCH) const override;
0071 
0072 private:
0073   const bool hardScatterOnly_;
0074   std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0075   const std::unordered_map<DetId, const HGCRecHit *> *hitMap_;
0076   unsigned layers_;
0077   edm::EDProductGetter const *productGetter_;
0078 };