StFemtoDstMaker.cxx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. #include "StFemtoDstMaker.h"
  2. #include "StBTofHeader.h"
  3. #include "TBranch.h"
  4. #include "StPhysicalHelixD.hh"
  5. #include "StDcaGeometry.h"
  6. ClassImp(StFemtoDstMaker)
  7. //
  8. // Set maximum file size to 1.9 GB (Root has a 2GB limit)
  9. //
  10. #define MAXFILESIZE 1900000000
  11. //_________________
  12. StFemtoDstMaker::StFemtoDstMaker(StMuDstMaker *muMaker,
  13. const char *calibPath,
  14. const Char_t *oFileName) {
  15. std::cout << "StFemtoDstMaker::StFemtoDstMaker - Creating an instance...";
  16. mAcceptTriggerFail = 0;
  17. mRefMultFail = 0;
  18. mAntiPileupFail = 0;
  19. mRankingFail = 0;
  20. mVtxNullFail = 0;
  21. mNPrimVtxFail = 0;
  22. mAcceptPrimVtxFail = 0;
  23. matrix = new TMatrixTSym<double>(2);
  24. mPtCut = 0.1;
  25. mOutFileName = oFileName;
  26. mMuDstMaker = muMaker;
  27. mRefMultCorrUtil = NULL;
  28. mCompression = 9;
  29. mCollisionType = false; // 0-pp, 1-AuAu
  30. mEventIsGood = false;
  31. mNEventsIn = 0;
  32. mNEventsPassed = 0;
  33. mAuAuCorrectZdc = true;
  34. mIsGoodTrack = false;
  35. mCurrentTrigger = 0;
  36. mCalibPath = calibPath;
  37. //
  38. // Default cut values
  39. //
  40. // initialize event cut variables
  41. mPrimVtxZ[0] = -70.;
  42. mPrimVtxZ[1] = 70.;
  43. mPrimVtxR[0] = -1.;
  44. mPrimVtxR[1] = 10.;
  45. mPrimVtxVpdVzDiff[0] = -10.;
  46. mPrimVtxVpdVzDiff[1]= 10.;
  47. mPrimVtxXShift = 0.;
  48. mPrimVtxYShift = 0.;
  49. // initialize single-particle cut variables
  50. mTrackMomentum[0] = 0.1;
  51. mTrackMomentum[1] = 2.;
  52. mTrackDca[0] = 0.;
  53. mTrackDca[1] = 5.;
  54. mTrackDcaGlobal[0] = 0.;
  55. mTrackDcaGlobal[1] = 5.;
  56. mTrackNHits[0] = 15;
  57. mTrackNHits[1] = 50;
  58. mTrackNHitsFit[0] = 15;
  59. mTrackNHitsFit[1] = 50;
  60. mTrackEta[0] = -1.1;
  61. mTrackEta[1] = 1.1;
  62. mTrackFlag[0] = 0;
  63. mTrackFlag[1] = 1000;
  64. // flags and cuts for exclusion
  65. mRemovePions = false;
  66. mRemoveKaons = false;
  67. mRemoveProtons = false;
  68. mPthresh = 0.4;
  69. mTpcPionNSigma[0] = -1.5;
  70. mTpcPionNSigma[1] = 1.5;
  71. mTofPionMassSqr[0] = -0.1;
  72. mTofPionMassSqr[1] = 0.15;
  73. mTpcKaonNSigma[0] = -1.5;
  74. mTpcKaonNSigma[1] = 1.5;
  75. mTofKaonMassSqr[0] = 0.2;
  76. mTofKaonMassSqr[1] = 0.35;
  77. mTpcProtonNSigma[0] = -1.5;
  78. mTpcProtonNSigma[1] = 1.5;
  79. mTofProtonMassSqr[0] = 0.7;
  80. mTofProtonMassSqr[1] = 1.1;
  81. std::cout << "\t[DONE]" << std::endl;
  82. }
  83. //_________________
  84. StFemtoDstMaker::~StFemtoDstMaker() {
  85. delete mQVMaker;
  86. delete matrix;
  87. }
  88. //_________________
  89. Int_t StFemtoDstMaker::Init() {
  90. std::cout << "StFemtoDstMaker::Init - Initializing the maker"
  91. << std::endl
  92. << "Creating output file: " << mOutFileName;
  93. mFemtoEvent = new StFemtoEvent();
  94. mOutFile = new TFile(mOutFileName, "RECREATE");
  95. mOutFile->SetCompressionLevel(mCompression);
  96. std::cout << "\t[DONE]" << std::endl;
  97. mTree = new TTree("StFemtoDst","StFemtoDst");
  98. mTree->SetMaxTreeSize(MAXFILESIZE);
  99. //mTree->SetAutoSave(1000000);
  100. mTree->Branch("StFemtoEvent","StFemtoEvent", &mFemtoEvent);
  101. if(mCollisionType == true) { // for AuAu only
  102. if(!mRefMultCorrUtil) {
  103. std::cout << "StFemtoDstMaker::Init - Initializing StRefMultCorr...";
  104. mRefMultCorrUtil = new StRefMultCorr("refmult");
  105. std::cout << "\t[DONE]" << endl;
  106. }
  107. // initialize reaction plane maker
  108. mQVMaker = new QVMaker(4 /* do not fill hEP histograms just calculate Psi */);
  109. }
  110. mNBytes = 0;
  111. std::cout << "StFemtoDstMaker::Init - Initialization has been finished"
  112. << std::endl;
  113. return StMaker::Init();
  114. }
  115. //________________
  116. void StFemtoDstMaker::Clear(Option_t *option) {
  117. StMaker::Clear();
  118. }
  119. //________________
  120. Int_t StFemtoDstMaker::Make() {
  121. mNEventsIn++;
  122. mMuDst = NULL;
  123. mMuEvent = NULL;
  124. //
  125. // MuDstMaker initialization
  126. //
  127. if(!mMuDstMaker) {
  128. mMuDstMaker = (StMuDstMaker*)GetMaker("MuDst");
  129. if (!mMuDstMaker) {
  130. LOG_ERROR << "StFemtoDstMaker::Make [ERROR] - Cannot find StMuDstMaker"
  131. << std::endl;
  132. return kStOk;
  133. }
  134. }
  135. //
  136. // Obtaining MuDst
  137. //
  138. mMuDst = mMuDstMaker->muDst();
  139. if (!mMuDst) {
  140. mMuDst = (StMuDst*)GetInputDS("MuDst");
  141. if (!mMuDst) {
  142. gMessMgr->Warning() << "StFemtoDstMaker::Make [WARNING] - No MuDst has been found"
  143. << endm;
  144. return kStOk;
  145. }
  146. }
  147. //
  148. // obtaining MuEvent
  149. //
  150. mMuEvent = (StMuEvent*)mMuDst->event();
  151. if(mMuEvent->refMult() < 0) { // multiplicity cannot be negative
  152. mRefMultFail++;
  153. return kStOk;
  154. }
  155. Int_t mNVertices = mMuDst->numberOfPrimaryVertices();
  156. Int_t mNPrimTracks = mMuDst->numberOfPrimaryTracks();
  157. Int_t mNGlobTracks = mMuDst->numberOfGlobalTracks();
  158. int iVert = 0;
  159. mPrimVertex = mMuDst->primaryVertex(iVert);
  160. StBTofHeader* mTofHeader = mMuDst->btofHeader();
  161. if (!mTofHeader || !mPrimVertex) return kStOk;
  162. if (mNVertices == 0) return kStOk;
  163. if (mPrimVertex->ranking() <= 0) // positive ranking only
  164. {
  165. mRankingFail++;
  166. return kStOk;
  167. }
  168. //
  169. // Check that position of the primary vertex if not (0,0,0)
  170. //
  171. if(mPrimVertex->position().x() == 0 &&
  172. mPrimVertex->position().y() == 0 &&
  173. mPrimVertex->position().z() == 0)
  174. {
  175. mVtxNullFail++;
  176. return kStOk;
  177. }
  178. if(mNPrimTracks < 0 || mNPrimTracks > 10000) // reasonable amount of tracks
  179. {
  180. mNPrimVtxFail++;
  181. return kStOk;
  182. }
  183. //
  184. // Some initializations of local variables
  185. //
  186. StThreeVectorF mVertPosition;
  187. Float_t mVpdVz = 0.;
  188. Int_t mCent16;
  189. Double_t mCentWeight;
  190. Double_t mRefMultCorrVal;
  191. Double_t mBeta;
  192. Double_t mMassSqr;
  193. Int_t mPrimVertIndex = -999;
  194. Float_t mRanking = -999.;
  195. Bool_t mGoodRPevent = false;
  196. if(mCollisionType == false) { // pp collisions means false state
  197. mCent16 = -1;
  198. mCentWeight = -999.;
  199. }
  200. //Calculate the amount of the pile-up vertices
  201. int mNVtxInBunchCross = 0;
  202. for (unsigned int i = 0; i < mMuDst->numberOfPrimaryVertices(); i++)
  203. {
  204. StMuPrimaryVertex *primVtx = mMuDst->primaryVertex(i);
  205. if(!primVtx || primVtx->ranking() <= 0.) continue;
  206. if(TMath::Abs(primVtx->position().x()) < 1e-5 &&
  207. TMath::Abs(primVtx->position().y()) < 1e-5 &&
  208. TMath::Abs(primVtx->position().z()) < 1e-5) continue;
  209. if(TMath::Abs( primVtx->position().z() - mTofHeader->vpdVz()) < 5. ) mNVtxInBunchCross++;
  210. }
  211. //There should be only one primary vertex that caused the trigger
  212. if(mNVtxInBunchCross > 1)
  213. {
  214. mAntiPileupFail++;
  215. return kStOk;
  216. }
  217. mEventIsGood = false;
  218. mPrimVertIndex = iVert;
  219. mRanking = mPrimVertex->ranking();
  220. mVertPosition = mPrimVertex->position();
  221. mVpdVz = mTofHeader->vpdVz();
  222. if(!AcceptTrigger(mMuEvent)) // if trigger is not found
  223. {
  224. mAcceptTriggerFail++;
  225. return kStOk;
  226. }
  227. if(!AcceptPrimVtx(mVertPosition, mVpdVz))
  228. {
  229. mAcceptPrimVtxFail++;
  230. return kStOk;
  231. }
  232. mEventIsGood = true;
  233. //
  234. // Set StRefMultCorr
  235. //
  236. if(mCollisionType == true) // AuAu collisions means true state
  237. {
  238. int mass1 = mMuEvent->runInfo().beamMassNumber(StBeamDirection::east);
  239. int mass2 = mMuEvent->runInfo().beamMassNumber(StBeamDirection::west);
  240. // if Au+Au
  241. if (mass1 == 197 && mass2 == 197) {
  242. mRefMultCorrUtil->init(mMuEvent->runId());
  243. if(mAuAuCorrectZdc == true) {
  244. mRefMultCorrUtil->initEvent(mMuEvent->refMult(),
  245. mVertPosition.z(),
  246. mMuEvent->runInfo().zdcCoincidenceRate());
  247. }
  248. else {
  249. mRefMultCorrUtil->initEvent(mMuEvent->refMult(),
  250. mVertPosition.z());
  251. }
  252. mCent16 = mRefMultCorrUtil->getCentralityBin16();
  253. if(mCent16 < 0) // some AuAu collisions have -1 value
  254. return kStOk;
  255. mCentWeight = mRefMultCorrUtil->getWeight();
  256. mRefMultCorrVal = mRefMultCorrUtil->getRefMultCorr();
  257. }
  258. else { // Assume that it is Cu+Au case
  259. mCent16 = GetCentralityBin(mMuEvent->refMult(), mVertPosition.z());
  260. }
  261. if (mCalibPath && LoadEPCalibParam(mMuEvent->runId()))
  262. mGoodRPevent = true;
  263. } //if(mCollisionType == true)
  264. mNEventsPassed++;
  265. mFemtoEvent->SetEventId(mMuEvent->eventId());
  266. mFemtoEvent->SetRunId(mMuEvent->runId());
  267. mFemtoEvent->SetCollisionType(mCollisionType);
  268. mFemtoEvent->SetRefMult(mMuEvent->refMult());
  269. mFemtoEvent->SetRefMultCorr(mRefMultCorrVal);
  270. mFemtoEvent->SetRefMultCorrWeight(mCentWeight);
  271. mFemtoEvent->SetRefMultPos(mMuEvent->refMultPos());
  272. mFemtoEvent->SetCent16(mCent16);
  273. //mFemtoEvent->SetZDCe(mMuEvent->zdcTriggerDetector().adc(4));
  274. //mFemtoEvent->SetZDCw(mMuEvent->zdcTriggerDetector().adc(0));
  275. mFemtoEvent->SetNumberOfBTofHit(mMuDst->numberOfBTofHit());
  276. mFemtoEvent->SetNumberOfPrimaryTracks(mNPrimTracks);
  277. mFemtoEvent->SetNumberOfGlobalTracks(mNGlobTracks);
  278. mFemtoEvent->SetMagneticField(mMuEvent->magneticField());
  279. mFemtoEvent->SetPrimaryVertexPosition(mVertPosition.x(),
  280. mVertPosition.y(),
  281. mVertPosition.z());
  282. mFemtoEvent->SetVpdVz(mVpdVz);
  283. mFemtoEvent->SetTriggerId(mCurrentTrigger);
  284. mFemtoEvent->SetPrimaryVertexRanking(mRanking);
  285. UInt_t refMult2 = 0;
  286. UInt_t refMult2Pos = 0;
  287. StFemtoTrack *mFTrack = NULL;
  288. //
  289. // Calculate transverse sphericity
  290. //
  291. float sph = -999.;
  292. float pt_full = 0.0;
  293. matrix->Zero();
  294. for (int i = 0; i < mNPrimTracks; i++)
  295. {
  296. mPrimTrack = mMuDst->primaryTracks(i);
  297. if (mPrimTrack->vertexIndex() != 0) return kStOk;
  298. float pt = mPrimTrack->pt();
  299. const StThreeVectorF &p = mPrimTrack->p();
  300. if (fabs(mPrimTrack->eta()) < 1.0 && pt > mPtCut)
  301. {
  302. float px = p.x();
  303. float py = p.y();
  304. (*matrix)(0, 0) += px*px/pt;
  305. (*matrix)(1, 1) += py*py/pt;
  306. (*matrix)(0, 1) += px*py/pt;
  307. (*matrix)(1, 0) += px*py/pt;
  308. pt_full += pt;
  309. }
  310. }
  311. *matrix *= 1./pt_full;
  312. TMatrixDSymEigen death_machine(*matrix);
  313. TVectorD eigen = death_machine.GetEigenValues();
  314. sph = 2.*eigen.Min()/(eigen[0] + eigen[1]);
  315. mFemtoEvent->SetSphericity(sph);
  316. //
  317. // Calculate reaction plane
  318. //
  319. float rpE = -999., rpW = -999.;
  320. if (mGoodRPevent) {
  321. int qZVtx = int((mPrimVertex->position().z() + 30.)/60. * NqvZvtx /* see ConstVar.h */);
  322. if (mCent16 >= 0 && mCent16 < NqvCent &&
  323. qZVtx >= 0 && qZVtx < NqvZvtx) {
  324. // SMD
  325. QV Q_SMD[NsubSMD];
  326. CalcQvSMD(mMuEvent, Q_SMD, mCent16, qZVtx);
  327. rpE = Q_SMD[0].get_Psi();
  328. rpW = Q_SMD[1].get_Psi();
  329. }
  330. }
  331. mFemtoEvent->SetRPeast(rpE);
  332. mFemtoEvent->SetRPwest(rpW);
  333. //
  334. // Loop over primary tracks
  335. //
  336. for(Int_t iTrk=0; iTrk<mNPrimTracks; iTrk++)
  337. {
  338. mPrimTrack = mMuDst->primaryTracks(iTrk);
  339. int idxGlob = mPrimTrack->index2Global();
  340. if (idxGlob < 0) continue;
  341. mGlobTrack = mMuDst->globalTracks(idxGlob);
  342. if (AcceptRefMult2(mPrimTrack))
  343. {
  344. refMult2++;
  345. if(mPrimTrack->charge() > 0) refMult2Pos++;
  346. }
  347. if (!AcceptTrack(mPrimTrack, iVert)) continue;
  348. Bool_t mIsTofTrack = IsTofTrack(mGlobTrack);
  349. if(mIsTofTrack) {
  350. mBeta = mGlobTrack->btofPidTraits().beta();
  351. mMassSqr = mPrimTrack->momentum().mag2() * ( 1./(mBeta * mBeta) - 1.);
  352. //
  353. // Next lines are cheat. But we should remove garbage
  354. //
  355. if(mMassSqr < -0.02) continue;
  356. if(mPrimTrack->momentum().mag() > 0.5) {
  357. if(mMassSqr > 0.06 && mMassSqr < 0.18) continue;
  358. if(mMassSqr > 0.35 && mMassSqr < 0.8) continue;
  359. if(mMassSqr > 1.) continue;
  360. }
  361. } //if(mIsTofTrack)
  362. else {
  363. mBeta = -999.;
  364. mMassSqr = -999.;
  365. }
  366. Bool_t mIsTpcPion = false;
  367. Bool_t mIsTpcKaon = false;
  368. Bool_t mIsTpcProton = false;
  369. Bool_t mIsTofPion = false;
  370. Bool_t mIsTofKaon = false;
  371. Bool_t mIsTofProton = false;
  372. if(mRemovePions) {
  373. mIsTpcPion = IsTpcPion(mPrimTrack);
  374. mIsTofPion = IsTofPion(mGlobTrack);
  375. if(mIsTpcPion==true || mIsTofPion==true)
  376. continue;
  377. }
  378. if(mRemoveKaons) {
  379. mIsTpcKaon = IsTpcKaon(mPrimTrack);
  380. mIsTofKaon = IsTofKaon(mGlobTrack);
  381. if(mIsTpcKaon==true || mIsTofKaon==true)
  382. continue;
  383. }
  384. if(mRemoveProtons) {
  385. mIsTpcProton = IsTpcProton(mPrimTrack);
  386. mIsTofProton = IsTofProton(mGlobTrack);
  387. if(mIsTpcProton==true || mIsTofProton==true)
  388. continue;
  389. }
  390. mFTrack = mFemtoEvent->AddFemtoTrack();
  391. mFTrack->SetId( mPrimTrack->id() );
  392. mFTrack->SetNHits( (Char_t)(mPrimTrack->charge()*mPrimTrack->nHits()) );
  393. mFTrack->SetNHitsPoss( mPrimTrack->nHitsPoss() );
  394. //mFTrack->SetNHitsDedx( mPrimTrack->nHitsDedx() );
  395. mFTrack->SetNSigmaElectron( mPrimTrack->nSigmaElectron() );
  396. mFTrack->SetNSigmaPion( mPrimTrack->nSigmaPion() );
  397. mFTrack->SetNSigmaKaon( mPrimTrack->nSigmaKaon() );
  398. mFTrack->SetNSigmaProton( mPrimTrack->nSigmaProton() );
  399. mFTrack->SetDedx( mPrimTrack->dEdx() );
  400. mFTrack->SetMap0( mGlobTrack->topologyMap().data(0) );
  401. mFTrack->SetMap1( mGlobTrack->topologyMap().data(1) );
  402. mFTrack->SetP( mPrimTrack->momentum().x(),
  403. mPrimTrack->momentum().y(),
  404. mPrimTrack->momentum().z() );
  405. mFTrack->SetDCAxGlobal( mPrimTrack->dcaGlobal().x() );
  406. mFTrack->SetDCAyGlobal( mPrimTrack->dcaGlobal().y() );
  407. mFTrack->SetDCAzGlobal( mPrimTrack->dcaGlobal().z() );
  408. mFTrack->SetGlobalP( mGlobTrack->p().x(),
  409. mGlobTrack->p().y(),
  410. mGlobTrack->p().z() );
  411. if(mIsTofTrack) {
  412. mFTrack->SetBeta(mBeta);
  413. }
  414. else {
  415. mFTrack->SetBeta(-999.);
  416. }
  417. } //for(Int_t iTrk=0; iTrk<mNPrimTracks; iTrk++)
  418. mFemtoEvent->SetRefMult2(refMult2);
  419. mFemtoEvent->SetRefMult2Pos(refMult2Pos);
  420. if(mEventIsGood) {
  421. mNBytes += mTree->Fill();
  422. mFemtoEvent->Clear();
  423. }
  424. return kStOk;
  425. }
  426. //_________________
  427. Bool_t StFemtoDstMaker::AcceptTrigger(StMuEvent *muEvent) {
  428. //We will store the bit mask for the list of triggers.
  429. //The list of triggers should be the same and in the same
  430. //order, in order to read it later
  431. Bool_t mIsGoodTrigger = false;
  432. mCurrentTrigger = 0;
  433. if(mTriggerIdCollection.empty()) {
  434. mIsGoodTrigger = true;
  435. }
  436. else {
  437. for (UInt_t iTrg = 0; iTrg < mTriggerIdCollection.size(); iTrg++) {
  438. if(muEvent->triggerIdCollection().nominal().isTrigger(mTriggerIdCollection.at(iTrg))) {
  439. mIsGoodTrigger = true;
  440. mCurrentTrigger |= (1<<iTrg);
  441. break;
  442. }
  443. } //for(UInt_t iTrg=0; iTrg<mTriggerIdCollection.size(); iTrg++)
  444. }
  445. return mIsGoodTrigger;
  446. }
  447. //_________________
  448. Bool_t StFemtoDstMaker::AcceptPrimVtx(StThreeVectorF vtxPos,
  449. Float_t vpdVz) {
  450. Float_t mVtxX = vtxPos.x() - mPrimVtxXShift;
  451. Float_t mVtxY = vtxPos.y() - mPrimVtxYShift;
  452. Float_t vtxR = TMath::Sqrt(mVtxX*mVtxX + mVtxY*mVtxY);
  453. Float_t vpdDiff = vtxPos.z() - vpdVz;
  454. Bool_t mIsGoodVtx = vtxPos.z() >= mPrimVtxZ[0] &&
  455. vtxPos.z() <= mPrimVtxZ[1] &&
  456. vtxR >= mPrimVtxR[0] &&
  457. vtxR <= mPrimVtxR[1] &&
  458. vpdDiff >= mPrimVtxVpdVzDiff[0] &&
  459. vpdDiff <= mPrimVtxVpdVzDiff[1];
  460. return mIsGoodVtx;
  461. }
  462. //_________________
  463. Bool_t StFemtoDstMaker::AcceptTrack(StMuTrack *trk, UShort_t vtxInd) {
  464. Bool_t mIsGoodTrack = trk->vertexIndex() == vtxInd &&
  465. trk->momentum().mag() >= mTrackMomentum[0] && trk->momentum().mag() <= mTrackMomentum[1] &&
  466. trk->type() == 1 &&
  467. trk->eta() >= mTrackEta[0] && trk->eta() <= mTrackEta[1] &&
  468. trk->nHits() >= mTrackNHits[0] && trk->nHits() <= mTrackNHits[1] &&
  469. trk->nHitsFit() >= mTrackNHitsFit[0] && trk->nHitsFit() <= mTrackNHitsFit[1] &&
  470. trk->flag() >= mTrackFlag[0] && trk->flag() <= mTrackFlag[1] &&
  471. trk->dca(vtxInd).perp() >= mTrackDca[0] && trk->dca(vtxInd).perp() <= mTrackDca[1] &&
  472. trk->dcaGlobal(vtxInd).perp() >= mTrackDcaGlobal[0] &&
  473. trk->dcaGlobal(vtxInd).perp() <= mTrackDcaGlobal[1];
  474. return mIsGoodTrack;
  475. }
  476. //_________________
  477. Bool_t StFemtoDstMaker::AcceptRefMult2(StMuTrack *trk) {
  478. Bool_t mIsGoodTrack = trk->flag()> 0 &&
  479. trk->charge() != 0 &&
  480. trk->nHitsFit() >= 10 &&
  481. trk->dca().mag() < 3.0 &&
  482. trk->momentum().mag() >= 1e-10 &&
  483. TMath::Abs(trk->eta()) <= 1.0;
  484. return mIsGoodTrack;
  485. }
  486. //_________________
  487. Bool_t StFemtoDstMaker::IsTofTrack(StMuTrack *trk) { //Only for globals
  488. Bool_t mIsTofHit = trk->btofPidTraits().beta() > 0 &&
  489. trk->btofPidTraits().timeOfFlight() > 0;
  490. return mIsTofHit;
  491. }
  492. //_________________
  493. Int_t StFemtoDstMaker::Finish() {
  494. mOutFile->cd();
  495. mOutFile->Write();
  496. //mTree->Write();
  497. mOutFile->Close();
  498. std::cout
  499. << "*************************************" << "\n"
  500. << "StFemtoDstMaker has been finished" << "\n"
  501. << "\t nEventsPassed : " << mNEventsPassed << "\n"
  502. << "\t nEventsProcessed: " << mNEventsIn << "\n"
  503. << "Accept trigger fail = " << mAcceptTriggerFail << "\n"
  504. << "RefMult fail = " << mRefMultFail << "\n"
  505. << "Anti-pileup fail = " << mAntiPileupFail << "\n"
  506. << "Ranking fail = " << mRankingFail << "\n"
  507. << "VtxNull fail = " << mVtxNullFail << "\n"
  508. << "NPrimVtx fail = " << mNPrimVtxFail << "\n"
  509. << "AcceptPrimVtx fail = " << mAcceptPrimVtxFail << "\n"
  510. << "*************************************" << "\n";
  511. return kStOk;
  512. }
  513. //_________________
  514. void StFemtoDstMaker::CleanVariables() {
  515. mEventIsGood = false;
  516. }
  517. //_________________
  518. Bool_t StFemtoDstMaker::IsTpcPion(StMuTrack *pTrk) {
  519. Bool_t isPion = false;
  520. if( pTrk->momentum().mag() <= mPthresh &&
  521. pTrk->nSigmaPion() >= mTpcPionNSigma[0] &&
  522. pTrk->nSigmaPion() <= mTpcPionNSigma[1] ) {
  523. isPion = true;
  524. }
  525. return isPion;
  526. }
  527. //_________________
  528. Bool_t StFemtoDstMaker::IsTpcKaon(StMuTrack *pTrk) {
  529. Bool_t isKaon = false;
  530. if( pTrk->momentum().mag() <= mPthresh &&
  531. pTrk->nSigmaKaon() >= mTpcKaonNSigma[0] &&
  532. pTrk->nSigmaKaon() <= mTpcKaonNSigma[1] ) {
  533. isKaon = true;
  534. }
  535. return isKaon;
  536. }
  537. //_________________
  538. Bool_t StFemtoDstMaker::IsTpcProton(StMuTrack *pTrk) {
  539. Bool_t isProton = false;
  540. if( pTrk->momentum().mag() <= mPthresh &&
  541. pTrk->nSigmaProton() >= mTpcProtonNSigma[0] &&
  542. pTrk->nSigmaProton() <= mTpcProtonNSigma[1] ) {
  543. isProton = true;
  544. }
  545. return isProton;
  546. }
  547. //_________________
  548. Bool_t StFemtoDstMaker::IsTofPion(StMuTrack *gTrk) {
  549. Bool_t isPion = false;
  550. Float_t beta = -999.;
  551. Float_t mSqr = -999.;
  552. if( gTrk->btofPidTraits().beta() > 0 &&
  553. gTrk->momentum().mag() > mPthresh ) {
  554. beta = gTrk->btofPidTraits().beta();
  555. mSqr = gTrk->momentum().mag2() * (1./(beta*beta) - 1.);
  556. if(mSqr >= mTofPionMassSqr[0] &&
  557. mSqr <= mTofPionMassSqr[1]) {
  558. isPion = true;
  559. }
  560. }
  561. return isPion;
  562. }
  563. //_________________
  564. Bool_t StFemtoDstMaker::IsTofKaon(StMuTrack *gTrk) {
  565. Bool_t isKaon = false;
  566. Float_t beta = -999.;
  567. Float_t mSqr = -999.;
  568. if( gTrk->btofPidTraits().beta() > 0 &&
  569. gTrk->momentum().mag() > mPthresh ) {
  570. beta = gTrk->btofPidTraits().beta();
  571. mSqr = gTrk->momentum().mag2() * (1./(beta*beta) - 1.);
  572. if(mSqr >= mTofKaonMassSqr[0] &&
  573. mSqr <= mTofKaonMassSqr[1]) {
  574. isKaon = true;
  575. }
  576. }
  577. return isKaon;
  578. }
  579. //_________________
  580. Bool_t StFemtoDstMaker::IsTofProton(StMuTrack *gTrk) {
  581. Bool_t isProton = false;
  582. Float_t beta = -999.;
  583. Float_t mSqr = -999.;
  584. if( gTrk->btofPidTraits().beta() > 0 &&
  585. gTrk->momentum().mag() > 0.5 ) {
  586. //gTrk->momentum().mag() > mPthresh ) {
  587. beta = gTrk->btofPidTraits().beta();
  588. mSqr = gTrk->momentum().mag2() * (1./(beta*beta) - 1.);
  589. if(mSqr >= mTofProtonMassSqr[0] &&
  590. mSqr <= mTofProtonMassSqr[1]) {
  591. isProton = true;
  592. }
  593. }
  594. return isProton;
  595. }
  596. //_________________
  597. void StFemtoDstMaker::SetTriggerId(const UInt_t &id) {
  598. mTriggerIdCollection.push_back(id);
  599. }
  600. //_________________
  601. int StFemtoDstMaker::LoadEPCalibParam(int runid) {
  602. if (!mCalibPath) return 0;
  603. TFile *in = new TFile(Form("%s/OutMuAna_%d.root", mCalibPath, runid));
  604. if (!in) return 0;
  605. mQVMaker->LoadParameters(in);
  606. in->Close();
  607. delete in;
  608. return 1;
  609. }
  610. //_________________
  611. int StFemtoDstMaker::GetCentralityBin(float refMult, int fVz) {
  612. const int multMax = 1000;
  613. const int mMultiplicityCut[2][17] = {{multMax, /* 0 */ // vpd-zdce-tac-protected
  614. 273, /* 0 1 */ //-30<vz<-25
  615. 235, /* 2 1 */
  616. 201, /* 2 3 */
  617. 270, /* 4 3 */
  618. 142, /* 4 5 */
  619. 118, /* 6 5 */
  620. 97, /* 6 7 */
  621. 78, /* 8 7 */
  622. 62, /* 8 9 */
  623. 49, /* 10 9 */
  624. 38, /* 10 11 */
  625. 29, /* 12 11 */
  626. 22, /* 12 13 */
  627. 16, /* 14 13 */
  628. 12, /* 14 15 */
  629. 8}, /* 15 */
  630. {multMax, // vz>-25
  631. 273,
  632. 235,
  633. 201,
  634. 170,
  635. 142,
  636. 118,
  637. 97,
  638. 78,
  639. 62,
  640. 49,
  641. 38,
  642. 29,
  643. 22,
  644. 16,
  645. 12,
  646. 8}};
  647. // NqvCent = 16 5% step up to 80%
  648. int i_vz = fVz > 0 ? 1 : 0;
  649. for (int iCent = 1; iCent <= NqvCent; iCent++) {
  650. if (mMultiplicityCut[i_vz][iCent] <= refMult &&
  651. refMult < mMultiplicityCut[i_vz][iCent - 1]) {
  652. return iCent - 1;
  653. }
  654. }
  655. return -1;
  656. }
  657. //_________________
  658. void StFemtoDstMaker::CalcQvSMD(StMuEvent *mEv, QV fQv[NsubSMD], int fCent, int fVz) {
  659. // Calculate raw flow vectors
  660. float fqv[NsubSMD][4] = {{0}}; //east-west-combined, xy+weight
  661. for (int iSub = 0; iSub < NsubSMD; iSub++) { // east-west
  662. int nStrip;
  663. for (int iXY = 0;iXY < 2; iXY++) {
  664. if (iXY == 0) nStrip = 8; // vertical strips (x-direction)
  665. else nStrip = 9; // horizontal strips (y-direction)
  666. for (int iStrip = 1; iStrip < nStrip; iStrip++) {
  667. // fqv[iSub][1-2] = position(cm) * adcThisTile
  668. fqv[iSub][iXY] += ZDCSMD_GetPosition(iSub, iXY, iStrip)*ZDCSMD(mEv, iSub, iXY, iStrip);
  669. // fqv[iSub][3-4] = adcThisTile
  670. fqv[iSub][iXY+2] += ZDCSMD(mEv, iSub, iXY, iStrip);
  671. }
  672. // normalization
  673. if(fqv[iSub][iXY+2] > 0)
  674. fqv[iSub][iXY] /= fqv[iSub][iXY+2];
  675. else
  676. fqv[iSub][iXY] = -9999;
  677. if (iSub == 0 && mEv->zdcTriggerDetector().adcSum(east) < 1)
  678. fqv[iSub][iXY] = -9999;
  679. if (iSub == 1 && mEv->zdcTriggerDetector().adcSum(west) < 1)
  680. fqv[iSub][iXY] = -9999;
  681. if (iSub == 2 && (fqv[0][iXY] < -9000 || fqv[1][iXY] < -9000))
  682. fqv[iSub][iXY] = -9999;
  683. } // iXY
  684. } // iSub
  685. // combined
  686. for (int iXY = 0; iXY < 2; iXY++) {
  687. fqv[2][iXY] = fqv[0][iXY] - fqv[1][iXY];
  688. if (fqv[0][iXY] == -9999 || fqv[1][iXY] == -9999)
  689. fqv[2][iXY] = -9999;
  690. }
  691. // Set raw Q-vectors and Calibration
  692. // -----------------------------------------------
  693. int fth = 0; // fth = fOrd in QV class
  694. float fQw = 1.0;
  695. for (int iSub = 0; iSub < NsubSMD; iSub++) {
  696. if (fqv[iSub][0] == -9999 || fqv[iSub][1] == -9999 ) fQw = -1;
  697. fQv[iSub].set_Qv(fqv[iSub][0], fqv[iSub][1], fQw, dZDC, iSub, fth, fCent, fVz);
  698. mQVMaker->doCalibration(&(fQv[iSub]));
  699. } // iSub
  700. }
  701. //_________________
  702. Float_t StFemtoDstMaker::ZDCSMD(StMuEvent *mEv, int eastwest, int verthori, int strip) {
  703. // return adc for each tile
  704. return mEv->zdcTriggerDetector().zdcSmd((StBeamDirection)eastwest, verthori, strip);
  705. }
  706. //_________________
  707. Float_t StFemtoDstMaker::ZDCSMD_GetPosition(int eastwest, int verthori, int strip) {
  708. // Get position of each slat;strip starts from 1
  709. Float_t zdcsmd_x[7] = {0.5, 2, 3.5, 5, 6.5, 8, 9.5};
  710. Float_t zdcsmd_y[8] = {1.25, 3.25, 5.25, 7.25, 9.25, 11.25, 13.25, 15.25};
  711. if (eastwest == 0 && verthori == 0) { return zdcsmd_x[strip-1] - mZDCSMDCenterex; }
  712. // east && vertical strips (x-direction)
  713. if (eastwest == 1 && verthori == 0) { return mZDCSMDCenterwx - zdcsmd_x[strip-1]; }
  714. // west && vertical strips (x-direction)
  715. if (eastwest == 0 && verthori == 1) { return zdcsmd_y[strip-1]/sqrt(2.) - mZDCSMDCenterey; }
  716. // east && horisontal strips (y-direction)
  717. if (eastwest == 1 && verthori == 1) { return zdcsmd_y[strip-1]/sqrt(2.) - mZDCSMDCenterwy; }
  718. // west && horisontal strips (y-direction)
  719. return 0;
  720. }