Correction (Raphael)
[u/mrichter/AliRoot.git] / PWG1 / VZERO / readQAPbPb.C
1 void readQAPbPb(const char * period ="LHC11h", char * files = "list.txt"){
2         gStyle->SetPalette(1);
3          TGrid::Connect("alien://");
4         // gSystem->Exec("alien_find /alice/data/2011/LHC11a/* ESDs/pass1/QA*/QAresults.root > list.txt");
5         // gSystem->Exec("sed '$d' < list.txt > tmplist.txt ; mv tmplist.txt list.txt");
6
7    // TGridResult *res = gGrid->Query(Form("/alice/data/2011/%s/*",period),"ESDs/pass1/QAresults.root");
8    // const Int_t nFiles = res->GetEntries();
9    // if (nFiles ==0) {
10    //   Error("QA","No QA files found");
11    //   delete res;
12    //   return;
13    // }
14
15         TArrayI valid(1);
16         TArrayI runs(1);
17         AliCDBManager *man = AliCDBManager::Instance();
18
19   man->SetDefaultStorage("raw://");
20
21 Int_t minRun = 1000000;
22 Int_t maxRun = 0;
23 Int_t nValid =0;
24
25 FILE * fin = fopen(files,"r");
26 Int_t runNumber, nfiles=0;
27 while(EOF!=fscanf(fin,"%d, ",&runNumber)){
28         valid.Set(nfiles+1);
29         runs.Set(nfiles+1);
30         valid.SetAt(kTRUE,nfiles);
31         runs.SetAt(runNumber,nfiles);
32
33
34  gEnv->SetValue("XNet.ConnectTimeout",10);
35  gEnv->SetValue("XNet.RequestTimeout",10);
36  gEnv->SetValue("XNet.MaxRedirectCount",2);
37  gEnv->SetValue("XNet.ReconnectTimeout",10);
38  gEnv->SetValue("XNet.FirstConnectMaxCnt",1);   
39
40         man->SetRun(runNumber);
41         AliCDBEntry *entry2=0;
42         entry2 = man->Get("GRP/GRP/Data");
43         AliGRPObject* fGRPData=0;
44         if (entry2) {
45         printf("Found an AliGRPObject in GRP/GRP/Data, reading it\n");
46         fGRPData = dynamic_cast<AliGRPObject*>(entry2->GetObject());  // new GRP entry
47         entry2->SetOwner(0);
48         }
49         TString activeDetList(AliDAQ::ListOfTriggeredDetectors(fGRPData->GetDetectorMask()));
50         TString runType(fGRPData->GetRunType());
51         TString beamType(fGRPData->GetBeamType());
52         TString machineMode(fGRPData->GetMachineMode());
53         TString lhcState(fGRPData->GetLHCState());
54         cout<<"beamType "<<beamType<<endl;
55         cout<<"machineMode "<<machineMode<<endl;
56         cout<<"lhcState "<<lhcState<<endl;
57         
58         time_t duration = fGRPData->GetTimeEnd() - fGRPData->GetTimeStart();
59
60         if(!lhcState.Contains("STABLE BEAMS")){ // Remove no BEAM runs
61                 valid.SetAt(kFALSE,nfiles);
62                 continue;
63         }
64         if(!activeDetList.Contains("VZERO")){ // Remove Runs where VZERO is not active
65                 valid.SetAt(kFALSE,nfiles);
66                 continue;
67         }
68         if(!runType.Contains("PHYSICS")){ // Remove no PHYSICS runs
69                 valid.SetAt(kFALSE,nfiles);
70                 continue;
71         }
72         if(duration<600){ // Remove Runs shorter than 10 min
73                 valid.SetAt(kFALSE,nfiles);
74                 continue;
75         }
76         nfiles++;
77         nValid++;
78         
79         if(runNumber>maxRun) maxRun = runNumber;
80         if(runNumber<minRun) minRun = runNumber;
81 }
82
83 TH1F * hTimeA = new TH1F("hTimeA","BB Leading time;;Time (ns)",nValid,-0.5,nValid-0.5);
84 TH1F * hTimeC = new TH1F("hTimeC","BB Leading time;;Time (ns)",nValid,-0.5,nValid-0.5);
85 TH1F * hBB_BG = new TH1F("hBB_BG","Trigger ratio",nValid,-0.5,nValid-0.5);
86 TH1F * hBB_EE = new TH1F("hBB_EE","Trigger ratio",nValid,-0.5,nValid-0.5);
87 TH1F * hAdcA = new TH1F("hAdcA","Average Charge",nValid,-0.5,nValid-0.5);
88 TH1F * hAdcC = new TH1F("hAdcC","Average Charge",nValid,-0.5,nValid-0.5);
89 TH1F * hMultA = new TH1F("hMultA","Average number of Fired cell",nValid,-0.5,nValid-0.5);
90 TH1F * hMultC = new TH1F("hMultC","Average number of Fired cell",nValid,-0.5,nValid-0.5);
91 TH1F * hTriggerEff_CVLN = new TH1F("hTriggerEff_CVLN","CVLN / CVBN",nValid,-0.5,nValid-0.5);
92 TH1F * hTriggerEff_CVHN = new TH1F("hTriggerEff_CVHN","CVHN / CVBN",nValid,-0.5,nValid-0.5);
93 TH1F * hTriggerEff_CVHN2 = new TH1F("hTriggerEff_CVHN2","CVHN / CVLN",nValid,-0.5,nValid-0.5);
94 TH1F * hPMTEdges[64];
95 for(int i = 0; i < 64; ++i){
96         hPMTEdges[i] = new  TH1F(Form("hPMTEdges%d",i),Form("Multiplicity edge Cell %d",i),nValid,-0.5,nValid-0.5);
97 }
98
99 int nEntries=0;
100 TString trigMB, trigCVLN, trigCVHN;
101 for(int ifile = nfiles-1; ifile >= 0; ifile--){
102
103         if(!valid.At(ifile)) continue;
104         runNumber = runs.At(ifile);
105         
106         if(runNumber>168171){
107                 trigMB   = "CPBI2_B1";
108                 trigCVLN = "CVLN_R1";
109                 trigCVHN = "CVHN_R2";
110         } else if(runNumber>167693){
111                 trigMB   = "CPBI2_B1";
112                 trigCVLN = "CVLN_B2";
113                 trigCVHN = "CVHN_R2";
114         } else if(runNumber>166532)     {
115                 trigMB   = "CPBI1";
116                 trigCVLN = "CVLN";
117                 trigCVHN = "CVHN";
118         } else {
119                 trigMB   = "CPBI1";
120                 trigCVLN = "CVLN";
121                 trigCVHN = "CVHN";
122         }
123                 
124         TGridResult *res;
125         if(strcmp(period,"LHC11h")==0){
126                 res = gGrid->Query(Form("/alice/data/2011/%s/000%d/*",period,runNumber),"ESDs/pass1_HLT/QAresults.root");
127         }
128
129
130 if (res->GetEntries() ==0) {
131      Error("QA",Form("No QA files found for run %d\n",runNumber));
132      delete res;
133          nEntries++;
134      continue;
135    }
136
137            man->SetRun(runNumber);
138         
139         AliCDBEntry *entryCTP = man->Get("GRP/CTP/Config");
140    AliTriggerConfiguration *configCTP = (AliTriggerConfiguration*)entryCTP->GetObject();
141         TObjArray  inputsArray = configCTP->GetInputs();
142         
143         Double_t rnd1=1., rnd2=1., bc1=1., bc2=1.;
144         AliTriggerInput * input;
145         input = (AliTriggerInput*)(inputsArray.FindObject("RND1"));
146         if(input) rnd1 =  (input->GetSignature())/(double)(0x7fffffff );
147         if(input)cout<<Form("RND1 = %d",input->GetSignature())<<endl;
148
149         input = (AliTriggerInput*)(inputsArray.FindObject("RND2"));
150         if(input) rnd2 =  (input->GetSignature())/(double)(0x7fffffff );
151         if(input)cout<<Form("RND2 = %d",input->GetSignature())<<endl;
152         
153         input = (AliTriggerInput*)(inputsArray.FindObject("BC1"));
154         if(input) bc1 =  1./(input->GetSignature()+1.);
155         if(input)cout<<Form("BC1 = %d",input->GetSignature())<<endl;
156         
157         input = (AliTriggerInput*)(inputsArray.FindObject("BC2"));
158         if(input) bc2 =  1./(input->GetSignature()+1.);
159         if(input)cout<<Form("BC2 = %d",input->GetSignature())<<endl;
160
161
162         
163         TString filename = res->GetKey(0, "turl");
164         TObjArray* tmp = filename.Tokenize("/");
165         if(filename == "") continue;
166         TFile *fQA = TFile::Open(filename.Data());
167         if (!fQA) {
168         Error("QA",Form("Can not open QA file found for run %d\n",runNumber));
169                 nEntries++;
170         continue;
171         }
172         TList *list = (TList*)fQA->Get("VZERO_PbPb_Performance/PbPbVZEROHists");
173         TH2F *hTriggerDecision = (TH2F*)list->FindObject("hTriggerDecision");
174         TH1F *hAdcNoTimeA = (TH1F*)list->FindObject("hAdcNoTimeV0A");
175         TH1F *hAdcWithTimeA = (TH1F*)list->FindObject("hAdcWithTimeV0A");
176         TH1F *hAdcNoTimeC = (TH1F*)list->FindObject("hAdcNoTimeV0C");
177         TH1F *hAdcWithTimeC = (TH1F*)list->FindObject("hAdcWithTimeV0C");
178         TH2F *hadcpmtwithtime = (TH2F*)list->FindObject("hadcpmtwithtime");     
179         TH1F *htimepmtA = (TH1F*)list->FindObject("htimepmtV0A");
180         TH1F *htimepmtC = (TH1F*)list->FindObject("htimepmtV0C");
181         TH1F *hwidthA = (TH1F*)list->FindObject("hwidthV0A");
182         TH1F *hwidthC = (TH1F*)list->FindObject("hwidthV0C");
183         TH1F *hV0ampl = (TH1F*)list->FindObject("hV0ampl");
184         TH2F *htimepmt = (TH2F*)list->FindObject("htimepmt");   
185         TH2F *hwidthpmt = (TH2F*)list->FindObject("hwidthpmt"); 
186         TH2F *hadcwidthA = (TH2F*)list->FindObject("hadcwidthV0A");     
187         TH2F *hadcwidthC = (TH2F*)list->FindObject("hadcwidthV0C");     
188         TH2F *hAdcTimeA = (TH2F*)list->FindObject("hAdcTimeV0A");       
189         TH2F *hAdcTimeC = (TH2F*)list->FindObject("hAdcTimeV0C");       
190         TH2F *htimecorr = (TH2F*)list->FindObject("htimecorr"); 
191         TH2F *hNFlags   = (TH2F*)list->FindObject("hNFlags");
192         TH1F *hV0A = (TH1F*)hNFlags->ProjectionX("hV0A",1,hNFlags->GetNbinsY());
193         TH1F *hV0C = (TH1F*)hNFlags->ProjectionY("hV0C",1,hNFlags->GetNbinsX());
194         TH2F* hVtxXYBB  =(TH2F*) list->FindObject("fhVtxXYBB");
195         TH1F* hVtxZBB   =(TH1F*) list->FindObject("fhVtxZBB");
196         TH2F* hVtxXYBGA =(TH2F*) list->FindObject("fhVtxXYBGA");
197         TH1F* hVtxZBGA  =(TH1F*) list->FindObject("fhVtxZBGA");
198         TH2F* hVtxXYBGC =(TH2F*) list->FindObject("fhVtxXYBGC");
199         TH1F* hVtxZBGC  =(TH1F*) list->FindObject("fhVtxZBGC");
200         
201         TH2F* hRecoMult = (TH2F*) list->FindObject(Form("hRecoMult_%s-",trigMB.Data()));
202         TH2F* hRecoMultPMT = (TH2F*) list->FindObject(Form("hRecoMultPMT_%s-",trigMB.Data()));
203         TH1F* hTotRecoMult = (TH1F*) list->FindObject(Form("hTotRecoMult_%s-",trigMB.Data()));
204         TH1F* hTotRecoMult_CVLN = (TH1F*) list->FindObject(Form("hTotRecoMult_%s-",trigCVLN.Data()));
205         TH1F* hTotRecoMult_CVHN = (TH1F*) list->FindObject(Form("hTotRecoMult_%s-",trigCVHN.Data()));
206         TH2F* hEqualizedMult = (TH2F*) list->FindObject(Form("hEqualizedMult_%s-",trigMB.Data()));
207         
208         Double_t BB  = hTriggerDecision->GetBinContent(2,2);
209         Double_t EE  = hTriggerDecision->GetBinContent(1,1);
210         Double_t BGA = hTriggerDecision->GetBinContent(3,2);
211         Double_t BGC = hTriggerDecision->GetBinContent(2,3);
212                 
213         hTimeA->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
214         hTimeC->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
215         hBB_BG->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
216         hBB_EE->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
217         hAdcA->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
218         hAdcC->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
219         hMultA->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
220         hMultC->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
221         hTriggerEff_CVLN->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
222         hTriggerEff_CVHN->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
223         hTriggerEff_CVHN2->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
224     for(int i = 0; i < 64; ++i) {
225         hPMTEdges[i]->GetXaxis()->SetBinLabel(nEntries+1,Form("%d",runNumber));
226     }
227         
228         if(hAdcWithTimeA->GetEntries()==0) \10{
229                 delete fQA;     
230                 nEntries++;             
231                 continue;
232         }
233
234         Double_t cVLN = hTotRecoMult_CVLN->GetEntries();
235         Double_t cVHN = hTotRecoMult_CVHN->GetEntries();
236         Double_t cVBN = hTotRecoMult->GetEntries();
237         
238         // Correct for downscaling factor
239         Double_t scaleVBN = 1., scaleVLN = 1., scaleVHN = 1.;
240         if(trigMB.Contains("B1")) {
241                 if(bc1>0.) scaleVBN=1./bc1;
242         } else  if(trigMB.Contains("B2")) {
243                 if(bc2>0.) scaleVBN=1./bc2;
244         } else if(trigMB.Contains("R1")) {
245                 if(rnd1>0.) scaleVBN=1./rnd1;
246         } else if(trigMB.Contains("R2")) {
247                 if(rnd2>0.) scaleVBN=1./rnd2;
248         }
249         if(trigCVLN.Contains("B1")) {
250                 if(bc1>0.) scaleVLN=1./bc1;
251         } else  if(trigCVLN.Contains("B2")) {
252                 if(bc2>0.) scaleVLN=1./bc2;
253         } else if(trigCVLN.Contains("R1")) {
254                 if(rnd1>0.) scaleVLN=1./rnd1;
255         } else if(trigCVLN.Contains("R2")) {
256                 if(rnd2>0.) scaleVLN=1./rnd2;
257         }
258         
259         if(trigCVHN.Contains("B1")) {
260                 if(bc1>0.) scaleVHN=1./bc1;
261         } else  if(trigCVHN.Contains("B2")) {
262                 if(bc2>0.) scaleVHN=1./bc2;
263         } else if(trigCVHN.Contains("R1")) {
264                 if(rnd1>0.) scaleVHN=1./rnd1;
265         } else if(trigCVHN.Contains("R2")) {
266                 if(rnd2>0.) scaleVHN=1./rnd2;
267         }
268
269         cout<<Form("CVBN = %lf \nCVLN = %lf \nCVHN = %lf\n",cVBN,cVLN,cVHN);
270         hTotRecoMult->Scale(scaleVBN);
271         hTotRecoMult_CVLN->Scale(scaleVLN);
272         hTotRecoMult_CVHN->Scale(scaleVHN);
273
274         cVBN *= scaleVBN/100.;
275         cVLN *= scaleVLN;
276         cVHN *= scaleVHN;
277         
278         cout<<Form("CVBN = %lf \nCVLN = %lf \nCVHN = %lf\n",cVBN,cVLN,cVHN);
279
280         if(cVBN >0.){
281                 hTriggerEff_CVLN->SetBinContent(nEntries+1,cVBN/cVLN);
282                 if(cVLN>0.) hTriggerEff_CVLN->SetBinError(nEntries+1,cVBN/cVLN*(TMath::Sqrt(1./cVLN+1./cVBN)));
283                 hTriggerEff_CVHN->SetBinContent(nEntries+1,cVBN/cVHN);
284                 if(cVHN>0.) hTriggerEff_CVHN->SetBinError(nEntries+1,cVBN/cVHN*(TMath::Sqrt(1./(cVHN/scaleVHN)+1./(cVBN/scaleVBN*100.))));
285                 if(cVLN>0.) hTriggerEff_CVHN2->SetBinContent(nEntries+1,cVLN/cVHN);
286                 if(cVHN>0. && cVLN>0.) hTriggerEff_CVHN2->SetBinError(nEntries+1,cVLN/cVHN*(TMath::Sqrt(1./(cVHN/scaleVHN)+1./(cVLN/scaleVLN))));
287         }
288
289     Double_t beta1[64], beta2[64];
290     Double_t q = 1. - 1.e-4;
291     Double_t q2 = 1. - 2.e-4;
292     for(int i = 0; i < 64; ++i) {
293         ((TH1D*)hRecoMultPMT->ProjectionY(Form("hRecoMultPMT%d",i),i+1,i+1))->GetQuantiles(1,&beta1[i],&q);
294         ((TH1D*)hRecoMultPMT->ProjectionY(Form("hRecoMultPMT%d",i),i+1,i+1))->GetQuantiles(1,&beta2[i],&q2);
295         hPMTEdges[i]->SetBinContent(nEntries+1,(beta1[i]+beta2[i])/2.);
296                 hPMTEdges[i]->SetBinError(nEntries+1,(beta1[i] - beta2[i]));
297     }
298
299     Double_t betaSide1[2];
300     Double_t betaSide2[2];
301     for(int i = 0; i < 2; ++i) {
302                 if(i==0){
303                         ((TH1D*)hRecoMult->ProjectionY(Form("hRecoMult1%d",i)))->GetQuantiles(1,&betaSide1[i],&q);
304                         ((TH1D*)hRecoMult->ProjectionY(Form("hRecoMult2%d",i)))->GetQuantiles(1,&betaSide2[i],&q2);
305             }else{
306                         ((TH1D*)hRecoMult->ProjectionX(Form("hRecoMult1%d",i)))->GetQuantiles(1,&betaSide1[i],&q);
307                         ((TH1D*)hRecoMult->ProjectionX(Form("hRecoMult2%d",i)))->GetQuantiles(1,&betaSide2[i],&q2);
308                 }
309     }
310         hAdcA->SetBinContent(nEntries+1,(betaSide1[1] + betaSide2[1])/2.);
311         hAdcC->SetBinContent(nEntries+1,(betaSide1[0] + betaSide2[0])/2.);
312         hAdcA->SetBinError(nEntries+1,(betaSide1[1] - betaSide2[1]));
313         hAdcC->SetBinError(nEntries+1,(betaSide1[0] - betaSide2[0]));
314         
315         
316
317         
318                 TSpectrum s;
319                 int nPeaksFound;
320                 float * peaks;
321                 float max;
322                 float shiftA = 8.;
323
324                 nPeaksFound = s.Search(htimepmtA); peaks = s.GetPositionX(); max = -25.;
325                 for(int i=0;i<nPeaksFound;i++) if(peaks[i]>max) max = peaks[i]; 
326                 htimepmtA->Fit("gaus","","",max-1.,max+1.);
327                 hTimeA->Fill(nEntries,gaus->GetParameter(1)-shiftA);
328
329                 nPeaksFound = s.Search(htimepmtC); peaks = s.GetPositionX(); max = -25.;
330                 for(int i=0;i<nPeaksFound;i++) if(peaks[i]>max) max = peaks[i]; 
331                 htimepmtC->Fit("gaus","","",max-1.,max+1.);
332                 hTimeC->Fill(nEntries,gaus->GetParameter(1));
333
334                 if(BB) {
335                         hBB_BG->SetBinContent(nEntries,(BGA+BGC)/BB);
336                         hBB_EE->SetBinContent(nEntries,EE/BB);
337                 } else {
338                         hBB_BG->SetBinContent(nEntries,0);
339                         hBB_EE->SetBinContent(nEntries,0);
340                 }
341
342                 hMultA->SetBinContent(nEntries,hV0A->GetMean());
343                 hMultC->SetBinContent(nEntries,hV0C->GetMean());
344
345                 //              hAdcA->SetBinContent(nEntries,hAdcWithTimeA->GetMean());
346                 //              hAdcC->SetBinContent(nEntries,hAdcWithTimeC->GetMean());
347
348 //-------------
349         TCanvas * cOut = new TCanvas("cOut",Form("Run %d",runNumber));
350         cOut->Divide(2,2);
351         cOut->cd(1); cOut->GetPad(1)->SetLogy();
352         hAdcNoTimeA->Draw("l");
353         hAdcWithTimeA->Draw("same"); hAdcWithTimeA->SetLineColor(2);
354         
355         cOut->cd(2); cOut->GetPad(2)->SetLogy();
356         hAdcNoTimeC->Draw("l");
357         hAdcWithTimeC->Draw("same"); hAdcWithTimeC->SetLineColor(2);
358         
359         cOut->cd(3); cOut->GetPad(3)->SetLogz();
360         hadcpmtwithtime->Draw("colz");
361
362
363         cOut->cd(4); cOut->GetPad(4)->SetLogy(0);cOut->GetPad(4)->SetLogz(1);
364         hEqualizedMult->Draw("colz");  
365         
366         cOut->Print(Form("QA_Run_%d.pdf(",runNumber));
367 //-------------
368
369         cOut->Clear();
370         cOut->cd(1); cOut->GetPad(1)->SetLogy();
371         htimepmtA->GetXaxis()->SetRangeUser(-25.,25.); htimepmtA->Draw();
372
373         cOut->cd(2); cOut->GetPad(2)->SetLogy();
374         htimepmtC->GetXaxis()->SetRangeUser(-25.,25.); htimepmtC->Draw();
375         
376         cOut->cd(3); cOut->GetPad(3)->SetLogy();cOut->GetPad(3)->SetLogz(0);
377         //hwidthA->GetXaxis()->SetRangeUser(0.,50.); 
378         hwidthA->Draw();
379         
380         cOut->cd(4); cOut->GetPad(4)->SetLogy();cOut->GetPad(4)->SetLogz(0);
381         //hwidthC->GetXaxis()->SetRangeUser(0.,50.); 
382         hwidthC->Draw();
383
384         cOut->Print(Form("QA_Run_%d.pdf",runNumber));
385 //-------------
386
387         cOut->Clear();
388         cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz();
389         htimepmt->Draw("colz");
390
391         cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz();
392         //hwidthpmt->GetYaxis()->SetRangeUser(0.,50.); 
393         hwidthpmt->Draw("colz");
394         
395         cOut->cd(3); cOut->GetPad(3)->SetLogy(0);cOut->GetPad(3)->SetLogz();
396         //hadcwidthA->GetYaxis()->SetRangeUser(0.,50.); 
397         hadcwidthA->Draw("colz");
398         
399         cOut->cd(4); cOut->GetPad(4)->SetLogy(0);cOut->GetPad(4)->SetLogz();
400         //hadcwidthC->GetYaxis()->SetRangeUser(0.,50.); 
401         hadcwidthC->Draw("colz");
402
403         cOut->Print(Form("QA_Run_%d.pdf",runNumber));
404 //-------------
405
406         cOut->Clear();
407         cOut->cd(1); cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz();
408         hAdcTimeA->Draw("colz");
409
410         cOut->cd(2); cOut->GetPad(2)->SetLogy(0);cOut->GetPad(2)->SetLogz();
411         hAdcTimeC->Draw("colz");
412         
413         cOut->cd(3); cOut->GetPad(3)->SetLogz();
414         hTriggerDecision->Draw("text");
415         
416         cOut->cd(4); cOut->GetPad(4)->SetLogz(); cOut->GetPad(4)->SetLogz(0);
417         htimecorr->Draw("colz");
418
419         cOut->Print(Form("QA_Run_%d.pdf",runNumber));
420 //-------------
421
422         cOut->Clear();
423         cOut->cd(1);  cOut->GetPad(1)->SetLogy(1);cOut->GetPad(1)->SetLogz(0);
424         hV0A->GetXaxis()->SetRangeUser(0.,33.);hV0A->Draw();
425
426         cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0);
427         hV0C->GetXaxis()->SetRangeUser(0.,33.);hV0C->Draw();
428
429         cOut->cd(3); cOut->GetPad(3)->SetLogy(0);cOut->GetPad(3)->SetLogz(0); cOut->GetPad(3)->SetGridy(1);
430         hTotRecoMult->Sumw2();
431         hTotRecoMult_CVLN->Sumw2();
432         hTotRecoMult_CVHN->Sumw2();
433         hTotRecoMult_CVLN->Divide(hTotRecoMult);
434         hTotRecoMult_CVHN->Divide(hTotRecoMult);
435         hTotRecoMult_CVLN->Draw("e"); hTotRecoMult_CVLN->SetLineColor(4);hTotRecoMult_CVLN->SetMarkerStyle(0);hTotRecoMult_CVLN->SetMaximum(1.2);
436         hTotRecoMult_CVLN->SetTitle("Multiplicity efficiency CVLN (blue) and CHVN (red)");
437         hTotRecoMult_CVHN->Draw("esame"); hTotRecoMult_CVHN->SetLineColor(2);hTotRecoMult_CVHN->SetMarkerStyle(0);
438         
439         cOut->cd(4); cOut->GetPad(4)->SetLogy(0);cOut->GetPad(4)->SetLogz(1); cOut->GetPad(4)->SetGridx(1); cOut->GetPad(4)->SetGridy(1);
440         hRecoMult->Draw("colz");
441         
442         
443         cOut->Print(Form("QA_Run_%d.pdf",runNumber));
444 //-------------
445
446         cOut->Clear();
447         cOut->Divide(2,3);
448
449         cOut->cd(1);  cOut->GetPad(1)->SetLogy(0);cOut->GetPad(1)->SetLogz(1);
450         hVtxXYBB->Draw("colz");
451
452         cOut->cd(2); cOut->GetPad(2)->SetLogy(1);cOut->GetPad(2)->SetLogz(0);
453         hVtxZBB->Draw();
454         
455         cOut->cd(3); cOut->GetPad(3)->SetLogy(0); cOut->GetPad(3)->SetLogz(1);
456         hVtxXYBGA->Draw("colz");
457         
458         cOut->cd(4); cOut->GetPad(4)->SetLogy(); cOut->GetPad(3)->SetLogz(0);
459         hVtxZBGA->Draw();
460         
461         cOut->cd(5); cOut->GetPad(5)->SetLogy(0); cOut->GetPad(5)->SetLogz(1);
462         hVtxXYBGC->Draw("colz");
463         
464         cOut->cd(6); cOut->GetPad(6)->SetLogy(); cOut->GetPad(6)->SetLogz(0);
465         hVtxZBGC->Draw();
466
467         cOut->Print(Form("QA_Run_%d.pdf)",runNumber));
468 //-------------
469
470                         delete cOut;
471                         delete fQA;                     
472
473                         nEntries++;
474
475                 }
476                 delete res;
477
478 gStyle->SetOptStat(0);
479 hTimeA->SetMarkerStyle(20);
480 hTimeA->SetMarkerColor(2);
481
482 hTimeC->SetMarkerStyle(20);
483 hTimeC->SetMarkerColor(4);
484
485 TCanvas * c = new TCanvas("c","Leading time versus run number");
486 c->SetGridy();
487 hTimeA->Draw("P");
488 hTimeA->SetMinimum(TMath::Min(hTimeA->GetMinimum(),hTimeC->GetMinimum())-1.);
489 hTimeA->SetMaximum(TMath::Max(hTimeA->GetMaximum(),hTimeC->GetMaximum())+1.);
490 // hTimeA->GetXaxis()->SetLabelOptions("v");
491 // hTimeC->GetXaxis()->SetLabelOptions("v");
492
493 hTimeC->Draw("Psame");
494 TLegend * lg = new TLegend(0.8,0.9,1,1);
495 lg->AddEntry(hTimeA,"V0A - 8 ns","p");
496 lg->AddEntry(hTimeC,"V0C","p");
497 lg->Draw("same");
498 // TPave * pavA = new TPave(-0.5,TMath::Max(hTimeA->GetMinimum(),1.5-shiftA),nValid-0.5,TMath::Min(hTimeA->GetMaximum(),33.5-shiftA),0);
499 // pavA->SetFillStyle(3004);
500 // pavA->SetFillColor(2);
501 // TPave * pavC = new TPave(-0.5,TMath::Max(hTimeA->GetMinimum(),0.5),nValid-0.5,TMath::Min(hTimeA->GetMaximum(),25.5),0);
502 // pavC->SetFillStyle(3005);
503 // pavC->SetFillColor(4);
504 // 
505 // pavA->Draw("same");
506 // pavC->Draw("same");
507 TFile * fout = TFile::Open(Form("QA_Resume_%d_%d.root",minRun,maxRun),"RECREATE");
508
509 c->Print(Form("QA_Resume_%d_%d.pdf(",minRun,maxRun));
510 c->Write();
511
512 TCanvas * c2 = new TCanvas("c2","Trigger ratios");
513 c2->SetGridy();
514
515 hBB_BG->SetMarkerStyle(20);
516 hBB_BG->SetMarkerColor(2);
517 hBB_EE->SetMarkerStyle(20);
518 hBB_EE->SetMarkerColor(4);
519
520 hBB_BG->Draw("P");hBB_BG->SetTitle("Beam-Gas / Beam-Beam");
521 // hBB_EE->Draw("Psame");
522 // TLegend * lg2 = new TLegend(0.8,0.9,1,1);
523 // lg2->AddEntry(hBB_BG,"BG / BB","p");
524 // lg2->AddEntry(hBB_EE,"EE / BB","p");
525 // lg2->Draw("same");
526
527 c2->Print(Form("QA_Resume_%d_%d.pdf",minRun,maxRun));
528 c2->Write();
529
530
531 TCanvas * c3 = new TCanvas("c3","Multiplicity Eddes V0A/V0C");
532 c3->SetGridy();
533
534 hAdcA->SetMarkerStyle(20);
535 hAdcA->SetMarkerColor(2);
536 hAdcC->SetMarkerStyle(20);
537 hAdcC->SetMarkerColor(4);
538 hAdcA->SetMinimum(0);
539 hAdcA->SetMaximum(100);
540
541 hAdcA->Draw("P");
542 hAdcC->Draw("Psame");
543 TLegend * lg3 = new TLegend(0.8,0.9,1,1);
544 lg3->AddEntry(hAdcA,"V0A","p");
545 lg3->AddEntry(hAdcC,"V0C","p");
546 lg3->Draw("same");
547
548 c3->Print(Form("QA_Resume_%d_%d.pdf",minRun,maxRun));
549 c3->Write();
550
551
552 TCanvas * c4 = new TCanvas("c4","Average number of cell");
553 c4->SetGridy();
554
555 hMultA->SetMarkerStyle(20);
556 hMultA->SetMarkerColor(2);
557 hMultC->SetMarkerStyle(20);
558 hMultC->SetMarkerColor(4);
559 hMultA->SetMinimum(0);
560 hMultA->SetMaximum(32);
561
562 hMultA->Draw("P");
563 hMultC->Draw("Psame");
564 TLegend * lg4 = new TLegend(0.8,0.9,1,1);
565 lg4->AddEntry(hMultA,"V0A","p");
566 lg4->AddEntry(hMultC,"V0C","p");
567 lg4->Draw("same");
568
569 c4->Print(Form("QA_Resume_%d_%d.pdf",minRun,maxRun));
570 c4->Write();
571
572 TCanvas * c5 = new TCanvas("c5","Trigger Efficiency");
573 c5->SetGridy();
574
575 hTriggerEff_CVLN->SetMarkerStyle(20);
576 hTriggerEff_CVLN->SetMarkerColor(2);
577 hTriggerEff_CVHN->SetMarkerStyle(20);
578 hTriggerEff_CVHN->SetMarkerColor(4);
579 hTriggerEff_CVHN2->SetMarkerStyle(4);
580 hTriggerEff_CVHN2->SetMarkerColor(1);
581 hTriggerEff_CVLN->SetMinimum(0);
582 hTriggerEff_CVLN->SetMaximum(15.);
583 hTriggerEff_CVLN->SetTitle("Centrality triggers fraction");
584
585 hTriggerEff_CVLN->Draw("P");
586 hTriggerEff_CVHN->Draw("Psame");
587 hTriggerEff_CVHN2->Draw("Psame");
588 TLegend * lg5 = new TLegend(0.7,0.8,1,1);
589 lg5->AddEntry(hTriggerEff_CVLN,"(CPBI2/100) / CVLN","p");
590 lg5->AddEntry(hTriggerEff_CVHN,"(CPBI2/100) / CVHN","p");
591 lg5->AddEntry(hTriggerEff_CVHN2,"CVLN / CVHN","p");
592 lg5->Draw("same");
593
594 c5->Print(Form("QA_Resume_%d_%d.pdf",minRun,maxRun));
595 c5->Write();
596
597
598 TCanvas * cedge[8];
599 for(int i = 0; i < 8; ++i){
600         cedge[i] = new TCanvas(Form("cedge%d",i),Form("Edge Ring %d",i));
601         cedge[i]->SetGridy();
602         cedge[i]->Divide(3,3);
603         for(int iCh = 0; iCh < 8; ++iCh){
604                 cedge[i]->cd(iCh+1);
605                 hPMTEdges[iCh+i*8]->SetMarkerStyle(20);
606                 hPMTEdges[iCh+i*8]->Draw("P");
607         }
608         if(i==7) cedge[i]->Print(Form("QA_Resume_%d_%d.pdf)",minRun,maxRun));
609         else cedge[i]->Print(Form("QA_Resume_%d_%d.pdf",minRun,maxRun));
610         cedge[i]->Write();
611 }
612
613
614
615
616
617 fout->Close();
618
619 gSystem->Exec(Form("tar cvf QA_Runs_%d_%d.tar QA_Run*.pdf QA_Resume_%d_%d.pdf QA_Resume_%d_%d.root",minRun,maxRun,minRun,maxRun,minRun,maxRun));
620 gSystem->Exec(Form("rm -f QA_Run*.pdf QA_Resume_%d_%d.pdf  QA_Resume_%d_%d.root",minRun,maxRun,minRun,maxRun));
621
622
623 }
624