CbmRoot
CbmTofTrackletParam.h
Go to the documentation of this file.
1 
8 #ifndef CBMTOFTRACKLETPARAM_H_
9 #define CBMTOFTRACKLETPARAM_H_
10 
11 #include <Rtypes.h> // for ClassDef
12 #include <RtypesCore.h> // for Double_t
13 #include <TObject.h> // for TObject
14 #include <TVector3.h> // for TVector3
15 
16 #include <math.h> // for abs, sqrt
17 #include <sstream> // for operator<<, basic_ostream, stringstream, cha...
18 #include <vector> // for vector
19 
27 class CbmTofTrackletParam : public TObject {
28 public:
33  : fX(0.)
34  , fY(0.)
35  , fZ(0.)
36  , fTx(0.)
37  , fTy(0.)
38  , fQp(0.)
39  , fLz(0.)
40  , fCovMatrix(15, 0.) {}
41 
45  virtual ~CbmTofTrackletParam() {}
46 
47  /* Getters */
48  Double_t GetX() const { return fX; }
49  Double_t GetY() const { return fY; }
50  Double_t GetZ() const { return fZ; }
51  Double_t GetLz() const { return fLz; }
52  Double_t GetTx() const { return fTx; }
53  Double_t GetTy() const { return fTy; }
54  Double_t GetQp() const { return fQp; }
55  Double_t GetCovariance(int index) const { return fCovMatrix[index]; }
56  const std::vector<Double_t>& GetCovMatrix() const { return fCovMatrix; }
57 
58  /* Setters */
59  void SetX(Double_t x) { fX = x; }
60  void SetY(Double_t y) { fY = y; }
61  void SetZ(Double_t z) { fZ = z; }
62  void SetLz(Double_t lz) { fLz = lz; }
63  void SetTx(Double_t tx) { fTx = tx; }
64  void SetTy(Double_t ty) { fTy = ty; }
65  void SetQp(Double_t qp) { fQp = qp; }
66  void SetCovMatrix(const std::vector<Double_t>& C) {
67  fCovMatrix.assign(C.begin(), C.end());
68  }
69  void SetCovariance(int index, Double_t cov) { fCovMatrix[index] = cov; }
70 
77  void GetDirCos(Double_t& nx, Double_t& ny, Double_t& nz) const {
78  Double_t p = (std::abs(fQp) != 0.) ? 1. / std::abs(fQp) : 1.e20;
79  Double_t pz = std::sqrt(p * p / (fTx * fTx + fTy * fTy + 1));
80  Double_t px = fTx * pz;
81  Double_t py = fTy * pz;
82  TVector3 unit = TVector3(px, py, pz).Unit();
83  nx = unit.X();
84  ny = unit.Y();
85  nz = unit.Z();
86  }
87 
92  std::vector<Double_t> GetStateVector() const {
93  std::vector<Double_t> state(5, 0.);
94  state[0] = GetX();
95  state[1] = GetY();
96  state[2] = GetTx();
97  state[3] = GetTy();
98  state[4] = GetQp();
99  return state;
100  }
101 
106  void SetStateVector(const std::vector<Double_t>& x) {
107  SetX(x[0]);
108  SetY(x[1]);
109  SetTx(x[2]);
110  SetTy(x[3]);
111  SetQp(x[4]);
112  }
113 
118  std::string ToString() const {
119  std::stringstream ss;
120  ss << "TrackletParam: pos=(" << fX << "," << fY << "," << fZ
121  << ") tx=" << fTx << " ty=" << fTy << " qp=" << fQp; // << std::endl;
122  // ss << "cov: ";
123  // for (Int_t i = 0; i < 15; i++) ss << fCovMatrix[i] << " ";
124  // ss << endl;
125  ss.precision(3);
126  ss << " cov: x=" << fCovMatrix[0] << " y=" << fCovMatrix[5]
127  << " tx=" << fCovMatrix[9] << " ty=" << fCovMatrix[12]
128  << " q/p=" << fCovMatrix[14];
129  return ss.str();
130  }
131 
132  Double_t GetZr(Double_t R) const;
133 
134  Double_t GetZy(Double_t Y) const {
135  if (fTy != 0.) { return (Y - fY) / fTy + fZ; }
136  return 0.;
137  }
138 
139 
140 private:
141  Double_t fX, fY, fZ; // X, Y, Z coordinates in [cm]
142  Double_t fTx, fTy; // Slopes: tx=dx/dz, ty=dy/dz
143  Double_t fQp; // Q/p: Q is a charge (+/-1), p is momentum in [GeV/c]
144  Double_t fLz; // tracklength in z - direction
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  std::vector<Double_t> fCovMatrix;
150 
152 };
153 
154 #endif /*CBMTOFTRACKLETPARAM_H_*/
CbmTofTrackletParam::SetQp
void SetQp(Double_t qp)
Definition: CbmTofTrackletParam.h:65
CbmTofTrackletParam::SetLz
void SetLz(Double_t lz)
Definition: CbmTofTrackletParam.h:62
CbmTofTrackletParam::GetStateVector
std::vector< Double_t > GetStateVector() const
Return state vector as vector.
Definition: CbmTofTrackletParam.h:92
CbmTofTrackletParam::SetTy
void SetTy(Double_t ty)
Definition: CbmTofTrackletParam.h:64
CbmTofTrackletParam::GetTy
Double_t GetTy() const
Definition: CbmTofTrackletParam.h:53
CbmTofTrackletParam::GetTx
Double_t GetTx() const
Definition: CbmTofTrackletParam.h:52
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmTofTrackletParam::SetCovMatrix
void SetCovMatrix(const std::vector< Double_t > &C)
Definition: CbmTofTrackletParam.h:66
CbmTofTrackletParam::fCovMatrix
std::vector< Double_t > fCovMatrix
Definition: CbmTofTrackletParam.h:149
CbmTofTrackletParam
Definition: CbmTofTrackletParam.h:27
CbmTofTrackletParam::fTx
Double_t fTx
Definition: CbmTofTrackletParam.h:142
CbmTofTrackletParam::SetCovariance
void SetCovariance(int index, Double_t cov)
Definition: CbmTofTrackletParam.h:69
CbmTofTrackletParam::SetY
void SetY(Double_t y)
Definition: CbmTofTrackletParam.h:60
CbmTofTrackletParam::~CbmTofTrackletParam
virtual ~CbmTofTrackletParam()
Destructor.
Definition: CbmTofTrackletParam.h:45
CbmTofTrackletParam::ToString
std::string ToString() const
Return string representation of class.
Definition: CbmTofTrackletParam.h:118
CbmTofTrackletParam::GetDirCos
void GetDirCos(Double_t &nx, Double_t &ny, Double_t &nz) const
Return direction cosines.
Definition: CbmTofTrackletParam.h:77
CbmTofTrackletParam::GetX
Double_t GetX() const
Definition: CbmTofTrackletParam.h:48
CbmTofTrackletParam::fX
Double_t fX
Definition: CbmTofTrackletParam.h:141
CbmTofTrackletParam::GetZr
Double_t GetZr(Double_t R) const
Definition: CbmTofTrackletParam.cxx:10
CbmTofTrackletParam::SetTx
void SetTx(Double_t tx)
Definition: CbmTofTrackletParam.h:63
CbmTofTrackletParam::fLz
Double_t fLz
Definition: CbmTofTrackletParam.h:144
CbmTofTrackletParam::fQp
Double_t fQp
Definition: CbmTofTrackletParam.h:143
CbmTofTrackletParam::GetZ
Double_t GetZ() const
Definition: CbmTofTrackletParam.h:50
CbmTofTrackletParam::GetLz
Double_t GetLz() const
Definition: CbmTofTrackletParam.h:51
CbmTofTrackletParam::SetStateVector
void SetStateVector(const std::vector< Double_t > &x)
Set parameters from vector.
Definition: CbmTofTrackletParam.h:106
CbmTofTrackletParam::GetQp
Double_t GetQp() const
Definition: CbmTofTrackletParam.h:54
CbmTofTrackletParam::SetX
void SetX(Double_t x)
Definition: CbmTofTrackletParam.h:59
CbmTofTrackletParam::fY
Double_t fY
Definition: CbmTofTrackletParam.h:141
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTofTrackletParam::GetCovariance
Double_t GetCovariance(int index) const
Definition: CbmTofTrackletParam.h:55
CbmTofTrackletParam::GetY
Double_t GetY() const
Definition: CbmTofTrackletParam.h:49
CbmTofTrackletParam::SetZ
void SetZ(Double_t z)
Definition: CbmTofTrackletParam.h:61
CbmTofTrackletParam::GetCovMatrix
const std::vector< Double_t > & GetCovMatrix() const
Definition: CbmTofTrackletParam.h:56
CbmTofTrackletParam::fTy
Double_t fTy
Definition: CbmTofTrackletParam.h:142
CbmTofTrackletParam::GetZy
Double_t GetZy(Double_t Y) const
Definition: CbmTofTrackletParam.h:134
CbmTofTrackletParam::fZ
Double_t fZ
Definition: CbmTofTrackletParam.h:141
CbmTofTrackletParam::ClassDef
ClassDef(CbmTofTrackletParam, 1)
CbmTofTrackletParam::CbmTofTrackletParam
CbmTofTrackletParam()
Constructor.
Definition: CbmTofTrackletParam.h:32