CbmRoot
CbmLitTrack.h
Go to the documentation of this file.
1 
8 #ifndef CBMLITTRACK_H_
9 #define CBMLITTRACK_H_
10 
11 #include "base/CbmLitEnums.h"
12 #include "base/CbmLitTypes.h"
13 #include "data/CbmLitFitNode.h"
14 #include "data/CbmLitHit.h"
15 #include "data/CbmLitTrackParam.h"
16 
17 #include <algorithm>
18 #include <string>
19 #include <vector>
20 using std::sort;
21 using std::string;
22 using std::vector;
23 
30 class CbmLitTrack {
31 public:
36  : fHits()
37  , fParamFirst()
38  , fParamLast()
39  , fFitNodes()
41  , fChi2(0)
42  , fNDF(0)
43  , fPreviousTrackId(0)
44  , fLastStationId(0)
45  , fPDG(211)
46  , fNofMissingHits(0)
47  , fRefId(-1)
48  , fLength(-1.) {}
49 
53  virtual ~CbmLitTrack() {}
54 
55  /* Getters */
56  Int_t GetNofHits() const { return fHits.size(); }
57  LitTrackQa GetQuality() const { return fQuality; }
58  litfloat GetChi2() const { return fChi2; }
59  Int_t GetNDF() const { return fNDF; }
60  Int_t GetPreviousTrackId() const { return fPreviousTrackId; }
61  Int_t GetPDG() const { return fPDG; };
62  const CbmLitTrackParam* GetParamFirst() const { return &fParamFirst; }
63  const CbmLitTrackParam* GetParamLast() const { return &fParamLast; }
64  Int_t GetLastStationId() const { return fLastStationId; };
65  const CbmLitHit* GetHit(Int_t index) const { return fHits[index]; }
66  const vector<const CbmLitHit*>& GetHits() const { return fHits; }
67  const CbmLitFitNode* GetFitNode(Int_t index) const {
68  return &fFitNodes[index];
69  }
70  const vector<CbmLitFitNode>& GetFitNodes() const { return fFitNodes; }
71  Int_t GetNofMissingHits() const { return fNofMissingHits; }
72  Int_t GetRefId() const { return fRefId; }
73  litfloat GetLength() const { return fLength; }
74 
75  /* Setters */
76  void SetQuality(LitTrackQa quality) { fQuality = quality; }
77  void SetChi2(litfloat chi2) { fChi2 = chi2; }
78  void SetNDF(Int_t ndf) { fNDF = ndf; }
79  void SetPreviousTrackId(Int_t id) { fPreviousTrackId = id; }
80  void SetPDG(Int_t pdg) { fPDG = pdg; }
81  void SetParamFirst(const CbmLitTrackParam* par) { fParamFirst = *par; }
82  void SetParamLast(const CbmLitTrackParam* par) { fParamLast = *par; }
83  /* TODO temporarily needed for equal_range algorithm */
84  void SetNofHits(Int_t nofHits) { fHits.resize(nofHits); }
85  void SetLastStationId(Int_t lastPlaneId) { fLastStationId = lastPlaneId; }
86  void SetFitNodes(const vector<CbmLitFitNode>& nodes) { fFitNodes = nodes; }
87  void SetNofMissingHits(Int_t nofMissingHits) {
88  fNofMissingHits = nofMissingHits;
89  }
90  void SetRefId(Int_t refId) { fRefId = refId; }
91  void SetLength(litfloat length) { fLength = length; }
92 
96  void AddHit(const CbmLitHit* hit) { fHits.push_back(hit); }
97 
101  void ClearHits() { fHits.clear(); }
102 
106  void RemoveHit(Int_t index) {
107  fHits.erase(fHits.begin() + index);
108  if (!fFitNodes.empty()) { fFitNodes.erase(fFitNodes.begin() + index); };
109  }
110 
115  void SortHits(Bool_t downstream = true) {
116  if (downstream) {
117  sort(fHits.begin(), fHits.end(), CompareHitPtrZLess());
118  } else {
119  sort(fHits.begin(), fHits.end(), CompareHitPtrZMore());
120  }
121  }
122 
127  Bool_t CheckParams() const {
128  std::vector<litfloat> covFirst(fParamFirst.GetCovMatrix());
129  std::vector<litfloat> covLast(fParamLast.GetCovMatrix());
130  for (Int_t i = 0; i < 21; i++) {
131  if (std::abs(covFirst[i]) > 10000. || std::abs(covLast[i]) > 10000.) {
132  return false;
133  }
134  }
135  if (GetNofHits() < 1) { return false; }
136  return true;
137  }
138 
143  string ToString() const {
144  std::stringstream ss;
145  ss << "Track: quality=" << fQuality << ", chi2=" << fChi2
146  << ", ndf=" << fNDF << ", previousTrackId=" << fPreviousTrackId
147  << ", lastStationId=" << fLastStationId << ", pdg=" << fPDG
148  << ", nofHits=" << fHits.size() << ", nofFitNodes=" << fFitNodes.size()
149  << std::endl;
150  return ss.str();
151  }
152 
153 private:
154  vector<const CbmLitHit*> fHits; // Array of hits
155  CbmLitTrackParam fParamFirst; // First track parameter
156  CbmLitTrackParam fParamLast; // Last track parameter
157  vector<CbmLitFitNode> fFitNodes; // Array of fit nodes
158  LitTrackQa fQuality; // Track quality
159  litfloat fChi2; // Chi-square
160  Int_t fNDF; // Number of degrees of freedom
161  Int_t fPreviousTrackId; // Index of the previous track, i.e. STS
162  Int_t fLastStationId; // Last detector station where track has a hit
163  Int_t fPDG; // PDG code
164  Int_t fNofMissingHits; // Number of missing hits
165  Int_t fRefId; // Reference to MC
166  litfloat fLength; // Track length
167 };
168 
173  public std::binary_function<const CbmLitTrack*, const CbmLitTrack*, Bool_t> {
174 public:
175  Bool_t operator()(const CbmLitTrack* track1,
176  const CbmLitTrack* track2) const {
177  return ((track1->GetChi2() / track1->GetNDF())
178  < (track2->GetChi2() / track2->GetNDF()));
179  }
180 };
181 
182 
187  public std::binary_function<const CbmLitTrack*, const CbmLitTrack*, Bool_t> {
188 public:
189  Bool_t operator()(const CbmLitTrack* track1,
190  const CbmLitTrack* track2) const {
191  return track1->GetPreviousTrackId() < track2->GetPreviousTrackId();
192  }
193 };
194 
195 
200  public std::binary_function<const CbmLitTrack*, const CbmLitTrack*, Bool_t> {
201 public:
202  Bool_t operator()(const CbmLitTrack* track1,
203  const CbmLitTrack* track2) const {
204  return track1->GetNofHits() > track2->GetNofHits();
205  }
206 };
207 
208 
213  public std::binary_function<const CbmLitTrack*, const CbmLitTrack*, Bool_t> {
214 public:
215  Bool_t operator()(const CbmLitTrack* track1,
216  const CbmLitTrack* track2) const {
217  return track1->GetNofHits() < track2->GetNofHits();
218  }
219 };
220 
221 
226  public std::binary_function<const CbmLitTrack*, const CbmLitTrack*, Bool_t> {
227 public:
228  Bool_t operator()(const CbmLitTrack* track1,
229  const CbmLitTrack* track2) const {
230  return track1->GetLastStationId() > track2->GetLastStationId();
231  }
232 };
233 
234 #endif /*CBMLITTRACK_H_*/
CbmLitTrackParam.h
Data class for track parameters.
litfloat
double litfloat
Definition: CbmLitFloat.h:15
CbmLitTrack::GetFitNode
const CbmLitFitNode * GetFitNode(Int_t index) const
Definition: CbmLitTrack.h:67
kLITGOOD
@ kLITGOOD
Definition: CbmLitEnums.h:32
CbmLitTrack::fChi2
litfloat fChi2
Definition: CbmLitTrack.h:159
CbmLitTrack::SetNofHits
void SetNofHits(Int_t nofHits)
Definition: CbmLitTrack.h:84
CbmLitTrack::fParamFirst
CbmLitTrackParam fParamFirst
Definition: CbmLitTrack.h:155
CbmLitTrack::SetNofMissingHits
void SetNofMissingHits(Int_t nofMissingHits)
Definition: CbmLitTrack.h:87
CompareTrackPtrNofHitsMore
Comparator for STL sorting algorithms.
Definition: CbmLitTrack.h:200
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmLitTrack::GetChi2
litfloat GetChi2() const
Definition: CbmLitTrack.h:58
CbmLitTrack::SetParamFirst
void SetParamFirst(const CbmLitTrackParam *par)
Definition: CbmLitTrack.h:81
CompareTrackPtrLastStationIdMore
Comparator for STL sorting algorithms.
Definition: CbmLitTrack.h:226
CbmLitTrack::fNDF
Int_t fNDF
Definition: CbmLitTrack.h:160
CbmLitTrack::GetLastStationId
Int_t GetLastStationId() const
Definition: CbmLitTrack.h:64
CompareHitPtrZMore
Definition: CbmLitHit.h:113
CbmLitFitNode.h
Data class for storage of fitted track parameters, transport matrix and chi-square on each detector s...
CbmLitTrack::SetPreviousTrackId
void SetPreviousTrackId(Int_t id)
Definition: CbmLitTrack.h:79
CbmLitTrack::~CbmLitTrack
virtual ~CbmLitTrack()
Destructor.
Definition: CbmLitTrack.h:53
LitTrackQa
LitTrackQa
Definition: CbmLitEnums.h:31
CbmLitTrack::SetParamLast
void SetParamLast(const CbmLitTrackParam *par)
Definition: CbmLitTrack.h:82
CbmLitTrack::GetPDG
Int_t GetPDG() const
Definition: CbmLitTrack.h:61
CbmLitTrack::SetPDG
void SetPDG(Int_t pdg)
Definition: CbmLitTrack.h:80
CbmLitTrack::SetNDF
void SetNDF(Int_t ndf)
Definition: CbmLitTrack.h:78
CbmLitEnums.h
Define enumerations used in littrack.
CbmLitTrack::fParamLast
CbmLitTrackParam fParamLast
Definition: CbmLitTrack.h:156
CbmLitTrack::SetLastStationId
void SetLastStationId(Int_t lastPlaneId)
Definition: CbmLitTrack.h:85
CbmLitTrack::fNofMissingHits
Int_t fNofMissingHits
Definition: CbmLitTrack.h:164
CbmLitTrack::GetFitNodes
const vector< CbmLitFitNode > & GetFitNodes() const
Definition: CbmLitTrack.h:70
CbmLitTrack::SetLength
void SetLength(litfloat length)
Definition: CbmLitTrack.h:91
CbmLitTrack::fFitNodes
vector< CbmLitFitNode > fFitNodes
Definition: CbmLitTrack.h:157
CbmLitTrack::GetPreviousTrackId
Int_t GetPreviousTrackId() const
Definition: CbmLitTrack.h:60
CbmLitTrack::GetRefId
Int_t GetRefId() const
Definition: CbmLitTrack.h:72
CbmLitHit
Base data class for hits.
Definition: CbmLitHit.h:26
CbmLitFitNode
Data class for storage of fitted track parameters, transport matrix and chi-square on each detector s...
Definition: CbmLitFitNode.h:21
CompareTrackPtrChiSqOverNdfLess
Comparator for STL sorting algorithms.
Definition: CbmLitTrack.h:173
CbmLitTrack
Base data class for track.
Definition: CbmLitTrack.h:30
CompareTrackPtrNofHitsLess::operator()
Bool_t operator()(const CbmLitTrack *track1, const CbmLitTrack *track2) const
Definition: CbmLitTrack.h:215
CbmLitTrack::ToString
string ToString() const
Return string representation of class.
Definition: CbmLitTrack.h:143
CbmLitTrack::fPreviousTrackId
Int_t fPreviousTrackId
Definition: CbmLitTrack.h:161
CompareTrackPtrLastStationIdMore::operator()
Bool_t operator()(const CbmLitTrack *track1, const CbmLitTrack *track2) const
Definition: CbmLitTrack.h:228
CbmLitTrack::fHits
vector< const CbmLitHit * > fHits
Definition: CbmLitTrack.h:154
CbmLitTrack::GetParamLast
const CbmLitTrackParam * GetParamLast() const
Definition: CbmLitTrack.h:63
CbmLitTrack::SetRefId
void SetRefId(Int_t refId)
Definition: CbmLitTrack.h:90
CbmLitTrack::GetNDF
Int_t GetNDF() const
Definition: CbmLitTrack.h:59
CbmLitTrack::fQuality
LitTrackQa fQuality
Definition: CbmLitTrack.h:158
CompareTrackPtrNofHitsMore::operator()
Bool_t operator()(const CbmLitTrack *track1, const CbmLitTrack *track2) const
Definition: CbmLitTrack.h:202
CbmLitTrack::fRefId
Int_t fRefId
Definition: CbmLitTrack.h:165
CbmLitTrack::SetFitNodes
void SetFitNodes(const vector< CbmLitFitNode > &nodes)
Definition: CbmLitTrack.h:86
CompareTrackPtrNofHitsLess
Comparator for STL sorting algorithms.
Definition: CbmLitTrack.h:213
CbmLitTrack::SetQuality
void SetQuality(LitTrackQa quality)
Definition: CbmLitTrack.h:76
CbmLitTrack::CheckParams
Bool_t CheckParams() const
Return true if track parameters are correct.
Definition: CbmLitTrack.h:127
CbmLitTrack::GetHits
const vector< const CbmLitHit * > & GetHits() const
Definition: CbmLitTrack.h:66
CompareTrackPtrChiSqOverNdfLess::operator()
Bool_t operator()(const CbmLitTrack *track1, const CbmLitTrack *track2) const
Definition: CbmLitTrack.h:175
CbmLitTrack::GetParamFirst
const CbmLitTrackParam * GetParamFirst() const
Definition: CbmLitTrack.h:62
CompareTrackPtrPrevTrackIdLess::operator()
Bool_t operator()(const CbmLitTrack *track1, const CbmLitTrack *track2) const
Definition: CbmLitTrack.h:189
CbmLitTrack::SortHits
void SortHits(Bool_t downstream=true)
Sort hits by Z position.
Definition: CbmLitTrack.h:115
CbmLitTrack::GetLength
litfloat GetLength() const
Definition: CbmLitTrack.h:73
CompareTrackPtrPrevTrackIdLess
Comparator for STL sorting algorithms.
Definition: CbmLitTrack.h:187
CbmLitTypes.h
Typedefs for data structures used in littrack.
CbmLitTrack::fLength
litfloat fLength
Definition: CbmLitTrack.h:166
CbmLitTrack::fPDG
Int_t fPDG
Definition: CbmLitTrack.h:163
CbmLitTrackParam::GetCovMatrix
const vector< litfloat > & GetCovMatrix() const
Definition: CbmLitTrackParam.h:61
CompareHitPtrZLess
Definition: CbmLitHit.h:102
CbmLitTrack::GetNofMissingHits
Int_t GetNofMissingHits() const
Definition: CbmLitTrack.h:71
CbmLitTrack::CbmLitTrack
CbmLitTrack()
Constructor.
Definition: CbmLitTrack.h:35
CbmLitTrack::ClearHits
void ClearHits()
Remove all hits from track. Do not delete memory.
Definition: CbmLitTrack.h:101
CbmLitTrack::GetQuality
LitTrackQa GetQuality() const
Definition: CbmLitTrack.h:57
CbmLitTrack::fLastStationId
Int_t fLastStationId
Definition: CbmLitTrack.h:162
CbmLitTrack::GetHit
const CbmLitHit * GetHit(Int_t index) const
Definition: CbmLitTrack.h:65
CbmLitTrack::AddHit
void AddHit(const CbmLitHit *hit)
Add hit to track. No additional memory is allocated for hit.
Definition: CbmLitTrack.h:96
CbmLitTrack::RemoveHit
void RemoveHit(Int_t index)
Remove hit and corresponding fit node.
Definition: CbmLitTrack.h:106
CbmLitHit.h
Base data class for hits.
CbmLitTrack::SetChi2
void SetChi2(litfloat chi2)
Definition: CbmLitTrack.h:77
CbmLitTrack::GetNofHits
Int_t GetNofHits() const
Definition: CbmLitTrack.h:56