Flow.C 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 = "oFlow.root";
  9. void Flow(const Char_t *inFileList = defaultInFile,
  10. const Char_t *outFileName = defaultOutFile)
  11. {
  12. std::cout << "*****************************" << std::endl
  13. << "* *" << std::endl
  14. << "* Flow analysis macro *" << std::endl
  15. << "* *" << std::endl
  16. << "*****************************" << std::endl;
  17. //
  18. // Load libraries
  19. //
  20. std::cout << "Loading libraries..." << std::endl;
  21. gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  22. loadSharedLibraries();
  23. gSystem->Load("libMinuit");
  24. gSystem->Load("StMuDSTMaker");
  25. gSystem->Load("StChain");
  26. gSystem->Load("StarClassLibrary");
  27. gSystem->Load("StRefMultCorr");
  28. gSystem->Load("StFlow");
  29. std::cout << "Libraries have been successfully loaded" << std::endl;
  30. //
  31. // Create chain
  32. //
  33. StChain *chain = new StChain("StChain");
  34. chain->SetDebug(0);
  35. StMuDebug::setLevel(0);
  36. //
  37. // Create MuDst reader
  38. //
  39. int nMaxFileToRead = 1e9;
  40. std::cout << Form("Try to read file: %s", inFileList) << std::endl;
  41. StMuDstMaker *muDstMaker = new StMuDstMaker(0, 0, "", inFileList, "MuDst", nMaxFileToRead);
  42. muDstMaker->SetStatus("*",0);
  43. muDstMaker->SetStatus("Event*",1);
  44. muDstMaker->SetStatus("MuEvent*",1);
  45. muDstMaker->SetStatus("PrimaryVertices*",1);
  46. muDstMaker->SetStatus("PrimaryTracks*",1);
  47. muDstMaker->SetStatus("GlobalTracks*",1);
  48. muDstMaker->SetStatus("BTofHeader*",1);
  49. TChain *currentTree = muDstMaker->chain();
  50. Long64_t nEvents = currentTree->GetEntries();
  51. std::cout << Form("Number of events in TTree: %d", nEvents) << std::endl;
  52. //
  53. // Create StTpcPidQA
  54. //
  55. StFlow *flow = new StFlow(muDstMaker, outFileName);
  56. chain->Init();
  57. Int_t iReturn = 0;
  58. Int_t nEventsProcessed = 0;
  59. Float_t percentCounter = 0.01;
  60. Float_t progress = 0.;
  61. for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
  62. progress = (Float_t)iEvent/(Float_t)nEvents;
  63. nEventsProcessed++;
  64. if(progress >= percentCounter) {
  65. percentCounter += 0.01;
  66. std::cout << Form("Processing progress: %4.2f%%", percentCounter*100.)
  67. << std::endl;
  68. }
  69. chain->Clear();
  70. iReturn = chain->Make(iEvent);
  71. if (iReturn != 0) {
  72. std::cout << "Error has been occured. Event processing has been stopped"
  73. << std::endl;
  74. break;
  75. }
  76. }
  77. chain->Finish();
  78. delete chain;
  79. std::cout << "*************************" << std::endl
  80. << "* Finish *" << std::endl
  81. << "*************************" << std::endl;
  82. }