FemtoDstMaker_Pythia8.C 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "TROOT.h"
  2. #include "TSystem.h"
  3. #include "TChain.h"
  4. #include "TFile.h"
  5. #include "TString.h"
  6. #include <iostream>
  7. const Char_t* defaultInFile = "test.list";
  8. const Char_t *defaultOutFile = "test.root";
  9. using namespace std;
  10. class StFemtoDstMaker_StarGen;
  11. StFemtoDstMaker_StarGen *femtoMaker = NULL;
  12. void FemtoDstMaker_Pythia8(const Char_t* inFileList = defaultInFile,
  13. const Char_t* outFileName = defaultOutFile)
  14. {
  15. cout << "**************************************" << endl
  16. << "* FemtoDstMaker for Star Generator *" << endl
  17. << "* Start *" << endl
  18. << "**************************************" << endl
  19. << endl;
  20. //Constants, cut and initial parameters
  21. Float_t cParticleMom[2] = {0.1, 2.0};
  22. Float_t cTrackEta[2] = {-1.1, 1.1};
  23. //Load libraries
  24. cout << "Loading libraries..." << endl;
  25. gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  26. loadSharedLibraries();
  27. gSystem->Load("libMinuit");
  28. gSystem->Load("StChain");
  29. gSystem->Load("StRefMultCorr");
  30. gSystem->Load("StFlowMaker");
  31. gSystem->Load("StHbtMaker");
  32. gSystem->Load("StPicoDstMakerRun11");
  33. gSystem->Load("libgsl");
  34. gSystem->Load("libgslcblas");
  35. gSystem->Load("libVMC.so");
  36. gSystem->Load("libStDb_Tables.so");
  37. gSystem->Load("libgen_Tables.so");
  38. gSystem->Load("libgeometry_Tables.so");
  39. gSystem->Load("libsim_Tables.so");
  40. gSystem->Load("libStarMagField.so");
  41. gSystem->Load("libSt_db_Maker.so");
  42. gSystem->Load("libSt_g2t.so");
  43. gSystem->Load("libSt_geant_Maker.so");
  44. gSystem->Load("StarGeneratorUtil.so");
  45. gSystem->Load("StarGeneratorEvent.so");
  46. gSystem->Load("StarGeneratorBase.so");
  47. gSystem->Load("StFemtoDstMakerSph");
  48. cout << "Libraries have been successfully loaded" << endl;
  49. //
  50. // Create chain
  51. //
  52. StChain *mChain = new StChain("StChain");
  53. femtoMaker = new StFemtoDstMaker_StarGen("", inFileList, outFileName, ".", 1e9);
  54. femtoMaker->SetParticleMomentum(cParticleMom[0], cParticleMom[1]);
  55. femtoMaker->SetTrackEta(cTrackEta[0], cTrackEta[1]);
  56. femtoMaker->SetPtCut(0.2);
  57. //
  58. // Chain initialization and loop over events
  59. //
  60. mChain->Init();
  61. Int_t mNEvents = femtoMaker->GetNEvents();
  62. Int_t iReturn = 0;
  63. Int_t mNEventsProcessed = 0;
  64. Float_t mPerConst = 0.05;
  65. Float_t mPercentCounter = 0.0;
  66. Float_t mProgress = 0.;
  67. unsigned int mSubCounter = 1; // time
  68. time_t mStartTime, mStopTime, mDiffTime; // time
  69. float mFrac; // time
  70. mStartTime = time(0); // time
  71. for (Int_t iEvent = 0; iEvent < mNEvents; iEvent++)
  72. {
  73. mProgress = (Float_t)iEvent/(Float_t)mNEvents;
  74. mNEventsProcessed++;
  75. if (mProgress >= mPercentCounter)
  76. {
  77. mPercentCounter += mPerConst;
  78. mStopTime = time(0);
  79. mDiffTime = difftime(mStopTime, mStartTime);
  80. mFrac = (float)mDiffTime*(float)(mNEvents - iEvent)/(float)iEvent;
  81. mSubCounter++;
  82. cout << Form("Processing progress: %4.2f%%. Time left: %.1 sec", mProgress*100., mFrac)
  83. << endl;
  84. }
  85. mChain->Clear();
  86. iReturn = mChain->Make(iEvent);
  87. if (iReturn != 0)
  88. {
  89. cout << "Error has been occured. Event processing has been stopped"
  90. << endl;
  91. break;
  92. }
  93. }
  94. mChain->Finish();
  95. delete femtoMaker;
  96. delete mChain;
  97. cout << "**************************************" << endl
  98. << "* FemtoDstMaker for Star Generator *" << endl
  99. << "* End *" << endl
  100. << "**************************************" << endl
  101. << endl;
  102. }