MpdEmcPointKI.cxx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "MpdEmcPointKI.h"
  2. #include <iostream>
  3. using std::cout;
  4. using std::endl;
  5. // ----- Default constructor -------------------------------------------
  6. MpdEmcPointKI::MpdEmcPointKI() : FairMCPoint() {}
  7. // -------------------------------------------------------------------------
  8. // ----- Standard constructor ------------------------------------------
  9. MpdEmcPointKI::MpdEmcPointKI(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t tof, Double_t length,
  10. Double_t ELoss)
  11. : FairMCPoint(trackID, detID, pos, mom, tof, length, ELoss)
  12. {
  13. }
  14. // -------------------------------------------------------------------------
  15. // ----- Destructor ----------------------------------------------------
  16. MpdEmcPointKI::~MpdEmcPointKI() {}
  17. // -------------------------------------------------------------------------
  18. // ----- Public method Print -------------------------------------------
  19. void MpdEmcPointKI::Print(const Option_t* opt) const
  20. {
  21. cout << "-I- MpdEmcPointKI: TutorialDet point for track " << fTrackID << " in detector " << fDetectorID << endl;
  22. cout << " Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl;
  23. cout << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl;
  24. cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"
  25. << endl;
  26. }
  27. // -------------------------------------------------------------------------
  28. Bool_t MpdEmcPointKI::operator<(const MpdEmcPointKI& rhs) const
  29. {
  30. if (GetDetectorID() == rhs.GetDetectorID())
  31. return GetTrackID() < rhs.GetTrackID();
  32. return GetDetectorID() < rhs.GetDetectorID();
  33. }
  34. Bool_t MpdEmcPointKI::operator==(const MpdEmcPointKI& rhs) const
  35. {
  36. return ((GetDetectorID() == rhs.GetDetectorID()) && (GetTrackID() == rhs.GetTrackID()));
  37. }
  38. MpdEmcPointKI& MpdEmcPointKI::operator+=(const MpdEmcPointKI& rhs)
  39. {
  40. if (rhs.GetEnergyLoss() > GetEnergyLoss())
  41. SetTime(rhs.GetTime());
  42. SetEnergyLoss(GetEnergyLoss() + rhs.GetEnergyLoss());
  43. return *this;
  44. }
  45. MpdEmcPointKI MpdEmcPointKI::operator+(const MpdEmcPointKI& rhs) const
  46. {
  47. MpdEmcPointKI result(*this);
  48. if (rhs.GetEnergyLoss() > result.GetEnergyLoss())
  49. result.SetTime(rhs.GetTime());
  50. result.SetEnergyLoss(result.GetEnergyLoss() + rhs.GetEnergyLoss());
  51. return *this;
  52. }
  53. Int_t MpdEmcPointKI::Compare(const TObject* obj) const
  54. {
  55. // Compares two MpdEmcPointKI with respect to its Id
  56. // to sort according increasing Id
  57. const MpdEmcPointKI* rhs = dynamic_cast<const MpdEmcPointKI*>(obj);
  58. if (!rhs) {
  59. return 1;
  60. }
  61. if (GetDetectorID() == rhs->GetDetectorID()) {
  62. if (GetTrackID() < rhs->GetTrackID()) {
  63. return -1;
  64. }
  65. if (GetTrackID() == rhs->GetTrackID()) {
  66. return 0;
  67. } else {
  68. return 1;
  69. }
  70. }
  71. if (GetDetectorID() < rhs->GetDetectorID()) {
  72. return -1;
  73. } else {
  74. return 1;
  75. }
  76. return 0; // never happens
  77. }
  78. ClassImp(MpdEmcPointKI)