CbmSttTrack.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // -------------------------------------------------------------------------
  2. // ----- CbmSttTrack source file -----
  3. // ----- Created 28/03/06 by R. Castelijns -----
  4. // -------------------------------------------------------------------------
  5. #include <iostream>
  6. #include "CbmSttHit.h"
  7. #include "CbmSttTrack.h"
  8. // ----- Default constructor -------------------------------------------
  9. CbmSttTrack::CbmSttTrack()
  10. {
  11. fRefAngle = 0.;
  12. fPidHypo = 0;
  13. fFlag = 0;
  14. fChi2Long = 0.;
  15. fChi2Rad = 0.;
  16. }
  17. // -------------------------------------------------------------------------
  18. // ----- Destructor ----------------------------------------------------
  19. CbmSttTrack::~CbmSttTrack()
  20. {
  21. fHitMap.clear();
  22. }
  23. // -------------------------------------------------------------------------
  24. // ----- Public method AddHit --------------------------------------
  25. void CbmSttTrack::AddHit(Int_t hitID, CbmSttHit* mHit)
  26. {
  27. Double_t
  28. wireX = mHit->GetX(),
  29. wireY = mHit->GetY(),
  30. wireZ = mHit->GetZ();
  31. // fHitMap[wireZ] = hitID;
  32. fHitMap[wireX * wireX + wireY * wireY] = hitID;
  33. }
  34. // -------------------------------------------------------------------------
  35. // ----- Public method Print -------------------------------------------
  36. void CbmSttTrack::Print()
  37. {
  38. cout << " Number of attached hits : "
  39. << fHits.GetSize() << endl;
  40. cout << " Parameters at first point: " << endl;
  41. fParamFirst.Print();
  42. cout << " Chi2Long: " << fChi2Long << ", Chi2Rad: " << fChi2Rad << ", Quality flag " << fFlag << endl;
  43. }
  44. // -------------------------------------------------------------------------
  45. void CbmSttTrack::SortHits()
  46. {
  47. // find the biggest z difference between hits
  48. // get the hit closest to the target
  49. Int_t
  50. index=0;
  51. map<Double_t, Int_t>::iterator
  52. it;
  53. fHits.Reset();
  54. fHits.Set(fHitMap.size());
  55. index = 0;
  56. for (it = fHitMap.begin(); it != fHitMap.end(); ++it)
  57. {
  58. fHits[index] = it->second;
  59. index++;
  60. }
  61. }
  62. // -------------------------------------------------------------------------
  63. Bool_t CbmSttTrack::AlreadyHasHit(Int_t iHit)
  64. {
  65. Bool_t
  66. retval = kFALSE;
  67. map<Double_t, Int_t>::iterator
  68. it;
  69. for (it = fHitMap.begin(); it != fHitMap.end(); ++it)
  70. {
  71. if (it->second == iHit)
  72. {
  73. retval = kTRUE;
  74. break;
  75. }
  76. }
  77. return retval;
  78. }
  79. ClassImp(CbmSttTrack)