refMultReader.C 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #define refMultReader_cxx
  2. #include "refMultReader.h"
  3. #include <TH2.h>
  4. #include <TStyle.h>
  5. #include <TFile.h>
  6. #include <TCanvas.h>
  7. #include <iostream>
  8. void refMultReader::Loop(const char* outfile)
  9. {
  10. // In a ROOT session, you can do:
  11. // root> .L refMultReader.C
  12. // root> refMultReader t
  13. // root> t.GetEntry(12); // Fill t data members with entry number 12
  14. // root> t.Show(); // Show values of entry 12
  15. // root> t.Show(16); // Read and show values of entry 16
  16. // root> t.Loop(); // Loop on all entries
  17. //
  18. // This is the loop skeleton where:
  19. // jentry is the global entry number in the chain
  20. // ientry is the entry number in the current Tree
  21. // Note that the argument to GetEntry must be:
  22. // jentry for TChain::GetEntry
  23. // ientry for TTree::GetEntry and TBranch::GetEntry
  24. //
  25. // To read only selected branches, Insert statements like:
  26. // METHOD1:
  27. // fChain->SetBranchStatus("*",0); // disable all branches
  28. // fChain->SetBranchStatus("branchname",1); // activate branchname
  29. // METHOD2: replace line
  30. // fChain->GetEntry(jentry); //read all branches
  31. //by b_branchname->GetEntry(ientry); //read only this branch
  32. if (fChain == 0) return;
  33. TH1F *hMult = new TH1F("hRefMult","refMult (|#eta|<0.5, p_{T}>0.15 GeV/c)",2500,0.,2500.);
  34. // Long64_t nentries = fChain->GetEntriesFast();
  35. Long64_t nentries = 500e3;
  36. Long64_t nbytes = 0, nb = 0;
  37. Int_t refMult;
  38. for (Long64_t jentry=0; jentry<nentries;jentry++) {
  39. Long64_t ientry = LoadTree(jentry);
  40. if (ientry < 0) break;
  41. nb = fChain->GetEntry(jentry); nbytes += nb;
  42. // if (Cut(ientry) < 0) continue;
  43. if (jentry%1000==0) std::cout << "Event [" << jentry << "/"
  44. << nentries << "]" << std::endl;
  45. refMult = 0;
  46. for (int iTr=0; iTr<n_tracks_mpd; iTr++)
  47. {
  48. if (TMath::Abs(signed_pt_mpd[iTr]) < 0.15) continue;
  49. if (TMath::Abs(eta_mpd[iTr]) > 0.5) continue;
  50. if (n_hits_mpd[iTr] < 32) continue;
  51. refMult++;
  52. }
  53. hMult->Fill(refMult);
  54. }
  55. TFile *fo = new TFile(outfile,"recreate");
  56. fo->cd();
  57. hMult->Write();
  58. fo->Close();
  59. }