CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PixelTrackCleanerBySharedHits Class Referencefinal

#include <PixelTrackCleanerBySharedHits.h>

Inheritance diagram for PixelTrackCleanerBySharedHits:
PixelTrackCleaner

Public Types

using TracksWithTTRHs = pixeltrackfitting::TracksWithTTRHs
 
using TrackWithTTRHs = pixeltrackfitting::TrackWithTTRHs
 
- Public Types inherited from PixelTrackCleaner
using Record = TrajectoryFilter::Record
 
typedef pixeltrackfitting::TracksWithRecHits TracksWithRecHits
 
using TracksWithTTRHs = pixeltrackfitting::TracksWithTTRHs
 

Public Member Functions

void cleanTracks (TracksWithTTRHs &tracksWithRecHits) const override
 
 PixelTrackCleanerBySharedHits (bool useQuadrupletAlgo)
 
 ~PixelTrackCleanerBySharedHits () override
 
- Public Member Functions inherited from PixelTrackCleaner
virtual TracksWithRecHits cleanTracks (const TracksWithRecHits &tracksWithRecHits) const
 
bool fast () const
 
virtual ~PixelTrackCleaner ()
 

Private Attributes

const bool useQuadrupletAlgo_
 

Additional Inherited Members

- Protected Member Functions inherited from PixelTrackCleaner
 PixelTrackCleaner (bool fast=false)
 

Detailed Description

Definition at line 17 of file PixelTrackCleanerBySharedHits.h.

Member Typedef Documentation

Definition at line 25 of file PixelTrackCleanerBySharedHits.h.

Definition at line 24 of file PixelTrackCleanerBySharedHits.h.

Constructor & Destructor Documentation

PixelTrackCleanerBySharedHits::PixelTrackCleanerBySharedHits ( bool  useQuadrupletAlgo)

Definition at line 14 of file PixelTrackCleanerBySharedHits.cc.

14  :
15  PixelTrackCleaner(true), // to mark this as fast algo
16  useQuadrupletAlgo_(useQuadrupletAlgo)
17 {}
PixelTrackCleaner(bool fast=false)
PixelTrackCleanerBySharedHits::~PixelTrackCleanerBySharedHits ( )
override

Definition at line 19 of file PixelTrackCleanerBySharedHits.cc.

20 {}

Member Function Documentation

void PixelTrackCleanerBySharedHits::cleanTracks ( TracksWithTTRHs tracksWithRecHits) const
overridevirtual

Reimplemented from PixelTrackCleaner.

Definition at line 23 of file PixelTrackCleanerBySharedHits.cc.

References connectstrParser::f2, plotBeamSpotDB::first, mps_fire::i, gen::k, LogDebug, min(), indexGen::s2, offlineSlimmedPrimaryVertices_cfi::score, edm::second(), findQualityFiles::size, jetUpdater_cfi::sort, mitigatedMETSequence_cff::U, useQuadrupletAlgo_, and findQualityFiles::v.

24 {
25 
26  LogDebug("PixelTrackCleanerBySharedHits") << "Cleanering tracks" << "\n";
27  unsigned int size = trackHitPairs.size();
28  if (size <= 1) return;
29 
30  // sort (stabilize cleaning)
31  uint16_t score[size];
32  unsigned int ind[size];
33  for (auto i = 0U; i < size; ++i) {
34  ind[i]=i;
35  score[i]= 32000-std::min(32000, int(trackHitPairs[i].first->chi2()*100.f)); // chi2: smaller is better
36  if (trackHitPairs[i].second.size()==4) score[i]+=32001; // s4 always better than s3
37  }
38  std::sort(ind,ind+size,[&](unsigned int i, unsigned int j){return score[i]>score[j];});
39 
40  auto kill = [&](unsigned int k) {delete trackHitPairs[k].first; trackHitPairs[k].first=nullptr;};
41 
42  // sorted: first is always better!
43 
44  // first loop: only first two hits....
45  for (auto i = 0U; i < size; ++i) {
46  auto iTrack1 = ind[i];
47  auto track1 = trackHitPairs[iTrack1].first;
48  if (!track1) continue;
49  auto const & recHits1 = trackHitPairs[iTrack1].second;
50  for (auto j = i+1; j < size; ++j) {
51  auto iTrack2 = ind[j];
52  auto track2 = trackHitPairs[iTrack2].first;
53  if (!track2) continue;
54  auto const & recHits2 = trackHitPairs[iTrack2].second;
55  if (recHits1[0] != recHits2[0]) continue;
56  if (recHits1[1] != recHits2[1]) continue;
57  kill(iTrack2);
58  } // tk2
59  } // tk1
60 
61 
62  // second loop: first and third hits....
63  for (auto i = 0U; i < size; ++i) {
64  auto iTrack1 = ind[i];
65  auto track1 = trackHitPairs[iTrack1].first;
66  if (!track1) continue;
67  auto const & recHits1 = trackHitPairs[iTrack1].second;
68  if (recHits1.size()<3) continue;
69  for (auto j = i+1; j < size; ++j) {
70  auto iTrack2 = ind[j];
71  auto track2 = trackHitPairs[iTrack2].first;
72  if (!track2) continue;
73  auto const & recHits2 = trackHitPairs[iTrack2].second;
74  if (recHits2.size()<3) continue;
75  if (recHits1[0] != recHits2[0]) continue;
76  if (recHits1[2] != recHits2[2]) continue;
77  kill(iTrack2);
78  } // tk2
79  } // tk1
80 
81 
82  // final loop: all the rest
83  for (auto i = 0U; i < size; ++i) {
84  auto iTrack1 = ind[i];
85  auto track1 = trackHitPairs[iTrack1].first;
86  if (!track1) continue;
87  auto const & recHits1 = trackHitPairs[iTrack1].second;
88  auto s1 = recHits1.size();
89  for (auto j = i+1; j < size; ++j) {
90  auto iTrack2 = ind[j];
91  auto track2 = trackHitPairs[iTrack2].first;
92  if (!track2) continue;
93  auto const & recHits2 = trackHitPairs[iTrack2].second;
94  auto s2 = recHits2.size();
95  auto commonRecHits = 0U;
96  auto f2=0U;
97  for (auto iRecHit1 = 0U; iRecHit1 < s1; ++iRecHit1) {
98  for (auto iRecHit2 = f2; iRecHit2 < s2; ++iRecHit2) {
99  if (recHits1[iRecHit1] == recHits2[iRecHit2]) { ++commonRecHits; f2=iRecHit2+1; break;} // if a hit is common, no other can be the same!
100  }
101  if (commonRecHits > 1) break;
102  }
103  if(useQuadrupletAlgo_) {
104  if(commonRecHits >= 1) {
105  if(s1 == 3 || commonRecHits > 1) { kill(iTrack2); }
106  }
107  }
108  else if (commonRecHits > 1) {
109  kill(iTrack2);
110  }
111  } // tk2
112  } //tk1
113 
114  trackHitPairs.erase(std::remove_if(trackHitPairs.begin(),trackHitPairs.end(),[&](TrackWithTTRHs & v){ return nullptr==v.first;}),trackHitPairs.end());
115 }
#define LogDebug(id)
size
Write out results.
std::pair< reco::Track *, SeedingHitSet > TrackWithTTRHs
U second(std::pair< T, U > const &p)
T min(T a, T b)
Definition: MathUtil.h:58
int k[5][pyjets_maxn]

Member Data Documentation

const bool PixelTrackCleanerBySharedHits::useQuadrupletAlgo_
private

Definition at line 29 of file PixelTrackCleanerBySharedHits.h.

Referenced by cleanTracks().