CbmRoot
Loading...
Searching...
No Matches
CbmLitTrack.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2017 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
12#ifndef CBMLITTRACK_H_
13#define CBMLITTRACK_H_
14
15#include "base/CbmLitEnums.h"
16#include "base/CbmLitTypes.h"
17#include "data/CbmLitFitNode.h"
18#include "data/CbmLitHit.h"
20
21#include <algorithm>
22#include <string>
23#include <vector>
24using std::sort;
25using std::string;
26using std::vector;
27
35 public:
40 : fHits()
41 , fParamFirst()
42 , fParamLast()
43 , fFitNodes()
45 , fChi2(0)
46 , fNDF(0)
49 , fPDG(211)
51 , fRefId(-1)
52 , fLength(-1.)
53 {
54 }
55
59 virtual ~CbmLitTrack() {}
60
61 /* Getters */
62 Int_t GetNofHits() const { return fHits.size(); }
63 LitTrackQa GetQuality() const { return fQuality; }
64 litfloat GetChi2() const { return fChi2; }
65 Int_t GetNDF() const { return fNDF; }
66 Int_t GetPreviousTrackId() const { return fPreviousTrackId; }
67 Int_t GetPDG() const { return fPDG; };
68 const CbmLitTrackParam* GetParamFirst() const { return &fParamFirst; }
69 const CbmLitTrackParam* GetParamLast() const { return &fParamLast; }
70 Int_t GetLastStationId() const { return fLastStationId; };
71 const CbmLitHit* GetHit(Int_t index) const { return fHits[index]; }
72 const vector<const CbmLitHit*>& GetHits() const { return fHits; }
73 const CbmLitFitNode* GetFitNode(Int_t index) const { return &fFitNodes[index]; }
74 const vector<CbmLitFitNode>& GetFitNodes() const { return fFitNodes; }
75 Int_t GetNofMissingHits() const { return fNofMissingHits; }
76 Int_t GetRefId() const { return fRefId; }
77 litfloat GetLength() const { return fLength; }
78
79 /* Setters */
80 void SetQuality(LitTrackQa quality) { fQuality = quality; }
81 void SetChi2(litfloat chi2) { fChi2 = chi2; }
82 void SetNDF(Int_t ndf) { fNDF = ndf; }
83 void SetPreviousTrackId(Int_t id) { fPreviousTrackId = id; }
84 void SetPDG(Int_t pdg) { fPDG = pdg; }
85 void SetParamFirst(const CbmLitTrackParam* par) { fParamFirst = *par; }
86 void SetParamLast(const CbmLitTrackParam* par) { fParamLast = *par; }
87 /* TODO temporarily needed for equal_range algorithm */
88 void SetNofHits(Int_t nofHits) { fHits.resize(nofHits); }
89 void SetLastStationId(Int_t lastPlaneId) { fLastStationId = lastPlaneId; }
90 void SetFitNodes(const vector<CbmLitFitNode>& nodes) { fFitNodes = nodes; }
91 void SetNofMissingHits(Int_t nofMissingHits) { fNofMissingHits = nofMissingHits; }
92 void SetRefId(Int_t refId) { fRefId = refId; }
93 void SetLength(litfloat length) { fLength = length; }
94
98 void AddHit(const CbmLitHit* hit) { fHits.push_back(hit); }
99
103 void ClearHits() { fHits.clear(); }
104
108 void RemoveHit(Int_t index)
109 {
110 fHits.erase(fHits.begin() + index);
111 if (!fFitNodes.empty()) {
112 fFitNodes.erase(fFitNodes.begin() + index);
113 };
114 }
115
120 void SortHits(Bool_t downstream = true)
121 {
122 if (downstream) {
123 sort(fHits.begin(), fHits.end(),
124 [](const CbmLitHit* hit1, const CbmLitHit* hit2) { return hit1->GetZ() < hit2->GetZ(); });
125 }
126 else {
127 sort(fHits.begin(), fHits.end(),
128 [](const CbmLitHit* hit1, const CbmLitHit* hit2) { return hit1->GetZ() > hit2->GetZ(); });
129 }
130 }
131
136 Bool_t CheckParams() const
137 {
138 std::vector<litfloat> covFirst(fParamFirst.GetCovMatrix());
139 std::vector<litfloat> covLast(fParamLast.GetCovMatrix());
140 // don't check the time error, because time can be unmeasured -- S.Gorbunov
141 for (Int_t i = 0; i < 15; i++) {
142 if (std::abs(covFirst[i]) > 10000. || std::abs(covLast[i]) > 10000.) {
143 return false;
144 }
145 }
146 return true;
147 }
148
153 string ToString() const
154 {
155 std::stringstream ss;
156 ss << "Track: quality=" << fQuality << ", chi2=" << fChi2 << ", ndf=" << fNDF
157 << ", previousTrackId=" << fPreviousTrackId << ", lastStationId=" << fLastStationId << ", pdg=" << fPDG
158 << ", nofHits=" << fHits.size() << ", nofFitNodes=" << fFitNodes.size() << std::endl;
159 return ss.str();
160 }
161
162 private:
163 vector<const CbmLitHit*> fHits; // Array of hits
164 CbmLitTrackParam fParamFirst; // First track parameter
165 CbmLitTrackParam fParamLast; // Last track parameter
166 vector<CbmLitFitNode> fFitNodes; // Array of fit nodes
167 LitTrackQa fQuality; // Track quality
168 litfloat fChi2; // Chi-square
169 Int_t fNDF; // Number of degrees of freedom
170 Int_t fPreviousTrackId; // Index of the previous track, i.e. STS
171 Int_t fLastStationId; // Last detector station where track has a hit
172 Int_t fPDG; // PDG code
173 Int_t fNofMissingHits; // Number of missing hits
174 Int_t fRefId; // Reference to MC
175 litfloat fLength; // Track length
176};
177
178#endif /*CBMLITTRACK_H_*/
Define enumerations used in littrack.
LitTrackQa
Definition CbmLitEnums.h:38
@ kLITGOOD
Definition CbmLitEnums.h:39
Data class for storage of fitted track parameters, transport matrix and chi-square on each detector s...
double litfloat
Definition CbmLitFloat.h:19
Base data class for hits.
Data class for track parameters.
Typedefs for data structures used in littrack.
Data class for storage of fitted track parameters, transport matrix and chi-square on each detector s...
Base data class for hits.
Definition CbmLitHit.h:29
Data class for track parameters.
const vector< litfloat > & GetCovMatrix() const
Base data class for track.
Definition CbmLitTrack.h:34
const vector< CbmLitFitNode > & GetFitNodes() const
Definition CbmLitTrack.h:74
void SetRefId(Int_t refId)
Definition CbmLitTrack.h:92
Int_t fNofMissingHits
Int_t fPreviousTrackId
void SetNofHits(Int_t nofHits)
Definition CbmLitTrack.h:88
string ToString() const
Return string representation of class.
void SetParamLast(const CbmLitTrackParam *par)
Definition CbmLitTrack.h:86
Int_t GetPreviousTrackId() const
Definition CbmLitTrack.h:66
void SetLength(litfloat length)
Definition CbmLitTrack.h:93
const CbmLitFitNode * GetFitNode(Int_t index) const
Definition CbmLitTrack.h:73
void SetParamFirst(const CbmLitTrackParam *par)
Definition CbmLitTrack.h:85
void SetNDF(Int_t ndf)
Definition CbmLitTrack.h:82
const CbmLitTrackParam * GetParamFirst() const
Definition CbmLitTrack.h:68
void SetNofMissingHits(Int_t nofMissingHits)
Definition CbmLitTrack.h:91
const vector< const CbmLitHit * > & GetHits() const
Definition CbmLitTrack.h:72
Int_t GetNofMissingHits() const
Definition CbmLitTrack.h:75
virtual ~CbmLitTrack()
Destructor.
Definition CbmLitTrack.h:59
void RemoveHit(Int_t index)
Remove hit and corresponding fit node.
void SortHits(Bool_t downstream=true)
Sort hits by Z position.
const CbmLitHit * GetHit(Int_t index) const
Definition CbmLitTrack.h:71
const CbmLitTrackParam * GetParamLast() const
Definition CbmLitTrack.h:69
Int_t GetPDG() const
Definition CbmLitTrack.h:67
CbmLitTrackParam fParamFirst
litfloat fLength
Int_t GetNDF() const
Definition CbmLitTrack.h:65
Int_t fLastStationId
CbmLitTrack()
Constructor.
Definition CbmLitTrack.h:39
void SetChi2(litfloat chi2)
Definition CbmLitTrack.h:81
vector< CbmLitFitNode > fFitNodes
void SetPDG(Int_t pdg)
Definition CbmLitTrack.h:84
void SetPreviousTrackId(Int_t id)
Definition CbmLitTrack.h:83
Int_t GetNofHits() const
Definition CbmLitTrack.h:62
void AddHit(const CbmLitHit *hit)
Add hit to track. No additional memory is allocated for hit.
Definition CbmLitTrack.h:98
LitTrackQa GetQuality() const
Definition CbmLitTrack.h:63
void ClearHits()
Remove all hits from track. Do not delete memory.
void SetQuality(LitTrackQa quality)
Definition CbmLitTrack.h:80
void SetFitNodes(const vector< CbmLitFitNode > &nodes)
Definition CbmLitTrack.h:90
Bool_t CheckParams() const
Return true if track parameters are correct.
litfloat GetLength() const
Definition CbmLitTrack.h:77
CbmLitTrackParam fParamLast
Int_t GetRefId() const
Definition CbmLitTrack.h:76
vector< const CbmLitHit * > fHits
void SetLastStationId(Int_t lastPlaneId)
Definition CbmLitTrack.h:89
Int_t GetLastStationId() const
Definition CbmLitTrack.h:70
LitTrackQa fQuality
litfloat fChi2
litfloat GetChi2() const
Definition CbmLitTrack.h:64