gregsEventCut.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. #include "StHbtMaker/Cut/gregsEventCut.h"
  2. #include <sstream>
  3. #ifdef __ROOT__
  4. ClassImp(gregsEventCut)
  5. #endif
  6. //_________________
  7. gregsEventCut::gregsEventCut() {
  8. mKLo = -1.e9;
  9. mKHi = 1.e9;
  10. mBLo = 0.;
  11. mBHi = 0.;
  12. mSphCut[0] = -1e6;
  13. mSphCut[1] = +1e6;
  14. mRPeast[0] = -1e6;
  15. mRPeast[1] = +1e6;
  16. mRPwest[0] = -1e6;
  17. mRPwest[1] = +1e6;
  18. mRefMult[0] = -1;
  19. mRefMult[1] = +1000000;
  20. mVtxX[0] = -1e9;
  21. mVtxX[1] = +1e9;
  22. mVtxY[0] = -1e9;
  23. mVtxY[1] = +1e9;
  24. mVtxZ[0] = -1e9;
  25. mVtxZ[1] = +1e9;
  26. mVtxR = 1e9;
  27. mVzVpdVzDiff[0] = -1e6;
  28. mVzVpdVzDiff[1] = +1e6;
  29. //0-p+p; 1-A+A
  30. mCollisionType = 0;
  31. mNumberOfCentralityBins = 9;
  32. mCentralityBinRange[0] = 0;
  33. mCentralityBinRange[1] = 8;
  34. mRefMultCorrUtil_curInitRunNumber = -1;
  35. mUseZdcRefMultCorr = false;
  36. mCheckBadRuns = true;
  37. //Do not forget to add: gSystem->Load("StRefMultCorr"); in the running macro
  38. //in case you want to run AuAu
  39. //The instance of the StRefMultCorr is now creating in the
  40. //gregsEventCut::SetCollisionType method.
  41. //Also you need to check the correspondence of the
  42. //centrality bin number and mNumberOfCentralityBins. There is an assert method...
  43. mVtxXShift = 0.;
  44. mVtxYShift = 0.;
  45. mNEventsPassed = mNEventsFailed = 0;
  46. }
  47. //_________________
  48. gregsEventCut::gregsEventCut(const gregsEventCut& c) : StHbtEventCut(c) {
  49. mRefMult[0] = c.mRefMult[0];
  50. mRefMult[1] = c.mRefMult[1];
  51. mVtxX[0] = c.mVtxX[0];
  52. mVtxX[1] = c.mVtxX[1];
  53. mVtxY[0] = c.mVtxY[0];
  54. mVtxY[1] = c.mVtxY[1];
  55. mVtxZ[0] = c.mVtxZ[0];
  56. mVtxZ[1] = c.mVtxZ[1];
  57. mRPeast[0] = c.mRPeast[0];
  58. mRPeast[1] = c.mRPeast[1];
  59. mRPwest[0] = c.mRPwest[0];
  60. mRPwest[1] = c.mRPwest[1];
  61. mKLo = c.mKLo;
  62. mKHi = c.mKHi;
  63. mBLo = c.mBLo;
  64. mBHi = c.mBHi;
  65. mVtxR = c.mVtxR;
  66. mVzVpdVzDiff[0] = c.mVzVpdVzDiff[0];
  67. mVzVpdVzDiff[1] = c.mVzVpdVzDiff[1];
  68. mCollisionType = c.mCollisionType;
  69. mNumberOfCentralityBins = c.mNumberOfCentralityBins;
  70. mCentralityBinRange[0] = c.mCentralityBinRange[0];
  71. mCentralityBinRange[1] = c.mCentralityBinRange[1];
  72. mCheckBadRuns = c.mCheckBadRuns;
  73. if(mCollisionType != 0) {
  74. mRefMultCorrUtil_curInitRunNumber = c.mRefMultCorrUtil_curInitRunNumber;
  75. mUseZdcRefMultCorr = c.mUseZdcRefMultCorr;
  76. }
  77. mVtxXShift = c.mVtxXShift;
  78. mVtxYShift = c.mVtxYShift;
  79. mNEventsPassed = 0;
  80. mNEventsFailed = 0;
  81. }
  82. //____________
  83. gregsEventCut::~gregsEventCut() {
  84. #ifdef STHBTDEBUG
  85. std::cout << "Event cut destructor" << std::endl;
  86. #endif
  87. if(mCollisionType != 0) {
  88. if(mRefMultCorrUtil != NULL) {
  89. delete mRefMultCorrUtil;
  90. mRefMultCorrUtil = NULL;
  91. }
  92. }
  93. #ifdef STHBTDEBUG
  94. std::cout << "Event cut is killed" << std::endl;
  95. #endif
  96. }
  97. //_________________
  98. bool gregsEventCut::Pass(const StHbtEvent* event) {
  99. //added by gnigmat
  100. #ifdef STHBTDEBUG
  101. std::cout << "gregsEventCut::Pass" << std::endl;
  102. #endif
  103. int mult = event->RefMult();
  104. int tofMult = event->TofMult();
  105. float multLo = (float)tofMult*mKLo + mBLo;
  106. float multHi = (float)tofMult*mKHi + mBHi;
  107. float vtxX = event->PrimVertPos().x();
  108. float vtxY = event->PrimVertPos().y();
  109. float vtxZ = event->PrimVertPos().z();
  110. float vtxXCorrected = vtxX - mVtxXShift;
  111. float vtxYCorrected = vtxY - mVtxYShift;
  112. float vtxR = ::sqrt(vtxXCorrected * vtxXCorrected +
  113. vtxYCorrected * vtxYCorrected);
  114. float vzVpdVzDiff = vtxZ - event->VpdVz();
  115. float sph = event->Sphericity();
  116. int mRunNumber = event->RunNumber();
  117. float rpEast = event->PsiRP1(0);
  118. float rpWest = event->PsiRP1(1);
  119. //added by gnigmat
  120. #ifdef STHBTDEBUG
  121. std::cout << "Sphericity: " << sph << std::endl;
  122. << "RefMult: " << mult << std::endl
  123. << "TofMult: " << tofMult << std::endl
  124. << "vtxX: " << vtxX
  125. << "\tvtxXCorrected: " << vtxXCorrected << std::endl
  126. << "vtxY: " << vtxY
  127. << "\tvtxYCorrected: " << vtxYCorrected << std::endl
  128. << "vtxZ: " << vtxZ
  129. <<"\tvtxR: " << vtxR
  130. << "\tvzVpdDiff: " <<vzVpdVzDiff
  131. << "\tCollisionType: " << mCollisionType << std::endl;
  132. #endif
  133. bool mGoodEvent = false;
  134. bool mGoodPrimVtx = false;
  135. bool mGoodRefMult = false;
  136. bool mIsBadRun = false;
  137. int mCentBin = mNumberOfCentralityBins == 9 ? event->Cent9() : event->Cent16();
  138. if(mCollisionType==0) { //mCollisionType=0 - pp collisions
  139. if (mCheckBadRuns)
  140. {
  141. mIsBadRun = isOnList(mRunNumber, pp_bad_run_list_200GeV, sizeof(pp_bad_run_list_200GeV)/sizeof(pp_bad_run_list_200GeV[0]));
  142. if (mIsBadRun) return false;
  143. }
  144. mGoodPrimVtx = ((vtxXCorrected >= mVtxX[0]) &&
  145. (vtxXCorrected <= mVtxX[1]) &&
  146. (vtxYCorrected >= mVtxY[0]) &&
  147. (vtxYCorrected <= mVtxY[1]) &&
  148. (vtxZ >= mVtxZ[0]) && (vtxZ <= mVtxZ[1]) &&
  149. (vtxR <= mVtxR) &&
  150. (vzVpdVzDiff >= mVzVpdVzDiff[0]) &&
  151. (vzVpdVzDiff <= mVzVpdVzDiff[1]) &&
  152. (mult <= multHi) &&
  153. (mult >= multLo) &&
  154. (mSphCut[0] < sph && sph <= mSphCut[1]) &&
  155. (mRPeast[0] < rpEast && mRPeast[1] > rpEast) &&
  156. (mRPwest[0] < rpWest && mRPwest[1] > rpWest));
  157. mGoodRefMult = ( (mult >= mRefMult[0]) && (mult<= mRefMult[1]) );
  158. //Main decision
  159. if(mGoodPrimVtx && mGoodRefMult) {
  160. mGoodEvent = true;
  161. }
  162. else { //This is not needed but it's easy to check
  163. mGoodEvent = false;
  164. }
  165. }
  166. else { //mCollisionType=1 - AuAu
  167. mGoodPrimVtx = ( (vtxZ >= mVtxZ[0]) && (vtxZ <= mVtxZ[1]) &&
  168. (vtxR <= mVtxR) &&
  169. (vzVpdVzDiff >= mVzVpdVzDiff[0]) &&
  170. (vzVpdVzDiff <= mVzVpdVzDiff[1]) );
  171. //If primary vertex is good then we try to
  172. //check bad runs and centrality bin
  173. if(mGoodPrimVtx) {
  174. if (event->IsSimulation()) {
  175. //
  176. // Temporary stub
  177. //
  178. mGoodRefMult = true;
  179. }
  180. else {
  181. mIsBadRun = ( isOnList( mRunNumber, bad_run_list_7GeV, n_bad_run_numbers[0] ) ||
  182. isOnList( mRunNumber, bad_run_list_11GeV, n_bad_run_numbers[1] ) ||
  183. isOnList( mRunNumber, bad_run_list_19GeV, n_bad_run_numbers[2] ) ||
  184. isOnList( mRunNumber, bad_run_list_27GeV, n_bad_run_numbers[3] ) ||
  185. isOnList( mRunNumber, bad_run_list_39GeV, n_bad_run_numbers[4] ) ||
  186. isOnList( mRunNumber, bad_run_list_62GeV, n_bad_run_numbers[5] ) ||
  187. isOnList( mRunNumber, bad_run_list_200GeV, n_bad_run_numbers[6] ) );
  188. if (!mIsBadRun) {
  189. mGoodRefMult = ( (mCentBin >= mCentralityBinRange[0]) &&
  190. (mCentBin <= mCentralityBinRange[1]) );
  191. }
  192. } // if (event->IsSimulation())
  193. } //if(mGoodPrimVtx)
  194. //Main decision
  195. if(mGoodPrimVtx && mGoodRefMult) {
  196. mGoodEvent = true;
  197. }
  198. else {
  199. mGoodEvent = false;
  200. }
  201. } //else for if(mCollisionType==0)
  202. mGoodEvent ? mNEventsPassed++ : mNEventsFailed++;
  203. return (mGoodEvent);
  204. }
  205. //_________________
  206. string gregsEventCut::Report() {
  207. stringstream rep_stream;
  208. if(mCollisionType==0) {
  209. rep_stream << mRefMult[0] << " <= Multiplicity <= " << mRefMult[1]
  210. << std::endl;
  211. }
  212. else {
  213. rep_stream << mCentralityBinRange[0] << " <= CentralityBin <= "
  214. << mCentralityBinRange[1] << std::endl;
  215. }
  216. rep_stream << mVtxX[0] << " <= VertexX <= " << mVtxX[1] << std::endl
  217. << mVtxY[0] << " <= VertexY <= " << mVtxY[1] << std::endl
  218. << mVtxZ[0] << " <= VertexZ <= " << mVtxZ[1] << std::endl
  219. << "VtxXShift: " << mVtxXShift << "\tVtxYShift: "
  220. << mVtxYShift << std::endl
  221. << "Vertex R <= " << mVtxR << std::endl
  222. << mVzVpdVzDiff[0] << " <= VpdVzDifference <= "
  223. << mVzVpdVzDiff[1] << std::endl
  224. << "Number of events passed: " << mNEventsPassed << std::endl
  225. << "Number of events failed: " << mNEventsFailed << std::endl;
  226. return ( rep_stream.str() );
  227. }
  228. //_________________
  229. Bool_t gregsEventCut::isOnList(int runNumber, const Int_t *list, int listSize) {
  230. for(Int_t iSize=0; iSize<listSize; iSize++) {
  231. if(list[iSize] == runNumber) {
  232. return true;
  233. }
  234. }
  235. return false;
  236. }
  237. //_________________
  238. void gregsEventCut::SetTofVsRef(float kLo, float kHi, float bLo, float bHi)
  239. {
  240. mKLo = kLo;
  241. mKHi = kHi;
  242. mBLo = bLo;
  243. mBHi = bHi;
  244. }
  245. //_________________
  246. const Int_t gregsEventCut::n_bad_run_numbers[7] = {328,27,38,105,35,34,219};
  247. //_________________
  248. const Int_t gregsEventCut::bad_run_list_7GeV[328] = {11114084,11114085,11114086,11114088,11114089,11114094,
  249. 11114095,11114100,11114109,11115005,11115007,11115013,
  250. 11115019,11115025,11115027,11115028,11115030,11115032,
  251. 11115051,11115062,11115064,11115069,11115072,11115078,
  252. 11115079,11115080,11115086,11115088,11115094,11116001,
  253. 11116002,11116005,11116006,11116010,11116014,11116020,
  254. 11116023,11116028,11116060,11116061,11116062,11116064,
  255. 11116068,11116070,11116072,11116073,11116075,11117002,
  256. 11117006,11117031,11117033,11117034,11117036,11117039,
  257. 11117044,11117045,11117046,11117052,11117055,11117063,
  258. 11117064,11117071,11117075,11117085,11117088,11117089,
  259. 11117090,11117093,11117094,11117095,11117098,11117100,
  260. 11117103,11117104,11117107,11118007,11118008,11118016,11118024,11118025,11118026,11118039,11118044,
  261. 11119001,11119003,11119006,11119007,11119009,11119012,11119013,11119015,11119016,11119017,11119022,
  262. 11119024,11119026,11119029,11119030,11119056,11119057,11119060,11119062,11119067,11119069,11119070,
  263. 11119071,11119074,11119075,11119077,11119079,11119081,11119090,11119091,11119100,11119101,11120003,
  264. 11120006,11120008,11120011,11120014,11120019,11120023,11120030,11120034,11120037,11120039,11120040,
  265. 11120045,11120052,11120057,11120062,11120063,11120069,11120070,11120071,11120074,11120077,11120078,
  266. 11120084,11120092,11121006,11121014,11121015,11121019,11121029,11121030,11121034,11121035,11121043,
  267. 11121044,11121054,11121058,11121066,11121067,11121070,11121075,11121082,11122001,11122007,11122008,
  268. 11122010,11122017,11122024,11122037,11122038,11122047,11122048,11122049,11122050,11122053,11122058,
  269. 11122062,11122069,11122073,11122078,11122085,11122097,11123003,11123004,11123015,11123026,11123028,
  270. 11123040,11123044,11123055,11123057,11123058,11123059,11123067,11123075,11123076,11123077,11123079,
  271. 11123081,11123084,11123086,11123088,11123089,11123093,11123094,11123095,11123100,11123101,11123102,
  272. 11123104,11124001,11124005,11124007,11124008,11124015,11124016,11124018,11124041,11124046,11124050,
  273. 11124051,11124052,11124053,11124058,11124060,11124061,11124062,11124063,11124064,11124065,11124066,
  274. 11124069,11125002,11125003,11125004,11125005,11125006,11125008,11125012,11125013,11125014,11125015,
  275. 11125016,11125017,11125020,11125021,11125022,11125023,11125073,11125081,11125089,11125090,11125096,
  276. 11125097,11126005,11126006,11126007,11126016,11126018,11126022,11126023,11127001,11127002,11127043,
  277. 11128005,11128012,11128018,11128050,11128056,11128072,11129018,11129022,11129028,11129051,11130027,
  278. 11130034,11130057,11131038,11131062,11132013,11132070,11133006,11133019,11134053,11134060,11134067,
  279. 11134076,11135068,11136003,11136005,11136006,11136007,11136008,11136012,11136013,11136014,11136061,
  280. 11136076,11136101,11136130,11136160,11136163,11137019,11138027,11138049,11138086,11138124,11139014,
  281. 11140076,11140086,11141063,11142117,11143026,11143028,11144001,11144009,11144031,11144033,11144040,
  282. 11144043,11144052,11145008,11145028,11145035,11146061,11146076,11146079,11147004,11147006,11147014,
  283. 11147017,11147021,11147023};
  284. //_________________
  285. const Int_t gregsEventCut::bad_run_list_11GeV[27] = {11148039,11148045,11149001,11149008,11149010,11149011,11149015,11149047,11150016,11150025,11150028,
  286. 11151036,11151040,11151050,11152016,11152036,11152078,11153032,11153042,11155001,11155009,11156003,
  287. 11156009,11157012,11158006,11158022,11158024};
  288. //_________________
  289. const Int_t gregsEventCut::bad_run_list_19GeV[35] = {12113091,12114007,12114035,12114078,12114092,12114116,12115009,12115014,12115015,12115016,12115018,
  290. 12115019,12115020,12115022,12115023,12115062,12115073,12115093,12115094,12116012,12116054,12117010,
  291. 12117016,12117020,12117065,12119040,12119042,12120017,12120026,12121017,12121022,12121034,12121050,
  292. 12121067,12122019};
  293. //_________________
  294. const Int_t gregsEventCut::bad_run_list_27GeV[34] = {12172050,12172051,12172055,12173030,12173031,12173032,12173033,12173034,12174067,12174085,12175062,
  295. 12175087,12175113,12175114,12175115,12176001,12176044,12176054,12176071,12177015,12177061,12177092,
  296. 12177099,12177101,12177106,12177107,12177108,12178003,12178004,12178005,12178006,12178013,12178099,
  297. 12178120};
  298. //_________________
  299. const Int_t gregsEventCut::bad_run_list_39GeV[38] = {11199124,11100002,11100045,11101046,11102012,11102051,11102052,11102053,11102054,11102055,11102058,
  300. 11103035,11103056,11103058,11103092,11103093,11105052,11105053,11105054,11105055,11107007,11107042,
  301. 11107057,11107061,11107065,11107074,11108101,11109013,11109077,11109088,11109090,11109127,11110013,
  302. 11110034,11110073,11110076,11111084,11111085};
  303. //_________________
  304. const Int_t gregsEventCut::bad_run_list_62GeV[105] = {11080072,11081023,11081025,11082012,11082013,11082046,11082056,11082057,11084009,11084011,11084012,
  305. 11084013,11084020,11084021,11084035,11084044,11084064,11085015,11085025,11085030,11085046,11085055,
  306. 11085056,11085057,11086005,11086007,11087001,11087002,11087003,11087004,11088013,11089026,11089028,
  307. 11089029,11089055,11089068,11089072,11091007,11091015,11091021,11091078,11092010,11092011,11092012,
  308. 11092032,11092033,11092034,11092067,11092096,11093001,11094016,11094017,11094018,11094019,11094020,
  309. 11094021,11094022,11094023,11094024,11094027,11094028,11094042,11094044,11094045,11094046,11094047,
  310. 11094048,11094050,11094051,11094052,11094053,11094054,11094055,11094074,11094075,11094077,11095001,
  311. 11095002,11095003,11095004,11095005,11095006,11095009,11095010,11095011,11095012,11095013,11095014,
  312. 11095015,11095022,11095040,11095048,11095050,11095051,11095061,11095062,11095063,11095064,11095082,
  313. 11095087,11096024,11096039,11096043,11096044,11097093};
  314. //_________________
  315. const Int_t gregsEventCut::bad_run_list_200GeV[219] = { 11002120, 11002121, 11002126, 11002127, 11002129, 11003010, 11003011, 11003101, 11003102, 11004007,
  316. 11004008, 11004009, 11004010, 11004011, 11004012, 11004013, 11004014, 11004015, 11004016, 11004018,
  317. 11004020, 11004021, 11004023, 11004024, 11004025, 11004026, 11004028, 11004029, 11004030, 11004032,
  318. 11004033, 11004034, 11004035, 11004037, 11004038, 11005042, 11006004, 11006005, 11006008, 11007015,
  319. 11010031, 11011019, 11011053, 11015069, 11015071, 11016024, 11017006, 11018003, 11018007, 11018008,
  320. 11018036, 11019001, 11019080, 11019081, 11021027, 11021028, 11021031, 11023048, 11025034, 11025038,
  321. 11025054, 11025067, 11025069, 11026005, 11026008, 11026021, 11026022, 11026023, 11026025, 11026067,
  322. 11026068, 11028004, 11028005, 11028006, 11028007, 11028008, 11028009, 11028010, 11028011, 11028012,
  323. 11028013, 11028018, 11028019, 11028020, 11028021, 11028022, 11028023, 11028024, 11028025, 11028026,
  324. 11028027, 11030041, 11030080, 11031061, 11031064, 11035008, 11035009, 11035072, 11036026, 11037035,
  325. 11037037, 11037060, 11037066, 11037067, 11038048, 11038049, 11038050, 11039047, 11039067, 11040078,
  326. 11040083, 11041022, 11041023, 11041040, 11041041, 11042001, 11042002, 11042003, 11042004, 11042005,
  327. 11042006, 11042007, 11042008, 11042011, 11042012, 11042018, 11042019, 11042020, 11042021, 11042022,
  328. 11042023, 11042024, 11042025, 11042026, 11042027, 11042042, 11042043, 11042044, 11042045, 11042046,
  329. 11042047, 11042048, 11042049, 11044029, 11047059, 11047065, 11047066, 11047067, 11048037, 11049001,
  330. 11049002, 11049005, 11049023, 11051038, 11051049, 11051051, 11051055, 11051063, 11051064, 11051068,
  331. 11052011, 11053057, 11054021, 11054022, 11054024, 11054059, 11054062, 11054066, 11057012, 11057035,
  332. 11057036, 11058005, 11058050, 11058083, 11059043, 11059055, 11059060, 11059075, 11059076, 11059077,
  333. 11060008, 11060049, 11060059, 11060069, 11060076, 11061008, 11061009, 11061021, 11061034, 11061037,
  334. 11061038, 11061095, 11063006, 11063007, 11063008, 11063011, 11063013, 11063014, 11063015, 11063016,
  335. 11063017, 11063036, 11063083, 11064003, 11064023, 11065038, 11066024, 11066045, 11071056, 11072032,
  336. 11072044, 11072045, 11073001, 11073002, 11073003, 11073049, 11075039, 11075045, 11075048};
  337. const Int_t gregsEventCut::pp_bad_run_list_200GeV[11] = {13044118,13047055,13049007,13049052,13049075,13052063,13054046,13054057,13057038,13058047,13058048};