CbmRoot
CbmLitTrackParam.h
Go to the documentation of this file.
1 
8 #ifndef CBMLITTRACKPARAM_H_
9 #define CBMLITTRACKPARAM_H_
10 
11 #include "TVector3.h"
12 #include "base/CbmLitFloat.h"
13 #include <cmath>
14 #include <sstream>
15 #include <string>
16 #include <vector>
17 
18 using std::endl;
19 using std::string;
20 using std::stringstream;
21 using std::vector;
22 
30 public:
32 
33 public:
38  : fX(0.)
39  , fY(0.)
40  , fZ(0.)
41  , fTx(0.)
42  , fTy(0.)
43  , fQp(0.)
44  , fTime(0.)
45  , fCovMatrix(21, 0.) {}
46 
50  virtual ~CbmLitTrackParam() {}
51 
52  /* Getters */
53  litfloat GetX() const { return fX; }
54  litfloat GetY() const { return fY; }
55  litfloat GetZ() const { return fZ; }
56  litfloat GetTx() const { return fTx; }
57  litfloat GetTy() const { return fTy; }
58  litfloat GetQp() const { return fQp; }
59  litfloat GetTime() const { return fTime; }
60  litfloat GetCovariance(int index) const { return fCovMatrix[index]; }
61  const vector<litfloat>& GetCovMatrix() const { return fCovMatrix; }
62 
63  /* Setters */
64  void SetX(litfloat x) { fX = x; }
65  void SetY(litfloat y) { fY = y; }
66  void SetZ(litfloat z) { fZ = z; }
67  void SetTx(litfloat tx) { fTx = tx; }
68  void SetTy(litfloat ty) { fTy = ty; }
69  void SetQp(litfloat qp) { fQp = qp; }
70  void SetTime(litfloat t) { fTime = t; }
71  void SetCovMatrix(const vector<litfloat>& C) {
72  fCovMatrix.assign(C.begin(), C.end());
73  }
74  void SetCovariance(int index, litfloat cov) { fCovMatrix[index] = cov; }
75 
82  void GetDirCos(litfloat& nx, litfloat& ny, litfloat& nz) const {
83  litfloat p = (std::abs(fQp) != 0.) ? 1. / std::abs(fQp) : 1.e20;
84  litfloat pz = std::sqrt(p * p / (fTx * fTx + fTy * fTy + 1));
85  litfloat px = fTx * pz;
86  litfloat py = fTy * pz;
87  TVector3 unit = TVector3(px, py, pz).Unit();
88  nx = unit.X();
89  ny = unit.Y();
90  nz = unit.Z();
91  }
92 
97  vector<litfloat> GetStateVector() const {
98  vector<litfloat> state(6, 0.);
99  state[0] = GetX();
100  state[1] = GetY();
101  state[2] = GetTx();
102  state[3] = GetTy();
103  state[4] = GetQp();
104  state[5] = GetTime();
105  return state;
106  }
107 
112  void SetStateVector(const vector<litfloat>& x) {
113  SetX(x[0]);
114  SetY(x[1]);
115  SetTx(x[2]);
116  SetTy(x[3]);
117  SetQp(x[4]);
118  SetTime(x[5]);
119  }
120 
125  string ToString() const {
126  stringstream ss;
127  ss << "TrackParam: pos=(" << fX << "," << fY << "," << fZ << ") tx=" << fTx
128  << " ty=" << fTy << " qp=" << fQp
129  << ", fTime=" << fTime; // << std::endl;
130  // ss << "cov: ";
131  // for (Int_t i = 0; i < 15; i++) ss << fCovMatrix[i] << " ";
132  // ss << endl;
133  ss.precision(3);
134  ss << " cov: x=" << fCovMatrix[0] << " y=" << fCovMatrix[6]
135  << " tx=" << fCovMatrix[11] << " ty=" << fCovMatrix[15]
136  << " q/p=" << fCovMatrix[18] << ", time=" << fCovMatrix[20] << endl;
137  return ss.str();
138  }
139 
140 private:
141  litfloat fX, fY, fZ; // X, Y, Z coordinates in [cm]
142  litfloat fTx, fTy; // Slopes: tx=dx/dz, ty=dy/dz
143  litfloat fQp; // Q/p: Q is a charge (+/-1), p is momentum in [GeV/c]
145 
146  /* Covariance matrix.
147  * Upper triangle symmetric matrix.
148  * a[0,0..4], a[1,1..4], a[2,2..4], a[3,3..4], a[4,4] */
149  vector<litfloat> fCovMatrix;
150 };
151 
152 #endif /*CBMLITTRACKPARAM_H_*/
CbmLitTrackParam::SetTy
void SetTy(litfloat ty)
Definition: CbmLitTrackParam.h:68
litfloat
double litfloat
Definition: CbmLitFloat.h:15
CbmLitTrackParam::GetX
litfloat GetX() const
Definition: CbmLitTrackParam.h:53
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
CbmLitTrackParam::GetY
litfloat GetY() const
Definition: CbmLitTrackParam.h:54
CbmLitTrackParam::GetQp
litfloat GetQp() const
Definition: CbmLitTrackParam.h:58
CbmLitTrackParam::CbmLitTrackParam
CbmLitTrackParam()
Constructor.
Definition: CbmLitTrackParam.h:37
CbmLitTrackParam::SetZ
void SetZ(litfloat z)
Definition: CbmLitTrackParam.h:66
CbmLitTrackParam::fTime
litfloat fTime
Definition: CbmLitTrackParam.h:144
CbmLitTrackParam::GetCovariance
litfloat GetCovariance(int index) const
Definition: CbmLitTrackParam.h:60
CbmLitTrackParam::SetQp
void SetQp(litfloat qp)
Definition: CbmLitTrackParam.h:69
CbmLitTrackParam::fY
litfloat fY
Definition: CbmLitTrackParam.h:141
CbmLitTrackParam::ToString
string ToString() const
Return string representation of class.
Definition: CbmLitTrackParam.h:125
CbmLitTrackParam::GetStateVector
vector< litfloat > GetStateVector() const
Return state vector as vector.
Definition: CbmLitTrackParam.h:97
CbmLitTrackParam::SetTime
void SetTime(litfloat t)
Definition: CbmLitTrackParam.h:70
CbmLitTrackParam::GetDirCos
void GetDirCos(litfloat &nx, litfloat &ny, litfloat &nz) const
Return direction cosines.
Definition: CbmLitTrackParam.h:82
CbmLitTrackParam::fTx
litfloat fTx
Definition: CbmLitTrackParam.h:142
CbmLitTrackParam::GetZ
litfloat GetZ() const
Definition: CbmLitTrackParam.h:55
CbmLitTrackParam::SetY
void SetY(litfloat y)
Definition: CbmLitTrackParam.h:65
CbmLitFloat.h
Define floating point number type litfloat.
CbmLitTrackParam::~CbmLitTrackParam
virtual ~CbmLitTrackParam()
Destructor.
Definition: CbmLitTrackParam.h:50
CbmLitTrackParam::fZ
litfloat fZ
Definition: CbmLitTrackParam.h:141
CbmLitTrackParam::SetStateVector
void SetStateVector(const vector< litfloat > &x)
Set parameters from vector.
Definition: CbmLitTrackParam.h:112
CbmLitTrackParam::fQp
litfloat fQp
Definition: CbmLitTrackParam.h:143
CbmLitTrackParam::SetCovMatrix
void SetCovMatrix(const vector< litfloat > &C)
Definition: CbmLitTrackParam.h:71
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmLitTrackParam::GetCovMatrix
const vector< litfloat > & GetCovMatrix() const
Definition: CbmLitTrackParam.h:61
CbmLitTrackParam::GetTy
litfloat GetTy() const
Definition: CbmLitTrackParam.h:57
CbmLitTrackParam::SetX
void SetX(litfloat x)
Definition: CbmLitTrackParam.h:64
CbmLitTrackParam::fX
litfloat fX
Definition: CbmLitTrackParam.h:141
CbmLitTrackParam::fTy
litfloat fTy
Definition: CbmLitTrackParam.h:142
CbmLitTrackParam::GetTime
litfloat GetTime() const
Definition: CbmLitTrackParam.h:59
CbmLitTrackParam::SetCovariance
void SetCovariance(int index, litfloat cov)
Definition: CbmLitTrackParam.h:74
CbmLitTrackParam::GetTx
litfloat GetTx() const
Definition: CbmLitTrackParam.h:56
CbmLitTrackParam::SetTx
void SetTx(litfloat tx)
Definition: CbmLitTrackParam.h:67
CbmLitTrackParam::fSpeedOfLight
static litfloat fSpeedOfLight
Definition: CbmLitTrackParam.h:31
CbmLitTrackParam::fCovMatrix
vector< litfloat > fCovMatrix
Definition: CbmLitTrackParam.h:149