pp200_run12_triggerQA.C 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 = "pp200_run12.list";
  8. const Char_t *defaultOutFile = "PicoDstQA.root";
  9. class StPicoDstQA;
  10. class StPicoDstMaker;
  11. void pp200_run12_triggerQA(const char *inFileList = defaultInFile,
  12. const char *outFileName = defaultOutFile)
  13. {
  14. std::cout << "**************************************" << std::endl
  15. << "* *" << std::endl
  16. << "* Hello, this is quality assurance *" << std::endl
  17. << "* for the pp200 PicoDst *" << std::endl
  18. << "* *" << std::endl
  19. << "**************************************" << std::endl;
  20. //
  21. // Load libraries
  22. //
  23. std::cout << "Loading libraries..." << std::endl;
  24. gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  25. loadSharedLibraries();
  26. gSystem->Load("libMinuit");
  27. gSystem->Load("StChain");
  28. gSystem->Load("StarClassLibrary");
  29. gSystem->Load("StFlowMaker");
  30. gSystem->Load("StHbtMaker");
  31. gSystem->Load("StPicoDstMaker");
  32. std::cout << "Libraries have been successfully loaded" << std::endl;
  33. //
  34. // Create chain
  35. //
  36. StChain *chain = new StChain("StChain");
  37. chain->SetDebug(0);
  38. //
  39. // Create PicoDst reader
  40. //
  41. std::cout << Form("Try to read file: %s", inFileList) << std::endl;
  42. StPicoDstMaker *picoMaker = new StPicoDstMaker(0, inFileList);
  43. StPicoDstTriggerQA *QAmaker = new StPicoDstTriggerQA(picoMaker, outFileName);
  44. chain->Init();
  45. TChain *currentTree = picoMaker->chain();
  46. Long64_t nEvents = currentTree->GetEntries();
  47. std::cout << Form("Number of events in TTree: %d", nEvents) << std::endl;
  48. Int_t iReturn = 0;
  49. Int_t nEventsProcessed = 0;
  50. Float_t percentCounter = 0.01;
  51. Float_t progress = 0.;
  52. for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
  53. progress = (Float_t)iEvent/(Float_t)nEvents;
  54. nEventsProcessed++;
  55. if(progress >= percentCounter) {
  56. percentCounter += 0.01;
  57. std::cout << Form("Processing progress: %4.2f%%", percentCounter*100.)
  58. << std::endl;
  59. }
  60. chain->Clear();
  61. iReturn = chain->Make(iEvent);
  62. if (iReturn != 0) {
  63. std::cout << "Error has been occured. Event processing has been stopped"
  64. << std::endl;
  65. break;
  66. }
  67. }
  68. chain->Finish();
  69. delete chain;
  70. std::cout << "*************************" << std::endl
  71. << "* Finish *" << std::endl
  72. << "*************************" << std::endl;
  73. }