nikTrackCut.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #include "StHbtMaker/Cut/nikTrackCut.h"
  2. #include <sstream>
  3. #ifdef __ROOT__
  4. ClassImp(nikTrackCut)
  5. #endif
  6. //_________________
  7. nikTrackCut::nikTrackCut() {
  8. mNTracksPassed = 0;
  9. mNTracksFailed = 0;
  10. mEta[0] = -1e9; mEta[1] = +1e9;
  11. mP[0] = -1e9; mP[1] = +1e9;
  12. mPt[0] = -1e9; mPt[1] = +1e9;
  13. mPx[0] = -1e9; mPx[1] = +1e9;
  14. mPy[0] = -1e9; mPy[1] = +1e9;
  15. mPz[0] = -1e9; mPz[1] = +1e9;
  16. mCharge = 0;
  17. }
  18. //_________________
  19. nikTrackCut *nikTrackCut::Clone() {
  20. nikTrackCut *c = new nikTrackCut(*this); return c;
  21. }
  22. //_________________
  23. nikTrackCut::nikTrackCut(const nikTrackCut &c) : StHbtTrackCut(c) {
  24. mNTracksPassed = 0;
  25. mNTracksFailed = 0;
  26. mCharge = c.mCharge;
  27. mP[0] = c.mP[0]; mP[1] = c.mP[1];
  28. mPt[0] = c.mPt[0]; mPt[1] = c.mPt[1];
  29. mPx[0] = c.mPx[0]; mPx[1] = c.mPx[1];
  30. mPy[0] = c.mPy[0]; mPy[1] = c.mPy[1];
  31. mPz[0] = c.mPz[0]; mPz[1] = c.mPz[1];
  32. mEta[0] = c.mEta[0]; mEta[1] = c.mEta[1];
  33. }
  34. //_________________
  35. nikTrackCut::~nikTrackCut() {
  36. /* empty */
  37. }
  38. //_________________
  39. bool nikTrackCut::Pass(const StHbtTrack *track) {
  40. //mMass has to be set in the macros and defined in the base class
  41. float p = track->P().mag();
  42. float pt = track->P().perp();
  43. float px = track->P().x();
  44. float py = track->P().y();
  45. float pz = track->P().z();
  46. float eta = 0.5*::log( (p + pz)/(p - pz) );
  47. float massSqr = track->TofMassSqr();
  48. //Main patterns
  49. bool mGoodCharge = mCharge == track->Charge();
  50. bool mGoodTrack = ((p >= mP[0] && p <= mP[1]) &&
  51. (pt >= mPt[0] && pt <= mPt[1]) &&
  52. (px >= mPx[0] && px <= mPx[1]) &&
  53. (py >= mPy[0] && py <= mPy[1]) &&
  54. (pz >= mPz[0] && pz <= mPz[1]) &&
  55. (eta >= mEta[0] && eta <= mEta[1]) &&
  56. (massSqr >= mMassSqr[0] &&
  57. massSqr <= mMassSqr[1]));
  58. bool mPassTrack = mGoodCharge && mGoodTrack;
  59. mPassTrack ? mNTracksPassed++ : mNTracksFailed++;
  60. }
  61. //_________________
  62. StHbtString nikTrackCut::Report() {
  63. stringstream rep_str;
  64. rep_str << std::endl << "--== nikTrackCut ==--" << std::endl
  65. << "Charge: " << mCharge << std::endl
  66. << mP[0] << " <= p <= " << mP[1] << std::endl
  67. << mPt[0] << " <= pT <= " << mPt[1] << std::endl
  68. << mPx[0] << " <= pX <= " << mPx[1] << std::endl
  69. << mPy[0] << " <= pY <= " << mPy[1] << std::endl
  70. << mPz[0] << " <= pZ <= " << mPz[1] << std::endl
  71. << mMassSqr[0] << " <= massSqr <= " << mMassSqr[1] << std::endl
  72. << mEta[0] << " <= PseudoRapidity <= " << mEta[1] << std::endl
  73. << " >>> N Tracks passed: " << mNTracksPassed << std::endl
  74. << " >>> N Tracks failed: " << mNTracksFailed << std::endl;
  75. return rep_str.str();
  76. }
  77. //_________________
  78. void nikTrackCut::SetP(float lo, float hi) {
  79. mP[0] = lo; mP[1] = hi;
  80. }
  81. //_________________
  82. void nikTrackCut::SetPt(float lo, float hi) {
  83. mPt[0] = lo; mPt[1] = hi;
  84. }
  85. //_________________
  86. void nikTrackCut::SetPx(float lo, float hi) {
  87. mPx[0] = lo; mPx[1] = hi;
  88. }
  89. //_________________
  90. void nikTrackCut::SetPy(float lo, float hi) {
  91. mPy[0] = lo; mPy[1] = hi;
  92. }
  93. //_________________
  94. void nikTrackCut::SetPz(float lo, float hi) {
  95. mPz[0] = lo; mPz[1] = hi;
  96. }
  97. //_________________
  98. void nikTrackCut::SetEta(float lo, float hi) {
  99. mEta[0] = lo; mEta[1] = hi;
  100. }
  101. //_________________
  102. void nikTrackCut::SetMassSqr(float lo, float hi) {
  103. mMassSqr[0] = lo; mMassSqr[1] = hi;
  104. }
  105. //_________________
  106. void nikTrackCut::SetCharge(int charge) {
  107. mCharge = charge;
  108. }