CbmRoot
Loading...
Searching...
No Matches
CbmTofTrackletParam.h
Go to the documentation of this file.
1/* Copyright (C) 2015-2021 PI-UHd, GSI
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Norbert Herrmann [committer], Florian Uhlig */
4
12#ifndef CBMTOFTRACKLETPARAM_H_
13#define CBMTOFTRACKLETPARAM_H_
14
15#include <Rtypes.h> // for ClassDef
16#include <TObject.h> // for TObject
17#include <TVector3.h> // for TVector3
18
19#include <cstdint>
20#include <sstream> // for operator<<, basic_ostream, stringstream, cha...
21#include <vector> // for vector
22
23#include <cmath> // for abs, sqrt
24
32class CbmTofTrackletParam : public TObject {
33public:
38 : fX(0.)
39 , fY(0.)
40 , fZ(0.)
41 , fT(0.)
42 , fTx(0.)
43 , fTy(0.)
44 , fTt(0.)
45 , fQp(0.)
46 , fLz(0.)
47 , fChiSq(0.)
48 , fCovMatrix(15, 0.)
49 {
50 }
51
56
57 /* Getters */
58 double GetX() const { return fX; }
59 double GetY() const { return fY; }
60 double GetZ() const { return fZ; }
61 double GetT() const { return fT; }
62 double GetLz() const { return fLz; }
63 double GetTx() const { return fTx; }
64 double GetTy() const { return fTy; }
65 double GetTt() const { return fTt; }
66 double GetQp() const { return fQp; }
67 double GetChiSq() const { return fChiSq; }
68 double GetCovariance(int index) const { return fCovMatrix[index]; }
69 const std::vector<double>& GetCovMatrix() const { return fCovMatrix; }
70
71 /* Setters */
72 void SetX(double x) { fX = x; }
73 void SetY(double y) { fY = y; }
74 void SetZ(double z) { fZ = z; }
75 void SetT(double t) { fT = t; }
76 void SetLz(double lz) { fLz = lz; }
77 void SetTx(double tx) { fTx = tx; }
78 void SetTy(double ty) { fTy = ty; }
79 void SetTt(double tt) { fTt = tt; }
80 void SetQp(double qp) { fQp = qp; }
81 void SetChiSq(double v) { fChiSq = v; }
82 void SetCovMatrix(const std::vector<double>& C) { fCovMatrix.assign(C.begin(), C.end()); }
83 void SetCovariance(int index, double cov) { fCovMatrix[index] = cov; }
84
91 void GetDirCos(double& nx, double& ny, double& nz) const
92 {
93 double p = (std::abs(fQp) != 0.) ? 1. / std::abs(fQp) : 1.e20;
94 double pz = std::sqrt(p * p / (fTx * fTx + fTy * fTy + 1));
95 double px = fTx * pz;
96 double py = fTy * pz;
97 TVector3 unit = TVector3(px, py, pz).Unit();
98 nx = unit.X();
99 ny = unit.Y();
100 nz = unit.Z();
101 }
102
107 std::vector<double> GetStateVector() const
108 {
109 std::vector<double> state(5, 0.);
110 state[0] = GetX();
111 state[1] = GetY();
112 state[2] = GetTx();
113 state[3] = GetTy();
114 state[4] = GetQp();
115 return state;
116 }
117
122 void SetStateVector(const std::vector<double>& x)
123 {
124 SetX(x[0]);
125 SetY(x[1]);
126 SetTx(x[2]);
127 SetTy(x[3]);
128 SetQp(x[4]);
129 }
130
135 std::string ToString() const
136 {
137 std::stringstream ss;
138 ss << "TofTrackletParam: pos=(" << fX << "," << fY << "," << fZ << ") tx=" << fTx << " ty=" << fTy
139 << " qp=" << fQp; // << std::endl;
140 // ss << "cov: ";
141 // for (int32_t i = 0; i < 15; i++) ss << fCovMatrix[i] << " ";
142 // ss << endl;
143 ss.precision(3);
144 ss << " cov: x=" << fCovMatrix[0] << " y=" << fCovMatrix[5] << " tx=" << fCovMatrix[9] << " ty=" << fCovMatrix[12]
145 << " q/p=" << fCovMatrix[14];
146 return ss.str();
147 }
148
149 double GetZr(double R) const;
150
151 double GetZy(double Y) const
152 {
153 if (fTy != 0.) { return (Y - fY) / fTy + fZ; }
154 return 0.;
155 }
156
157
158private:
159 double fX, fY, fZ, fT; // X, Y, Z coordinates in [cm]
160 double fTx, fTy, fTt; // Slopes: tx=dx/dz, ty=dy/dz
161 double fQp; // Q/p: Q is a charge (+/-1), p is momentum in [GeV/c]
162 double fLz; // tracklength in z - direction
163 double fChiSq;
164 /* Covariance matrix.
165 * Upper triangle symmetric matrix.
166 * a[0,0..4], a[1,1..4], a[2,2..4], a[3,3..4], a[4,4] */
167 std::vector<double> fCovMatrix;
168
170};
171
172#endif /*CBMTOFTRACKLETPARAM_H_*/
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
void SetCovMatrix(const std::vector< double > &C)
std::vector< double > fCovMatrix
void GetDirCos(double &nx, double &ny, double &nz) const
Return direction cosines.
double GetZy(double Y) const
void SetStateVector(const std::vector< double > &x)
Set parameters from vector.
CbmTofTrackletParam()
Constructor.
const std::vector< double > & GetCovMatrix() const
double GetCovariance(int index) const
std::vector< double > GetStateVector() const
Return state vector as vector.
ClassDef(CbmTofTrackletParam, 1)
void SetCovariance(int index, double cov)
std::string ToString() const
Return string representation of class.
virtual ~CbmTofTrackletParam()
Destructor.
double GetZr(double R) const