AliPhysics  9b6b435 (9b6b435)
DrawHFAODQATrendVsRun.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TTree.h>
3 #include <TH1.h>
4 #include <TFile.h>
5 #include <TCanvas.h>
6 #include <TLegend.h>
7 #include <TLegendEntry.h>
8 #endif
9 
10 // Macro to draw the trending information from the output of readMCPerform.C
11 
12 TH1F* CreateHisto(TString nam, Int_t tote);
13 
14 Bool_t DrawHFAODQATrendVsRun(TString mergedTrendFile = "trending.root",
15  TString treename="trendingHF"){
16 
17  TFile *fin = TFile::Open(mergedTrendFile.Data());
18  if(!fin){
19  printf("Cannot open file with HF QA trending: %s\n",mergedTrendFile.Data());
20  return kFALSE;
21  }
22  TTree * ttree = (TTree*) fin->Get(treename.Data());
23  if (!ttree){
24  printf("Trending tree %s not found in file %s\n",treename.Data(),mergedTrendFile.Data());
25  return kFALSE;
26  }
27  Int_t nrun;
28  ttree->SetBranchAddress("nrun",&nrun);
29  TObjArray* lb=(TObjArray*)ttree->GetListOfBranches();
30  Int_t nVars=lb->GetEntries();
31  Int_t totEnt=ttree->GetEntries();
32  Float_t* vectVars=new Float_t[nVars-1];
33  Float_t* vectErrs=new Float_t[nVars-1];
34  for(Int_t j=0; j<nVars-1; j++){
35  vectVars[j]=-999.;
36  vectErrs[j]=-999.;
37  }
38  TH1F** htr=new TH1F*[nVars-1];
39  Int_t kv=0;
40  for(Int_t j=0; j<nVars; j++){
41  TBranch* br=(TBranch*)lb->At(j);
42  printf("Branch %d %s\n",j,br->GetName());
43  TString bnam=br->GetName();
44  if(!bnam.Contains("nrun")){
45  ttree->SetBranchAddress(bnam,&vectVars[kv]);
46  htr[kv]=CreateHisto(bnam,totEnt);
47  ++kv;
48  }
49  }
50  Int_t totHisto=kv;
51 
52  for(Int_t je=0; je<totEnt; je++){
53  ttree->GetEvent(je);
54  printf(" Run %d\n",nrun);
55  for(Int_t k=0; k<totHisto; k++){
56  htr[k]->SetBinContent(je+1,vectVars[k]);
57  if(vectErrs[k]>-900) htr[k]->SetBinError(je+1,vectErrs[k]);
58  else htr[k]->SetBinError(je+1,0.00001);
59  htr[k]->GetXaxis()->SetBinLabel(je+1,Form("%d",nrun));
60  }
61  }
62 
63  TCanvas* ccan=new TCanvas("ccan","Candidates",1400,900);
64  ccan->Divide(3,2);
65  for(Int_t k=0; k<totHisto; k++){
66  TString hname=htr[k]->GetName();
67  Bool_t draw=kFALSE;
68  if(hname.Contains("nDzeroCandperEv")){
69  htr[k]->GetYaxis()->SetTitle("N. D^{0} candidates / event");
70  ccan->cd(1);
71  draw=kTRUE;
72  }
73  else if(hname.Contains("nDplusCandperEv")){
74  htr[k]->GetYaxis()->SetTitle("N. D^{+} candidates / event");
75  ccan->cd(2);
76  draw=kTRUE;
77  }
78  else if(hname.Contains("nDsCandperEv")){
79  htr[k]->GetYaxis()->SetTitle("N. D_{s}^{+} candidates / event");
80  ccan->cd(4);
81  draw=kTRUE;
82  }
83  else if(hname.Contains("nDstarCandperEv")){
84  htr[k]->GetYaxis()->SetTitle("N. D*^{+} candidates / event");
85  ccan->cd(3);
86  draw=kTRUE;
87  }
88  else if(hname.Contains("nLcCandperEv")){
89  htr[k]->GetYaxis()->SetTitle("N. #Lambda_{c}^{+} candidates / event");
90  ccan->cd(5);
91  draw=kTRUE;
92  }
93  if(draw) htr[k]->Draw();
94  }
95  ccan->SaveAs("TrendHFCandidates.png");
96  ccan->SaveAs("TrendHFCandidates.root");
97 
98  return kTRUE;
99 }
100 
101 TH1F* CreateHisto(TString nam, Int_t tote){
102  TH1F* h=new TH1F(nam.Data(),Form(" ; run ; %s",nam.Data()),tote,0.5,tote+0.5);
103  h->SetStats(0);
104  h->SetMarkerStyle(20);
105  return h;
106 }
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
TH1F * CreateHisto(TString nam, Int_t tote)
Bool_t draw[nPtBins]
Bool_t DrawHFAODQATrendVsRun(TString mergedTrendFile="trending.root", TString treename="trendingHF")
bool Bool_t
Definition: External.C:53