CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 16 of file PixelTrackCleanerBySharedHits.h.

Member Typedef Documentation

Definition at line 23 of file PixelTrackCleanerBySharedHits.h.

Definition at line 22 of file PixelTrackCleanerBySharedHits.h.

Constructor & Destructor Documentation

PixelTrackCleanerBySharedHits::PixelTrackCleanerBySharedHits ( bool  useQuadrupletAlgo)

Definition at line 14 of file PixelTrackCleanerBySharedHits.cc.

15  : PixelTrackCleaner(true), // to mark this as fast algo
PixelTrackCleaner(bool fast=false)
tuple useQuadrupletAlgo
PixelTrackCleanerBySharedHits::~PixelTrackCleanerBySharedHits ( )
override

Definition at line 18 of file PixelTrackCleanerBySharedHits.cc.

18 {}

Member Function Documentation

void PixelTrackCleanerBySharedHits::cleanTracks ( TracksWithTTRHs tracksWithRecHits) const
overridevirtual

Reimplemented from PixelTrackCleaner.

Definition at line 20 of file PixelTrackCleanerBySharedHits.cc.

References validate-o2o-wbm::f2, first, mps_fire::i, dqmiolumiharvest::j, isotrackApplyRegressor::k, LogDebug, min(), edm::second(), findQualityFiles::size, useQuadrupletAlgo_, and findQualityFiles::v.

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

Member Data Documentation

const bool PixelTrackCleanerBySharedHits::useQuadrupletAlgo_
private

Definition at line 27 of file PixelTrackCleanerBySharedHits.h.

Referenced by cleanTracks().