CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RedundantSeedCleaner.cc
Go to the documentation of this file.
1 
9 
10 //-------------------------------
11 // Collaborating Class Headers --
12 //-------------------------------
13 
21 
22 using namespace edm;
23 using namespace reco;
24 
25 //
26 // definition of vectors
27 //
28 
29 void RedundantSeedCleaner::define(std::vector<TrajectorySeed> & coll)
30 {
31 
32  std::vector<TrajectorySeed> triplets;
33 
34  //search for triplest
35  for(TrajectorySeedCollection::iterator itr =coll.begin(); itr != coll.end(); ++itr){
36  //fill vector of triplets
37  if(itr->nHits()==3) triplets.push_back(*itr);
38 
39  }
40 
41  // clean from shared input
42  if (!triplets.empty()) clean(triplets,coll);
43 }
44 
45 //
46 // the sharedHits cleaner
47 //
48 
49 void RedundantSeedCleaner::clean(const std::vector<TrajectorySeed> & seedTr, std::vector<TrajectorySeed> & seed)
50 {
51 
52  // loop over triplets
53  std::vector<TrajectorySeed> result;
54 
55  std::vector<bool> maskPairs = std::vector<bool>(seed.size(),true);
56  int iPair = 0;
57 
58  for(TrajectorySeedCollection::iterator s1 =seed.begin(); s1 != seed.end(); ++s1){
59  //rechits from seed
60 
61  TrajectorySeed::range r1 = s1->recHits();
62 
63  for(TrajectorySeedCollection::const_iterator s2 = seedTr.begin(); s2 != seedTr.end(); ++s2){
64  //empty
65  if(s2->nHits()==0) continue ;
66 
67  TrajectorySeed::range r2 = s2->recHits();
68  TrajectorySeed::const_iterator h2 = r2.first;
69 
70  //number of shared hits;
71  int shared = 0;
72 
73  for(;h2 < r2.second;h2++){
74  for(TrajectorySeed::const_iterator h1 = r1.first; h1 < r1.second;h1++){
75  if(h2->sharesInput(&(*h1),TrackingRecHit::all)) shared++;
76  if(s1->nHits()!=3) LogDebug(theCategory)<< shared<< " shared hits counter if 2 erease the seed.";
77  }
78  }
79 
80  if(shared ==2 && s1->nHits()!=3) {
81  maskPairs[iPair] = false;
82  }
83 
84  }//end triplets loop
85  ++iPair;
86  }// end pairs loop
87 
88  iPair = 0;
89  //remove pairs in triplets
90  for(TrajectorySeedCollection::iterator s1 = seed.begin(); s1 != seed.end(); ++s1){
91  if (maskPairs[iPair]) result.push_back(*s1);
92  ++iPair;
93  }
94 
95  // cleaned collection
96  seed.swap(result);
97 }
98 
#define LogDebug(id)
void define(std::vector< TrajectorySeed > &)
collection definition
tuple s2
Definition: indexGen.py:106
recHitContainer::const_iterator const_iterator
tuple result
Definition: query.py:137
std::pair< const_iterator, const_iterator > range
std::vector< T * > clean
Definition: MVATrainer.cc:156
JetCorrectorParametersCollection coll
Definition: classes.h:16
void clean(const std::vector< TrajectorySeed > &, std::vector< TrajectorySeed > &)
clean