]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/VZERO/trending/DrawTrendingV0QA.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / VZERO / trending / DrawTrendingV0QA.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TError.h>
3 #include <TROOT.h>
4 #include <TKey.h>
5 #include <TH2.h>
6 #include <TF1.h>
7 #include <TH1.h>
8 #include <TFile.h>
9 #include <TCanvas.h>
10 #include <TPad.h>
11 #include <TStyle.h>
12 #include <TGrid.h>
13 #include <TGridResult.h>
14 #include <TEnv.h>
15 #include <TLegend.h>
16 #include <TMath.h>
17 #include <TSpectrum.h>
18 #include <TTree.h>
19
20 #include "AliCDBManager.h"
21 #include "AliCDBEntry.h"
22 #include "AliGRPObject.h"
23 #include "AliTriggerInput.h"
24 #include "AliTriggerConfiguration.h"
25 #endif
26
27 Int_t DrawTrendingV0QA(TString mergedTrendFile ="trending.root")
28 {
29         if(!mergedTrendFile)
30         {
31                 printf("Cannot open merged trend file with V0 QA");
32                 return 1;
33         }
34         char outfilename[200]="ProductionQA.hist.root";
35         TString plotDir(".");
36         
37         Int_t runNumber=0, NumberVoieOff=0, numberBadOffset=0;
38         TFile*fin=TFile::Open(mergedTrendFile.Data());
39         if(!fin)
40         {
41                 Printf("ERROR: trending file not found. Exiting ...\n");
42                 return -1;
43         }
44         TTree*ttree=(TTree*)fin->Get("trending");
45         if(!ttree)
46         {
47                 printf("Invalid trending tree");
48                 return 2;
49         }
50         Float_t TimesA=0.,TimesC=0., BB_BG=0.,BB_EE=0.,AdcA=0.;
51         Float_t AdcC=0.,MultA=0.,MultC=0.;
52         
53         
54         ttree->SetBranchAddress("run",&runNumber);
55         ttree->SetBranchAddress("TimesA",&TimesA);
56         ttree->SetBranchAddress("TimesC",&TimesC);
57         ttree->SetBranchAddress("BB_BG",&BB_BG);
58         ttree->SetBranchAddress("BB_EE",&BB_EE);
59         ttree->SetBranchAddress("AdcA" ,&AdcA );
60         ttree->SetBranchAddress("AdcC" ,&AdcC );
61         ttree->SetBranchAddress("MultA",&MultA);
62         ttree->SetBranchAddress("MultC",&MultC);
63         ttree->SetBranchAddress("NumberVoieOff",&NumberVoieOff);
64         ttree->SetBranchAddress("numberBadOffset",&numberBadOffset);
65         
66         Int_t nRuns=ttree->GetEntries();
67         TList list;
68         
69         TH1F * hTimeA = new TH1F("hTimeA","BB Leading time;;Time (ns)",nRuns,-0.5,nRuns-0.5);
70         TH1F * hTimeC = new TH1F("hTimeC","BB Leading time;;Time (ns)",nRuns,-0.5,nRuns-0.5);
71         TH1F * hBB_BG = new TH1F("hBB_BG","Trigger ratio",nRuns,-0.5,nRuns-0.5);
72         TH1F * hBB_EE = new TH1F("hBB_EE","Trigger ratio",nRuns,-0.5,nRuns-0.5);
73         TH1F * hAdcA = new TH1F("hAdcA","Average Charge",nRuns,-0.5,nRuns-0.5);
74         TH1F * hAdcC = new TH1F("hAdcC","Average Charge",nRuns,-0.5,nRuns-0.5);
75         TH1F * hMultA = new TH1F("hMultA","Average number of Fired cell",nRuns,-0.5,nRuns-0.5);
76         TH1F * hMultC = new TH1F("hMultC","Average number of Fired cell",nRuns,-0.5,nRuns-0.5);
77         TH1F * hNumberVoieOff=new TH1F("hNumberVoieOff","Number of chanel off",nRuns,-0.5,nRuns-0.5);
78         hNumberVoieOff->SetMaximum(70);
79         TH1F * hNumberBadOffset=new TH1F("hNumberBadOffset","Number of pdestal",nRuns,-0.5,nRuns-0.5);
80         hNumberBadOffset->SetMaximum(70);
81         
82         list.Add(hTimeA);
83         list.Add(hTimeC);
84         list.Add(hBB_BG);
85         list.Add(hBB_EE);
86         list.Add(hAdcA );
87         list.Add(hAdcC );
88         list.Add(hMultA);
89         list.Add(hMultC);
90         list.Add(hNumberVoieOff);
91         list.Add(hNumberBadOffset);
92         char runlabel[6];
93         
94         
95         for(Int_t irun=0;irun<nRuns;irun++)
96         {
97                 ttree->GetEntry(irun);
98                 sprintf(runlabel,"%i",runNumber);
99                 
100                 hTimeA->SetBinContent(irun+1,TimesA);
101                 hTimeA->GetXaxis()->SetBinLabel(irun+1,runlabel);
102                 
103                 hTimeC->SetBinContent(irun+1,TimesC);
104                 hTimeC->GetXaxis()->SetBinLabel(irun+1,runlabel);
105                 
106                 hBB_BG->SetBinContent(irun+1,BB_BG);
107                 hBB_BG->GetXaxis()->SetBinLabel(irun+1,runlabel);
108                 
109                 hBB_EE->SetBinContent(irun+1,BB_EE);
110                 hBB_EE->GetXaxis()->SetBinLabel(irun+1,runlabel);
111                 
112                 hAdcA->SetBinContent(irun+1,AdcA);
113                 hAdcA ->GetXaxis()->SetBinLabel(irun+1,runlabel);
114                 
115                 hAdcC->SetBinContent(irun+1,AdcC);
116                 hAdcC ->GetXaxis()->SetBinLabel(irun+1,runlabel);
117                 
118                 hMultA->SetBinContent(irun+1,MultA);
119                 hMultA->GetXaxis()->SetBinLabel(irun+1,runlabel);
120                 
121                 hMultC->SetBinContent(irun+1,MultC);
122                 hMultC->GetXaxis()->SetBinLabel(irun+1,runlabel);
123                 
124                 hNumberVoieOff->SetBinContent(irun+1,NumberVoieOff);
125                 hNumberVoieOff->GetXaxis()->SetBinLabel(irun+1,runlabel);
126                 
127                 hNumberBadOffset->SetBinContent(irun+1,numberBadOffset);
128                 hNumberBadOffset->GetXaxis()->SetBinLabel(irun+1,runlabel);
129         }
130         
131         TFile*fout=new TFile(outfilename,"recreate");
132         fout->cd();
133         list.Write();
134         fout->Close();
135         int maxRun =runNumber;
136         ttree->GetEntry(0);
137         int minRun = runNumber;
138         
139         gStyle->SetOptStat(0);
140         hTimeA->SetMarkerStyle(20);
141         hTimeA->SetMarkerColor(2);
142   
143         hTimeC->SetMarkerStyle(20);
144         hTimeC->SetMarkerColor(4);
145
146         
147         
148         
149         TCanvas * c = new TCanvas("c","Leading time versus run number");
150         hTimeA->GetYaxis()->SetRange(0,10);
151         hTimeA->Draw("P");
152         hTimeA->SetMinimum(TMath::Min(hTimeA->GetMinimum(),hTimeC->GetMinimum())-1.);
153         hTimeA->SetMaximum(TMath::Max(hTimeA->GetMaximum(),hTimeC->GetMaximum())+1.);
154   
155         hTimeC->GetYaxis()->SetRange(0,10);
156         hTimeC->Draw("Psame");
157         TLegend * lg = new TLegend(0.8,0.9,1,1);
158         lg->AddEntry(hTimeA,"V0A - 8 ns","p");
159         lg->AddEntry(hTimeC,"V0C","p");
160         lg->Draw("same");
161         float shiftA=8.0;
162         TPave * pavA = new TPave(-0.5,TMath::Max(hTimeA->GetMinimum(),1.5-shiftA),nRuns-0.5,TMath::Min(hTimeA->GetMaximum(),33.5-shiftA),0);
163         pavA->SetFillStyle(3004);
164         pavA->SetFillColor(2);
165         TPave * pavC = new TPave(-0.5,TMath::Max(hTimeC->GetMinimum(),0.5),nRuns-0.5,TMath::Min(hTimeC->GetMaximum(),25.5),0);
166         pavC->SetFillStyle(3005);
167         pavC->SetFillColor(4);
168   
169         pavA->Draw("same");
170         pavC->Draw("same");
171
172         
173         c->Print(Form("%s/QA_Resume_%d_%d.pdf(",plotDir.Data(),minRun,maxRun));
174         c->Write();
175   
176         TCanvas * c2 = new TCanvas("c2","Trigger ratios");
177         c2->SetGridy();
178   
179         hBB_BG->SetMarkerStyle(20);
180         hBB_BG->SetMarkerColor(2);
181         hBB_EE->SetMarkerStyle(20);
182         hBB_EE->SetMarkerColor(4);
183         
184         hBB_BG->Draw("P");
185         hBB_EE->Draw("Psame");
186         TLegend * lg2 = new TLegend(0.8,0.9,1,1);
187         lg2->AddEntry(hBB_BG,"BG / BB","p");
188         lg2->AddEntry(hBB_EE,"EE / BB","p");
189         lg2->Draw("same");
190         
191         c2->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));
192         c2->Write();
193         
194         
195         TCanvas * c3 = new TCanvas("c3","Average Charge");
196         c3->SetGridy();
197         
198         hAdcA->SetMarkerStyle(20);
199         hAdcA->SetMarkerColor(2);
200         hAdcC->SetMarkerStyle(20);
201         hAdcC->SetMarkerColor(4);
202         hAdcA->SetMinimum(0);
203         hAdcA->SetMaximum(100);
204         
205         hAdcA->Draw("P");
206         hAdcC->Draw("Psame");
207         TLegend * lg3 = new TLegend(0.8,0.9,1,1);
208         lg3->AddEntry(hAdcA,"V0A","p");
209         lg3->AddEntry(hAdcC,"V0C","p");
210         lg3->Draw("same");
211         
212         c3->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));
213         c3->Write();
214         
215   
216         TCanvas * c4 = new TCanvas("c4","Average number of cell");
217         c4->SetGridy();
218         
219         hMultA->SetMarkerStyle(20);
220         hMultA->SetMarkerColor(2);
221         hMultC->SetMarkerStyle(20);
222         hMultC->SetMarkerColor(4);
223         hMultA->SetMinimum(0);
224         hMultA->SetMaximum(32);
225         
226         hMultA->Draw("P");
227         hMultC->Draw("Psame");
228         TLegend * lg4 = new TLegend(0.8,0.9,1,1);
229         lg4->AddEntry(hMultA,"V0A","p");
230         lg4->AddEntry(hMultC,"V0C","p");
231         lg4->Draw("same");
232         
233         c4->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));
234         c4->Write();
235
236         TCanvas * c5 = new TCanvas("c5","");
237         c5->cd();
238         hNumberVoieOff->Draw();
239         TCanvas * c6 = new TCanvas("c6","");
240         c6->cd();
241         hNumberBadOffset->Draw();
242         c5->Print(Form("%s/QA_Resume_%d_%d.pdf",plotDir.Data(),minRun,maxRun));
243         c6->Print(Form("%s/QA_Resume_%d_%d.pdf)",plotDir.Data(),minRun,maxRun));
244         c5->Write();
245         return 0;
246 }