test
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 
34 
35  LogDebug("PixelTrackCleanerBySharedHits") << "Cleanering tracks" << "\n";
36  int size = trackHitPairs.size();
37 
38  bool trackOk[size];
39  for (int i = 0; i < size; i++) trackOk[i] = true;
40 
41  for (auto iTrack1 = 0; iTrack1 < size; iTrack1++) {
42  auto track1 = trackHitPairs[iTrack1].first;
43  const RecHits& recHits1 = trackHitPairs[iTrack1].second;
44 
45  if (!trackOk[iTrack1]) continue;
46 
47  for (auto iTrack2 = iTrack1 + 1; iTrack2 < size; iTrack2++)
48  {
49  if ( !trackOk[iTrack2]) continue;
50 
51  auto track2 = trackHitPairs[iTrack2].first;
52  const RecHits& recHits2 = trackHitPairs[iTrack2].second;
53 
54  int commonRecHits = 0;
55  for (auto iRecHit1 = 0U; iRecHit1 < recHits1.size(); iRecHit1++) {
56  for (auto iRecHit2 = 0U; iRecHit2 < recHits2.size(); iRecHit2++) {
57  if (recHitsAreEqual(recHits1[iRecHit1], recHits2[iRecHit2])) { commonRecHits++; break;} // if a hit is common, no other can be the same!
58  }
59  if (commonRecHits > 1) break;
60  }
61 
62  if (commonRecHits > 1) {
63  if (track1->pt() > track2->pt()) trackOk[iTrack2] = false;
64  else { trackOk[iTrack1] = false; break;}
65  }
66 
67  }
68  }
69 
70  vector<TrackWithRecHits> cleanedTracks;
71 
72  for (int i = 0; i < size; i++)
73  {
74  if (trackOk[i]) cleanedTracks.push_back(trackHitPairs[i]);
75  else delete trackHitPairs[i].first;
76  }
77  return cleanedTracks;
78 }
79 
80 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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