gregsPionTrackCut.cxx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. #include "StHbtMaker/Cut/gregsPionTrackCut.h"
  2. #include <sstream>
  3. #ifdef __ROOT__
  4. ClassImp(gregsPionTrackCut)
  5. #endif
  6. //_________________
  7. gregsPionTrackCut::gregsPionTrackCut() { //Constructor
  8. mNTracksPassed = 0;
  9. mNTracksFailed = 0;
  10. mSelType = 3;
  11. mType = 1;
  12. mCharge = 0;
  13. mNHits[0] = 14; mNHits[1] = 46;
  14. mFlag[0] = 0; mFlag[1] = 1000;
  15. mAntiSplit = 0.; //nHitsFit/nHitsPoss
  16. mNHitsFit[0] = 0; mNHitsFit[1] = 46;
  17. mP[0] = 0.15; mP[1] = 1.5;
  18. mPt[0] = -1e9; mPt[1] = +1e9;
  19. mPx[0] = -1e9; mPx[1] = +1e9;
  20. mPy[0] = -1e9; mPy[1] = +1e9;
  21. mPz[0] = -1e9; mPz[1] = +1e9;
  22. mRapidity[0] = -1e9; mRapidity[1] = +1e9;
  23. mEta[0] = -1.; mEta[1] = 1.;
  24. mDCA[0] = -0.01; mDCA[0] = 3.;
  25. mDCAGlobal[0] = -0.01; mDCAGlobal[1] = 3.;
  26. mMass = 0.139570;
  27. mTpcMomentum[0] = 0.15; mTpcMomentum[1] = 0.55;
  28. mTpcNSigmaElectron[0] = -2.; mTpcNSigmaElectron[1] = 2.;
  29. mTpcNSigmaPion[0] = -2.; mTpcNSigmaPion[1] = 2.;
  30. mTpcNSigmaKaon[0] = -2.; mTpcNSigmaKaon[1] = 2.;
  31. mTpcNSigmaProton[0] = -2.; mTpcNSigmaProton[1] = 2.;
  32. mTofMomentum[0] = 0.15; mTofMomentum[1] = 1.45;
  33. mTofMassSqr[0] = 0.2; mTofMassSqr[1] = 0.32;
  34. mTofInvBetaDiff[0] = -1e9; mTofInvBetaDiff[1] = +1e9;
  35. mTnTMomentum[0] = 0.15; mTnTMomentum[1] = 1.45;
  36. mTnTNSigmaPion[0] = -3.; mTnTNSigmaPion[1] = 3.;
  37. }
  38. //_________________
  39. gregsPionTrackCut::gregsPionTrackCut(const gregsPionTrackCut &c) : StHbtTrackCut(c) {
  40. mNTracksPassed = 0;
  41. mNTracksFailed = 0;
  42. mSelType = c.mSelType;
  43. mCharge = c.mCharge;
  44. mType = c.mType;
  45. mAntiSplit = c.mAntiSplit;
  46. mFlag[0] = c.mFlag[0]; mFlag[1] = c.mFlag[1];
  47. mNHits[0] = c.mNHits[0]; mNHits[1] = c.mNHits[1];
  48. mNHitsFit[0] = c.mNHitsFit[0]; mNHitsFit[1] = c.mNHitsFit[1];
  49. mP[0] = c.mP[0]; mP[1] = c.mP[1];
  50. mPt[0] = c.mPt[0]; mPt[1] = c.mPt[1];
  51. mPx[0] = c.mPx[0]; mPx[1] = c.mPx[1];
  52. mPy[0] = c.mPy[0]; mPy[1] = c.mPy[1];
  53. mPz[0] = c.mPz[0]; mPz[1] = c.mPz[1];
  54. mRapidity[0] = c.mRapidity[0]; mRapidity[1] = c.mRapidity[1];
  55. mEta[0] = c.mEta[0]; mEta[1] = c.mEta[1];
  56. mDCA[0] = c.mDCA[0]; mDCA[1] = c.mDCA[1];
  57. mDCAGlobal[0] = c.mDCAGlobal[0]; mDCAGlobal[1] = c.mDCAGlobal[1];
  58. mTpcMomentum[0] = c.mTpcMomentum[0]; mTpcMomentum[1] = c.mTpcMomentum[1];
  59. mTpcNSigmaElectron[0] = c.mTpcNSigmaElectron[0]; mTpcNSigmaElectron[1] = c.mTpcNSigmaElectron[1];
  60. mTpcNSigmaPion[0] = c.mTpcNSigmaPion[0]; mTpcNSigmaPion[1] = c.mTpcNSigmaPion[1];
  61. mTpcNSigmaKaon[0] = c.mTpcNSigmaKaon[0]; mTpcNSigmaKaon[1] = c.mTpcNSigmaKaon[1];
  62. mTpcNSigmaProton[0] = -c.mTpcNSigmaProton[0]; mTpcNSigmaProton[1] = c.mTpcNSigmaProton[1];
  63. mTofMomentum[0] = c.mTofMomentum[0]; mTofMomentum[1] = c.mTofMomentum[1];
  64. mTofMassSqr[0] = c.mTofMassSqr[0]; mTofMassSqr[1] = c.mTofMassSqr[1];
  65. mTofInvBetaDiff[0] = c.mTofInvBetaDiff[0]; mTofInvBetaDiff[1] = c.mTofInvBetaDiff[1];
  66. mTnTMomentum[0] = c.mTnTMomentum[0]; mTnTMomentum[1] = c.mTnTMomentum[1];
  67. mTnTNSigmaPion[0] = c.mTnTNSigmaPion[0]; mTnTNSigmaPion[1] = c.mTnTNSigmaPion[1];
  68. }
  69. //_________________
  70. gregsPionTrackCut::~gregsPionTrackCut() {
  71. /* empty */
  72. }
  73. //_________________
  74. bool gregsPionTrackCut::Pass(const StHbtTrack *track) {
  75. float mEnergy = ::sqrt(track->P().mag2() + mMass*mMass);
  76. float mY = 0.5*::log( (mEnergy+track->P().z()) / (mEnergy-track->P().z()) );
  77. bool mGoodCharge = false;
  78. bool mGoodTrack = false;
  79. bool mGoodPID = false;
  80. bool mIsTofTrack = false;
  81. float mom = track->P().mag();
  82. bool mPassTrack = false;
  83. //Check the correctness of the detector selection
  84. if(mSelType<0 || mSelType>3) {
  85. std::cout << "gregsPionTrackCut::Pass [WARNING] Wrong detector selection type"
  86. << mSelType << " . Resetting to 3" << std::endl;
  87. mSelType = 3;
  88. }
  89. //Is the right charge
  90. if(track->Charge() == mCharge) {
  91. mGoodCharge = true;
  92. }
  93. #ifdef STHBTDEBUG
  94. std::cout << "gregsPionTrackCut [DEBUG]" << std::endl
  95. << "type: " << track->TrackType()
  96. << " nHF/nHPoss: " << track->NHitsFit2PossRatio()
  97. << " p: " << track->P().mag() << " eta: " << track->Eta()
  98. << " y: " << mY << " beta: " << track->TofBeta()
  99. << " flag: " << track->Flag() <<
  100. << " dcaXYGlobal: " << track->DCAxyGlobal() << std::endl;
  101. #endif
  102. //Is the good track
  103. if( (track->TrackType() == mType) &&
  104. (track->NHitsFit2PossRatio() >= mAntiSplit) &&
  105. (track->DCAxy() >= mDCA[0]) &&
  106. (track->DCAxy() <= mDCA[1]) &&
  107. (track->DCAxyGlobal() >= mDCAGlobal[0]) &&
  108. (track->DCAxyGlobal() <= mDCAGlobal[1]) &&
  109. (track->NHits() >= mNHits[0]) &&
  110. (track->NHits() <= mNHits[1]) &&
  111. (track->NHitsFit() >= mNHitsFit[0]) &&
  112. (track->NHitsFit() <= mNHitsFit[1]) &&
  113. (mom >= mP[0]) &&
  114. (mom <= mP[1]) &&
  115. (track->Pt() >= mPt[0]) &&
  116. (track->Pt() <= mPt[1]) &&
  117. (track->P().x() >= mPx[0]) &&
  118. (track->P().x() <= mPx[1]) &&
  119. (track->P().y() >= mPy[0]) &&
  120. (track->P().y() <= mPy[1]) &&
  121. (track->P().z() >= mPz[0]) &&
  122. (track->P().z() <= mPz[1]) &&
  123. (track->Eta() >= mEta[0]) &&
  124. (track->Eta() <= mEta[1]) &&
  125. (mY >= mRapidity[0]) &&
  126. (mY <= mRapidity[1]) &&
  127. (track->Flag() >= mFlag[0]) &&
  128. (track->Flag() <= mFlag[1]) ) {
  129. mGoodTrack = true;
  130. }
  131. if(track->TofBeta() > 0) {
  132. mIsTofTrack = true;
  133. }
  134. if(mSelType == 0) { //TPC selection
  135. #ifndef TPC_DNDX
  136. if( (mom >= mTpcMomentum[0]) && (mom <= mTpcMomentum[1]) &&
  137. ( track->NSigmaPion() >= mTpcNSigmaPion[0]) && (track->NSigmaPion() <= mTpcNSigmaPion[1]) &&
  138. ( (track->NSigmaElectron() <= mTpcNSigmaElectron[0]) || (track->NSigmaElectron() >= mTpcNSigmaElectron[1]) ) &&
  139. ( (track->NSigmaKaon() <= mTpcNSigmaKaon[0]) || (track->NSigmaKaon() >= mTpcNSigmaKaon[1]) ) &&
  140. ( (track->NSigmaProton() <= mTpcNSigmaProton[0]) || (track->NSigmaProton() >= mTpcNSigmaProton[1]) ) ) {
  141. mGoodPID = true;
  142. }
  143. #else
  144. if( (track->P().mag() >= mTpcMomentum[0]) && (track->P().mag() <= mTpcMomentum[1]) &&
  145. (track->DndxNSigmaPion() >= mTpcNSigmaPion[0]) && (track->DndxNSigmaPion() <= mTpcNSigmaPion[1]) &&
  146. ( (track->DndxNSigmaElectron() <= mTpcNSigmaElectron[0]) || (track->DndxNSigmaElectron() >= mTpcNSigmaElectron[1]) ) &&
  147. ( (track->DndxNSigmaKaon() <= mTpcNSigmaKaon[0]) || (track->DndxNSigmaKaon() >= mTpcNSigmaKaon[1]) ) &&
  148. ( (track->DndxNSigmaProton() <= mTpcNSigmaProton[0]) || (track->DndxNSigmaProton() >= mTpcNSigmaProton[1]) ) ) {
  149. mGoodPID = true;
  150. }
  151. #endif
  152. }
  153. else if(mSelType == 1) { //ToF selection
  154. if( mIsTofTrack &&
  155. (track->TofMassSqr() >= mTofMassSqr[0]) && (track->TofMassSqr() <= mTofMassSqr[1]) &&
  156. (track->P().mag() >= mTofMomentum[0]) && (track->P().mag() <= mTofMomentum[1]) ) {
  157. mGoodPID = true;
  158. }
  159. }
  160. else if(mSelType == 2) { //TnT selection
  161. if( mIsTofTrack &&
  162. (track->P().mag() >= mTnTMomentum[0]) && (track->P().mag() <= mTnTMomentum[1]) &&
  163. (track->TofMassSqr() >= mTofMassSqr[0]) && (track->TofMassSqr() <= mTofMassSqr[1]) &&
  164. (track->NSigmaPion() >= mTnTNSigmaPion[0]) && (track->NSigmaPion() <= mTnTNSigmaPion[1]) ) {
  165. mGoodPID = true;
  166. }
  167. }
  168. else if(mSelType == 3) { //if(ToF signal) {TnT selection} else {TPC selection}
  169. if(mIsTofTrack) {
  170. #ifndef TPC_DNDX
  171. if( (track->P().mag() >= mTnTMomentum[0]) && (track->P().mag() <= mTnTMomentum[1]) &&
  172. (track->TofMassSqr() >= mTofMassSqr[0]) && (track->TofMassSqr() <= mTofMassSqr[1]) &&
  173. (track->NSigmaPion() >= mTnTNSigmaPion[0]) && (track->NSigmaPion() <= mTnTNSigmaPion[1]) ) {
  174. mGoodPID = true;
  175. }
  176. #else
  177. if( (track->P().mag() >= mTnTMomentum[0]) && (track->P().mag() <= mTnTMomentum[1]) &&
  178. (track->TofMassSqr() >= mTofMassSqr[0]) && (track->TofMassSqr() <= mTofMassSqr[1]) &&
  179. (track->DndxNSigmaPion() >= mTnTNSigmaPion[0]) && (track->DndxNSigmaPion() <= mTnTNSigmaPion[1]) ) {
  180. mGoodPID = true;
  181. }
  182. #endif
  183. }
  184. else {
  185. #ifndef TPC_DNDX
  186. if( (track->P().mag() >= mTpcMomentum[0]) && (track->P().mag() <= mTpcMomentum[1]) &&
  187. (track->NSigmaPion() >= mTpcNSigmaPion[0]) && (track->NSigmaPion() <= mTpcNSigmaPion[1]) &&
  188. ( (track->NSigmaElectron() <= mTpcNSigmaElectron[0]) || (track->NSigmaElectron() >= mTpcNSigmaElectron[1]) ) &&
  189. ( (track->NSigmaKaon() <= mTpcNSigmaKaon[0]) || (track->NSigmaKaon() >= mTpcNSigmaKaon[1]) ) &&
  190. ( (track->NSigmaProton() <= mTpcNSigmaProton[0]) || (track->NSigmaProton() >= mTpcNSigmaProton[1]) ) ) {
  191. mGoodPID = true;
  192. }
  193. #else
  194. if( (track->P().mag() >= mTpcMomentum[0]) && (track->P().mag() <= mTpcMomentum[1]) &&
  195. (track->DndxNSigmaPion() >= mTpcNSigmaPion[0]) && (track->DndxNSigmaPion() <= mTpcNSigmaPion[1]) &&
  196. ( (track->DndxNSigmaElectron() <= mTpcNSigmaElectron[0]) || (track->DndxNSigmaElectron() >= mTpcNSigmaElectron[1]) ) &&
  197. ( (track->DndxNSigmaKaon() <= mTpcNSigmaKaon[0]) || (track->DndxNSigmaKaon() >= mTpcNSigmaKaon[1]) ) &&
  198. ( (track->DndxNSigmaProton() <= mTpcNSigmaProton[0]) || (track->DndxNSigmaProton() >= mTpcNSigmaProton[1]) ) ) {
  199. mGoodPID = true;
  200. }
  201. #endif
  202. }
  203. } //End with PID
  204. #ifdef STHBTDEBUG
  205. std::cout << " gregsPionTrackCut::Pass() [DEBUG] "
  206. << "mGoodCharge: " << mGoodCharge << " mGoodTrack: " << mGoodTrack
  207. << " mGoodPID: " << mGoodPID << std::endl;
  208. #endif
  209. if(mGoodCharge && mGoodTrack && mGoodPID) {
  210. mPassTrack = true;
  211. mNTracksPassed++;
  212. }
  213. else {
  214. mNTracksFailed++;
  215. }
  216. return mPassTrack;
  217. }
  218. //_________________
  219. StHbtString gregsPionTrackCut::Report() {
  220. stringstream rep_str;
  221. rep_str << std::endl << "-- gregsPionTrackCut --" << std::endl
  222. << "Particle mass: " << mMass << std::endl
  223. << " Charge: " << mCharge << std::endl
  224. << mP[0] << " <= p <= " << mP[1] << std::endl
  225. << mPt[0] << " <= pT <= " << mPt[1] << std::endl
  226. << mEta[0] << " <= eta <= " << mEta[1] << std::endl
  227. << mRapidity[0] << " <= y <= " << mRapidity[1] << std::endl
  228. << mNHits[0] << " <= nHits <= " << mNHits[1] << std::endl
  229. << mNHitsFit[0] << " <= nHitsFit <= " << mNHitsFit[1] << std::endl
  230. << "nHitsFit/nHitsPoss >= " << mAntiSplit << std::endl
  231. << "Selection type = " << mSelType << std::endl
  232. << "== TPC identification info:" << std::endl
  233. << mTpcMomentum[0] << " <= p <= " << mTpcMomentum[1] << std::endl
  234. << mTpcNSigmaPion[0] << " <= nSigma(pi) <= " << mTpcNSigmaPion[1] << std::endl
  235. << "nSigma(e) <= " << mTpcNSigmaElectron[0] << " || nSigma(e) >= " << mTpcNSigmaElectron[1] << std::endl
  236. << "nSigma(K) <= " << mTpcNSigmaKaon[0] << " || nSigma(K) >= " << mTpcNSigmaKaon[1] << std::endl
  237. << "nSigma(p) <= " << mTpcNSigmaProton[0] << " || nSigma(p) >= " << mTpcNSigmaProton[1] << std::endl
  238. << "== ToF identification info:" << std::endl
  239. << mTofMomentum[0] << " <= p <= " << mTofMomentum[1] << std::endl
  240. << mTofMassSqr[0] << " <= mTofMassSqr <= " << mTofMassSqr[1] << std::endl
  241. << mTofInvBetaDiff[0] << " <= mInvBetaDiff <= " << mTofInvBetaDiff[1] << std::endl
  242. << "== TnT identification info:" << std::endl
  243. << mTnTMomentum[0] << " <= p <= " << mTnTMomentum[1] << std::endl
  244. << mTnTNSigmaPion[0] << " <= nSigma(pi) <= " << mTnTNSigmaPion[1] << std::endl
  245. << " >>> N Tracks passed: " << mNTracksPassed << std::endl
  246. << " >>> N Tracks failed: " << mNTracksFailed << std::endl;
  247. return rep_str.str();
  248. }