![]() |
|
|||
File indexing completed on 2025-08-03 08:20:15
0001 /* 0002 * This file is part of KFParticle package 0003 * Copyright (C) 2007-2019 FIAS Frankfurt Institute for Advanced Studies 0004 * 2007-2019 Goethe University of Frankfurt 0005 * 2007-2019 Ivan Kisel <I.Kisel@compeng.uni-frankfurt.de> 0006 * 2007-2019 Maksym Zyzak 0007 * 0008 * KFParticle is free software: you can redistribute it and/or modify 0009 * it under the terms of the GNU General Public License as published by 0010 * the Free Software Foundation, either version 3 of the License, or 0011 * (at your option) any later version. 0012 * 0013 * KFParticle is distributed in the hope that it will be useful, 0014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 * GNU General Public License for more details. 0017 * 0018 * You should have received a copy of the GNU General Public License 0019 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0020 */ 0021 0022 #ifndef KFPTrack_H 0023 #define KFPTrack_H 0024 0025 /** @class KFPTrack 0026 ** @brief A scalar class for storage of the track in the cartesian parametrisation. 0027 ** @author M.Zyzak, I.Kisel 0028 ** @date 05.02.2019 0029 ** @version 1.0 0030 ** 0031 ** A track is described with the state vector { X, Y, Z, Px, Py, Pz } 0032 ** and the corresponding covariance matrix. Also contains charge of the 0033 ** track, chi2 of the track fit, the corresponding number of degrees of freedom, 0034 ** the unique Id of the track and the field approximation along the track trajectory. 0035 **/ 0036 0037 #include <cmath> 0038 #include "TObject.h" 0039 class KFPTrack 0040 #ifdef __ROOT__ 0041 : public TObject 0042 #endif 0043 { 0044 0045 public: 0046 KFPTrack():fChi2(-1.f), fQ(0), fNDF(-1), fId(-1) { } 0047 ~KFPTrack() { } 0048 0049 int GetID() const { return fId; } ///< Returns Id of the track. 0050 0051 bool GetXYZPxPyPz(float *p) const 0052 { 0053 /** Fills an array p with the parameters of the track. 0054 ** \param[out] p - array where { X, Y, Z, Px, Py, Pz } are copied 0055 **/ 0056 for(int i=0; i<6; i++) 0057 p[i] = fP[i]; 0058 return 1; 0059 } 0060 bool GetCovarianceXYZPxPyPz(float cv[21]) const 0061 { 0062 /** Copies the covariance matrix of the track to the array of floats. 0063 ** \param[out] cv[21] - the output array, where the covariance matrix is copied 0064 **/ 0065 for (int i=0; i<21; i++) 0066 cv[i] = fC[i]; 0067 return 1; 0068 } 0069 bool GetCovarianceXYZPxPyPz(double cv[21]) const 0070 { 0071 /** Copies the covariance matrix of the track to the array of doubles. 0072 ** \param[out] cv[21] - the output array, where the covariance matrix is copied 0073 **/ 0074 for (int i=0; i<21; i++) 0075 cv[i] = fC[i]; 0076 return 1; 0077 } 0078 0079 /** Copies position of the track to the output array of floats. \param[out] position - the output array with the position of the track **/ 0080 void GetXYZ(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} 0081 /** Copies 3 momentum components of the track to the output array of floats. \param[out] position - the output array with the momentum of the track **/ 0082 void GetPxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} 0083 /** Copies position of the track to the output array of floats. \param[out] position - the output array with the position of the track **/ 0084 void XvYvZv(float *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} 0085 /** Copies 3 momentum components of the track to the output array of floats. \param[out] position - the output array with the momentum of the track **/ 0086 void PxPyPz(float *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} 0087 /** Copies position of the track to the output array of doubles. \param[out] position - the output array with the position of the track **/ 0088 void XvYvZv(double *position) const {position[0] = fP[0]; position[1] = fP[1]; position[2] = fP[2];} 0089 /** Copies 3 momentum components of the track to the output array of doubles. \param[out] position - the output array with the momentum of the track **/ 0090 void PxPyPz(double *position) const {position[0] = fP[3]; position[1] = fP[4]; position[2] = fP[5];} 0091 0092 float GetX() const { return fP[0]; } ///< Returns X coordinate of the track. 0093 float GetY() const { return fP[1]; } ///< Returns Y coordinate of the track. 0094 float GetZ() const { return fP[2]; } ///< Returns Z coordinate of the track. 0095 float GetPx() const { return fP[3]; } ///< Returns Px component of the momentum of the track. 0096 float GetPy() const { return fP[4]; } ///< Returns Py component of the momentum of the track. 0097 float GetPz() const { return fP[5]; } ///< Returns Pz component of the momentum of the track. 0098 0099 float GetPt() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]); } ///< Returns Pt - transverse momentum of the track. 0100 float GetP() const { return sqrt(fP[3]*fP[3]+fP[4]*fP[4]+fP[5]*fP[5]); } ///< Returns P - momentum of the track. 0101 0102 void GetCovarianceMatrix(float *covmatrix) 0103 { 0104 /** Copies the covariance matrix of the track to the array of floats. 0105 ** \param[out] covmatrix[21] - the output array, where the covariance matrix is copied 0106 **/ 0107 for (int i=0; i<21; i++) 0108 covmatrix[i] = fC[i]; 0109 } 0110 float GetParameter(int i) const { return fP[i]; } ///< Returns parameter "i" of the track. \param[in] i - index of the parameter to be returned 0111 float GetCovariance(int i) const { return fC[i]; } ///< Returns element of the covariance matrix "i" of the track. \param[in] i - index of the element to be returned 0112 0113 int Charge() const { return fQ; } ///< Returns charge of the track. 0114 float GetChi2perNDF() const { return fChi2/fNDF; } ///< Returns Chi2/NDF of the track, NDF is a number of degrees of freedom. 0115 float GetChi2() const { return fChi2; } ///< Returns Chi2 of the track. 0116 int GetNDF() const { return fNDF; } ///< Returns number of degrees of freedom of the track. 0117 0118 const float * GetTrack() const { return fP; } ///< Returns a pointer to the array of track parameters. 0119 const float * GetCovMatrix() const { return fC; } ///< Returns a pointer to the array of the covariance matrix elements stored in a lower triangular form. 0120 0121 void SetParameters(const float *position) 0122 { 0123 /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track from the input array of floats. 0124 ** \param[in] position - input array with the track parameters 0125 **/ 0126 for(int i=0; i<6; i++) 0127 fP[i] = position[i]; 0128 } 0129 void SetParameters(double *position) 0130 { 0131 /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track from the input array of doubles. 0132 ** \param[in] position - input array with the track parameters 0133 **/ 0134 for(int i=0; i<6; i++) 0135 fP[i] = position[i]; 0136 } 0137 void SetParameters(float x, float y, float z, float px, float py, float pz) 0138 { 0139 /** Sets parameters { X, Y, Z, Px, Py, Pz } of the track. 0140 ** \param[in] x - X coordinate to be set 0141 ** \param[in] y - Y coordinate to be set 0142 ** \param[in] z - Z coordinate to be set 0143 ** \param[in] Px - Px momentum component to be set 0144 ** \param[in] Py - Py momentum component to be set 0145 ** \param[in] Pz - Pz momentum component to be set 0146 **/ 0147 fP[0] = x; fP[1] = y; fP[2] = z; 0148 fP[3] = px; fP[4] = py; fP[5] = pz; 0149 } 0150 void SetXYZ(float x, float y, float z) 0151 { 0152 /** Sets position { X, Y, Z } of the track. 0153 ** \param[in] x - X coordinate to be set 0154 ** \param[in] y - Y coordinate to be set 0155 ** \param[in] z - Z coordinate to be set 0156 **/ 0157 fP[0] = x; fP[1] = y; fP[2] = z; 0158 } 0159 void SetPxPyPz(float px, float py, float pz) 0160 { 0161 /** Sets momentum { Px, Py, Pz } of the track. 0162 ** \param[in] Px - Px momentum component to be set 0163 ** \param[in] Py - Py momentum component to be set 0164 ** \param[in] Pz - Pz momentum component to be set 0165 **/ 0166 fP[3] = px; fP[4] = py; fP[5] = pz; 0167 } 0168 void SetID(int id) {fId = id;} ///< Sets Id of the track. 0169 0170 void SetX(float x) { fP[0] = x; } ///< Sets X coordinate of the track. 0171 void SetY(float y) { fP[1] = y; } ///< Sets Y coordinate of the track. 0172 void SetZ(float z) { fP[2] = z; } ///< Sets Z coordinate of the track. 0173 void SetPx(float px) { fP[3] = px; } ///< Sets Px component of the track momentum. 0174 void SetPy(float py) { fP[4] = py; } ///< Sets Py component of the track momentum. 0175 void SetPz(float pz) { fP[5] = pz; } ///< Sets Pz component of the track momentum. 0176 void SetCharge(int q) { fQ = q; } ///< Sets charge of the track. 0177 void SetChi2(float chi) { fChi2 = chi; } ///< Sets a value of the track Chi2. 0178 void SetNDF(int ndf) { fNDF = ndf; } ///< Sets a value of the number of degrees of freedom. 0179 0180 void SetCovarianceMatrix(const float *C) 0181 { 0182 /** Sets the covariance matrix from the input array of floats. 0183 ** \param[in] C[21] - array with the input elements of the covariance matrix stored in the lower triangular form 0184 **/ 0185 for (int i=0; i<21; i++) 0186 fC[i] = C[i]; 0187 } 0188 void SetCovarianceMatrix(const double *C) 0189 { 0190 /** Sets the covariance matrix from the input array of doubles. 0191 ** \param[in] C[21] - array with the input elements of the covariance matrix stored in the lower triangular form 0192 **/ 0193 for (int i=0; i<21; i++) 0194 fC[i] = C[i]; 0195 } 0196 0197 /** Sets an element of the covariance matrix with index "i". \param[in] c - value to be set \param[in] i - index of the element */ 0198 void SetCovariance(const int i, const float c) { fC[i]=c; } 0199 0200 void RotateXY( float alpha ); // rotate on alpha in XY plane. Should be useful for CS change 0201 0202 int Id() const { return fId; } ///< Returns Id of the track. 0203 void SetId( int id ){ fId = id; } ///< Sets Id of the track. 0204 0205 #ifdef NonhomogeneousField 0206 const float* GetFieldCoeff() const { return fieldRegion; } ///< Returns array of the coefficients for field approximation. 0207 /** Sets a field coefficient with index "i". \param[in] c - value to be set \param[in] i - index of the element */ 0208 void SetFieldCoeff(float c, int i) { fieldRegion[i] = c; } 0209 #endif 0210 private: 0211 0212 float fP[6]; ///< Parameters of the track: { X, Y, Z, Px, Py, Pz }. 0213 float fC[21]; ///< Covariance matrix of the track parameters. Stored in the lower triangular form. 0214 float fChi2; ///< Chi-square of the track fit. 0215 char fQ; ///< Charge of the track. 0216 short fNDF; ///< Number of degree of freedom of the fit. 0217 int fId; ///< Id of the track. 0218 0219 #ifdef NonhomogeneousField 0220 /** \brief Approximation of the magnetic field along the track trajectory. 0221 ** Each component (Bx, By, Bz) is approximated with the parabola depending on Z coordinate. Is defined in case of #ifdef NonhomogeneousField. 0222 **/ 0223 float fieldRegion[10]; 0224 #endif 0225 #ifdef __ROOT__ 0226 ClassDef(KFPTrack,1) 0227 #endif 0228 }; 0229 0230 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |