StPicoTrack.cxx 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #include "StPicoTrack.h"
  2. #include "StPicoCut.h"
  3. #include "StPicoConstants.h"
  4. #include "StPicoDstMaker.h"
  5. #include "TVector2.h"
  6. #include "StMuDSTMaker/COMMON/StMuDst.h"
  7. #include "StMuDSTMaker/COMMON/StMuTrack.h"
  8. #include "StMuDSTMaker/COMMON/StMuEvent.h"
  9. #include "StMuDSTMaker/COMMON/StMuBTofHit.h"
  10. #include "StMuDSTMaker/COMMON/StMuBTofPidTraits.h"
  11. ClassImp(StPicoTrack)
  12. //----------------------------------------------------------------------------------
  13. StPicoTrack::StPicoTrack()
  14. {
  15. Clear();
  16. }
  17. /////////////////////////////////////////////////////////////////////////////////////////
  18. // t - the global track. p - the associated primary track from the first primary vertex
  19. /////////////////////////////////////////////////////////////////////////////////////////
  20. //----------------------------------------------------------------------------------
  21. StPicoTrack::StPicoTrack(StMuTrack* t, StMuTrack* p, float phi_weight, int flowFlag, double B,
  22. int id, int adc0, float* e, float* dist, int* nhit, int* ntow)
  23. {
  24. Clear();
  25. if(!t || t->type()!=global || (p && ( p->type()!=primary || p->id()!=t->id() ) ) ) {
  26. LOG_WARN << " Bad StPicoTrack constructor ...... Check!" << endm;
  27. } else {
  28. mId = (UShort_t)t->id();
  29. mChi2 = (t->chi2()*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(t->chi2()*1000.));
  30. mGMomentum = t->helix().momentum(B*kilogauss);
  31. if(p) {
  32. mPMomentum = p->p();
  33. mChi2Prob = (p->chi2prob()*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(p->chi2prob()*1000.));
  34. } else {
  35. mPMomentum.set(0.,0.,0.);
  36. mChi2Prob = Pico::USHORTMAX ;
  37. }
  38. StThreeVectorF o = t->helix().origin();
  39. mOriginX = (fabs(o.x()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(o.x()*100.));
  40. mOriginY = (fabs(o.y()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(o.y()*100.));
  41. mOriginZ = (fabs(o.z()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(o.z()*100.));
  42. int q = t->charge();
  43. mGDca = (t->dcaGlobal().mag()*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(t->dcaGlobal().mag()*1000.));
  44. mDedx = (t->dEdx()*1e6*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(t->dEdx()*1e6*1000.));
  45. int flag = t->flag();
  46. if(flag/100<7) { // TPC tracks
  47. mNHitsFit = (UChar_t)(t->nHitsFit(kTpcId)*q);
  48. mNHitsMax = (Char_t)(t->nHitsPoss(kTpcId));
  49. } else { // FTPC tracks
  50. if(mGMomentum.pseudoRapidity()>0.) {
  51. mNHitsFit = (UChar_t)(t->nHitsFit(kFtpcWestId)*q);
  52. mNHitsMax = (Char_t)(t->nHitsPoss(kFtpcWestId));
  53. } else {
  54. mNHitsFit = (UChar_t)(t->nHitsFit(kFtpcEastId)*q);
  55. mNHitsMax = (Char_t)(t->nHitsPoss(kFtpcEastId));
  56. }
  57. }
  58. mNHitsDedx = (Char_t)(t->nHitsDedx());
  59. mNSigmaPion = (fabs(t->nSigmaPion()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->nSigmaPion()*100.));
  60. mNSigmaKaon = (fabs(t->nSigmaKaon()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->nSigmaKaon()*100.));
  61. mNSigmaProton = (fabs(t->nSigmaProton()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->nSigmaProton()*100.));
  62. mNSigmaElectron = (fabs(t->nSigmaElectron()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->nSigmaElectron()*100.));
  63. // Flow analysis
  64. mFlowFlag = (UChar_t)(flowFlag);
  65. #if 0
  66. if(mFlowFlag==others) {
  67. mQXi = 0.;
  68. mQYi = 0.;
  69. } else {
  70. float pt = mPMomentum.perp();
  71. float pt_weight = (pt<2.) ? pt : 2.;
  72. mQXi = pt_weight * phi_weight * TMath::Cos(2.*mPMomentum.phi());
  73. mQYi = pt_weight * phi_weight * TMath::Sin(2.*mPMomentum.phi());
  74. if(mQXi > 10. || mQYi > 10.) {
  75. LOG_WARN << " WARN!!! something is wrong with this Qi " << mQXi << " " << mQYi << " flag=" << flowFlag << " phi_weight=" << phi_weight << " pt=" << pt << endm;
  76. }
  77. }
  78. #endif
  79. // TOF
  80. StMuBTofHit *btofHit = (StMuBTofHit *)t->tofHit();
  81. if(btofHit) {
  82. int tray = btofHit->tray(); int module = btofHit->module(); int cell = btofHit->cell();
  83. float tof = t->btofPidTraits().timeOfFlight();
  84. float beta = (p) ? p->btofPidTraits().beta() : -999.;
  85. StThreeVectorF pos = t->btofPidTraits().position();
  86. mBTofCellId = (Short_t)((tray-1)*192+(module-1)*6+(cell-1));
  87. mBTofMatchFlag = (UChar_t)(t->btofPidTraits().matchFlag());
  88. if(tof<0) { mBTof = 0; }
  89. else { mBTof = (tof*1000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(tof*1000.)); }
  90. if(beta<0) { mBTofBeta = 0; }
  91. else { mBTofBeta = (beta*20000.>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)(TMath::Nint(beta*20000.)); }
  92. mBTofHitPosX = (fabs(pos.x()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(pos.x()*100.));
  93. mBTofHitPosY = (fabs(pos.y()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(pos.y()*100.));
  94. mBTofHitPosZ = (fabs(pos.z()*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(pos.z()*100.));
  95. mBTofYLocal = (fabs(t->btofPidTraits().yLocal())*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->btofPidTraits().yLocal()*1000.));
  96. mBTofZLocal = (fabs(t->btofPidTraits().zLocal())*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(t->btofPidTraits().zLocal()*1000.));
  97. }
  98. #if EMCON == 1
  99. // EMC - filled in a separated function
  100. mBEMCId = (id>Pico::SHORTMAX) ? -1 : (Short_t)id;
  101. mBTOWADC0 = (adc0>Pico::USHORTMAX) ? Pico::USHORTMAX : (UShort_t)adc0;
  102. mBTOWE0 = (e[0]*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(e[0]*1000.));
  103. mBTOWE = (e[1]*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(e[1]*1000.));
  104. mBEMCDistZ = (fabs(dist[0]*100.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(dist[0]*100.));
  105. mBEMCDistPhi = (fabs(dist[1]*10000.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(dist[1]*10000.));
  106. mBSMDNEta = (nhit[0]>Pico::UCHARMAX) ? Pico::UCHARMAX : (UChar_t)(nhit[0]);
  107. mBSMDNPhi = (nhit[1]>Pico::UCHARMAX) ? Pico::UCHARMAX : (UChar_t)(nhit[1]);
  108. mBTOWId = (ntow[0]<=0 || ntow[0]>4800) ? -1 : (Short_t)ntow[0];
  109. mBTOWId23 = (ntow[1]<0 || ntow[1]>=9 || ntow[2]<0 || ntow[2]>=9) ? -1 : (Char_t)(ntow[1]*10+ntow[2]);
  110. mBTOWE1 = (e[2]*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(e[2]*1000.));
  111. mBTOWE2 = (e[3]*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(e[3]*1000.));
  112. mBTOWE3 = (e[4]*1000.>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(e[4]*1000.));
  113. mBTOWDistEta = (fabs(dist[2]*10000.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(dist[2]*10000.));
  114. mBTOWDistPhi = (fabs(dist[3]*10000.)>Pico::SHORTMAX) ? Pico::SHORTMAX : (Short_t)(TMath::Nint(dist[3]*10000.));
  115. #endif
  116. }// end if
  117. }
  118. //----------------------------------------------------------------------------------
  119. StPicoTrack::~StPicoTrack()
  120. { /* noop */ }
  121. //----------------------------------------------------------------------------------
  122. void StPicoTrack::Clear(const Option_t* opt)
  123. {
  124. mId = 0;
  125. mChi2 = Pico::USHORTMAX;
  126. mChi2Prob = Pico::USHORTMAX;
  127. mGMomentum.set(0.,0.,0.);
  128. mPMomentum.set(0.,0.,0.);
  129. mFlowFlag = 0;
  130. // mQXi = 0.;
  131. // mQYi = 0.;
  132. mOriginX = 0;
  133. mOriginY = 0;
  134. mOriginZ = 0;
  135. mGDca = Pico::USHORTMAX;
  136. mDedx = 0;
  137. mNHitsFit = 0;
  138. mNHitsMax = 0;
  139. mNHitsDedx = 0;
  140. mNSigmaPion = Pico::SHORTMAX;
  141. mNSigmaKaon = Pico::SHORTMAX;
  142. mNSigmaProton = Pico::SHORTMAX;
  143. mNSigmaElectron = Pico::SHORTMAX;
  144. mBTofCellId = -1;
  145. mBTofMatchFlag = 0;
  146. mBTof = 0;
  147. mBTofBeta = 0;
  148. mBTofYLocal = Pico::SHORTMAX;
  149. mBTofZLocal = Pico::SHORTMAX;
  150. mBTofHitPosX = 0;
  151. mBTofHitPosY = 0;
  152. mBTofHitPosZ = 0;
  153. #if EMCON == 1
  154. mBEMCId = -1;
  155. mBTOWADC0 = 0;
  156. mBTOWE0 = -1*Pico::SHORTMAX;
  157. mBTOWE = -1*Pico::SHORTMAX;
  158. mBEMCDistZ = Pico::SHORTMAX;
  159. mBEMCDistPhi = Pico::SHORTMAX;
  160. mBSMDNEta = 0;
  161. mBSMDNPhi = 0;
  162. mBTOWId = -1;
  163. mBTOWId23 = -1;
  164. mBTOWE1 = -1*Pico::SHORTMAX;
  165. mBTOWE2 = -1*Pico::SHORTMAX;
  166. mBTOWE3 = -1*Pico::SHORTMAX;
  167. mBTOWDistEta = Pico::SHORTMAX;
  168. mBTOWDistPhi = Pico::SHORTMAX;
  169. #endif
  170. }
  171. //----------------------------------------------------------------------------------
  172. void StPicoTrack::Print(const Char_t *option) const {
  173. if(strcmp(option,"tpc")==0 || strcmp(option,"")==0) {
  174. LOG_INFO << "id=" << id() << " flowflag=" << flowFlag() << " chi2=" << chi2() << " dca=" << dca() << endm;
  175. LOG_INFO << "gMom=" << gMom() << endm;
  176. LOG_INFO << "pMom=" << pMom() << endm;
  177. LOG_INFO << "Origin=" << origin() << endm;
  178. // LOG_INFO << "Q vector=" << mQXi << " " << mQYi << endm;
  179. LOG_INFO << " nHitsFit = " << nHitsFit() << " nHitsdEdx = " << nHitsDedx() << endm;
  180. LOG_INFO << " nSigma Pi/K/P/E = " << nSigmaPion() << "/" << nSigmaKaon() << "/" << nSigmaProton() << "/" << nSigmaElectron() << endm;
  181. }
  182. if(strcmp(option,"tof")==0 || strcmp(option,"")==0) {
  183. LOG_INFO << " BTOF cellId = " << btofCellId() << " tof = " << btof() << " beta = " << btofBeta() << endm;
  184. LOG_INFO << " BTOF match = " << btofMatchFlag() << " yLocal/zLocal " << btofYLocal() << " " << btofZLocal() << endm;
  185. }
  186. if(strcmp(option,"emc")==0 || strcmp(option,"")==0) {
  187. LOG_INFO << " BEMC Id = " << bemcId() << " BTOW ADC0 = " << adc0() << " energy0 = " << e0() << " e = " << e() << endm;
  188. LOG_INFO << " BEMC distz = " << zDist() << " distphi = " << phiDist() << endm;
  189. LOG_INFO << " BSMD nEta/nPhi = " << nEta() << "/" << nPhi() << endm;
  190. LOG_INFO << " BTOW Id = " << btowId() << " tower Id 2/3 = " << btowId2() << " " << btowId3() << endm;
  191. LOG_INFO << " BTOW energy = " << e1() << " " << e2() << " " << e3() << endm;
  192. LOG_INFO << " BTOW position to center = " << etaTowDist() << " " << phiTowDist() << endm;
  193. }
  194. }