StHbtThPair.cc 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /***************************************************************************
  2. *
  3. * $Id:
  4. *
  5. * Author: Laurent Conin, Fabrice Retiere, Subatech, France
  6. ***************************************************************************
  7. *
  8. * Description : implementation of StHbtThPair
  9. *
  10. ***************************************************************************
  11. *
  12. * $Log:
  13. *
  14. ***************************************************************************/
  15. #include <Stiostream.h>
  16. #include <Stsstream.h>
  17. #include <stdlib.h>
  18. #include "StHbtMaker/Base/StHbtThPair.hh"
  19. #include "StHbtMaker/Base/StHbtFsiWeight.hh"
  20. #ifdef __ROOT__
  21. ClassImp(StHbtThPair)
  22. #endif
  23. StHbtThPair::StHbtThPair(){
  24. mMomentum1=mMomentum2=mEmPoint1=mEmPoint2=0;
  25. mPid1=mPid2=0;
  26. mMeasPair=0;
  27. mWeight=0;
  28. mWeightNum=mWeightDen=1.;
  29. mWeightOk=false;
  30. mPairPurity=1;
  31. };
  32. void StHbtThPair::setVariables(const StHbtPair*){
  33. /* no-op */
  34. }
  35. void StHbtThPair::setMomRes1(int aPid){
  36. if(aPid==7 || aPid==8){// pion
  37. mMomRes1=1;
  38. mPLoss1[0]=-0.00275; // (PRec-Pmc)P = [0]+[1]*P^[2]
  39. mPLoss1[1]=-0.000335;
  40. mPLoss1[2]=-2.052;
  41. mPtRes1[0]=0.0178; // Dpt/pt = [0] + [1]*Pt^[2]
  42. mPtRes1[1]=7.95e-5;
  43. mPtRes1[2]=-2.273;
  44. mPhiRes1[0]=0.0642; // DPhi = [0] +[1]*P^[2]
  45. mPhiRes1[1]=0.0322;
  46. mPhiRes1[2]=-1.511;
  47. mThetaRes1[0]=0.0779; // DTheta = [0] + P^[2]
  48. mThetaRes1[1]=0.0445;
  49. mThetaRes1[2]=-1.528;
  50. }
  51. if(aPid==11 || aPid==12){//kaon
  52. mMomRes1=1;
  53. }
  54. }
  55. void StHbtThPair::setMomRes2(int aPid){
  56. if(aPid==7 || aPid==8){// pion
  57. mMomRes2=1;
  58. mPLoss2[0]=-0.00275; // (PRec-Pmc)P = [0]+[1]*P^[2]
  59. mPLoss2[1]=-0.000335;
  60. mPLoss2[2]=-2.052;
  61. mPtRes2[0]=0.0178; // Dpt/pt = [0] + [1]*Pt^[2]
  62. mPtRes2[1]=7.95e-5;
  63. mPtRes2[2]=-2.273;
  64. mPhiRes2[0]=0.0642; // DPhi = [0] +[1]*P^[2]
  65. mPhiRes2[1]=0.0322;
  66. mPhiRes2[2]=-1.511;
  67. mThetaRes2[0]=0.0779; // DTheta = [0] + P^[2]
  68. mThetaRes2[1]=0.0445;
  69. mThetaRes2[2]=-1.528;
  70. }
  71. if(aPid==11 || aPid==12){//kaon
  72. mMomRes2=1;
  73. }
  74. }
  75. void StHbtThPair::UpdateWeight() {
  76. if (mWeight) {
  77. mWeightNum=mWeight->GetWeight(this);
  78. mWeightNum=(mWeightNum-1.)*mPairPurity+1.;
  79. mWeightDen=mWeight->GetWeightDen();
  80. if(mWeightNum<=0. || mWeightNum>1000.){
  81. ostrstream tCom;
  82. tCom << "echo ---> " << mWeightNum << " "
  83. << mEmPoint1 << " " << mEmPoint2 << " "
  84. << mMomentum1 << " " << mMomentum2 << " >> Err.txt" << ends;
  85. system(tCom.str());
  86. mWeightNum=1;
  87. }
  88. } else {
  89. cout << "StHbtThPair Error - No Weight Generator plugged - set to 1 " <<endl;
  90. mWeightNum=mWeightDen=1.;
  91. }
  92. mWeightOk=true;
  93. }
  94. StHbtString StHbtThPair::Report() {
  95. ostrstream tStr;
  96. tStr << "Default StHbtThPair Report" << endl;
  97. if (mWeight) {
  98. tStr << mWeight->Report() << endl;
  99. } else {
  100. tStr << "No Weight Generator plugged - Weight set to 1 " << endl;
  101. }
  102. StHbtString returnThis = tStr.str();
  103. return returnThis;
  104. }
  105. double StHbtThPair::RealqSideCMS() const {
  106. double x1 = mMomentum1->x(); double y1 = mMomentum1->y();
  107. double x2 = mMomentum2->x(); double y2 = mMomentum2->y();
  108. double xt = x1+x2; double yt = y1+y2;
  109. double k1 = ::sqrt(xt*xt+yt*yt);
  110. double tmp = 2.0*(x1*y2-x2*y1)/k1;
  111. return (tmp);
  112. }
  113. double StHbtThPair::RealqOutCMS() const {
  114. double dx = mMomentum1->x() - mMomentum2->x();
  115. double xt = mMomentum1->x() + mMomentum2->x();
  116. double dy = mMomentum1->y() - mMomentum2->y();
  117. double yt = mMomentum1->y() + mMomentum2->y();
  118. double k1 = (::sqrt(xt*xt+yt*yt));
  119. double k2 = (dx*xt+dy*yt);
  120. double tmp = k2/k1;
  121. return (tmp);
  122. }
  123. double StHbtThPair::RealqLongCMS() const {
  124. double dz = mMomentum1->z() - mMomentum2->z();
  125. double zz = mMomentum1->z() + mMomentum2->z();
  126. double dt = mMomentum1->t() - mMomentum2->t();
  127. double tt = mMomentum1->t() + mMomentum2->t();
  128. double beta = zz/tt;
  129. double gamma = 1.0/::sqrt(1.0 - beta*beta);
  130. double temp = gamma*(dz - beta*dt);
  131. return (temp);
  132. }
  133. //________________________________
  134. double StHbtThPair::RealqOutPf() const
  135. {
  136. double dt = mMomentum1->t() - mMomentum2->t();
  137. double tt = mMomentum1->t() + mMomentum2->t();
  138. double xt = mMomentum1->x() + mMomentum2->x();
  139. double yt = mMomentum1->y() + mMomentum2->y();
  140. double k1 = ::sqrt(xt*xt + yt*yt);
  141. double bOut = k1/tt;
  142. double gOut = 1.0/::sqrt(1.0 - bOut*bOut);
  143. double temp = gOut*(this->RealqOutCMS() - bOut*dt);
  144. return (temp);
  145. }
  146. //___________________________________
  147. double StHbtThPair::RealqSidePf() const
  148. {
  149. return(this->RealqSideCMS());
  150. }
  151. //___________________________________
  152. double StHbtThPair::RealqLongPf() const
  153. {
  154. return(this->RealqLongCMS());
  155. }
  156. //___________________________________
  157. void StHbtThPair::calcMomParameters() const{ // fortran like function! faster?
  158. mMomParCalculated=1;
  159. double tPx1(mMomentum1->px());
  160. double tPy1(mMomentum1->py());
  161. double tPz1(mMomentum1->pz());
  162. double tE1(mMomentum1->e());
  163. double tPx(tPx1+mMomentum2->px());
  164. double tPy(tPy1+mMomentum2->py());
  165. double tPz(tPz1+mMomentum2->pz());
  166. double tE(tE1 +mMomentum2->e());
  167. mPt = tPx*tPx + tPy*tPy;
  168. double tP = tPz*tPz;
  169. double tMt = tE*tE - tP;
  170. tP += mPt;
  171. tP = ::sqrt(tP);
  172. double tM = ::sqrt(tMt - mPt);
  173. tMt = ::sqrt(tMt);
  174. mPt = ::sqrt(mPt);
  175. mBetat = mPt/tMt;
  176. mUt = mPt/tMt;
  177. // Boost to LCMS
  178. double tBeta = tPz/tE;
  179. double tGamma = tE/tMt;
  180. mKStarLong = tGamma * (tPz1 - tBeta * tE1);
  181. double tE1L = tGamma * (tE1 - tBeta * tPz1);
  182. // Rotate in transverse plane
  183. mKStarOut = ( tPx1*tPx + tPy1*tPy)/mPt;
  184. mKStarSide = (-tPx1*tPy + tPy1*tPx)/mPt;
  185. // Boost to pair cms
  186. mKStarOut = tMt/tM * (mKStarOut - mPt/tMt * tE1L);
  187. mKStar = ::sqrt(mKStarOut*mKStarOut+mKStarSide*mKStarSide+
  188. mKStarLong*mKStarLong);
  189. mCVK = (mKStarOut*mPt + mKStarLong*tPz)/mKStar/mCVK;
  190. mKStarLong = (tPz>=0)* mKStarLong - (tPz<0)*mKStarLong;
  191. }
  192. void StHbtThPair::calcPosParameters() const{ // fortran like function! faster?
  193. mPosParCalculated=1;
  194. double tPx = mMomentum1->px()+mMomentum2->px();
  195. double tPy = mMomentum1->py()+mMomentum2->py();
  196. double tPz = mMomentum1->pz()+mMomentum2->pz();
  197. double tE = mMomentum1->e()+mMomentum2->e();
  198. double tPt = tPx*tPx + tPy*tPy;
  199. double tMt = tE*tE - tPz*tPz;
  200. double tM = ::sqrt(tMt - tPt);
  201. tMt = ::sqrt(tMt);
  202. tPt = ::sqrt(tPt);
  203. double tDX = mEmPoint1->x()-mEmPoint2->x();
  204. double tDY = mEmPoint1->y()-mEmPoint2->y();
  205. mRLong = mEmPoint1->z()-mEmPoint2->z();
  206. mDTime = mEmPoint1->t()-mEmPoint2->t();
  207. mRTrans = tDX>0.? ::sqrt(tDX*tDX+tDY*tDY) : -1.*::sqrt(tDX*tDX+tDY*tDY);
  208. mROut = (tDX*tPx + tDY*tPy)/tPt;
  209. mRSide = (-tDX*tPy + tDY*tPx)/tPt;
  210. mRSidePairCMS = mRSide;
  211. // Lab -> LCMS -> PRF method
  212. double tBeta = tPz/tE;
  213. double tGamma = tE/tMt;
  214. mRLongPairCMS = tGamma*(mRLong - tBeta* mDTime);
  215. mDTimePairLCMS = tGamma*(mDTime - tBeta* mRLong);
  216. tBeta = tPt/tMt;
  217. tGamma = tMt/tM;
  218. mROutPairCMS = tGamma*(mROut - tBeta* mDTimePairLCMS);
  219. mDTimePairCMS = tGamma*(mDTimePairLCMS - tBeta* mROut);
  220. mRStar = ::sqrt(mROutPairCMS*mROutPairCMS + mRSidePairCMS*mRSidePairCMS +
  221. mRLongPairCMS*mRLongPairCMS);
  222. /*
  223. // Lab -> PRF method
  224. double tRS12 = DX*Px+DY*Py+mRLong*Pz;
  225. double tH1 = (tRS12/(E+M) - mDTime) / M;
  226. double DXPairCMS = DX + Px* tH1;
  227. double DYPairCMS = DY + Py* tH1;
  228. mRLongPairCMS = mRLong + Pz* tH1;
  229. //mRLong = Pz*mRLong>0? mRLong : -mRLong;
  230. //mRLongPairCMS = Pz*mRLongPairCMS>0? mRLongPairCMS : -mRLongPairCMS;
  231. mDTimePairCMS = (E* mDTime - tRS12) / M;
  232. mRStar = ::sqrt(DXPairCMS*DXPairCMS + DYPairCMS*DYPairCMS +
  233. mRLongPairCMS * mRLongPairCMS);
  234. mROutPairCMS = (DXPairCMS*Px + DYPairCMS*Py)/Ptrans;
  235. mRSidePairCMS = (-DXPairCMS*Py + DYPairCMS*Px)/Ptrans;
  236. */
  237. }