Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /** \class RedundantSeedCleaner 
0002  * Description:
0003  * RedundantSeedCleaner (TrackerSeedGenerator) duplicate removal from triplets pairs pixel seeds .
0004  *
0005  * \author Alessandro Grelli, Jean-Roch Vlimant
0006 */
0007 
0008 #include "RecoMuon/TrackerSeedGenerator/interface/RedundantSeedCleaner.h"
0009 
0010 //-------------------------------
0011 // Collaborating Class Headers --
0012 //-------------------------------
0013 
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0016 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0017 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0018 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0019 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h"
0020 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h"
0021 
0022 using namespace edm;
0023 using namespace reco;
0024 
0025 //
0026 // definition of vectors
0027 //
0028 
0029 void RedundantSeedCleaner::define(std::vector<TrajectorySeed>& coll) {
0030   std::vector<TrajectorySeed> triplets;
0031 
0032   //search for triplest
0033   for (TrajectorySeedCollection::iterator itr = coll.begin(); itr != coll.end(); ++itr) {
0034     //fill vector of triplets
0035     if (itr->nHits() == 3)
0036       triplets.push_back(*itr);
0037   }
0038 
0039   // clean from shared input
0040   if (!triplets.empty())
0041     clean(triplets, coll);
0042 }
0043 
0044 //
0045 // the sharedHits cleaner
0046 //
0047 
0048 void RedundantSeedCleaner::clean(const std::vector<TrajectorySeed>& seedTr, std::vector<TrajectorySeed>& seed) {
0049   // loop over triplets
0050   std::vector<TrajectorySeed> result;
0051 
0052   std::vector<bool> maskPairs = std::vector<bool>(seed.size(), true);
0053   int iPair = 0;
0054 
0055   for (TrajectorySeedCollection::iterator s1 = seed.begin(); s1 != seed.end(); ++s1) {
0056     //rechits from seed
0057 
0058     for (TrajectorySeedCollection::const_iterator s2 = seedTr.begin(); s2 != seedTr.end(); ++s2) {
0059       //empty
0060       if (s2->nHits() == 0)
0061         continue;
0062 
0063       //number of shared hits;
0064       int shared = 0;
0065 
0066       for (auto const& h2 : s2->recHits()) {
0067         for (auto const& h1 : s1->recHits()) {
0068           if (h2.sharesInput(&h1, TrackingRecHit::all))
0069             shared++;
0070           if (s1->nHits() != 3)
0071             LogDebug(theCategory) << shared << " shared hits counter if 2 erease the seed.";
0072         }
0073       }
0074 
0075       if (shared == 2 && s1->nHits() != 3) {
0076         maskPairs[iPair] = false;
0077       }
0078 
0079     }  //end triplets loop
0080     ++iPair;
0081   }  // end pairs loop
0082 
0083   iPair = 0;
0084   //remove pairs in triplets
0085   for (TrajectorySeedCollection::iterator s1 = seed.begin(); s1 != seed.end(); ++s1) {
0086     if (maskPairs[iPair])
0087       result.push_back(*s1);
0088     ++iPair;
0089   }
0090 
0091   // cleaned collection
0092   seed.swap(result);
0093 }