CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {}
14 
16 {}
17 
18 namespace {
19  inline
20  bool recHitsAreEqual(const TrackingRecHit *recHit1, const TrackingRecHit *recHit2) {
21  if (recHit1->geographicalId() != recHit2->geographicalId()) return false;
22  LocalPoint pos1 = recHit1->localPosition();
23  LocalPoint pos2 = recHit2->localPosition();
24  return ((pos1.x() == pos2.x()) && (pos1.y() == pos2.y()));
25  }
26 
27 }
28 
30  const TrackerTopology *tTopo)
31 {
32  typedef std::vector<const TrackingRecHit *> RecHits;
33  vector<TrackWithRecHits> cleanedTracks;
34 
35  LogDebug("PixelTrackCleanerBySharedHits") << "Cleanering tracks" << "\n";
36  unsigned int size = trackHitPairs.size();
37  if (size == 0) return cleanedTracks;
38 
39  bool trackOk[size];
40  for (auto i = 0U; i < size; i++) trackOk[i] = true;
41 
42  for (auto iTrack1 = 0U; iTrack1 < size; iTrack1++) {
43  auto track1 = trackHitPairs[iTrack1].first;
44  const RecHits& recHits1 = trackHitPairs[iTrack1].second;
45 
46  if (!trackOk[iTrack1]) continue;
47 
48  for (auto iTrack2 = iTrack1 + 1U; iTrack2 < size; iTrack2++)
49  {
50  if ( !trackOk[iTrack2]) continue;
51 
52  auto track2 = trackHitPairs[iTrack2].first;
53  const RecHits& recHits2 = trackHitPairs[iTrack2].second;
54 
55  auto commonRecHits = 0U;
56  for (auto iRecHit1 = 0U; iRecHit1 < recHits1.size(); iRecHit1++) {
57  for (auto iRecHit2 = 0U; iRecHit2 < recHits2.size(); iRecHit2++) {
58  if (recHitsAreEqual(recHits1[iRecHit1], recHits2[iRecHit2])) { commonRecHits++; break;} // if a hit is common, no other can be the same!
59  }
60  if (commonRecHits > 1) break;
61  }
62 
63  if (commonRecHits > 1) {
64  if (track1->pt() > track2->pt()) trackOk[iTrack2] = false;
65  else { trackOk[iTrack1] = false; break;}
66  }
67 
68  }
69  }
70 
71  for (auto i = 0U; i < size; i++)
72  {
73  if (trackOk[i]) cleanedTracks.push_back(trackHitPairs[i]);
74  else delete trackHitPairs[i].first;
75  }
76  return cleanedTracks;
77 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:293
T y() const
Definition: PV3DBase.h:63
PixelTrackCleanerBySharedHits(const edm::ParameterSet &cfg)
virtual TracksWithRecHits cleanTracks(const TracksWithRecHits &tracksWithRecHits, const TrackerTopology *tTopo)
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
tuple size
Write out results.
pixeltrackfitting::TracksWithRecHits TracksWithRecHits