Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KFPTrack.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file KFPTrack.h
1 /*
2  * This file is part of KFParticle package
3  * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies
4  * 2007-2019 Goethe University of Frankfurt
5  * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de>
6  * 2007-2019 Maksym Zyzak
7  *
8  * KFParticle is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * KFParticle is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef KFPTrack_H
23 #define KFPTrack_H
24 
37 #include <cmath>
38 #include "TObject.h"
39 class KFPTrack
40 #ifdef __ROOT__
41 : public TObject
42 #endif
43 {
44 
45 public:
46  KFPTrack():fChi2(-1.f), fQ(0), fNDF(-1), fId(-1) { }
47  ~KFPTrack() { }
48 
49  int GetID() const { return fId; }
50 
51  bool GetXYZPxPyPz(float *p) const
52  {
56  for(int i=0; i<6; i++)
57  p[i] = fP[i];
58  return 1;
59  }
60  bool GetCovarianceXYZPxPyPz(float cv[21]) const
61  {
65  for (int i=0; i<21; i++)
66  cv[i] = fC[i];
67  return 1;
68  }
69  bool GetCovarianceXYZPxPyPz(double cv[21]) const
70  {
74  for (int i=0; i<21; i++)
75  cv[i] = fC[i];
76  return 1;
77  }
78 
80  void GetXYZ(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];}
82  void GetPxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];}
84  void XvYvZv(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];}
86  void PxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];}
88  void XvYvZv(double *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];}
90  void PxPyPz(double *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];}
91 
92  float GetX() const { return fP[0]; }
93  float GetY() const { return fP[1]; }
94  float GetZ() const { return fP[2]; }
95  float GetPx() const { return fP[3]; }
96  float GetPy() const { return fP[4]; }
97  float GetPz() const { return fP[5]; }
98 
99  float GetPt() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]); }
100  float GetP() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]+fP[5]*fP[5]); }
101 
102  void GetCovarianceMatrix(float *covmatrix)
103  {
107  for (int i=0; i<21; i++)
108  covmatrix[i] = fC[i];
109  }
110  float GetParameter(int i) const { return fP[i]; }
111  float GetCovariance(int i) const { return fC[i]; }
112 
113  int Charge() const { return fQ; }
114  float GetChi2perNDF() const { return fChi2/fNDF; }
115  float GetChi2() const { return fChi2; }
116  int GetNDF() const { return fNDF; }
117 
118  const float * GetTrack() const { return fP; }
119  const float * GetCovMatrix() const { return fC; }
120 
121  void SetParameters(const float *position)
122  {
126  for(int i=0; i<6; i++)
127  fP[i] = position[i];
128  }
129  void SetParameters(double *position)
130  {
134  for(int i=0; i<6; i++)
135  fP[i] = position[i];
136  }
137  void SetParameters(float x, float y, float z, float px, float py, float pz)
138  {
147  fP[0] = x; fP[1] = y; fP[2] = z;
148  fP[3] = px; fP[4] = py; fP[5] = pz;
149  }
150  void SetXYZ(float x, float y, float z)
151  {
157  fP[0] = x; fP[1] = y; fP[2] = z;
158  }
159  void SetPxPyPz(float px, float py, float pz)
160  {
166  fP[3] = px; fP[4] = py; fP[5] = pz;
167  }
168  void SetID(int id) {fId = id;}
169 
170  void SetX(float x) { fP[0] = x; }
171  void SetY(float y) { fP[1] = y; }
172  void SetZ(float z) { fP[2] = z; }
173  void SetPx(float px) { fP[3] = px; }
174  void SetPy(float py) { fP[4] = py; }
175  void SetPz(float pz) { fP[5] = pz; }
176  void SetCharge(int q) { fQ = q; }
177  void SetChi2(float chi) { fChi2 = chi; }
178  void SetNDF(int ndf) { fNDF = ndf; }
179 
180  void SetCovarianceMatrix(const float *C)
181  {
185  for (int i=0; i<21; i++)
186  fC[i] = C[i];
187  }
188  void SetCovarianceMatrix(const double *C)
189  {
193  for (int i=0; i<21; i++)
194  fC[i] = C[i];
195  }
196 
198  void SetCovariance(const int i, const float c) { fC[i]=c; }
199 
200  void RotateXY( float alpha ); // rotate on alpha in XY plane. Should be useful for CS change
201 
202  int Id() const { return fId; }
203  void SetId( int id ){ fId = id; }
204 
205 #ifdef NonhomogeneousField
206  const float* GetFieldCoeff() const { return fieldRegion; }
207 
208  void SetFieldCoeff(float c, int i) { fieldRegion[i] = c; }
209 #endif
210  private:
211 
212  float fP[6];
213  float fC[21];
214  float fChi2;
215  char fQ;
216  short fNDF;
217  int fId;
218 
219 #ifdef NonhomogeneousField
220 
223  float fieldRegion[10];
224 #endif
225 #ifdef __ROOT__
226  ClassDef(KFPTrack,1)
227 #endif
228 };
229 
230 #endif