MpdTpcHit.cxx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /// \class MpdTpcHit
  2. ///
  3. /// Hit in MPD TPC
  4. /// \author Alexander Zinchenko (LHEP, JINR, Dubna) - extension of TpcHit
  5. //#include "TpcCommon.h"
  6. #include "MpdTpcHit.h"
  7. #include "MpdKalmanHit.h"
  8. #include "MpdTpc2dCluster.h"
  9. #include "FairLinkManager.h"
  10. //---------------------------------------------------------------------------
  11. MpdTpcHit::MpdTpcHit(Int_t detID, TVector3 pos, TVector3 dpos, Int_t index)
  12. : FairHit(detID, pos, dpos, index),
  13. fiPad(-1), fiBin(-1), fLayer(-1), fNdigits(0), fFlag(0), fQ(0), fStep(0), fLength(0), fLocalX(0), fLocalY(0), fLocalZ(0)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. Int_t MpdTpcHit::Compare(const TObject* hit) const
  18. {
  19. /// "Compare" function to sort in descending order in radius
  20. MpdTpcHit *tpcHit = (MpdTpcHit*) hit;
  21. if (fLayer < tpcHit->GetLayer()) return 1;
  22. else if (fLayer > tpcHit->GetLayer()) return -1;
  23. else {
  24. if (GetR() < tpcHit->GetR()) return 1;
  25. else if (GetR() > tpcHit->GetR()) return -1;
  26. else return 0;
  27. }
  28. }
  29. //---------------------------------------------------------------------------
  30. Int_t MpdTpcHit::GetTrackID() const
  31. {
  32. // Returns track ID (from the link with the smallest weight)
  33. if (FairLinkManager::Instance() == NULL) return fIDs[0];
  34. FairMultiLinkedData links = GetLinksWithType(MpdTpcHit::MCTrackIndex);
  35. Int_t nLinks = links.GetNLinks();
  36. Int_t id = links.GetLink(0).GetIndex();
  37. Float_t w = links.GetLink(0).GetWeight();
  38. for (Int_t i = 1; i < nLinks; ++i) {
  39. FairLink link = links.GetLink(i);
  40. if (link.GetWeight() < w) {
  41. id = link.GetIndex();
  42. w = link.GetWeight();
  43. }
  44. }
  45. return id;
  46. }
  47. //---------------------------------------------------------------------------
  48. void MpdTpcHit::SetFlags(const MpdTpc2dCluster *clus)
  49. {
  50. // Transfer flags from the cluster
  51. if (clus->Virtual()) fFlag |= MpdKalmanHit::kVirtual;
  52. if (clus->Overflows()) fFlag |= MpdKalmanHit::kOverflow;
  53. if (clus->Edge()) fFlag |= MpdKalmanHit::kEdge;
  54. if (clus->Flag() & 1) fFlag |= MpdKalmanHit::kMlem;
  55. }
  56. //---------------------------------------------------------------------------
  57. ClassImp(MpdTpcHit)