StO97Track.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #include "StO97Track.h"
  2. ClassImp(StO97Track)
  3. //________________
  4. StO97Track::StO97Track() : mId(0), mPdgId(0), mPx(0), mPy(0), mPz(0),
  5. mMass(0), mXfr(0), mYfr(0), mZfr(0), mTfr(0) {
  6. /* emtpy */
  7. }
  8. //_________________
  9. StO97Track::StO97Track(const StO97Track &t) {
  10. //Copy constructor
  11. mId = t.mId;
  12. mPdgId = t.mPdgId;
  13. mPx = t.mPx; mPy = t.mPy; mPz = t.mPz; mMass = t.mMass;
  14. mXfr = t.mXfr; mYfr = t.mYfr; mZfr = t.mZfr; mTfr = t.mTfr;
  15. }
  16. //________________
  17. Int_t StO97Track::GetPdgId(const TDatabasePDG *pdgDb)
  18. {
  19. return pdgDb->ConvertIsajetToPdg(mPdgId);
  20. }
  21. //________________
  22. StO97Track &StO97Track::operator=(const StO97Track &t) {
  23. //Assignment constructor
  24. if (this != &t) {
  25. mId = t.mId;
  26. mPdgId = t.mPdgId;
  27. mPx = t.mPx;
  28. mPy = t.mPy;
  29. mPz = t.mPz;
  30. mMass = t.mMass;
  31. mXfr = t.mXfr;
  32. mYfr = t.mYfr;
  33. mZfr = t.mZfr;
  34. mTfr = t.mTfr;
  35. }
  36. return *this;
  37. }
  38. //_________________
  39. Int_t StO97Track::GetCharge(const TDatabasePDG *pdgDb, bool isajet) {
  40. int pdg = isajet ? pdgDb->ConvertIsajetToPdg(mPdgId) : mPdgId;
  41. TParticlePDG *pdgInfo = pdgDb->GetParticle(pdg);
  42. if (pdgInfo != NULL) {
  43. return (Int_t)(pdgInfo->Charge()/3.);
  44. }
  45. else {
  46. std::cout << "[StO97Track WARN]: can't get TPartcilePDG, using mPdgId > 0 ? 1 : -1\n";
  47. return GetCharge();
  48. }
  49. }
  50. //_________________
  51. StO97Track::~StO97Track() {
  52. /* empty */
  53. }
  54. //_________________
  55. void StO97Track::SetId(Int_t id) {
  56. //Set id of the track
  57. if( ( id < std::numeric_limits<unsigned short>::min() ) ||
  58. ( id > std::numeric_limits<unsigned short>::max() ) ) {
  59. mId = std::numeric_limits<unsigned short>::max();
  60. }
  61. else {
  62. mId = (UShort_t)id;
  63. }
  64. }
  65. //________________
  66. void StO97Track::SetTrack(Int_t id, Int_t pdgId,
  67. Float_t px, Float_t py, Float_t pz, Float_t mass,
  68. Float_t xFr, Float_t yFr, Float_t zFr, Float_t tFr) {
  69. //Set all track information
  70. SetId(id);
  71. SetPdgId(pdgId);
  72. mPx = px; mPy = py; mPz = pz; mMass = mass;
  73. mXfr = xFr; mYfr = yFr; mZfr = zFr; mTfr = tFr;
  74. }
  75. //_________________
  76. Bool_t StO97Track::GetIsSpec() {
  77. //Check if the particle is a spectator
  78. Bool_t mIsSpectator = false;
  79. if( TMath::Abs(mXfr) < 0.0001 &&
  80. TMath::Abs(mYfr) < 0.0001 &&
  81. TMath::Abs(mZfr) < 0.0001 &&
  82. mTfr < 0.0001 ) {
  83. mIsSpectator = true;
  84. }
  85. return mIsSpectator;
  86. }
  87. //_________________
  88. Float_t StO97Track::GetPt() {
  89. return TMath::Sqrt( mPx*mPx + mPy*mPy );
  90. }
  91. //_________________
  92. Float_t StO97Track::GetPtot() {
  93. return TMath::Sqrt( mPx*mPx + mPy*mPy + mPz*mPz );
  94. }
  95. //_________________
  96. Float_t StO97Track::GetEnergy() {
  97. //Calculate energy
  98. return TMath::Sqrt( mPx*mPx + mPy*mPy + mPz*mPz + mMass*mMass);
  99. }
  100. //_________________
  101. Float_t StO97Track::GetE() {
  102. return GetEnergy();
  103. }
  104. //_________________
  105. Float_t StO97Track::GetPseudoRapidity() {
  106. return ( 0.5 * TMath::Log( (GetPtot() + mPz) / (GetPtot() - mPz) ) );
  107. }
  108. //_________________
  109. Float_t StO97Track::GetEta() {
  110. return GetPseudoRapidity();
  111. }
  112. //_________________
  113. Float_t StO97Track::GetRapidity() {
  114. return ( 0.5 * TMath::Log( (GetEnergy() + mPz) / (GetEnergy() - mPz) ) );
  115. }
  116. //_________________
  117. Float_t StO97Track::GetY() {
  118. return GetRapidity();
  119. }