MpdTofPoint.cxx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //------------------------------------------------------------------------------------------------------------------------
  2. #include <iostream>
  3. #include "MpdTofPoint.h"
  4. using namespace std;
  5. ClassImp(MpdTofPoint)
  6. //------------------------------------------------------------------------------------------------------------------------
  7. MpdTofPoint::MpdTofPoint() : FairMCPoint() { }
  8. //------------------------------------------------------------------------------------------------------------------------
  9. MpdTofPoint::MpdTofPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss)
  10. : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss)
  11. {
  12. }
  13. //------------------------------------------------------------------------------------------------------------------------
  14. void MpdTofPoint::Print(const Option_t* opt) const
  15. {
  16. cout<<"\n-I- MpdTofPoint: tid="<<fTrackID<<", duid="<<fDetectorID
  17. <<", Position("<<fX<<", "<<fY<<", "<<fZ <<") cm"<<", Momentum("<<fPx<<", "<<fPy<<", "<<fPz<<") GeV/c"
  18. <<", time="<<fTime<<" ns, tr. length "<<fLength<<" cm, Eloss="<<fELoss*1.e06 <<" keV.";
  19. }
  20. //------------------------------------------------------------------------------------------------------------------------
  21. bool MpdTofPoint::PrintSuid(Int_t suid, const char* comment, ostream& os)
  22. {
  23. if(comment != nullptr) os<<comment;
  24. Int_t sector, detector, gap, strip;
  25. ParseSuid(suid, sector, detector, gap, strip);
  26. os<<" suid=0x"<<hex<<suid<<dec<<" : sector="<<sector<<", detector="<<detector<<", gap="<<gap<<", strip="<<strip;
  27. return true;
  28. }
  29. //------------------------------------------------------------------------------------------------------------------------
  30. void MpdTofPoint::ParseSuid(Int_t suid, Int_t& sector, Int_t& detector, Int_t& gap, Int_t& strip)
  31. {
  32. sector = GetSector(suid);
  33. detector = GetDetector(suid);
  34. gap = GetGap(suid);
  35. strip = GetStrip(suid);
  36. }
  37. //------------------------------------------------------------------------------------------------------------------------
  38. Int_t MpdTofPoint::GetSuid72(Int_t sector, Int_t detector, Int_t strip)
  39. {
  40. const Int_t nStrips = 24;
  41. Int_t gap = (strip -1) / nStrips +1; // gap range [1,3]
  42. strip = (strip-1) % nStrips + 1; // strip range [1,72] -> [1,24]
  43. return GetSuid24(sector, detector, gap, strip);
  44. }
  45. //------------------------------------------------------------------------------------------------------------------------
  46. Int_t MpdTofPoint::GetSuid24(Int_t sector, Int_t detector, Int_t gap, Int_t strip)
  47. {
  48. #ifdef DEBUG
  49. Int_t suid = (sector<<24) + (detector<<16) + (gap<<8) + strip;
  50. Int_t sectorID = GetSector(suid);
  51. Int_t detectorID = GetDetector(suid);
  52. Int_t gapID = GetGap(suid);
  53. Int_t stripID = GetStrip(suid);
  54. assert(sector == sectorID);
  55. assert(detector == detID);
  56. assert(gap == gapID);
  57. assert(strip == stripID);
  58. return suid;
  59. #else
  60. return (sector<<24) + (detector<<16) + (gap<<8) + strip;
  61. #endif
  62. }
  63. //------------------------------------------------------------------------------------------------------------------------
  64. bool MpdTofPoint::IsSameDetector(Int_t suid1, Int_t suid2)
  65. {
  66. #ifdef DEBUG
  67. assert( ((suid1 & 0xFFFF0000) == (suid2 & 0xFFFF0000)) == (GetSector(suid1) == GetSector(suid2) && GetDetector(suid1) == GetDetector(suid2)));
  68. #endif
  69. return ((suid1 & 0xFFFF0000) == (suid2 & 0xFFFF0000));
  70. }
  71. //------------------------------------------------------------------------------------------------------------------------
  72. bool MpdTofPoint::IsSameStrip(Int_t suid1, Int_t suid2)
  73. {
  74. #ifdef DEBUG
  75. assert( ((suid1 & 0xFFFF00FF) == (suid2 & 0xFFFF00FF)) == (GetSector(suid1) == GetSector(suid2) && GetDetector(suid1) == GetDetector(suid2) && GetStrip(suid1) == GetStrip(suid2)));
  76. #endif
  77. return ((suid1 & 0xFFFF00FF) == (suid2 & 0xFFFF00FF));
  78. }
  79. //------------------------------------------------------------------------------------------------------------------------
  80. bool MpdTofPoint::IsSameGap(Int_t suid1, Int_t suid2)
  81. {
  82. #ifdef DEBUG
  83. assert( ((suid1 & 0x0000FF00) == (suid2 & 0x0000FF00)) == (GetGap(suid1) == GetGap(suid2)) );
  84. #endif
  85. return ((suid1 & 0x0000FF00) == (suid2 & 0x0000FF00));
  86. }
  87. //------------------------------------------------------------------------------------------------------------------------