StPicoV0.cxx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #include "StPicoV0.h"
  2. #include "StPicoDst.h"
  3. #include "StPicoConstants.h"
  4. #include "StPicoEvent.h"
  5. #include "StPicoTrack.h"
  6. #include "TMath.h"
  7. #include "StMuDSTMaker/COMMON/StMuDst.h"
  8. #include "StMuDSTMaker/COMMON/StMuTrack.h"
  9. #include "StMuDSTMaker/COMMON/StMuEvent.h"
  10. #include "StPhysicalHelixD.hh"
  11. #include "StLorentzVectorF.hh"
  12. ClassImp(StPicoV0)
  13. StPicoV0::StPicoV0()
  14. {
  15. Clear();
  16. }
  17. StPicoV0::StPicoV0(StPicoV0* t)
  18. {
  19. if(!t) Clear();
  20. else {
  21. mIndex2Track[pos] = (Short_t)t->index2Track(pos);
  22. mIndex2Track[neg] = (Short_t)t->index2Track(neg);
  23. mMomentum[pos] = t->momentum(pos);
  24. mMomentum[neg] = t->momentum(neg);
  25. mV0Pos = t->v0Pos();
  26. mDcaDaughters = (UShort_t)(t->dcaDaughters()*1000.);
  27. mDca2Vtx = (UShort_t)(t->dca2Vertex()*1000.);
  28. mM = t->m();
  29. }
  30. }
  31. StPicoV0::~StPicoV0()
  32. { /* */ }
  33. StPicoV0::StPicoV0(StPicoTrack *t_pos, StPicoTrack *t_neg, StMuEvent *ev, Int_t *map2Track)
  34. {
  35. if(!t_pos || !t_neg || !ev) {
  36. Clear();
  37. } else {
  38. double B = ev->magneticField();
  39. StThreeVectorF primaryVertex = ev->primaryVertexPosition();
  40. StPhysicalHelixD helix_pos(t_pos->gMom(), t_pos->origin(), B*kilogauss, t_pos->charge());
  41. StPhysicalHelixD helix_neg(t_neg->gMom(), t_neg->origin(), B*kilogauss, t_neg->charge());
  42. double res = 3.0; // allow resolution
  43. double xc_pos = helix_pos.xcenter();
  44. double yc_pos = helix_pos.ycenter();
  45. double xc_neg = helix_neg.xcenter();
  46. double yc_neg = helix_neg.ycenter();
  47. double dd = TMath::Sqrt((xc_pos-xc_neg)*(xc_pos-xc_neg)+(yc_pos-yc_neg)*(yc_pos-yc_neg));
  48. double r_pos = 1./helix_pos.curvature();
  49. double r_neg = 1./helix_neg.curvature();
  50. if( fabs(r_pos-r_neg)-res < dd && dd < r_pos+r_neg+res ) {
  51. pair<double,double> s = helix_pos.pathLengths(helix_neg);
  52. StThreeVectorF dcaP_pos = helix_pos.at(s.first);
  53. StThreeVectorF dcaP_neg = helix_neg.at(s.second);
  54. float dcaDaughters = (dcaP_pos - dcaP_neg).mag();
  55. if(dcaDaughters<Pico::mV0DcaDaughtersMax) {
  56. StThreeVectorF v0 = (dcaP_pos+dcaP_neg)*0.5;
  57. StThreeVectorF mom_pos = helix_pos.momentumAt(s.first, B*kilogauss);
  58. StThreeVectorF mom_neg = helix_neg.momentumAt(s.second, B*kilogauss);
  59. StThreeVectorF mom_v0 = mom_pos + mom_neg;
  60. float angle = (v0-primaryVertex).angle(mom_v0);
  61. float dca2vtx = (v0-primaryVertex).mag()*TMath::Sin(angle);
  62. mIndex2Track[pos] = map2Track[t_pos->id()];
  63. mIndex2Track[neg] = map2Track[t_neg->id()];
  64. mMomentum[pos] = mom_pos;
  65. mMomentum[neg] = mom_neg;
  66. mV0Pos = v0;
  67. mDcaDaughters = (dcaDaughters*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(dcaDaughters*1000.);
  68. mDca2Vtx = (dca2vtx*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(dca2vtx*1000.);
  69. mM = 0; // invMass need to be calculated with particle hypothesis
  70. } else {
  71. Clear();
  72. }
  73. }
  74. }
  75. }
  76. void StPicoV0::Clear(const Option_t* opt)
  77. {
  78. mIndex2Track[pos] = -1; mIndex2Track[neg] = -1;
  79. mMomentum[pos].set(0.,0.,0.); mMomentum[neg].set(0.,0.,0.);
  80. mV0Pos.set(-999.,-999.,-999.);
  81. mDcaDaughters = Pico::USHORTMAX;
  82. mDca2Vtx = Pico::USHORTMAX;
  83. mM = 0.;
  84. }
  85. Int_t StPicoV0::index2Track(const Int_t i) const
  86. {
  87. if(i==pos||i==neg) return (Int_t)mIndex2Track[i];
  88. else return -1;
  89. }
  90. StPicoTrack* StPicoV0::track(const Int_t i) const
  91. {
  92. if(i==pos||i==neg) return (StPicoTrack*)StPicoDst::picoArray(picoTrack)->UncheckedAt(mIndex2Track[i]);
  93. else return 0;
  94. }
  95. StThreeVectorF StPicoV0::momentum(const Int_t i) const
  96. {
  97. StThreeVectorF ret(0.,0.,0.);
  98. if(i==pos||i==neg) return mMomentum[i];
  99. else return ret;
  100. }
  101. void StPicoV0::setIndex2Track(const Int_t id_pos, const Int_t id_neg)
  102. {
  103. mIndex2Track[pos] = (UShort_t)id_pos;
  104. mIndex2Track[neg] = (UShort_t)id_neg;
  105. }
  106. void StPicoV0::setParticleHypothesis(const Int_t ip_pos, const Int_t ip_neg)
  107. {
  108. if(ip_pos<0 || ip_pos>=nPar || ip_neg<0 || ip_neg>=nPar) return;
  109. StLorentzVectorF fourMom_pos(mMomentum[pos], (Float_t)TMath::Sqrt(mMomentum[pos].mag2()+Pico::mMass[ip_pos]*Pico::mMass[ip_pos]));
  110. StLorentzVectorF fourMom_neg(mMomentum[neg], (Float_t)TMath::Sqrt(mMomentum[neg].mag2()+Pico::mMass[ip_neg]*Pico::mMass[ip_neg]));
  111. mM = (fourMom_pos + fourMom_neg).m();
  112. }
  113. Float_t StPicoV0::decayLength() const
  114. {
  115. StPicoEvent *ev = (StPicoEvent *)StPicoDst::picoArray(picoEvent)->UncheckedAt(0);
  116. return (mV0Pos - ev->primaryVertex()).mag();
  117. }
  118. StThreeVectorF StPicoV0::momentum() const
  119. {
  120. return mMomentum[pos] + mMomentum[neg];
  121. }
  122. void StPicoV0::rotateTrack(const Int_t i)
  123. {
  124. if(i!=pos&&i!=neg) {
  125. return;
  126. }
  127. mMomentum[i].set(-1.*mMomentum[i].x(), -1.*mMomentum[i].y(), mMomentum[i].z());
  128. }