CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoParticleFlow/PFClusterTools/src/ClusterClusterMapping.cc

Go to the documentation of this file.
00001 #include "RecoParticleFlow/PFClusterTools/interface/ClusterClusterMapping.h"
00002 
00003 // returns true as soon as the two clusters have one hit in common
00004 bool ClusterClusterMapping::overlap(const reco::CaloCluster & sc1, const reco::CaloCluster & sc2, float minfrac,bool debug)  {
00005   const std::vector< std::pair<DetId, float> > & hits1 = sc1.hitsAndFractions();
00006   const std::vector< std::pair<DetId, float> > & hits2 = sc2.hitsAndFractions();
00007   unsigned nhits1=hits1.size();
00008   unsigned nhits2=hits2.size();
00009   
00010   for(unsigned i1=0;i1<nhits1;++i1)
00011     { 
00012       // consider only with a minimum fraction of minfrac (default 1%) of the RecHit
00013       if(hits1[i1].second<minfrac) {
00014           if(debug) std::cout << " Discarding " << hits1[i1].first << " with " << hits1[i1].second << std::endl;
00015           continue;
00016         }
00017       for(unsigned i2=0;i2<nhits2;++i2)
00018         {
00019           // consider only with a minimum fraction of minfract (default 1%) of the RecHit
00020           if(hits2[i2].second<minfrac ) {
00021             if(debug) std::cout << " Discarding " << hits2[i2].first << " with " << hits2[i2].second << std::endl;
00022             continue;
00023           }
00024           if(hits1[i1].first==hits2[i2].first)
00025             {
00026               if(debug)
00027                 {
00028                   std::cout << " Matching hits " << hits1[i1].first << " with " <<  hits1[i1].second << " and " <<  hits2[i2].first;
00029                   std::cout << " with " << hits2[i2].second << std::endl;                 
00030                 }
00031               return true;
00032             }
00033         }
00034     }
00035   return false;
00036 }
00037 
00038 int ClusterClusterMapping::checkOverlap(const reco::PFCluster & pfc, std::vector<const reco::SuperCluster *> sc,float minfrac,bool debug) {
00039   int result=-1;
00040   unsigned nsc=sc.size();
00041   
00042   for(unsigned isc=0;isc<nsc;++isc) {
00043     if(overlap(pfc,*(sc[isc]),minfrac,debug))
00044       return isc;
00045   }
00046   return result;
00047 }