StFemtoTrack.cxx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // The StFemtoTrack class stores track information
  3. //
  4. // C++ headers
  5. #include <limits>
  6. #include <cmath>
  7. #include <iostream>
  8. // FemtoDst headers
  9. #include "StFemtoTrack.h"
  10. // ROOT headers
  11. #include "TMath.h"
  12. ClassImp(StFemtoTrack)
  13. //_________________
  14. StFemtoTrack::StFemtoTrack() : TObject(),
  15. mId(0), mNHits(0), mNHitsPoss(0), mNHitsDedx(0),
  16. mDedx(0), mMap{}, mChi2(0),
  17. mNSigmaElectron(-60), mNSigmaPion(-60), mNSigmaKaon(-60), mNSigmaProton(-60),
  18. mBeta(0),
  19. mPrimMomX(0), mPrimMomY(0), mPrimMomZ(0),
  20. mGlobMomX(0), mGlobMomY(0), mGlobMomZ(0),
  21. mOriginX(0), mOriginY(0), mOriginZ(0) { // Default constructor
  22. /* empty */
  23. }
  24. //_________________
  25. StFemtoTrack::StFemtoTrack(const StFemtoTrack &t) : TObject() {
  26. // Copy constructor
  27. mId = t.mId;
  28. mNHits = t.mNHits;
  29. mNHitsPoss = t.mNHitsPoss;
  30. mNHitsDedx = t.mNHitsDedx;
  31. mDedx = t.mDedx;
  32. mMap[0] = t.mMap[0];
  33. mMap[1] = t.mMap[1];
  34. mChi2 = t.mChi2;
  35. mNSigmaElectron = t.mNSigmaElectron;
  36. mNSigmaPion = t.mNSigmaPion;
  37. mNSigmaKaon = t.mNSigmaKaon;
  38. mNSigmaProton = t.mNSigmaProton;
  39. mBeta = t.mBeta;
  40. mPrimMomX = t.mPrimMomX;
  41. mPrimMomY = t.mPrimMomY;
  42. mPrimMomZ = t.mPrimMomZ;
  43. mGlobMomX = t.mGlobMomX;
  44. mGlobMomY = t.mGlobMomY;
  45. mGlobMomZ = t.mGlobMomZ;
  46. mOriginX = t.mOriginX;
  47. mOriginY = t.mOriginY;
  48. mOriginZ = t.mOriginZ;
  49. }
  50. //_________________
  51. Float_t StFemtoTrack::massSqr() const {
  52. // Calculate squared mass of the track via TOF beta measurement
  53. Float_t mSqr = -999.;
  54. if( isTofTrack() && isPrimary() ) {
  55. mSqr = p() * p() * ( invBeta() * invBeta() - 1.);
  56. }
  57. return mSqr;
  58. }
  59. //_________________
  60. void StFemtoTrack::setDedx(const Float_t& dEdx) {
  61. // Set dE/dx value
  62. if( (dEdx * 1e9) >= std::numeric_limits<unsigned short>::max() ) {
  63. mDedx = std::numeric_limits<unsigned short>::max();
  64. }
  65. else {
  66. mDedx = (UShort_t)(dEdx * 1e9);
  67. }
  68. }
  69. //_________________
  70. void StFemtoTrack::setDedx(const Double_t& dEdx) {
  71. // Set dE/dx value
  72. if( (dEdx * 1e9) >= std::numeric_limits<unsigned short>::max() ) {
  73. mDedx = std::numeric_limits<unsigned short>::max();
  74. }
  75. else {
  76. mDedx = (UShort_t)(dEdx * 1e9);
  77. }
  78. }
  79. //_________________
  80. Float_t StFemtoTrack::gDCAz(const Float_t& pVtxZ) const {
  81. // Calculate DCA z of the global track to pVtx
  82. return (mOriginZ - pVtxZ);
  83. }
  84. //_________________
  85. Float_t StFemtoTrack::gDCAxy(const Float_t& pVtxX, const Float_t& pVtxY) const {
  86. // Calculate DCA perp of the global track to pVtx
  87. return TMath::Sqrt( (mOriginX - pVtxX) * (mOriginX - pVtxX) +
  88. (mOriginY - pVtxY) * (mOriginY - pVtxY) );
  89. }
  90. //_________________
  91. Float_t StFemtoTrack::gDCA(const Float_t& pVtxX, const Float_t& pVtxY,
  92. const Float_t& pVtxZ) const {
  93. // Calculate DCA of the global track to pVtx
  94. return TMath::Sqrt( gDCAxy(pVtxX, pVtxY) * gDCAxy(pVtxX, pVtxY) +
  95. gDCAz(pVtxZ) * gDCAz(pVtxZ) );
  96. }
  97. //_________________
  98. TVector3 StFemtoTrack::gDCA(TVector3 point) const {
  99. // Return DCA value between the point of DCA to isPrimary
  100. // vertex and the point
  101. return ( origin() - point );
  102. }
  103. //_________________
  104. void StFemtoTrack::print() {
  105. std::cout << "Track info: " << std::endl
  106. << "id: " << id() << " type: " << type() << " isPrimary: " << isPrimary()
  107. << " flag: " << flag() << " charge: " << charge() << std::endl
  108. << "nHits: " << nHits() << " nHitsPoss: " << nHitsPoss() << std::endl
  109. << "ns(e): " << nSigmaElectron() << " ns(pi): " << nSigmaPion()
  110. << " ns(K): " << nSigmaKaon() << " ns(p): " << nSigmaProton() << std::endl
  111. << "dEdx: " << dEdx() << " map0: " << map0() << " map1: " << map1() << chi2() << std::endl
  112. << "isTofTrack: " << isTofTrack() << " beta: " << beta() << " m^2: " << massSqr() << std::endl
  113. << "pMomentum z,y,z: " << pMom().X() << " , " << pMom().Y() << " , " << pMom().Z() << std::endl
  114. << "origin x,y,z: " << origin().X() << " , " << origin().Y() << " , " << origin().Z() << std::endl
  115. << "gMomentum x,y,z: " << gMom().X() << " , " << gMom().Y() << " , " << gMom().Z() << std::endl
  116. << std::endl;
  117. }
  118. //_________________
  119. void StFemtoTrack::setNSigmaElectron(const Float_t& ns) {
  120. // Set nSigma(electron)
  121. mNSigmaElectron = ( TMath::Abs(ns * 1000.) > std::numeric_limits<short>::max() ?
  122. ( (ns>0) ? std::numeric_limits<short>::max() :
  123. std::numeric_limits<short>::min() ) :
  124. (Short_t)(ns * 1000.) );
  125. }
  126. //_________________
  127. void StFemtoTrack::setNSigmaPion(const Float_t& ns) {
  128. // Set nSigma(pion)
  129. mNSigmaPion = ( TMath::Abs(ns * 1000.) > std::numeric_limits<short>::max() ?
  130. ( (ns>0) ? std::numeric_limits<short>::max() :
  131. std::numeric_limits<short>::min() ) :
  132. (Short_t)(ns * 1000.) );
  133. }
  134. //_________________
  135. void StFemtoTrack::setNSigmaKaon(const Float_t& ns) {
  136. // Set nSigma(kaon)
  137. mNSigmaKaon = ( TMath::Abs(ns * 1000.) > std::numeric_limits<short>::max() ?
  138. ( (ns>0) ? std::numeric_limits<short>::max() :
  139. std::numeric_limits<short>::min() ) :
  140. (Short_t)(ns * 1000.) );
  141. }
  142. //_________________
  143. void StFemtoTrack::setNSigmaProton(const Float_t& ns) {
  144. // Set nSigma(proton)
  145. mNSigmaProton = ( TMath::Abs(ns * 1000.) > std::numeric_limits<short>::max() ?
  146. ( (ns>0) ? std::numeric_limits<short>::max() :
  147. std::numeric_limits<short>::min() ) :
  148. (Short_t)(ns * 1000.) );
  149. }
  150. //_________________
  151. void StFemtoTrack::setChi2(const Float_t& chi2) {
  152. // Set chi2 value
  153. if( chi2<=0 ) {
  154. mChi2 = 0;
  155. }
  156. else {
  157. mChi2 = ( (chi2 * 10.) > std::numeric_limits<unsigned char>::max() ?
  158. std::numeric_limits<unsigned char>::max() :
  159. (UChar_t)(chi2 * 10.) );
  160. }
  161. }
  162. //_________________
  163. void StFemtoTrack::setBeta(const Float_t& beta) {
  164. // Set TOF beta
  165. if( beta <= 0 ) {
  166. mBeta = 0;
  167. }
  168. else {
  169. mBeta = ( (beta * 20000.) > std::numeric_limits<unsigned short>::max() ?
  170. std::numeric_limits<unsigned short>::max() :
  171. (UShort_t)(beta * 20000.) );
  172. }
  173. }