CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoMuon/TrackerSeedGenerator/src/RedundantSeedCleaner.cc

Go to the documentation of this file.
00001 
00008 #include "RecoMuon/TrackerSeedGenerator/interface/RedundantSeedCleaner.h"
00009 
00010 //-------------------------------
00011 // Collaborating Class Headers --
00012 //-------------------------------
00013 
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00016 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00017 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00018 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00019 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h"
00020 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h"
00021 
00022 using namespace edm;
00023 using namespace reco;
00024 
00025 //
00026 // definition of vectors 
00027 //
00028 
00029 void RedundantSeedCleaner::define(std::vector<TrajectorySeed> & coll)
00030 {
00031 
00032   std::vector<TrajectorySeed> triplets;
00033   
00034   //search for triplest
00035   for(TrajectorySeedCollection::iterator itr =coll.begin(); itr != coll.end(); ++itr){
00036       //fill vector of triplets
00037       if(itr->nHits()==3) triplets.push_back(*itr);
00038       
00039    }
00040 
00041   // clean from shared input
00042   if (!triplets.empty()) clean(triplets,coll);
00043 }
00044 
00045 //
00046 // the sharedHits cleaner
00047 //
00048 
00049 void RedundantSeedCleaner::clean(const std::vector<TrajectorySeed> & seedTr, std::vector<TrajectorySeed> & seed) 
00050 {
00051 
00052     // loop over triplets
00053     std::vector<TrajectorySeed> result;
00054 
00055     std::vector<bool> maskPairs = std::vector<bool>(seed.size(),true);
00056     int iPair = 0;
00057 
00058     for(TrajectorySeedCollection::iterator s1 =seed.begin(); s1 != seed.end(); ++s1){
00059        //rechits from seed
00060 
00061        TrajectorySeed::range r1 = s1->recHits();
00062 
00063        for(TrajectorySeedCollection::const_iterator s2 = seedTr.begin(); s2 != seedTr.end(); ++s2){
00064           //empty
00065           if(s2->nHits()==0) continue ;
00066 
00067           TrajectorySeed::range r2 = s2->recHits();
00068           TrajectorySeed::const_iterator h2 = r2.first;
00069 
00070           //number of shared hits;
00071           int shared = 0;
00072  
00073           for(;h2 < r2.second;h2++){
00074             for(TrajectorySeed::const_iterator h1  = r1.first; h1 < r1.second;h1++){
00075                if(h2->sharesInput(&(*h1),TrackingRecHit::all)) shared++;
00076                if(s1->nHits()!=3) LogDebug(theCategory)<< shared<< " shared hits counter if 2 erease the seed.";
00077             }
00078           }
00079           
00080           if(shared ==2 && s1->nHits()!=3) {
00081              maskPairs[iPair] = false;
00082           }
00083 
00084        }//end triplets loop
00085        ++iPair;
00086      }// end pairs loop
00087 
00088      iPair = 0;
00089      //remove pairs in triplets
00090      for(TrajectorySeedCollection::iterator s1 = seed.begin(); s1 != seed.end(); ++s1){
00091         if (maskPairs[iPair]) result.push_back(*s1);
00092         ++iPair;
00093      }
00094 
00095      // cleaned collection
00096       seed.swap(result);
00097 }
00098