CbmRoot
Loading...
Searching...
No Matches
CbmLitTrackParam.h
Go to the documentation of this file.
1/* Copyright (C) 2008-2017 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Timur Ablyazimov */
4
12#ifndef CBMLITTRACKPARAM_H_
13#define CBMLITTRACKPARAM_H_
14
15#include "TVector3.h"
16#include "base/CbmLitFloat.h"
17
18#include <cmath>
19#include <sstream>
20#include <string>
21#include <vector>
22
23using std::endl;
24using std::string;
25using std::stringstream;
26using std::vector;
27
35 public:
37
38 public:
42 CbmLitTrackParam() : fX(0.), fY(0.), fZ(0.), fTx(0.), fTy(0.), fQp(0.), fTime(0.), fCovMatrix(21, 0.) {}
43
47 virtual ~CbmLitTrackParam() {}
48
49 /* Getters */
50 litfloat GetX() const { return fX; }
51 litfloat GetY() const { return fY; }
52 litfloat GetZ() const { return fZ; }
53 litfloat GetTx() const { return fTx; }
54 litfloat GetTy() const { return fTy; }
55 litfloat GetQp() const { return fQp; }
56 litfloat GetTime() const { return fTime; }
57 litfloat GetCovariance(int index) const { return fCovMatrix[index]; }
58 const vector<litfloat>& GetCovMatrix() const { return fCovMatrix; }
59
60 /* Setters */
61 void SetX(litfloat x) { fX = x; }
62 void SetY(litfloat y) { fY = y; }
63 void SetZ(litfloat z) { fZ = z; }
64 void SetTx(litfloat tx) { fTx = tx; }
65 void SetTy(litfloat ty) { fTy = ty; }
66 void SetQp(litfloat qp) { fQp = qp; }
67 void SetTime(litfloat t) { fTime = t; }
68 void SetCovMatrix(const vector<litfloat>& C) { fCovMatrix.assign(C.begin(), C.end()); }
69 void SetCovariance(int index, litfloat cov) { fCovMatrix[index] = cov; }
70
77 void GetDirCos(litfloat& nx, litfloat& ny, litfloat& nz) const
78 {
79 litfloat p = (std::abs(fQp) != 0.) ? 1. / std::abs(fQp) : 1.e20;
80 litfloat pz = std::sqrt(p * p / (fTx * fTx + fTy * fTy + 1));
81 litfloat px = fTx * pz;
82 litfloat py = fTy * pz;
83 TVector3 unit = TVector3(px, py, pz).Unit();
84 nx = unit.X();
85 ny = unit.Y();
86 nz = unit.Z();
87 }
88
93 vector<litfloat> GetStateVector() const
94 {
95 vector<litfloat> state(6, 0.);
96 state[0] = GetX();
97 state[1] = GetY();
98 state[2] = GetTx();
99 state[3] = GetTy();
100 state[4] = GetQp();
101 state[5] = GetTime();
102 return state;
103 }
104
109 void SetStateVector(const vector<litfloat>& x)
110 {
111 SetX(x[0]);
112 SetY(x[1]);
113 SetTx(x[2]);
114 SetTy(x[3]);
115 SetQp(x[4]);
116 SetTime(x[5]);
117 }
118
123 string ToString() const
124 {
125 stringstream ss;
126 ss << "TrackParam: pos=(" << fX << "," << fY << "," << fZ << ") tx=" << fTx << " ty=" << fTy << " qp=" << fQp
127 << ", fTime=" << fTime; // << std::endl;
128 // ss << "cov: ";
129 // for (Int_t i = 0; i < 15; i++) ss << fCovMatrix[i] << " ";
130 // ss << endl;
131 ss.precision(3);
132 ss << " cov: x=" << fCovMatrix[0] << " y=" << fCovMatrix[6] << " tx=" << fCovMatrix[11] << " ty=" << fCovMatrix[15]
133 << " q/p=" << fCovMatrix[18] << ", time=" << fCovMatrix[20] << endl;
134 return ss.str();
135 }
136
137 private:
138 litfloat fX, fY, fZ; // X, Y, Z coordinates in [cm]
139 litfloat fTx, fTy; // Slopes: tx=dx/dz, ty=dy/dz
140 litfloat fQp; // Q/p: Q is a charge (+/-1), p is momentum in [GeV/c]
142
143 /* Covariance matrix.
144 * Upper triangle symmetric matrix.
145 * a[0,0..4], a[1,1..4], a[2,2..4], a[3,3..4], a[4,4] */
146 vector<litfloat> fCovMatrix;
147};
148
149#endif /*CBMLITTRACKPARAM_H_*/
Define floating point number type litfloat.
double litfloat
Definition CbmLitFloat.h:19
Data class for track parameters.
litfloat GetZ() const
void GetDirCos(litfloat &nx, litfloat &ny, litfloat &nz) const
Return direction cosines.
litfloat GetTx() const
void SetX(litfloat x)
void SetQp(litfloat qp)
void SetTx(litfloat tx)
string ToString() const
Return string representation of class.
virtual ~CbmLitTrackParam()
Destructor.
void SetStateVector(const vector< litfloat > &x)
Set parameters from vector.
static litfloat fSpeedOfLight
litfloat GetX() const
void SetY(litfloat y)
litfloat GetY() const
void SetTy(litfloat ty)
void SetCovariance(int index, litfloat cov)
litfloat GetTy() const
vector< litfloat > GetStateVector() const
Return state vector as vector.
void SetZ(litfloat z)
CbmLitTrackParam()
Constructor.
void SetTime(litfloat t)
litfloat GetTime() const
const vector< litfloat > & GetCovMatrix() const
void SetCovMatrix(const vector< litfloat > &C)
vector< litfloat > fCovMatrix
litfloat GetCovariance(int index) const
litfloat GetQp() const