Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:27

0001 #include "RecoParticleFlow/PFClusterTools/interface/ClusterClusterMapping.h"
0002 
0003 // returns true as soon as the two clusters have one hit in common
0004 bool ClusterClusterMapping::overlap(const reco::CaloCluster &sc1,
0005                                     const reco::CaloCluster &sc2,
0006                                     float minfrac,
0007                                     bool debug) {
0008   const std::vector<std::pair<DetId, float> > &hits1 = sc1.hitsAndFractions();
0009   const std::vector<std::pair<DetId, float> > &hits2 = sc2.hitsAndFractions();
0010   unsigned nhits1 = hits1.size();
0011   unsigned nhits2 = hits2.size();
0012 
0013   for (unsigned i1 = 0; i1 < nhits1; ++i1) {
0014     // consider only with a minimum fraction of minfrac (default 1%) of the RecHit
0015     if (hits1[i1].second < minfrac) {
0016       if (debug)
0017         std::cout << " Discarding " << hits1[i1].first << " with " << hits1[i1].second << std::endl;
0018       continue;
0019     }
0020     for (unsigned i2 = 0; i2 < nhits2; ++i2) {
0021       // consider only with a minimum fraction of minfract (default 1%) of the RecHit
0022       if (hits2[i2].second < minfrac) {
0023         if (debug)
0024           std::cout << " Discarding " << hits2[i2].first << " with " << hits2[i2].second << std::endl;
0025         continue;
0026       }
0027       if (hits1[i1].first == hits2[i2].first) {
0028         if (debug) {
0029           std::cout << " Matching hits " << hits1[i1].first << " with " << hits1[i1].second << " and "
0030                     << hits2[i2].first;
0031           std::cout << " with " << hits2[i2].second << std::endl;
0032         }
0033         return true;
0034       }
0035     }
0036   }
0037   return false;
0038 }
0039 
0040 bool ClusterClusterMapping::overlap(const reco::PFClusterRef &pfclustest,
0041                                     const reco::SuperCluster &sc,
0042                                     const edm::ValueMap<reco::CaloClusterPtr> &pfclusassoc) {
0043   for (reco::CaloCluster_iterator caloclus = sc.clustersBegin(); caloclus != sc.clustersEnd(); ++caloclus) {
0044     if (pfclusassoc.contains(caloclus->id())) {
0045       const reco::CaloClusterPtr &pfclus = pfclusassoc[*caloclus];
0046       //printf("pfclus prodidx = %i, key = %i, pfclustest prodidx = %i, key = %i\n",pfclus.id().productIndex(),int(pfclus.key()),pfclustest.id().productIndex(),int(pfclustest.key()));
0047       if (pfclus.id() == pfclustest.id() && pfclus.key() == pfclustest.key())
0048         return true;
0049     }
0050   }
0051   return false;
0052 }
0053 
0054 int ClusterClusterMapping::checkOverlap(const reco::PFCluster &pfc,
0055                                         const std::vector<const reco::SuperCluster *> &sc,
0056                                         float minfrac,
0057                                         bool debug) {
0058   int result = -1;
0059   unsigned nsc = sc.size();
0060 
0061   for (unsigned isc = 0; isc < nsc; ++isc) {
0062     if (overlap(pfc, *(sc[isc]), minfrac, debug))
0063       return isc;
0064   }
0065   return result;
0066 }
0067 
0068 int ClusterClusterMapping::checkOverlap(const reco::PFCluster &pfc,
0069                                         const std::vector<reco::SuperClusterRef> &sc,
0070                                         float minfrac,
0071                                         bool debug) {
0072   int result = -1;
0073   unsigned nsc = sc.size();
0074 
0075   for (unsigned isc = 0; isc < nsc; ++isc) {
0076     if (overlap(pfc, *sc[isc], minfrac, debug))
0077       return isc;
0078   }
0079   return result;
0080 }
0081 
0082 int ClusterClusterMapping::checkOverlap(const reco::PFClusterRef &pfc,
0083                                         const std::vector<reco::SuperClusterRef> &sc,
0084                                         const edm::ValueMap<reco::CaloClusterPtr> &pfclusassoc) {
0085   int result = -1;
0086   unsigned nsc = sc.size();
0087 
0088   for (unsigned isc = 0; isc < nsc; ++isc) {
0089     if (overlap(pfc, *sc[isc], pfclusassoc))
0090       return isc;
0091   }
0092   return result;
0093 }