gregsProtonTrackCut.cxx 11 KB

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