MpdKalmanTrack.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #ifndef MPDKALMANTRACK_H
  2. #define MPDKALMANTRACK_H
  3. /// \ingroup rec
  4. /// \class MpdKalmanTrack
  5. /// \brief Kalman track in MPD
  6. ///
  7. /// \author Alexander Zinchenko, LHEP JINR Dubna
  8. #include <TMath.h>
  9. #include <TMatrixD.h>
  10. #include <TMatrixDSym.h>
  11. #include <TObjArray.h>
  12. #include <TString.h>
  13. #include <TVector3.h>
  14. #include <map>
  15. class MpdKalmanTrack : public TObject
  16. {
  17. public:
  18. enum TrackDir {kInward, kOutward};
  19. enum TrackType {kBarrel, kEndcap};
  20. enum TrackFlag {kOk, kNoOut};
  21. public:
  22. MpdKalmanTrack(); ///< Default ctor
  23. MpdKalmanTrack(Double_t pos, TVector3 &vertex); ///< Ctor from position and vertex
  24. virtual ~MpdKalmanTrack(); ///< Destructor
  25. MpdKalmanTrack (const MpdKalmanTrack& track); ///< copy constructor
  26. MpdKalmanTrack& operator=(const MpdKalmanTrack& track); ///< assignment operator
  27. Int_t GetTrackID() const { return fID; } ///< get track ID
  28. TrackDir GetDirection() const { return fTrackDir; } ///< Get track direction
  29. TrackType GetType() const { return fTrackType; } ///< Get track type
  30. TrackFlag GetFlag() const { return fFlag; } ///< Get track flag
  31. Int_t GetLastLay() const { return fLastLay; } ///< get the outermost layer
  32. Int_t GetNofWrong() const { return fNofWrong; } ///< number of wrong hits
  33. TString GetNode() const { return fNode; } ///< node path
  34. TString GetNodeNew() const { return fNodeNew; } ///< node path
  35. Double_t GetPartID() const { return fPartID; } ///< get particle ID
  36. Double_t GetDedx(Double_t coef = 6.036e-3) const { return fPartID * coef; } ///< get particle ID (De/dx converted from ADC counts to keV)
  37. Double_t GetPos() const { return fPos; } ///< Get current position
  38. Double_t GetPosNew() const { return fPosNew; } ///< Get propagated position
  39. Double_t GetPosAtHit() const { return fPosAtHit; } ///< Get position of outermost hit
  40. Double_t GetZ() const { return fTrackType == kEndcap ? fPos : GetParam(1); } ///< Z-position
  41. Double_t GetChi2() const { return fChi2; } ///< Get track Chi2
  42. Double_t GetChi2Vertex() const { return fChi2Vertex; } ///< Get Chi2 to vertex
  43. Double_t GetLength() const { return fLength; } ///< Get track length
  44. Double_t GetLengAtHit() const { return fLengAtHit; } ///< Get track length at last hit
  45. TMatrixD* GetParam() const { return fParam; } ///< get param. matrix
  46. TMatrixD* GetParamNew() const { return fParamNew; } ///< get new param. matrix
  47. TMatrixD* GetParamAtHit() const { return fParamAtHit; } ///< get param. matrix at last hit
  48. Double_t GetParam(Int_t i) const { return (*fParam)(i,0); } ///< get param. value
  49. Double_t GetParamNew(Int_t i) const { return (*fParamNew)(i,0); } ///< get new param. value
  50. TMatrixDSym* GetCovariance() const { return fCovar; } ///< Get covariance matrix
  51. TMatrixDSym* Weight2Cov(); ///< Get covariance matrix from weight matrix
  52. TMatrixDSym* GetWeight() const { return fWeight; } ///< Get weight matrix
  53. TMatrixDSym* GetWeightAtHit() const { return fWeightAtHit; } ///< Get weight matrix at last hit
  54. Int_t GetNofHits() const { return fHits ? fHits->GetEntriesFast() : fNhits; } ///< Get number of track hits
  55. TObjArray* GetHits() const { return fHits; } ///< Get track hits container
  56. TVector3& GetVertex() { return fVertex; } ///< AZ
  57. void SetTrackID(Int_t id) { fID = id; } ///< set track ID
  58. void SetNofHits(Int_t nHits) { fNhits = nHits; } ///< Set number of track hits
  59. void SetDirection(TrackDir dir) { fTrackDir = dir; } ///< set track direction
  60. void SetType(TrackType type) { fTrackType = type; } ///< set track type
  61. void SetFlag(TrackFlag flag) { fFlag = flag; } ///< set track flag
  62. void SetLastLay(Int_t lay) { fLastLay = lay; } ///< set last layer
  63. void SetNofWrong(Int_t nWrong) { fNofWrong = nWrong; } ///< set number of wrong hits
  64. void SetNode(TString node) { fNode = node; } ///< set node path
  65. void SetNodeNew(TString node) { fNodeNew = node; } ///< set node path
  66. void SetPartID(Double_t id) { fPartID = id; } ///< set particle ID
  67. void SetPos(Double_t pos) { fPos = pos; } ///< set position
  68. void SetPosNew(Double_t posNew) { fPosNew = posNew; } ///< set propagated position
  69. void SetPosAtHit(Double_t posHit) { fPosAtHit = posHit; } ///< set position of outermost hit
  70. void SetChi2(Double_t chi2) { fChi2 = chi2; } ///< set chi2
  71. void SetChi2Vertex(Double_t chi2) { fChi2Vertex = chi2; } ///< set chi2 to vertex
  72. void SetLength(Double_t length) { fLength = length; } ///< set length
  73. void SetLengAtHit(Double_t length) { fLengAtHit = length; } ///< set length at last hit
  74. void UpdateLength(Double_t length) { fLength += length; } ///< update length
  75. void SetParam(TMatrixD &param) { *fParam = param; } ///< set param. matrix
  76. void SetParamNew(TMatrixD &param) { *fParamNew = param; } ///< set new param. matrix
  77. void SetParamAtHit(TMatrixD &param) { *fParamAtHit = param; } ///< set param. matrix at last hit
  78. void SetParam(Int_t i, Double_t val) { (*fParam)(i,0) = val; } ///< set param. value
  79. void SetCovariance(TMatrixDSym &cov) { *fCovar = cov; } ///< set covar. matrix
  80. void SetWeight(TMatrixD &weight) { fWeight->SetMatrixArray(weight.GetMatrixArray()); } ///< set weight matrix
  81. void SetWeight(TMatrixDSym &weight) { *fWeight = weight; } ///< set weight matrix
  82. void SetWeightAtHit(TMatrixDSym &weight) { *fWeightAtHit = weight; } ///< set weight matrix at last hit
  83. void ReSetWeight(); ///< set weight from covariance
  84. virtual void StartBack() {}; ///< prepare for back tracing
  85. virtual void Clear(); ///< reset track (similar to destructor)
  86. void PrintNode(Bool_t nNew = kFALSE) const; ///< printout node name
  87. std::map<Int_t,Double_t>& GetSteps() { return fStepMap; } ///< steps between points
  88. // Getters of "physics" track parameters
  89. Double_t Pt() const { return TMath::Abs(GetParam(4)) > 0.01 ? 1. / TMath::Abs(GetParam(4)) : 100. ; }
  90. Double_t Phi() const { return GetParam(2); }
  91. Double_t Theta() const { return TMath::PiOver2() - GetParam(3); }
  92. Double_t Momentum() const { return TMath::Abs(Pt() / TMath::Cos(GetParam(3))); }
  93. Int_t Charge() const { return TMath::Nint(TMath::Sign(1., -GetParam(4))); }
  94. TVector3 Momentum3() const { return TVector3(Pt()*TMath::Cos(Phi()), Pt()*TMath::Sin(Phi()), Momentum()*TMath::Cos(Theta())); }
  95. Double_t DCA() const; ///< signed DCA
  96. //Bool_t IsSortable() const { return kTRUE; }
  97. //Int_t Compare(const TObject* track) const; ///< sort in descending order in Pt
  98. //private:
  99. protected:
  100. Int_t fID; ///< trackID
  101. Int_t fNhits; ///< number of hits (just for convenience of tree browsing)
  102. TrackDir fTrackDir; ///< track direction (inward/outward)
  103. TrackType fTrackType; ///< track type (kBarrel/kEndcap)
  104. Int_t fLastLay; ///< the outermost layer number achieved
  105. Int_t fNofWrong; ///< number of wrong hits (different from the track ID)
  106. TString fNode; ///< node path (for local track parameters)
  107. TString fNodeNew; ///< node path (for local track parameters)
  108. Double32_t fPartID; ///< particle ID
  109. Double32_t fPos; ///< current track radial position
  110. Double32_t fPosNew; ///< propagated track radial position
  111. Double32_t fPosAtHit; ///< radial position of outermost hit
  112. Double32_t fChi2; ///< track Chi2
  113. Double32_t fChi2Vertex; ///< track Chi2-distance to primary vertex
  114. Double32_t fLength; ///< track length
  115. Double32_t fLengAtHit; ///< track length at last hit
  116. TMatrixD *fParam; ///< pointer to track parameter matrix
  117. TMatrixD *fParamNew; ///<! pointer to track parameter matrix after propagation
  118. TMatrixD *fParamAtHit; ///< pointer to track parameter matrix at last hit
  119. TMatrixDSym *fCovar; ///< pointer to covariance matrix
  120. TMatrixDSym *fWeight; ///<! pointer to weight matrix
  121. TMatrixDSym *fWeightAtHit; ///< pointer to weight matrix at last hit
  122. TVector3 fVertex; ///< track vertex
  123. TObjArray *fHits; ///<! array of hit pointers assigned to the track
  124. std::map<Int_t,Double_t> fStepMap; ///<! steps between points on track
  125. TrackFlag fFlag; ///< track flag
  126. ClassDef(MpdKalmanTrack,5);
  127. };
  128. #endif