gregsSimpleTrackCut.cxx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. #include "StHbtMaker/Cut/gregsSimpleTrackCut.h"
  2. #include <sstream>
  3. #ifdef __ROOT__
  4. ClassImp(gregsSimpleTrackCut)
  5. #endif
  6. //_________________
  7. gregsSimpleTrackCut::gregsSimpleTrackCut() {
  8. mNTracksPassed = mNTracksFailed = 0;
  9. mTnTNSigmaElectron[0] = -1e9; mTnTNSigmaElectron[1] = +1e9;
  10. mTnTNSigmaPion[0] = -1e9; mTnTNSigmaPion[1] = +1e9;
  11. mTnTNSigmaKaon[0] = -1e9; mTnTNSigmaKaon[1] = +1e9;
  12. mTnTNSigmaProton[0]= -1e9; mTnTNSigmaProton[1]= +1e9;
  13. mEta[0] = -1e9; mEta[1] = +1e9;
  14. mRapidity[0] = -1e9; mRapidity[1] = +1e9;
  15. mP[0] = -1e9; mP[1] = +1e9;
  16. mPt[0] = -1e9; mPt[1] = +1e9;
  17. mPx[0] = -1e9; mPx[1] = +1e9;
  18. mPy[0] = -1e9; mPy[1] = +1e9;
  19. mPz[0] = -1e9; mPz[1] = +1e9;
  20. mDCA[0] = -1e9; mDCA[1] = +1e9;
  21. mFlag[0] = 0; mFlag[1] = 1000;
  22. mDCAGlobal[0] = -1e9; mDCAGlobal[1] = +1e9;
  23. mNHits[0] = 0; mNHits[1] = 60;
  24. mNHitsFit[0] = 0; mNHitsFit[1] = 60;
  25. mNdEdxHits[0] = 0; mNdEdxHits[1] = 60;
  26. mAntiSplit = 0.;
  27. mCharge = 0;
  28. mType = 1; //0-global, 1-primary
  29. //TPC identification
  30. mTpcMomentum[0]=0.; mTpcMomentum[1]=+1e9;
  31. mNSigmaElectron[0] = -1e9; mNSigmaElectron[1] = +1e9;
  32. mNSigmaPion[0] = -1e9; mNSigmaPion[1] = +1e9;
  33. mNSigmaKaon[0] = -1e9; mNSigmaKaon[1] = +1e9;
  34. mNSigmaProton[0] = -1e9; mNSigmaProton[1] = +1e9;
  35. //TOF identification
  36. mTofMassSqr[0] = -1e9; mTofMassSqr[1] = +1e9;
  37. mTofMomentum[0] = 0.; mTofMomentum[1] = +1e9;
  38. //TPC&&TOF
  39. mTnTMomentum[0]=0.; mTnTMomentum[1]=+1e9;
  40. mTnTNSigmaElectron[0]=-1e9; mTnTNSigmaElectron[1]=+1e9;
  41. mTnTNSigmaPion[0]=-1e9; mTnTNSigmaPion[1]=+1e9;
  42. mTnTNSigmaKaon[0]=-1e9; mTnTNSigmaKaon[1]=+1e9;
  43. mTnTNSigmaProton[0]=-1e9; mTnTNSigmaProton[1]=+1e9;
  44. //TPC&&TOF (P>Pthresh) || TPC (P<Pthresh)
  45. mTTTMomentumThresh = 0.4;
  46. mDetSelection = 3; // 0-TPC, 1-ToF, 2-TPC+ToF, 3-ToF||TPC, 4-TPC&&TOF(P>Pthr)||TPC(P<Pthr)
  47. }
  48. //_________________
  49. gregsSimpleTrackCut::gregsSimpleTrackCut(const gregsSimpleTrackCut &c) : StHbtTrackCut(c) {
  50. mNTracksPassed = mNTracksFailed = 0;
  51. mCharge = c.mCharge;
  52. mType = c.mType;
  53. mAntiSplit = c.mAntiSplit;
  54. mFlag[0] = c.mFlag[0]; mFlag[1] = c.mFlag[1];
  55. mNHits[0] = c.mNHits[0]; mNHits[1] = c.mNHits[1];
  56. mNHitsFit[0] = c.mNHitsFit[0]; mNHitsFit[1] = c.mNHitsFit[1];
  57. mNdEdxHits[0] = c.mNdEdxHits[0]; mNdEdxHits[1] = c.mNdEdxHits[1];
  58. mP[0] = c.mP[0]; mP[1] = c.mP[1];
  59. mPt[0] = c.mPt[0]; mPt[1] = c.mPt[1];
  60. mPx[0] = c.mPx[0]; mPx[1] = c.mPx[1];
  61. mPy[0] = c.mPy[0]; mPy[1] = c.mPy[1];
  62. mPz[0] = c.mPz[0]; mPz[1] = c.mPz[1];
  63. mRapidity[0] = c.mRapidity[0]; mRapidity[1] = c.mRapidity[1];
  64. mEta[0] = c.mEta[0]; mEta[1] = c.mEta[1];
  65. mDCA[0] = c.mDCA[0]; mDCA[1] = c.mDCA[1];
  66. mDCAGlobal[0] = c.mDCAGlobal[0]; mDCAGlobal[1] = c.mDCAGlobal[1];
  67. mDetSelection = c.mDetSelection;
  68. //TPC identification
  69. mTpcMomentum[0] = c.mTpcMomentum[0]; mTpcMomentum[1] = c.mTpcMomentum[1];
  70. mNSigmaElectron[0] = c.mNSigmaElectron[0]; mNSigmaElectron[1] = c.mNSigmaElectron[1];
  71. mNSigmaPion[0] = c.mNSigmaPion[0]; mNSigmaPion[1] = c.mNSigmaPion[1];
  72. mNSigmaKaon[0] = c.mNSigmaKaon[0]; mNSigmaKaon[1] = c.mNSigmaKaon[1];
  73. mNSigmaProton[0] = c.mNSigmaProton[0]; mNSigmaProton[1] = c.mNSigmaProton[1];
  74. //TOF identification
  75. mTofMomentum[0] = c.mTofMomentum[0]; mTofMomentum[1] = c.mTofMomentum[1];
  76. mTofMassSqr[0] = c.mTofMassSqr[0]; mTofMassSqr[1] = c.mTofMassSqr[1];
  77. //TPC&&TOF
  78. mTnTMomentum[0] = c.mTnTMomentum[0]; mTnTMomentum[1] = c.mTnTMomentum[1];
  79. mTnTNSigmaElectron[0] = c.mTnTNSigmaElectron[0]; mTnTNSigmaElectron[1] = c.mTnTNSigmaElectron[1];
  80. mTnTNSigmaPion[0] = c.mTnTNSigmaPion[0]; mTnTNSigmaPion[1] = c.mTnTNSigmaPion[1];
  81. mTnTNSigmaKaon[0] = c.mTnTNSigmaKaon[0]; mTnTNSigmaKaon[1] = c.mTnTNSigmaKaon[1];
  82. mTnTNSigmaProton[0] = c.mTnTNSigmaProton[0]; mTnTNSigmaProton[1] = c.mTnTNSigmaProton[1];
  83. //TPC&&TOF (P>Pthresh) || TPC (P<Pthresh)
  84. mTTTMomentumThresh = c.mTTTMomentumThresh;
  85. }
  86. //_________________
  87. gregsSimpleTrackCut::~gregsSimpleTrackCut() {
  88. /* empty */
  89. }
  90. //_________________
  91. bool gregsSimpleTrackCut::Pass(const StHbtTrack *track) {
  92. //mMass has to be set in the macros and defined in the base class
  93. float tEnergy = ::sqrt(track->P().mag2() + mMass*mMass);
  94. float tRapidity = 0.5*::log( (tEnergy+track->P().z())/(tEnergy-track->P().z()) );
  95. float tPseudoRap = 0.5*::log( (track->P().mag()+track->P().z())/(track->P().mag()-track->P().z()) );
  96. float tAntiSplit = (float)track->NHitsFit()/track->NHitsPossible();
  97. //Main patterns
  98. bool mGoodCharge = false;
  99. bool mGoodTrack = false;
  100. bool mGoodTpcPID = false;
  101. bool mGoodTofPID = false;
  102. bool mGoodToTPID = false;
  103. bool mGoodTnTPID = false;
  104. bool mGoodTTTPID = false;
  105. bool mGoodPID = false;
  106. bool mPassTrack = false;
  107. if(mDetSelection<0 || mDetSelection>4) {
  108. std::cout << "gregsSimpleTrackCut::Pass[WARNING] Wrong detector selection type: "
  109. << mDetSelection << " . Resetting to 3" << std::endl;
  110. }
  111. //If is right charge
  112. mGoodCharge = (track->Charge() == mCharge);
  113. //If is normal track
  114. mGoodTrack = ( (track->TrackType() == mType) &&
  115. (tAntiSplit >= mAntiSplit ) &&
  116. (track->DCAxy() >= mDCA[0]) && (track->DCAxy() <= mDCA[1]) &&
  117. (track->DCAxyGlobal() >= mDCAGlobal[0]) && (track->DCAxyGlobal() <= mDCAGlobal[1]) &&
  118. (track->NHits() >= mNHits[0]) && (track->NHits() <= mNHits[1]) &&
  119. (track->NHitsFit() >= mNHitsFit[0]) && (track->NHitsFit() <= mNHitsFit[1]) &&
  120. (track->NHitsDedx() >= mNdEdxHits[0]) && (track->NHitsDedx() <= mNdEdxHits[1]) &&
  121. (track->P().mag() >= mP[0]) && (track->P().mag() <= mP[1]) &&
  122. (track->Pt() >= mPt[0]) && (track->Pt() <= mPt[1]) &&
  123. (track->P().x() >= mPx[0]) && (track->P().x() <= mPx[1]) &&
  124. (track->P().y() >= mPy[0]) && (track->P().y() <= mPy[1]) &&
  125. (track->P().z() >= mPz[0]) && (track->P().z() <= mPz[1]) &&
  126. (tPseudoRap >= mEta[0]) && (tPseudoRap <= mEta[1]) &&
  127. (tRapidity >= mRapidity[0]) && (tRapidity <= mRapidity[1]) &&
  128. (track->Flag() >= mFlag[0]) && (track->Flag() <= mFlag[1])
  129. );
  130. //If is good TPC identification: TPC nSigma always smaller the nTofNSigma
  131. mGoodTpcPID = ( (track->NSigmaElectron() >= mNSigmaElectron[0]) &&
  132. (track->NSigmaElectron() <= mNSigmaElectron[1]) &&
  133. (track->NSigmaPion() >= mNSigmaPion[0]) &&
  134. (track->NSigmaPion() <= mNSigmaPion[1]) &&
  135. (track->NSigmaKaon() >= mNSigmaKaon[0]) &&
  136. (track->NSigmaKaon() <= mNSigmaKaon[1]) &&
  137. (track->NSigmaProton() >= mNSigmaProton[0]) &&
  138. (track->NSigmaProton() <= mNSigmaProton[1]) &&
  139. (track->P().mag() >= mTpcMomentum[0]) &&
  140. (track->P().mag() <= mTpcMomentum[1])
  141. );
  142. //If is good TOF identification (in case when the TOF hit does exist)
  143. if(track->TofBeta() > 0) {
  144. mGoodTofPID = ( (track->TofMassSqr() >= mTofMassSqr[0]) &&
  145. (track->TofMassSqr() <= mTofMassSqr[1]) &&
  146. (track->P().mag() >= mTofMomentum[0]) &&
  147. (track->P().mag() <= mTofMomentum[1])
  148. );
  149. }
  150. //TOF identification (if ToF hit), and TPC (if no ToF hit)
  151. if(track->TofBeta() > 0) {
  152. mGoodToTPID = mGoodTofPID;
  153. }
  154. else {
  155. mGoodToTPID = mGoodTpcPID;
  156. }
  157. //TPC&&TOF identification
  158. mGoodTnTPID = ( (track->TofBeta() > 0) &&
  159. (track->NSigmaElectron() >= mTnTNSigmaElectron[0]) &&
  160. (track->NSigmaElectron() <= mTnTNSigmaElectron[1]) &&
  161. (track->NSigmaPion() >= mTnTNSigmaPion[0]) &&
  162. (track->NSigmaPion() <= mTnTNSigmaPion[1]) &&
  163. (track->NSigmaKaon() >= mTnTNSigmaKaon[0]) &&
  164. (track->NSigmaKaon() <= mTnTNSigmaKaon[1]) &&
  165. (track->NSigmaProton() >= mTnTNSigmaProton[0]) &&
  166. (track->NSigmaProton() <= mTnTNSigmaProton[1]) &&
  167. (track->TofMassSqr() >= mTofMassSqr[0]) &&
  168. (track->TofMassSqr() <= mTofMassSqr[1]) &&
  169. (track->P().mag() >= mTnTMomentum[0]) &&
  170. (track->P().mag() <= mTnTMomentum[1])
  171. );
  172. //TPC&&TOF (P>Pthresh) || TPC (P<Pthresh)
  173. if( (track->P().mag() >= mTTTMomentumThresh) &&
  174. (track->P().mag() <= mTofMomentum[1]) ) {
  175. if(track->TofBeta() > 0) {
  176. mGoodTTTPID = mGoodTnTPID;
  177. }
  178. }
  179. else if( (track->P().mag() >= mTpcMomentum[0]) &&
  180. (track->P().mag() < mTTTMomentumThresh) ){
  181. mGoodTTTPID = mGoodTpcPID;
  182. }
  183. //Detector selection criteria
  184. switch(mDetSelection) {
  185. case 0: //TPC only
  186. if(mGoodTpcPID == 1) {
  187. mGoodPID = true;
  188. }
  189. break;
  190. case 1: //ToF only
  191. if(mGoodTofPID == 1) {
  192. mGoodPID = true;
  193. }
  194. break;
  195. case 2: //TPC && ToF
  196. if(mGoodTnTPID == 1) {
  197. mGoodPID = true;
  198. }
  199. break;
  200. case 3: //ToF, if no ToF signal then use TPC
  201. if(mGoodToTPID == 1) {
  202. mGoodPID = true;
  203. }
  204. break;
  205. case 4:
  206. if(mGoodTTTPID) {
  207. mGoodPID = true;
  208. }
  209. break;
  210. default:
  211. if(mGoodToTPID) {
  212. mGoodPID = true;
  213. }
  214. break;
  215. };
  216. if(mGoodCharge && mGoodTrack && mGoodPID) {
  217. mPassTrack = true;
  218. mNTracksPassed++;
  219. }
  220. else {
  221. mNTracksFailed++;
  222. }
  223. return mPassTrack;
  224. }
  225. //_________________
  226. StHbtString gregsSimpleTrackCut::Report() {
  227. stringstream rep_str;
  228. rep_str << std::endl << "-- gregsSimpleTrackCut --" << std::endl
  229. << "Charge: " << mCharge << std::endl
  230. << "Selection type = " << mDetSelection << std::endl
  231. << "TPC identification:" << std::endl
  232. << mTpcMomentum[0] << " <= mTpcMomentum <= " << mTpcMomentum[1] << std::endl
  233. << mNSigmaElectron[0] << " <= nSigma(e) <= " << mNSigmaElectron[1] << std::endl
  234. << mNSigmaPion[0] << " <= nSigma(pi) <= " << mNSigmaPion[1] << std::endl
  235. << mNSigmaKaon[0] << " <= nSigma(K) <= " << mNSigmaKaon[1] << std::endl
  236. << mNSigmaProton[0] << " <= nSigma(p) <= " << mNSigmaProton[1] << std::endl
  237. << "TOF identification: " << std::endl
  238. << mTofMomentum[0] << " <= mTofMomentum <= " << mTofMomentum[1] << std::endl
  239. << mTofMassSqr[0] << " <= mTofMassSqr <= " << mTofMassSqr[1] << std::endl
  240. << "TnT identification: " << std::endl
  241. << mTnTMomentum[0] << " <= mTnTMomentum <= " << mTnTMomentum[1] << std::endl
  242. << mTnTNSigmaElectron[0] << " <= nTnTSigma(e) <= " << mTnTNSigmaElectron[1] << std::endl
  243. << mTnTNSigmaPion[0] << " <= nTnTSigma(pi) <= " << mTnTNSigmaPion[1] << std::endl
  244. << mTnTNSigmaKaon[0] << " <= nTnTSigma(K) <= " << mTnTNSigmaKaon[1] << std::endl
  245. << mTnTNSigmaProton[0] << " <= nTnTSigma(p) <= " << mTnTNSigmaProton[1] << std::endl
  246. << "TPC&TOF || TPC: " << std::endl
  247. << "Pthreshold = " << mTTTMomentumThresh << std::endl
  248. << "Genereal cut values:" << std::endl
  249. << mNHits[0] << " <= NHits <= " << mNHits[1] << std::endl
  250. << mNHitsFit[0] << " <= NHitsFit <= " << mNHitsFit[1] << std::endl
  251. << mNdEdxHits[0] << " <= NHits <= " << mNdEdxHits[1] << std::endl
  252. << mPt[0] << " <= pT <= " << mPt[1] << std::endl
  253. << mP[0] << " <= p <= " << mP[1] << std::endl
  254. << mRapidity[0] << " <= Rapidity <= " << mRapidity[1] << std::endl
  255. << mEta[0] << " <= PseudoRapidity <= " << mEta[1] << std::endl
  256. << "nHitsFit/nHitsPoss >= " << mAntiSplit << std::endl
  257. << " >>> N Tracks passed: " << mNTracksPassed << std::endl
  258. << " >>> N Tracks failed: " << mNTracksFailed << std::endl;
  259. return ( rep_str.str() );
  260. }