FemtoDstMaker_mesons_pp510_y2011_PicoDst.C 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include "TROOT.h"
  2. #include "TSystem.h"
  3. #include "TChain.h"
  4. #include "TFile.h"
  5. #include "TString.h"
  6. #include <iostream>
  7. using namespace std;
  8. const Char_t *defaultInFile = "test.list";
  9. const Char_t *defaultOutFile = "oFemtoDstMesons_pp510_2011.root";
  10. void FemtoDstMaker_mesons_pp510_y2011_PicoDst(const Char_t* inFileList = defaultInFile,
  11. const Char_t* outFileName = defaultOutFile)
  12. {
  13. cout << "*******************************************************" << endl
  14. << "* FemtoDstMaker for p+p 510 GeV year 2011 (PicoDst) *" << endl
  15. << "* Start *" << endl
  16. << "*******************************************************" << endl
  17. << endl;
  18. //Constants, cut and initial parameters
  19. Float_t cVtxZ[2] = {-70., 70.};
  20. Float_t cVtxR[2] = {0., 3.};
  21. Float_t cVtxXShift = 0.;
  22. Float_t cVtxYShift = 0.;
  23. Float_t cVtxVpdVzDiff[2] = {-7., 7.};
  24. Float_t cParticleMom[2] = {0.15, 1.65};
  25. Float_t cTrackDcaGlobal[2] = {-0.01, 3.};
  26. Int_t cTrackNHitsFit[2] = {5, 50};
  27. Float_t cTrackEta[2] = {-1., 1.};
  28. Int_t cTrackFlag[2] = {0, 1000};
  29. Float_t cPionTpcNSigmaElectron[2] = {-2., 2.};
  30. Float_t cPionTpcNSigmaPion[2] = {-3., 3.};
  31. Float_t cPionTpcNSigmaKaon[2] = {-2., 2.};
  32. Float_t cPionTpcNSigmaProton[2] = {-3., 3.};
  33. Float_t cKaonTpcNSigmaElectron[2] = {-3., 3.};
  34. Float_t cKaonTpcNSigmaPion[2] = {-2., 2.};
  35. Float_t cKaonTpcNSigmaKaon[2] = {-3., 3.};
  36. Float_t cKaonTpcNSigmaProton[2] = {-3., 3.};
  37. //
  38. // Load libraries
  39. //
  40. std::cout << "Loading libraries..." << std::endl;
  41. gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  42. loadSharedLibraries();
  43. gSystem->Load("libMinuit");
  44. gSystem->Load("StChain");
  45. gSystem->Load("StRefMultCorr");
  46. gSystem->Load("StFlowMaker");
  47. gSystem->Load("StHbtMaker");
  48. gSystem->Load("StPicoDstMakerRun11");
  49. gSystem->Load("StFemtoDstMaker");
  50. std::cout << "Libraries have been successfully loaded" << std::endl;
  51. //
  52. // Create chain
  53. //
  54. StChain *mChain = new StChain("StChain");
  55. mChain->SetDebug(0);
  56. //
  57. // Create PicoDst reader
  58. //
  59. int nMaxFileToRead = 1e9;
  60. std::cout << Form("Try to read file: %s", inFileList) << std::endl;
  61. StPicoDstMaker *picoMaker = new StPicoDstMaker(0, inFileList);
  62. //
  63. // StFemtoDstPicoRun11Maker initialization
  64. //
  65. femtoDstPicoMaker = new StFemtoDstPicoRun11Maker(picoMaker, outFileName);
  66. //
  67. // Event cuts
  68. //
  69. femtoDstPicoMaker->SetVtxZCut(cVtxZ[0], cVtxZ[1]);
  70. femtoDstPicoMaker->SetVtxRCut(cVtxR[0], cVtxR[1]);
  71. femtoDstPicoMaker->SetVtxShift(cVtxXShift, cVtxYShift);
  72. femtoDstPicoMaker->SetVtxVpdVzDiffCut(cVtxVpdVzDiff[0], cVtxVpdVzDiff[1]);
  73. //
  74. // Track cuts
  75. //
  76. femtoDstPicoMaker->SetParticleMomentum(cParticleMom[0], cParticleMom[1]);
  77. femtoDstPicoMaker->SetTrackDcaGlobal(cTrackDcaGlobal[0], cTrackDcaGlobal[1]);
  78. femtoDstPicoMaker->SetTrackNHitsFit(cTrackNHitsFit[0], cTrackNHitsFit[1]);
  79. femtoDstPicoMaker->SetTrackEta(cTrackEta[0], cTrackEta[1]);
  80. //Chain initialization and loop over events
  81. mChain->Init();
  82. TChain *mCurrentTree = picoMaker->chain();
  83. Long64_t mNEvents = mCurrentTree->GetEntries();
  84. std::cout << Form("Number of events in TTree: %d", mNEvents) << std::endl;
  85. Int_t iReturn = 0;
  86. Int_t mNEventsProcessed = 0;
  87. Float_t mPercentStep = 0.05;
  88. Float_t mPercentCounter = mPercentStep;
  89. Float_t mProgress = 0.;
  90. time_t mStartTime, mStopTime, mDiffTime; // time
  91. float mFrac; // time
  92. mStartTime = time(0); // time
  93. for (int iEvent=0; iEvent<mNEvents; iEvent++)
  94. {
  95. mProgress = (Float_t)iEvent/(Float_t)mNEvents;
  96. mNEventsProcessed++;
  97. if(mProgress >= mPercentCounter) {
  98. mPercentCounter += mPercentStep;
  99. mStopTime = time(0);
  100. mDiffTime = difftime(mStopTime, mStartTime);
  101. mFrac = (float)mDiffTime*(float)(mNEvents - iEvent)/(float)iEvent;
  102. std::cout << Form("Processing progress: %3.0f%%. ETA: %.1f sec", mProgress*100., mFrac)
  103. << std::endl;
  104. }
  105. mChain->Clear();
  106. iReturn = mChain->Make(iEvent);
  107. if(iReturn != 0) {
  108. std::cout << "Error has been occured. Event processing has been stopped"
  109. << std::endl;
  110. break;
  111. }
  112. }
  113. mChain->Finish();
  114. delete femtoDstPicoMaker;
  115. delete mChain;
  116. }