CMS 3D CMS Logo

PixelTrackCleanerBySharedHits.cc
Go to the documentation of this file.
2 
7 
8 using namespace std;
9 using namespace reco;
10 using namespace pixeltrackfitting;
11 
13  PixelTrackCleaner(true), // to mark this as fast algo
14  useQuadrupletAlgo_(useQuadrupletAlgo)
15 {}
16 
18 {}
19 
20 
22 {
23 
24  LogDebug("PixelTrackCleanerBySharedHits") << "Cleanering tracks" << "\n";
25  unsigned int size = trackHitPairs.size();
26  if (size <= 1) return;
27 
28  auto kill = [&](unsigned int i) { delete trackHitPairs[i].first; trackHitPairs[i].first=nullptr;};
29 
30  for (auto iTrack1 = 0U; iTrack1 < size; iTrack1++) {
31 
32  auto track1 = trackHitPairs[iTrack1].first;
33  if (!track1) continue;
34 
35  auto const & recHits1 = trackHitPairs[iTrack1].second;
36  auto s1 = recHits1.size();
37  for (auto iTrack2 = iTrack1 + 1U; iTrack2 < size; iTrack2++)
38  {
39  auto track2 = trackHitPairs[iTrack2].first;
40  if (!track2) continue;
41  auto const & recHits2 = trackHitPairs[iTrack2].second;
42  auto s2 = recHits2.size();
43  auto f2=0U;
44  auto commonRecHits = 0U;
45  for (auto iRecHit1 = 0U; iRecHit1 < s1; ++iRecHit1) {
46  for (auto iRecHit2 = f2; iRecHit2 < s2; ++iRecHit2) {
47  if (recHits1[iRecHit1] == recHits2[iRecHit2]) { ++commonRecHits; f2=iRecHit2+1; break;} // if a hit is common, no other can be the same!
48  }
49  if (commonRecHits > 1) break;
50  }
51 
52  auto cleanTrack = [&](){
53  if (track1->pt() > track2->pt()) { kill(iTrack2); return false; }
54  kill(iTrack1);
55  return true;
56  };
57 
58  if(useQuadrupletAlgo_) {
59  if(commonRecHits >= 1) {
60  if (s1 > s2) kill(iTrack2);
61  else if(s1 < s2) { kill(iTrack1); break;}
62  else if(s1 == 3) { if(cleanTrack()) break; } // same number of hits
63  else if(commonRecHits > 1) { if(cleanTrack()) break; }// same number of hits, size != 3 (i.e. == 4)
64  }
65  }
66  else if (commonRecHits > 1) {
67  if(cleanTrack()) break;
68  }
69  }
70  }
71 
72  trackHitPairs.erase(std::remove_if(trackHitPairs.begin(),trackHitPairs.end(),[&](TrackWithTTRHs & v){ return nullptr==v.first;}),trackHitPairs.end());
73 }
#define LogDebug(id)
size
Write out results.
int i
Definition: DBlmapReader.cc:9
PixelTrackCleanerBySharedHits(bool useQuadrupletAlgo)
void cleanTracks(TracksWithTTRHs &tracksWithRecHits) const override
fixed size matrix
pixeltrackfitting::TrackWithTTRHs TrackWithTTRHs
pixeltrackfitting::TracksWithTTRHs TracksWithTTRHs