CbmRoot
LitTrackSelection.h
Go to the documentation of this file.
1 
10 #ifndef LITTRACKSELECTION_H_
11 #define LITTRACKSELECTION_H_
12 
13 #include "LitScalTrack.h"
14 
15 #include <algorithm>
16 #include <functional>
17 #include <set>
18 #include <utility>
19 #include <vector>
20 
21 using std::equal_range;
22 using std::pair;
23 using std::set;
24 using std::sort;
25 
26 namespace lit {
27  namespace parallel {
28 
29 
30  void DoSortNofHits(vector<LitScalTrack*>& tracks) {
31  sort(tracks.begin(), tracks.end(), CompareLitScalTrackNofHitsMore());
32 
33  unsigned int maxNofHits = tracks.front()->GetNofHits();
34  unsigned int minNofHits = tracks.back()->GetNofHits();
35 
36  for (unsigned int iNofHits = minNofHits; iNofHits <= maxNofHits;
37  iNofHits++) {
38  LitScalTrack value;
39  value.SetNofHits(iNofHits);
40 
41  pair<vector<LitScalTrack*>::iterator, vector<LitScalTrack*>::iterator>
42  bounds;
43  bounds = equal_range(tracks.begin(),
44  tracks.end(),
45  &value,
47 
48  if (bounds.first == bounds.second) { continue; }
49 
50  sort(
51  bounds.first, bounds.second, CompareLitScalTrackChiSqOverNdfLess());
52  }
53  }
54 
55  void DoSortLastStation(vector<LitScalTrack*>& tracks) {
56  sort(
58 
59  unsigned int maxPlaneId = tracks.front()->GetLastStationId();
60  unsigned int minPlaneId = tracks.back()->GetLastStationId();
61 
62  for (unsigned int iPlaneId = minPlaneId; iPlaneId <= maxPlaneId;
63  iPlaneId++) {
64  LitScalTrack value;
65  value.SetLastStationId(iPlaneId);
66 
67  pair<vector<LitScalTrack*>::iterator, vector<LitScalTrack*>::iterator>
68  bounds;
69  bounds = equal_range(tracks.begin(),
70  tracks.end(),
71  &value,
73 
74  if (bounds.first == bounds.second) { continue; }
75 
76  sort(
77  bounds.first, bounds.second, CompareLitScalTrackChiSqOverNdfLess());
78  }
79  }
80 
81  void DoSortChiSqOverNDF(vector<LitScalTrack*>& tracks) {
82  sort(tracks.begin(), tracks.end(), CompareLitScalTrackChiSqOverNdfLess());
83  }
84 
85 
86  void DoSelectSharedHits(vector<LitScalTrack*>& tracks) {
87  static const int NOF_SHARED_HITS = 3;
88  if (tracks.empty()) return;
89 
91 
92  set<int> hitsId;
93  // const int STRIPSTART = 100000;
94  // const int TRDSTART = 1000000;
95 
96  unsigned int nofTracks = tracks.size();
97  for (unsigned int iTrack = 0; iTrack < nofTracks; iTrack++) {
98  LitScalTrack* track = tracks[iTrack];
99 
100  if (!track->IsGood()) { continue; }
101 
102  int nofSharedHits = 0;
103  int nofHits = track->GetNofHits();
104  for (int iHit = 0; iHit < nofHits; iHit++) {
105  int hitId = track->GetHit(iHit)->refId;
106  // LitHitType type = track->GetHit(iHit)->GetType();
107  // LitSystemId sysId = track->GetHit(iHit)->GetSystem();
108  // if (type == kLITSTRIPHIT) { hitId += STRIPSTART; }
109  // if (sysId == kLITTRD) { hitId += TRDSTART; }
110  if (hitsId.find(hitId) != hitsId.end()) {
111  nofSharedHits++;
112  if (nofSharedHits > NOF_SHARED_HITS) {
113  track->IsGood(false);
114  break;
115  }
116  }
117  }
118 
119  if (!track->IsGood()) { continue; }
120 
121  for (int iHit = 0; iHit < nofHits; iHit++) {
122  int hitId = track->GetHit(iHit)->refId;
123  //LitHitType type = track->GetHit(iHit)->GetType();
124  //LitSystemId detId = track->GetHit(iHit)->GetSystem();
125  // if (type == kLITSTRIPHIT) { hitId += STRIPSTART; }
126  // if (detId == kLITTRD) { hitId += TRDSTART; }
127  hitsId.insert(hitId);
128  }
129  }
130  hitsId.clear();
131  }
132 
133  } // namespace parallel
134 } // namespace lit
135 #endif /* LITTRACKSELECTION_H_ */
lit::parallel::CompareLitScalTrackChiSqOverNdfLess
Comparator class used in STL algorithms for LitScalTrack class.
Definition: LitScalTrack.h:252
lit::parallel::LitScalTrack::GetHit
const LitScalPixelHit * GetHit(unsigned short index) const
Returns pointer to the hit.
Definition: LitScalTrack.h:82
lit::parallel::DoSortChiSqOverNDF
void DoSortChiSqOverNDF(vector< LitScalTrack * > &tracks)
Definition: LitTrackSelection.h:81
lit::parallel::CompareLitScalTrackNofHitsMore
Comparator class used in STL algorithms for LitScalTrack class.
Definition: LitScalTrack.h:274
lit::parallel::LitScalTrack::SetLastStationId
void SetLastStationId(unsigned short lastStationId)
Set last station ID.
Definition: LitScalTrack.h:166
lit::parallel::LitScalTrack
Scalar track data class.
Definition: LitScalTrack.h:33
lit::parallel::LitScalTrack::GetNofHits
unsigned short GetNofHits() const
Returns number of hits in track.
Definition: LitScalTrack.h:66
lit::parallel::DoSelectSharedHits
void DoSelectSharedHits(vector< LitScalTrack * > &tracks)
Definition: LitTrackSelection.h:86
lit::parallel::LitScalTrack::SetNofHits
void SetNofHits(unsigned short nofHits)
Depricated.
Definition: LitScalTrack.h:75
lit::parallel::LitScalTrack::IsGood
bool IsGood() const
Returns true if track is good.
Definition: LitScalTrack.h:196
tracks
TClonesArray * tracks
Definition: Analyze_matching.h:17
lit::parallel::DoSortLastStation
void DoSortLastStation(vector< LitScalTrack * > &tracks)
Definition: LitTrackSelection.h:55
LitScalTrack.h
Scalar track data class.
lit::parallel::CompareLitScalTrackLastStationIdMore
Comparator class used in STL algorithms for LitScalTrack class.
Definition: LitScalTrack.h:295
lit::parallel::LitScalPixelHit::refId
unsigned short refId
Definition: LitScalPixelHit.h:77
lit::parallel::DoSortNofHits
void DoSortNofHits(vector< LitScalTrack * > &tracks)
Definition: LitTrackSelection.h:30
lit
Definition: LitTrackFinderNNVecElectron.h:19