Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-29 23:13:10

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 ticl {
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 ticl
0044 
0045 class TSToSimTSHitLCAssociatorByEnergyScoreImpl : public ticl::TracksterToSimTracksterHitLCAssociatorBaseImpl {
0046 public:
0047   explicit TSToSimTSHitLCAssociatorByEnergyScoreImpl(edm::EDProductGetter const &,
0048                                                      bool,
0049                                                      std::shared_ptr<hgcal::RecHitTools>,
0050                                                      const std::unordered_map<DetId, const unsigned int> *,
0051                                                      std::vector<const HGCRecHit *> &hits);
0052 
0053   ticl::association_t makeConnections(const edm::Handle<ticl::TracksterCollection> &tCH,
0054                                       const edm::Handle<reco::CaloClusterCollection> &lCCH,
0055                                       const edm::Handle<SimClusterCollection> &sCCH,
0056                                       const edm::Handle<CaloParticleCollection> &cPCH,
0057                                       const edm::Handle<ticl::TracksterCollection> &sTCH) const;
0058 
0059   ticl::RecoToSimCollectionSimTracksters associateRecoToSim(
0060       const edm::Handle<ticl::TracksterCollection> &tCH,
0061       const edm::Handle<reco::CaloClusterCollection> &lCCH,
0062       const edm::Handle<SimClusterCollection> &sCCH,
0063       const edm::Handle<CaloParticleCollection> &cPCH,
0064       const edm::Handle<ticl::TracksterCollection> &sTCH) const override;
0065 
0066   ticl::SimToRecoCollectionSimTracksters associateSimToReco(
0067       const edm::Handle<ticl::TracksterCollection> &tCH,
0068       const edm::Handle<reco::CaloClusterCollection> &lCCH,
0069       const edm::Handle<SimClusterCollection> &sCCH,
0070       const edm::Handle<CaloParticleCollection> &cPCH,
0071       const edm::Handle<ticl::TracksterCollection> &sTCH) const override;
0072 
0073 private:
0074   const bool hardScatterOnly_;
0075   std::shared_ptr<hgcal::RecHitTools> recHitTools_;
0076   const std::unordered_map<DetId, const unsigned int> *hitMap_;
0077   std::vector<const HGCRecHit *> hits_;
0078   unsigned layers_;
0079   edm::EDProductGetter const *productGetter_;
0080 };