Physics selection QA
[u/mrichter/AliRoot.git] / PWG1 / macros / PhysSel / read.C
1 #include "QALHC11c_QA69.h"
2 #include "DefinePlots.h"
3 #include "TGraphErrors.h"
4
5 TH1F *fAccOverAll[3];
6 TH1F *fBGOverAll[3];
7 TH1F *fV0BGOverAll[3];
8 TH1F *fV0ABGOverAll[3];
9 TH1F *fV0CBGOverAll[3];
10 TH1F *fAfterOverBefore[3];
11 TH1F *fV0AOverV0C[3];
12 TH1F *fF02OverAll[3];
13 TH1F *fF01OverAll[3];
14
15 TFile fou;
16 TLine *l1=new TLine(153776, 0, 153776, 1);
17 TH1F * GetEmpty(const char * name, Int_t nfile);
18 TGraphErrors * GetGraphRej(TGraphErrors * gr, TList * rejRunList, const char * reason, Float_t &mean, Bool_t doDraw) ;
19 double GetMedian(double* arr, int n);
20 double meanMed(double* vec, int np, double nsigmaCut, int &nrej, int *rejList);
21 TGraphErrors * graph[kNGraphs];
22
23
24 void read(){
25   
26   for(Int_t i=0;i<3;++i){
27     fAccOverAll[i]=new TH1F(Form("fAccOverAll_%d",i),Form("fAccOverAll_%d",i),100,0,1);
28     fBGOverAll[i]=new TH1F(Form("fBGOverAll_%d",i),Form("fBGOverAll_%d",i),50,0,0.5);
29     fV0BGOverAll[i]=new TH1F(Form("fV0BGOverAll_%d",i),Form("fV0BGOverAll_%d",i),50,0,0.1);
30     fV0ABGOverAll[i]=new TH1F(Form("fV0ABGOverAll_%d",i),Form("fV0ABGOverAll_%d",i),50,0,0.1);
31     fV0CBGOverAll[i]=new TH1F(Form("fV0CBGOverAll_%d",i),Form("fV0CBGOverAll_%d",i),50,0,0.1);
32     fAfterOverBefore[i]=new TH1F(Form("fAfterOverBefore_%d",i),Form("fAfterOverBefore_%d",i),100,0.5,1);
33     fV0AOverV0C[i]=new TH1F(Form("fV0AOverV0C_%d",i),Form("fV0AOverV0C_%d",i),100,0.7,1.2);
34     fF01OverAll[i]=new TH1F(Form("fF01OverAll_%d",i),Form("fF01OverAll_%d",i),200,0.6,1.1);
35     fF02OverAll[i]=new TH1F(Form("fF02OverAll_%d",i),Form("fF02OverAll_%d",i),200,0.6,1.1);
36   }
37
38
39
40
41   TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
42   dir.ReplaceAll("read.C","");
43   dir.ReplaceAll("/./","/");
44   
45   // read file and add to fit object
46   Double_t *run = new Double_t[1330];
47   Double_t *ratio1 = new Double_t[1330];
48   Double_t *nofill = new Double_t[1330];
49   Double_t vX, vY, vZ;
50   Int_t vNData = 0;
51   ifstream vInput;
52   vInput.open(Form("%srct.dat",dir.Data()));
53   while (1) {
54     vInput >> vX >> vY >> vZ;
55     if (!vInput.good()) break;
56     run[vNData] = vX;
57     ratio1[vNData] = vY;
58     nofill[vNData] = vZ;
59     vNData++;
60   }//while
61   vInput.close();
62
63   grin = new TGraph(vNData,run,ratio1);
64   cout<<"n points="<<grin->GetN()<<endl;
65
66
67   Int_t NoFillings=0;
68   for(Int_t i=1;i<grin->GetN();++i){
69     if(nofill[i]!=nofill[i-1])
70       NoFillings++;
71   }
72   cout<<"No. Dif. de Fill="<<NoFillings<<endl;
73
74   Int_t *boundary_run=new Double_t[NoFillings];
75   Int_t *boundary_fill=new Double_t[NoFillings];
76   Int_t counter=0;
77   for(Int_t i=1;i<grin->GetN();++i){
78     if(nofill[i]!=nofill[i-1]){
79       boundary_run[counter]=run[i-1];
80       boundary_fill[counter]=nofill[i-1];
81       counter++;
82     }
83     
84   }
85
86
87   const Int_t NoOfFill =NoFillings;
88   TLine *l2[NoOfFill];
89
90   for(Int_t i=0;i<NoFillings;++i){
91     cout<<"interfaz run="<<boundary_run[i]<<";  Fill #"<<boundary_fill[i]<<endl;
92     l2[i]=new TLine(boundary_run[i], 0, boundary_run[i], 20);
93   }
94
95
96
97
98   gStyle->SetOptStat(0);
99   gStyle->SetPalette(1);
100   gStyle->SetCanvasColor(10);
101   gStyle->SetFrameFillColor(10);
102   gStyle->SetOptStat(0);
103   gStyle->SetOptTitle(0);
104   
105
106
107
108
109
110   loadlibs();
111   TList * listRejectedRuns = new TList(); // keep track of rejected runes
112
113   
114   
115   
116   
117   
118   for(Int_t i=0;i<3;++i)
119     cout<<gnames[i]<<endl;
120   
121   fou = new TFile("qaLHC10apass2.root");
122   for(Int_t igraph = 0; igraph < kNGraphs; igraph++){
123     graph[igraph]=(TGraphErrors *)  fou.Get(gnames[igraph]);
124   }
125   
126   GetHisto(graph[kGraphBGOverAllAC],fBGOverAll[0]);
127   GetHisto(graph[kGraphBGOverAllAC2],fBGOverAll[1]);
128   GetHisto(graph[kGraphBGOverAllSMH],fBGOverAll[2]);
129   
130   GetHisto(graph[kGraphV0BGOverAllAC],fV0BGOverAll[0]);
131   GetHisto(graph[kGraphV0BGOverAllAC2],fV0BGOverAll[1]);
132   GetHisto(graph[kGraphV0BGOverAllSMH],fV0BGOverAll[2]);
133   
134   
135   GetHisto(graph[kGraphV0ABGOverAllAC],fV0ABGOverAll[0]);
136   GetHisto(graph[kGraphV0ABGOverAllAC2],fV0ABGOverAll[1]);
137   GetHisto(graph[kGraphV0ABGOverAllSMH],fV0ABGOverAll[2]);
138   
139   GetHisto(graph[kGraphV0CBGOverAllAC],fV0CBGOverAll[0]);
140   GetHisto(graph[kGraphV0CBGOverAllAC2],fV0CBGOverAll[1]);
141   GetHisto(graph[kGraphV0CBGOverAllSMH],fV0CBGOverAll[2]);
142   
143   GetHisto(graph[kGraphNevACratioAfter],fAfterOverBefore[0]);
144   GetHisto(graph[kGraphNevAC2ratioAfter],fAfterOverBefore[1]);
145   GetHisto(graph[kGraphNevSMHratioAfter],fAfterOverBefore[2]);
146
147   GetHisto(graph[kGraphV0AOverV0CAC],fV0AOverV0C[0]);
148   GetHisto(graph[kGraphV0AOverV0CAC2],fV0AOverV0C[1]);
149   GetHisto(graph[kGraphV0AOverV0CSMH],fV0AOverV0C[2]);
150
151   GetHisto(graph[kGraphFO1OverAllAC],fF01OverAll[0]);
152   GetHisto(graph[kGraphFO1OverAllAC2],fF01OverAll[1]);
153   GetHisto(graph[kGraphFO1OverAllSMH],fF01OverAll[2]);
154
155   GetHisto(graph[kGraphFO2OverAllAC],fF02OverAll[0]);
156   GetHisto(graph[kGraphFO2OverAllAC2],fF02OverAll[1]);
157   GetHisto(graph[kGraphFO2OverAllSMH],fF02OverAll[2]);
158
159
160
161   Float_t meanDummy;
162   
163
164
165
166   /*
167     THREE TRIGGERS IN THE SAME CANVAS
168     
169   */
170   c4a = new TCanvas("GraphACCOverAll","GraphACCOverAll",1000,700);
171   
172
173   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
174   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
175   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
176
177   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
178   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
179   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
180
181   pad1->Draw();
182   pad2->Draw();
183   pad3->Draw();
184   pad1a->Draw();
185   pad2a->Draw();
186   pad3a->Draw();
187
188
189   pad1->SetBottomMargin(0);
190   pad1->SetBorderSize(0);
191   pad1->SetRightMargin(0.01);
192
193   pad2->SetBottomMargin(0.0);
194   pad2->SetTopMargin(0);
195   pad2->SetRightMargin(0.01);
196   pad2->SetBorderSize(0);
197
198   pad3->SetBottomMargin(0.2);
199   pad3->SetTopMargin(0);
200   pad3->SetRightMargin(0.01);
201   pad3->SetBorderSize(0);
202
203   pad1a->SetBottomMargin(0);
204   pad1a->SetBorderSize(0);
205   pad1a->SetRightMargin(0.01);
206
207   pad2a->SetBottomMargin(0.0);
208   pad2a->SetTopMargin(0);
209   pad2a->SetRightMargin(0.01);
210   pad2a->SetBorderSize(0);
211
212   pad3a->SetBottomMargin(0.2);
213   pad3a->SetTopMargin(0);
214   pad3a->SetRightMargin(0.01);
215   pad3a->SetBorderSize(0);
216
217
218   // Draw a global picture title
219   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
220                                      Form("%s",period));
221
222   title->SetFillColor(0);
223   title->SetTextFont(52);
224   title->SetTextColor(4);
225   title->SetTextSize(0.7);
226   title->Draw();
227
228
229   c4a->cd();
230   pad1->Draw();
231
232
233   pad1->cd();
234
235
236   graph[kGraphACCOverAllAC]->Draw("PA");
237   graph[kGraphACCOverAllACRej] = GetGraphRej(graph[kGraphACCOverAllAC] , listRejectedRuns, "Acc/All AC" ,  meanDummy, 1);
238
239   l1->SetLineStyle(3);
240   l1->Draw();
241
242   for(Int_t i=25;i<NoFillings;++i){
243     l2[i]->SetLineStyle(3);
244     l2[i]->SetLineColor(4);
245     l2[i]->Draw();
246   }
247
248   pad1a->cd();
249   pad1a->cd()->SetGridx(1);
250   GetHisto(graph[kGraphACCOverAllAC],fAccOverAll[0]);
251   fAccOverAll[0]->Draw();
252
253
254
255
256
257   pad2->cd();
258
259
260   graph[kGraphACCOverAllACS2]->Draw("PA");
261   graph[kGraphACCOverAllACS2Rej] = GetGraphRej(graph[kGraphACCOverAllACS2] , listRejectedRuns, "Acc/All [ACS2]" ,  meanDummy, 1);
262
263   l1->SetLineStyle(3);
264   l1->Draw();
265
266   for(Int_t i=25;i<NoFillings;++i){
267     l2[i]->SetLineStyle(3);
268     l2[i]->SetLineColor(4);
269     l2[i]->Draw();
270   }
271
272
273   pad2a->cd();
274   pad2a->cd()->SetGridx(1);
275   GetHisto(graph[kGraphACCOverAllACS2],fAccOverAll[1]);
276   fAccOverAll[1]->Draw();
277
278
279
280   pad3->cd();
281
282
283   graph[kGraphACCOverAllSMH]->Draw("PA");
284   graph[kGraphACCOverAllSMHRej] = GetGraphRej(graph[kGraphACCOverAllSMH] , listRejectedRuns, "Acc/All SMH" ,  meanDummy, 1);
285
286   l1->SetLineStyle(3);
287   l1->Draw();
288
289   for(Int_t i=25;i<NoFillings;++i){
290     l2[i]->SetLineStyle(3);
291     l2[i]->SetLineColor(4);
292     l2[i]->Draw();
293   }
294
295
296   //fAccOverAll[i]
297
298   pad3a->cd();
299   pad3a->cd()->SetGridx(1);
300   GetHisto(graph[kGraphACCOverAllSMH],fAccOverAll[2]);
301   fAccOverAll[2]->Draw();
302   fAccOverAll[2]->GetXaxis()->SetTitle("Accepted / All");
303
304   /*
305   for(Int_t ipoint = 0; ipoint < graph[kGraphACCOverAllAC]->GetN(); ipoint++){
306     fhistTest->Fill(graph[kGraphACCOverAllAC]->GetY()[ipoint]);
307   }
308
309   pad1->cd(4);
310   fhistTest->Sumw2();
311   fhistTest->SetMarkerStyle(25);
312   fhistTest->GetXaxis()->SetTitle(ylabels[kGraphACCOverAllAC]);
313   fhistTest->GetYaxis()->SetTitle("Entries");
314   fhistTest->Draw();
315   */
316   //pad1->cd(2);
317
318
319
320
321
322   c4a->Update();
323   gSystem->ProcessEvents();
324   c4a->SaveAs(Form("picturesLHC11hAOD50/c4a_%s.png",c4a->GetName()));
325
326
327
328   c5a = new TCanvas("GraphNev","GraphNev",1000,700);
329   
330   TPad *pad1 = new TPad("pad1",
331                         "The pad with the function",0.01,0.01,0.99,0.94,0);
332   pad1->Draw();
333
334
335   // Draw a global picture title
336   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
337                                      Form("%s",period));
338
339   title->SetFillColor(0);
340   title->SetTextFont(52);
341   title->SetTextColor(4);
342   title->SetTextSize(0.7);
343   title->Draw();
344
345
346
347
348   pad1->Divide(1,3);
349   pad1->cd(1);
350   //pad1->cd(1)->SetLogy(1);
351   graph[kGraphNevAC]->Draw("PA");
352
353   pad1->cd(2);
354   //pad1->cd(2)->SetLogy(1);
355   graph[kGraphNevAC2]->Draw("PA");
356
357
358   pad1->cd(3);
359   //pad1->cd(3)->SetLogy(1);
360   graph[kGraphNevSMH]->Draw("PA");
361  
362
363
364   c5a->Update();
365   gSystem->ProcessEvents();
366   c5a->SaveAs(Form("picturesLHC11hAOD50/c5a_%s.png",c5a->GetName()));
367
368
369
370
371
372   c7a = new TCanvas("GraphBGOverAll","GraphACCOverAll",1000,700);
373   
374
375   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
376   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
377   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
378
379   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
380   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
381   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
382
383   pad1->Draw();
384   pad2->Draw();
385   pad3->Draw();
386   pad1a->Draw();
387   pad2a->Draw();
388   pad3a->Draw();
389
390
391   pad1->SetBottomMargin(0);
392   pad1->SetBorderSize(0);
393   pad1->SetRightMargin(0.01);
394
395   pad2->SetBottomMargin(0.0);
396   pad2->SetTopMargin(0);
397   pad2->SetRightMargin(0.01);
398   pad2->SetBorderSize(0);
399
400   pad3->SetBottomMargin(0.2);
401   pad3->SetTopMargin(0);
402   pad3->SetRightMargin(0.01);
403   pad3->SetBorderSize(0);
404
405   pad1a->SetBottomMargin(0);
406   pad1a->SetBorderSize(0);
407   pad1a->SetRightMargin(0.01);
408
409   pad2a->SetBottomMargin(0.0);
410   pad2a->SetTopMargin(0);
411   pad2a->SetRightMargin(0.01);
412   pad2a->SetBorderSize(0);
413
414   pad3a->SetBottomMargin(0.2);
415   pad3a->SetTopMargin(0);
416   pad3a->SetRightMargin(0.01);
417   pad3a->SetBorderSize(0);
418
419
420   // Draw a global picture title
421   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
422                                      Form("%s",period));
423
424   title->SetFillColor(0);
425   title->SetTextFont(52);
426   title->SetTextColor(4);
427   title->SetTextSize(0.7);
428   title->Draw();
429
430
431   c7a->cd();
432   pad1->Draw();
433
434
435   pad1->cd();
436
437   graph[kGraphBGOverAllAC]->Draw("PA");
438   graph[kGraphBGOverAllAC] = GetGraphRej(graph[kGraphBGOverAllAC] , listRejectedRuns, "BG/All AC" ,  meanDummy, 1);
439
440   l1->SetLineStyle(3);
441   l1->Draw();
442
443   for(Int_t i=25;i<NoFillings;++i){
444     l2[i]->SetLineStyle(3);
445     l2[i]->SetLineColor(4);
446     l2[i]->Draw();
447   }
448
449
450   pad1a->cd();
451   pad1a->cd()->SetGridx(1);
452   fBGOverAll[0]->Draw();
453  
454
455
456
457
458
459
460   pad2->cd();
461
462   graph[kGraphBGOverAllAC2]->Draw("PA");
463   graph[kGraphBGOverAllAC2] = GetGraphRej(graph[kGraphBGOverAllAC2] , listRejectedRuns, "BG/All AC2" ,  meanDummy, 1);
464
465   l1->SetLineStyle(3);
466   l1->Draw();
467
468   for(Int_t i=25;i<NoFillings;++i){
469     l2[i]->SetLineStyle(3);
470     l2[i]->SetLineColor(4);
471     l2[i]->Draw();
472   }
473
474
475   pad2a->cd();
476   pad2a->cd()->SetGridx(1);
477   fBGOverAll[1]->Draw();
478
479
480
481   pad3->cd();
482
483  
484   graph[kGraphBGOverAllSMH]->Draw("PA");
485   graph[kGraphBGOverAllSMHRej] = GetGraphRej(graph[kGraphBGOverAllSMH] , listRejectedRuns, "BG/All SMH" ,  meanDummy, 1);
486
487   l1->SetLineStyle(3);
488   l1->Draw();
489
490   for(Int_t i=25;i<NoFillings;++i){
491     l2[i]->SetLineStyle(3);
492     l2[i]->SetLineColor(4);
493     l2[i]->Draw();
494   }
495
496
497   pad3a->cd();
498   pad3a->cd()->SetGridx(1);
499
500   fBGOverAll[2]->GetXaxis()->SetTitle("BG / All");
501   fBGOverAll[2]->Draw();
502
503
504   for(Int_t i=25;i<NoFillings;++i){
505     l2[i]->SetLineStyle(3);
506     l2[i]->SetLineColor(4);
507     l2[i]->Draw();
508   }
509
510   c7a->Update();
511   gSystem->ProcessEvents();
512   c7a->SaveAs(Form("picturesLHC11hAOD50/c7a_%s.png",c7a->GetName()));
513
514
515
516   c7b = new TCanvas("GraphV0BGOverAll","GraphV0BGOverAll",1000,700);
517     TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
518   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
519   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
520
521   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
522   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
523   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
524
525   pad1->Draw();
526   pad2->Draw();
527   pad3->Draw();
528   pad1a->Draw();
529   pad2a->Draw();
530   pad3a->Draw();
531
532
533   pad1->SetBottomMargin(0);
534   pad1->SetBorderSize(0);
535   pad1->SetRightMargin(0.01);
536
537   pad2->SetBottomMargin(0.0);
538   pad2->SetTopMargin(0);
539   pad2->SetRightMargin(0.01);
540   pad2->SetBorderSize(0);
541
542   pad3->SetBottomMargin(0.2);
543   pad3->SetTopMargin(0);
544   pad3->SetRightMargin(0.01);
545   pad3->SetBorderSize(0);
546
547   pad1a->SetBottomMargin(0);
548   pad1a->SetBorderSize(0);
549   pad1a->SetRightMargin(0.01);
550
551   pad2a->SetBottomMargin(0.0);
552   pad2a->SetTopMargin(0);
553   pad2a->SetRightMargin(0.01);
554   pad2a->SetBorderSize(0);
555
556   pad3a->SetBottomMargin(0.2);
557   pad3a->SetTopMargin(0);
558   pad3a->SetRightMargin(0.01);
559   pad3a->SetBorderSize(0);
560
561
562   // Draw a global picture title
563   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
564                                      Form("%s",period));
565
566   title->SetFillColor(0);
567   title->SetTextFont(52);
568   title->SetTextColor(4);
569   title->SetTextSize(0.7);
570   title->Draw();
571
572
573   c7b->cd();
574
575
576
577   pad1->cd();
578
579   graph[kGraphV0BGOverAllAC]->Draw("PA");
580   graph[kGraphV0BGOverAllAC] = GetGraphRej(graph[kGraphV0BGOverAllAC] , listRejectedRuns, "V0BG/All AC" ,  meanDummy, 1);
581
582   l1->SetLineStyle(3);
583   l1->Draw();
584
585   for(Int_t i=25;i<NoFillings;++i){
586     l2[i]->SetLineStyle(3);
587     l2[i]->SetLineColor(4);
588     l2[i]->Draw();
589   }
590
591
592
593   pad1a->cd();
594   pad1a->cd()->SetGridx(1);
595   fV0BGOverAll[0]->Draw();
596
597
598   pad2->cd();
599   graph[kGraphV0BGOverAllAC2]->Draw("PA");
600   graph[kGraphV0BGOverAllAC2] = GetGraphRej(graph[kGraphV0BGOverAllAC2] , listRejectedRuns, "V0BG/All AC2" ,  meanDummy, 1);
601
602   l1->SetLineStyle(3);
603   l1->Draw();
604
605   for(Int_t i=25;i<NoFillings;++i){
606     l2[i]->SetLineStyle(3);
607     l2[i]->SetLineColor(4);
608     l2[i]->Draw();
609   }
610
611
612   pad2a->cd();
613   pad2a->cd()->SetGridx(1);
614   fV0BGOverAll[1]->Draw();
615
616   pad3->cd();
617   graph[kGraphV0BGOverAllSMH]->Draw("PA");
618   graph[kGraphV0BGOverAllSMHRej] = GetGraphRej(graph[kGraphV0BGOverAllSMH] , listRejectedRuns, "V0BG/All SMH" ,  meanDummy, 1);
619
620   l1->SetLineStyle(3);
621   l1->Draw();
622
623   for(Int_t i=25;i<NoFillings;++i){
624     l2[i]->SetLineStyle(3);
625     l2[i]->SetLineColor(4);
626     l2[i]->Draw();
627   }
628
629
630   pad3a->cd();
631   pad3a->cd()->SetGridx(1);
632   fV0BGOverAll[2]->GetXaxis()->SetTitle("V0BG / All");
633   fV0BGOverAll[2]->Draw();
634
635
636
637   c7b->Update();
638   gSystem->ProcessEvents();
639   c7b->SaveAs(Form("picturesLHC11hAOD50/c7b_%s.png",c7b->GetName()));
640
641
642
643
644
645
646
647
648
649
650   c7c = new TCanvas("GraphV0A_BGOverAll","GraphV0A_BGOverAll",1000,700);
651    TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
652   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
653   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
654
655   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
656   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
657   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
658
659   pad1->Draw();
660   pad2->Draw();
661   pad3->Draw();
662   pad1a->Draw();
663   pad2a->Draw();
664   pad3a->Draw();
665
666
667   pad1->SetBottomMargin(0);
668   pad1->SetBorderSize(0);
669   pad1->SetRightMargin(0.01);
670
671   pad2->SetBottomMargin(0.0);
672   pad2->SetTopMargin(0);
673   pad2->SetRightMargin(0.01);
674   pad2->SetBorderSize(0);
675
676   pad3->SetBottomMargin(0.2);
677   pad3->SetTopMargin(0);
678   pad3->SetRightMargin(0.01);
679   pad3->SetBorderSize(0);
680
681   pad1a->SetBottomMargin(0);
682   pad1a->SetBorderSize(0);
683   pad1a->SetRightMargin(0.01);
684
685   pad2a->SetBottomMargin(0.0);
686   pad2a->SetTopMargin(0);
687   pad2a->SetRightMargin(0.01);
688   pad2a->SetBorderSize(0);
689
690   pad3a->SetBottomMargin(0.2);
691   pad3a->SetTopMargin(0);
692   pad3a->SetRightMargin(0.01);
693   pad3a->SetBorderSize(0);
694
695
696   // Draw a global picture title
697   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
698                                      Form("%s",period));
699
700   title->SetFillColor(0);
701   title->SetTextFont(52);
702   title->SetTextColor(4);
703   title->SetTextSize(0.7);
704   title->Draw();
705
706
707   c7c->cd();
708
709   pad1->cd(); 
710
711
712   graph[kGraphV0ABGOverAllAC]->Draw("PA");
713   graph[kGraphV0ABGOverAllAC] = GetGraphRej(graph[kGraphV0ABGOverAllAC] , listRejectedRuns, "V0A_BG/All AC" ,  meanDummy, 1);
714
715   l1->SetLineStyle(3);
716   l1->Draw();
717
718
719   pad1a->cd();
720   pad1a->cd()->SetGridx(1);
721   fV0ABGOverAll[0]->Draw();
722
723
724
725   pad2->cd(); 
726   graph[kGraphV0ABGOverAllAC2]->Draw("PA");
727   graph[kGraphV0ABGOverAllAC2] = GetGraphRej(graph[kGraphV0ABGOverAllAC2] , listRejectedRuns, "V0A_BG/All AC2" ,  meanDummy, 1);
728
729   l1->SetLineStyle(3);
730   l1->Draw();
731
732
733   pad2a->cd();
734   pad2a->cd()->SetGridx(1);
735   fV0ABGOverAll[1]->Draw();
736
737   pad3->cd(); 
738   graph[kGraphV0ABGOverAllSMH]->Draw("PA");
739   graph[kGraphV0ABGOverAllSMHRej] = GetGraphRej(graph[kGraphV0ABGOverAllSMH] , listRejectedRuns, "V0A_BG/All SMH" ,  meanDummy, 1);
740
741   l1->SetLineStyle(3);
742   l1->Draw();
743
744
745   pad3a->cd();
746   pad3a->cd()->SetGridx(1);
747   fV0ABGOverAll[2]->Draw();
748   fV0ABGOverAll[2]->GetXaxis()->SetTitle("V0ABG / All");
749
750
751   c7c->Update();
752   gSystem->ProcessEvents();
753   c7c->SaveAs(Form("picturesLHC11hAOD50/c7c_%s.png",c7c->GetName()));
754
755
756
757
758
759   c7d = new TCanvas("GraphV0C_BGOverAll","GraphV0C_BGOverAll",1000,700);
760   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
761   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
762   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
763
764   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
765   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
766   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
767
768   pad1->Draw();
769   pad2->Draw();
770   pad3->Draw();
771   pad1a->Draw();
772   pad2a->Draw();
773   pad3a->Draw();
774
775
776   pad1->SetBottomMargin(0);
777   pad1->SetBorderSize(0);
778   pad1->SetRightMargin(0.01);
779
780   pad2->SetBottomMargin(0.0);
781   pad2->SetTopMargin(0);
782   pad2->SetRightMargin(0.01);
783   pad2->SetBorderSize(0);
784
785   pad3->SetBottomMargin(0.2);
786   pad3->SetTopMargin(0);
787   pad3->SetRightMargin(0.01);
788   pad3->SetBorderSize(0);
789
790   pad1a->SetBottomMargin(0);
791   pad1a->SetBorderSize(0);
792   pad1a->SetRightMargin(0.01);
793
794   pad2a->SetBottomMargin(0.0);
795   pad2a->SetTopMargin(0);
796   pad2a->SetRightMargin(0.01);
797   pad2a->SetBorderSize(0);
798
799   pad3a->SetBottomMargin(0.2);
800   pad3a->SetTopMargin(0);
801   pad3a->SetRightMargin(0.01);
802   pad3a->SetBorderSize(0);
803
804
805   // Draw a global picture title
806   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
807                                      Form("%s",period));
808
809   title->SetFillColor(0);
810   title->SetTextFont(52);
811   title->SetTextColor(4);
812   title->SetTextSize(0.7);
813   title->Draw();
814
815
816   c7d->cd();
817
818   pad1->cd();
819   graph[kGraphV0CBGOverAllAC]->Draw("PA");
820   graph[kGraphV0CBGOverAllAC] = GetGraphRej(graph[kGraphV0CBGOverAllAC] , listRejectedRuns, "V0C_BG/All AC" ,  meanDummy, 1);
821
822   l1->SetLineStyle(3);
823   l1->Draw();
824
825
826   pad1a->cd();
827   pad1a->cd()->SetGridx(1);
828   fV0CBGOverAll[0]->Draw();
829
830
831   pad2->cd();
832   graph[kGraphV0CBGOverAllAC2]->Draw("PA");
833   graph[kGraphV0CBGOverAllAC2] = GetGraphRej(graph[kGraphV0CBGOverAllAC2] , listRejectedRuns, "V0C_BG/All AC2" ,  meanDummy, 1);
834
835   l1->SetLineStyle(3);
836   l1->Draw();
837
838   pad2a->cd();
839   pad2a->cd()->SetGridx(1);
840   fV0CBGOverAll[1]->Draw();
841
842
843            pad3->cd();
844   graph[kGraphV0CBGOverAllSMH]->Draw("PA");
845   graph[kGraphV0CBGOverAllSMHRej] = GetGraphRej(graph[kGraphV0CBGOverAllSMH] , listRejectedRuns, "V0A_BG/All SMH" ,  meanDummy, 1);
846
847
848   l1->SetLineStyle(3);
849   l1->Draw();
850
851   pad3a->cd();
852   pad3a->cd()->SetGridx(1);
853   fV0CBGOverAll[2]->Draw();
854   fV0CBGOverAll[2]->GetXaxis()->SetTitle("V0CBG / All");
855
856
857
858   c7d->Update();
859   gSystem->ProcessEvents();
860   c7d->SaveAs(Form("picturesLHC11hAOD50/c7d_%s.png",c7d->GetName()));
861
862
863
864
865
866   c8a = new TCanvas("GraphAfterOverBefore","GraphAfterOverBefore",1000,700);
867   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
868   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
869   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
870
871   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
872   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
873   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
874
875   pad1->Draw();
876   pad2->Draw();
877   pad3->Draw();
878   pad1a->Draw();
879   pad2a->Draw();
880   pad3a->Draw();
881
882
883   pad1->SetBottomMargin(0);
884   pad1->SetBorderSize(0);
885   pad1->SetRightMargin(0.01);
886
887   pad2->SetBottomMargin(0.0);
888   pad2->SetTopMargin(0);
889   pad2->SetRightMargin(0.01);
890   pad2->SetBorderSize(0);
891
892   pad3->SetBottomMargin(0.2);
893   pad3->SetTopMargin(0);
894   pad3->SetRightMargin(0.01);
895   pad3->SetBorderSize(0);
896
897   pad1a->SetBottomMargin(0);
898   pad1a->SetBorderSize(0);
899   pad1a->SetRightMargin(0.01);
900
901   pad2a->SetBottomMargin(0.0);
902   pad2a->SetTopMargin(0);
903   pad2a->SetRightMargin(0.01);
904   pad2a->SetBorderSize(0);
905
906   pad3a->SetBottomMargin(0.2);
907   pad3a->SetTopMargin(0);
908   pad3a->SetRightMargin(0.01);
909   pad3a->SetBorderSize(0);
910
911
912   // Draw a global picture title
913   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
914                                      Form("%s",period));
915
916   title->SetFillColor(0);
917   title->SetTextFont(52);
918   title->SetTextColor(4);
919   title->SetTextSize(0.7);
920   title->Draw();
921   
922   pad1->cd();
923   
924   graph[kGraphNevACratioAfter]->Draw("PA");
925   graph[kGraphNevACratioAfterRej] = GetGraphRej(graph[kGraphNevACratioAfter] , listRejectedRuns, "V0BG/All AC" ,  meanDummy, 1);
926
927   l1->SetLineStyle(3);
928   l1->Draw();
929
930   for(Int_t i=25;i<NoFillings;++i){
931     l2[i]->SetLineStyle(3);
932     l2[i]->SetLineColor(4);
933     l2[i]->Draw();
934   }
935
936
937
938
939   
940   pad1a->cd();
941   pad1a->cd()->SetGridx(1);
942   fAfterOverBefore[0]->Draw();
943
944
945   pad2->cd();
946   graph[kGraphNevAC2ratioAfter]->Draw("PA");
947   graph[kGraphNevAC2ratioAfterRej] = GetGraphRej(graph[kGraphNevAC2ratioAfter] , listRejectedRuns, "V0BG/All AC2" ,  meanDummy, 1);
948
949  l1->SetLineStyle(3);
950   l1->Draw();
951
952
953   for(Int_t i=25;i<NoFillings;++i){
954     l2[i]->SetLineStyle(3);
955     l2[i]->SetLineColor(4);
956     l2[i]->Draw();
957   }
958
959
960   pad2a->cd();
961   pad2a->cd()->SetGridx(1);
962   fAfterOverBefore[1]->Draw();
963
964   pad3->cd();
965   graph[kGraphNevSMHratioAfter]->Draw("PA");
966   graph[kGraphNevSMHratioAfterRej] = GetGraphRej(graph[kGraphNevSMHratioAfter] , listRejectedRuns, "V0BG/All SMH" ,  meanDummy, 1);
967
968  l1->SetLineStyle(3);
969   l1->Draw();
970
971   for(Int_t i=25;i<NoFillings;++i){
972     l2[i]->SetLineStyle(3);
973     l2[i]->SetLineColor(4);
974     l2[i]->Draw();
975   }
976
977
978
979   pad3a->cd();
980   pad3a->cd()->SetGridx(1);
981   fAfterOverBefore[2]->Draw();
982   fAfterOverBefore[2]->GetXaxis()->SetTitle("After_PS / Before_PS");
983
984
985   c8a->Update();
986   gSystem->ProcessEvents();
987   c8a->SaveAs(Form("picturesLHC11hAOD50/c8a_%s.png",c8a->GetName()));
988
989
990
991
992
993   c8b = new TCanvas("GraphNevBefore","GraphNevBefore",1000,700);
994   
995   TPad *pad1 = new TPad("pad1",
996                         "The pad with the function",0.01,0.01,0.99,0.94,0);
997   pad1->Draw();
998
999
1000   // Draw a global picture title
1001   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
1002                                      Form("%s",period));
1003
1004   title->SetFillColor(0);
1005   title->SetTextFont(52);
1006   title->SetTextColor(4);
1007   title->SetTextSize(0.7);
1008   title->Draw();
1009
1010
1011
1012
1013   pad1->Divide(1,3);
1014
1015   pad1->cd(1);
1016   graph[kGraphNevACBefore]->Draw("PA");
1017
1018   pad1->cd(2);
1019   graph[kGraphNevAC2Before]->Draw("PA");
1020
1021   pad1->cd(3);
1022   graph[kGraphNevSMHBefore]->Draw("PA");
1023
1024
1025
1026   c8b->Update();
1027   gSystem->ProcessEvents();
1028   c8b->SaveAs(Form("picturesLHC11hAOD50/c8b_%s.png",c8b->GetName()));
1029
1030
1031
1032
1033
1034   c8c = new TCanvas("GraphNevAfter","GraphNevAfter",1000,700);
1035   
1036   TPad *pad1 = new TPad("pad1",
1037                         "The pad with the function",0.01,0.01,0.99,0.94,0);
1038   pad1->Draw();
1039
1040
1041   // Draw a global picture title
1042   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
1043                                      Form("%s",period));
1044
1045   title->SetFillColor(0);
1046   title->SetTextFont(52);
1047   title->SetTextColor(4);
1048   title->SetTextSize(0.7);
1049   title->Draw();
1050
1051
1052
1053
1054   pad1->Divide(1,3);
1055
1056   pad1->cd(1);
1057   graph[kGraphNevACAfter]->Draw("PA");
1058
1059
1060   pad1->cd(2);
1061   graph[kGraphNevAC2After]->Draw("PA");
1062
1063
1064   pad1->cd(3);
1065
1066   graph[kGraphNevSMHAfter]->Draw("PA");
1067
1068
1069
1070   c8c->Update();
1071   gSystem->ProcessEvents();
1072   c8c->SaveAs(Form("picturesLHC11hAOD50/c8c_%s.png",c8c->GetName()));
1073
1074
1075
1076
1077
1078
1079
1080
1081   c9a = new TCanvas("GraphV0AOverV0C","GraphV0AOverV0C",1000,700);
1082   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
1083   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
1084   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
1085
1086   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
1087   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
1088   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
1089
1090   pad1->Draw();
1091   pad2->Draw();
1092   pad3->Draw();
1093   pad1a->Draw();
1094   pad2a->Draw();
1095   pad3a->Draw();
1096
1097
1098   pad1->SetBottomMargin(0);
1099   pad1->SetBorderSize(0);
1100   pad1->SetRightMargin(0.01);
1101
1102   pad2->SetBottomMargin(0.0);
1103   pad2->SetTopMargin(0);
1104   pad2->SetRightMargin(0.01);
1105   pad2->SetBorderSize(0);
1106
1107   pad3->SetBottomMargin(0.2);
1108   pad3->SetTopMargin(0);
1109   pad3->SetRightMargin(0.01);
1110   pad3->SetBorderSize(0);
1111
1112   pad1a->SetBottomMargin(0);
1113   pad1a->SetBorderSize(0);
1114   pad1a->SetRightMargin(0.01);
1115
1116   pad2a->SetBottomMargin(0.0);
1117   pad2a->SetTopMargin(0);
1118   pad2a->SetRightMargin(0.01);
1119   pad2a->SetBorderSize(0);
1120
1121   pad3a->SetBottomMargin(0.2);
1122   pad3a->SetTopMargin(0);
1123   pad3a->SetRightMargin(0.01);
1124   pad3a->SetBorderSize(0);
1125
1126
1127   // Draw a global picture title
1128   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
1129                                      Form("%s",period));
1130
1131   title->SetFillColor(0);
1132   title->SetTextFont(52);
1133   title->SetTextColor(4);
1134   title->SetTextSize(0.7);
1135   title->Draw();
1136
1137   pad1->cd();
1138   graph[kGraphV0AOverV0CAC]->Draw("PA");
1139   graph[kGraphV0AOverV0CACRej] = GetGraphRej(graph[kGraphV0AOverV0CAC] , listRejectedRuns, "Nev_V0A/Nev_V0C AC" ,  meanDummy, 1);
1140
1141
1142  l1->SetLineStyle(3);
1143   l1->Draw();
1144
1145   for(Int_t i=25;i<NoFillings;++i){
1146     l2[i]->SetLineStyle(3);
1147     l2[i]->SetLineColor(4);
1148     l2[i]->Draw();
1149   }
1150
1151
1152   pad1a->cd();
1153   pad1a->cd()->SetGridx(1);
1154   fV0AOverV0C[0]->Draw();
1155
1156
1157   pad2->cd();
1158   graph[kGraphV0AOverV0CAC2]->Draw("PA");
1159   graph[kGraphV0AOverV0CAC2Rej] = GetGraphRej(graph[kGraphV0AOverV0CAC2] , listRejectedRuns, "Nev_V0A/Nev_V0C AC2" ,  meanDummy, 1);
1160
1161  l1->SetLineStyle(3);
1162   l1->Draw();
1163
1164   for(Int_t i=25;i<NoFillings;++i){
1165     l2[i]->SetLineStyle(3);
1166     l2[i]->SetLineColor(4);
1167     l2[i]->Draw();
1168   }
1169
1170
1171
1172   pad2a->cd();
1173   pad2a->cd()->SetGridx(1);
1174   fV0AOverV0C[1]->Draw();
1175
1176
1177   pad3->cd();
1178   graph[kGraphV0AOverV0CSMH]->Draw("PA");
1179   graph[kGraphV0AOverV0CSMHRej] = GetGraphRej(graph[kGraphV0AOverV0CSMH] , listRejectedRuns, "Nev_V0A/Nev_V0C SMH" ,  meanDummy, 1);
1180
1181  l1->SetLineStyle(3);
1182   l1->Draw();
1183
1184
1185   for(Int_t i=25;i<NoFillings;++i){
1186     l2[i]->SetLineStyle(3);
1187     l2[i]->SetLineColor(4);
1188     l2[i]->Draw();
1189   }
1190
1191
1192   pad3a->cd();
1193   pad3a->cd()->SetGridx(1);
1194   fV0AOverV0C[2]->Draw();
1195   fV0AOverV0C[2]->GetXaxis()->SetTitle("V0A / VOC");
1196
1197
1198
1199   c9a->Update();
1200   gSystem->ProcessEvents();
1201   c9a->SaveAs(Form("picturesLHC11hAOD50/c9a_%s.png",c9a->GetName()));
1202
1203
1204
1205   c10a = new TCanvas("GraphFO1OverAll","GraphFO1OverAll",1000,700);
1206   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
1207   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
1208   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
1209
1210   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
1211   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
1212   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
1213
1214   pad1->Draw();
1215   pad2->Draw();
1216   pad3->Draw();
1217   pad1a->Draw();
1218   pad2a->Draw();
1219   pad3a->Draw();
1220
1221
1222   pad1->SetBottomMargin(0);
1223   pad1->SetBorderSize(0);
1224   pad1->SetRightMargin(0.01);
1225
1226   pad2->SetBottomMargin(0.0);
1227   pad2->SetTopMargin(0);
1228   pad2->SetRightMargin(0.01);
1229   pad2->SetBorderSize(0);
1230
1231   pad3->SetBottomMargin(0.2);
1232   pad3->SetTopMargin(0);
1233   pad3->SetRightMargin(0.01);
1234   pad3->SetBorderSize(0);
1235
1236   pad1a->SetBottomMargin(0);
1237   pad1a->SetBorderSize(0);
1238   pad1a->SetRightMargin(0.01);
1239
1240   pad2a->SetBottomMargin(0.0);
1241   pad2a->SetTopMargin(0);
1242   pad2a->SetRightMargin(0.01);
1243   pad2a->SetBorderSize(0);
1244
1245   pad3a->SetBottomMargin(0.2);
1246   pad3a->SetTopMargin(0);
1247   pad3a->SetRightMargin(0.01);
1248   pad3a->SetBorderSize(0);
1249
1250
1251   // Draw a global picture title
1252   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
1253                                      Form("%s",period));
1254
1255   title->SetFillColor(0);
1256   title->SetTextFont(52);
1257   title->SetTextColor(4);
1258   title->SetTextSize(0.7);
1259   title->Draw();  
1260
1261
1262   pad1->cd();
1263   graph[kGraphFO1OverAllAC]->Draw("PA");
1264   graph[kGraphFO1OverAllACRej] = GetGraphRej(graph[kGraphFO1OverAllAC] , listRejectedRuns, "Nev_FO1/All AC" ,  meanDummy, 1);
1265
1266  l1->SetLineStyle(3);
1267   l1->Draw();
1268
1269   for(Int_t i=25;i<NoFillings;++i){
1270     l2[i]->SetLineStyle(3);
1271     l2[i]->SetLineColor(4);
1272     l2[i]->Draw();
1273   }
1274
1275
1276
1277   pad1a->cd();
1278   pad1a->cd()->SetGridx(1);
1279   fF01OverAll[0]->Draw();
1280
1281
1282   pad2->cd();
1283   graph[kGraphFO1OverAllAC2]->Draw("PA");
1284   graph[kGraphFO1OverAllAC2Rej] = GetGraphRej(graph[kGraphFO1OverAllAC2] , listRejectedRuns, "Nev_FO1/All AC2" ,  meanDummy, 1);
1285
1286  l1->SetLineStyle(3);
1287   l1->Draw();
1288
1289   for(Int_t i=25;i<NoFillings;++i){
1290     l2[i]->SetLineStyle(3);
1291     l2[i]->SetLineColor(4);
1292     l2[i]->Draw();
1293   }
1294
1295
1296
1297   pad2a->cd();
1298   pad2a->cd()->SetGridx(1);
1299   fF01OverAll[1]->Draw();
1300
1301
1302
1303   pad3->cd();
1304   graph[kGraphFO1OverAllSMH]->Draw("PA");
1305   graph[kGraphFO1OverAllSMHRej] = GetGraphRej(graph[kGraphFO1OverAllSMH] , listRejectedRuns, "Nev_FO1/All SMH" ,  meanDummy, 1);
1306
1307  l1->SetLineStyle(3);
1308   l1->Draw();
1309
1310   for(Int_t i=25;i<NoFillings;++i){
1311     l2[i]->SetLineStyle(3);
1312     l2[i]->SetLineColor(4);
1313     l2[i]->Draw();
1314   }
1315
1316
1317
1318   pad3a->cd();
1319   pad3a->cd()->SetGridx(1);
1320   fF01OverAll[2]->Draw();
1321   fF01OverAll[2]->GetXaxis()->SetTitle("F01 / All");
1322
1323
1324
1325
1326   c10a->Update();
1327   gSystem->ProcessEvents();
1328   c10a->SaveAs(Form("picturesLHC11hAOD50/c10a_%s.png",c10a->GetName()));
1329
1330
1331
1332
1333   c10b = new TCanvas("GraphFO2OverAll","GraphFO2OverAll",1000,700);
1334   TPad * pad1=new TPad("pad1","pad1",0.01,0.635,0.7,0.94,0);
1335   TPad * pad2=new TPad("pad2","pad2",0.01,0.33,0.7,0.635,0);
1336   TPad * pad3=new TPad("pad3","pad3",0.01,0.01,0.7,0.33,0);
1337
1338   TPad * pad1a=new TPad("pad1a","pad1a",0.7,0.635,0.99,0.94,0);
1339   TPad * pad2a=new TPad("pad2a","pad2a",0.7,0.33,0.99,0.635,0);
1340   TPad * pad3a=new TPad("pad3a","pad3a",0.7,0.01,0.99,0.33,0);
1341
1342   pad1->Draw();
1343   pad2->Draw();
1344   pad3->Draw();
1345   pad1a->Draw();
1346   pad2a->Draw();
1347   pad3a->Draw();
1348
1349
1350   pad1->SetBottomMargin(0);
1351   pad1->SetBorderSize(0);
1352   pad1->SetRightMargin(0.01);
1353
1354   pad2->SetBottomMargin(0.0);
1355   pad2->SetTopMargin(0);
1356   pad2->SetRightMargin(0.01);
1357   pad2->SetBorderSize(0);
1358
1359   pad3->SetBottomMargin(0.2);
1360   pad3->SetTopMargin(0);
1361   pad3->SetRightMargin(0.01);
1362   pad3->SetBorderSize(0);
1363
1364   pad1a->SetBottomMargin(0);
1365   pad1a->SetBorderSize(0);
1366   pad1a->SetRightMargin(0.01);
1367
1368   pad2a->SetBottomMargin(0.0);
1369   pad2a->SetTopMargin(0);
1370   pad2a->SetRightMargin(0.01);
1371   pad2a->SetBorderSize(0);
1372
1373   pad3a->SetBottomMargin(0.2);
1374   pad3a->SetTopMargin(0);
1375   pad3a->SetRightMargin(0.01);
1376   pad3a->SetBorderSize(0);
1377
1378
1379   // Draw a global picture title
1380   TPaveLabel *title = new TPaveLabel(0.01,0.95,0.99,0.99,
1381                                      Form("%s",period));
1382
1383   title->SetFillColor(0);
1384   title->SetTextFont(52);
1385   title->SetTextColor(4);
1386   title->SetTextSize(0.7);
1387   title->Draw();  
1388
1389
1390   pad1->cd();
1391   graph[kGraphFO2OverAllAC]->Draw("PA");
1392   graph[kGraphFO2OverAllACRej] = GetGraphRej(graph[kGraphFO2OverAllAC] , listRejectedRuns, "Nev_FO2/All AC" ,  meanDummy, 1);
1393
1394   pad1a->cd();
1395   pad1a->cd()->SetGridx(1);
1396   fF02OverAll[0]->Draw();
1397   fF02OverAll[0]->GetXaxis()->SetTitle("F02 / All");
1398
1399
1400   pad2->cd();
1401   graph[kGraphFO2OverAllAC2]->Draw("PA");
1402   graph[kGraphFO2OverAllAC2Rej] = GetGraphRej(graph[kGraphFO2OverAllAC2] , listRejectedRuns, "Nev_FO2/All AC2" ,  meanDummy, 1);
1403
1404   pad2a->cd();
1405   pad2a->cd()->SetGridx(1);
1406   fF02OverAll[1]->Draw();
1407   fF02OverAll[1]->GetXaxis()->SetTitle("F02 / All");
1408
1409   pad3->cd();
1410   graph[kGraphFO2OverAllSMH]->Draw("PA");
1411   graph[kGraphFO2OverAllSMHRej] = GetGraphRej(graph[kGraphFO2OverAllSMH] , listRejectedRuns, "Nev_FO2/All SMH" ,  meanDummy, 1);
1412
1413   pad3a->cd();
1414   pad3a->cd()->SetGridx(1);
1415   fF02OverAll[2]->Draw();
1416   fF02OverAll[2]->GetXaxis()->SetTitle("F02 / All");
1417
1418
1419
1420
1421
1422   c10b->Update();
1423   gSystem->ProcessEvents();
1424   c10b->SaveAs(Form("picturesLHC11hAOD50/c10b_%s.png",c10b->GetName()));
1425
1426
1427
1428
1429
1430
1431
1432
1433 }
1434 double meanMed(double* vec, int np, double nsigmaCut, int &nrej, int *rejList)
1435 {
1436   // compute the mean of the array "vec" rejecting the outliers
1437   // if rejlist array is provided, fill indices of rejected values
1438   // This method works assuming that the "good" points are nearly normally 
1439   // distrubted around the mean (i.e. there is no significant trend)
1440   //
1441   // create copy of the vector
1442   double *vec1 = new Double_t[np];
1443   memcpy(vec1, vec, np*sizeof(double));
1444   //
1445   // get median of the vector as a robust initial estimate of the mean
1446   cout << "Points " << np << endl;
1447   double md = GetMedian(vec1,np);
1448   //
1449   // compute squared differences to median, 
1450   for (int i=0;i<np;i++) {
1451     vec1[i] = TMath::Abs(vec1[i] - md);
1452   }
1453   //
1454   // compute median squared difference for robust estimate of the sigma
1455   double sigmd = GetMedian(vec1,np);
1456   //
1457   printf("Median Value: %+e | Median abs residual: %e\n",md,sigmd);
1458   //
1459   sigmd /= 0.6745; // go to sigma assuming normal distribution
1460   printf("Estimate of sigma: %+e\n",sigmd);
1461   // if the estimate of the sigma is null, do not look for outliers
1462
1463   cout<<"md="<<md<<endl;
1464
1465   if(!sigmd) return md;
1466
1467  
1468
1469
1470   // compute mean rejecting more than nsigmaCut deviations
1471   double mean = 0;
1472   int npok = 0;
1473   for (int i=0;i<np;i++) {
1474     double dev =  TMath::Abs(vec[i]-md)/sigmd;
1475     if ( dev < nsigmaCut ) {
1476       mean += vec[i];
1477       npok++;
1478     }
1479     else {
1480       printf("Reject#%d (Y=%+e) : deviation: %e\n",i,vec[i],dev);
1481       if (rejList) rejList[nrej] = i; 
1482       nrej++;
1483     }
1484   }
1485   //
1486   delete vec1;
1487   return npok ? mean/npok : 0;
1488   //
1489
1490
1491   cout<<"ending meanMed"<<endl;
1492
1493 }
1494
1495 double GetMedian(double* arr, int n)
1496 {
1497   // get median by Wirths algroithm
1498   int i=0,j=0,l=0,m=0;
1499   double x;
1500   l=0 ; m=n-1;
1501   int k = (n&1) ? n/2 : n/2-1;
1502   while (l<m) {
1503     x=arr[k] ;
1504     i=l ;
1505     j=m ;
1506     do {
1507       //      cout << arr[i] << " " << arr[j] << i<<","<<j << " " << arr[k]  << " " << k << " " << x<< endl;
1508       
1509       while (arr[i]<x) i++ ;
1510       while (x<arr[j]) j-- ;
1511       if (i<=j) { // swap elements        
1512         //      cout << "Swapping" << endl;       
1513         double t = arr[i];
1514         arr[i] = arr[j];
1515         arr[j] = t;
1516         i++ ; j-- ;
1517       }      
1518     } while (i<=j) ;
1519     if (j<k) l=i ;
1520     if (k<i) m=j ;
1521   }
1522   return arr[k] ;
1523 }
1524
1525 // double GetMedian(double* arr, int n)
1526 // {
1527 //   // get median by Wirths algroithm
1528 //   int i,j,l,m;
1529 //   double x;
1530 //   l=0 ; m=n-1;
1531 //   int k = (n&1) ? n/2 : n/2-1;
1532 //   while (l<m) {
1533 //     x=arr[k] ;
1534 //     i=l ;
1535 //     j=m ;
1536 //     do {
1537 //       //      cout << i << " " << j << endl;
1538       
1539 //       //skip runs which were not set (value is -1)
1540 //       while (arr[i]<x) i++ ;
1541 //       while (x<arr[j]) j-- ;
1542 //       if(i<=j) { // swap elements
1543 //      // if((TMath::Abs(arr[i]+1)< 0.0001) && ((TMath::Abs(arr[j]+1)<0.0001))){
1544 //      //   i++ ; j-- ;
1545 //      // } else {
1546 //        double t = arr[i];
1547 //        arr[i] = arr[j];
1548 //        arr[j] = t;
1549 //        i++ ; j-- ;
1550 //        //    }
1551 //       }      
1552 //     } while (i<=j) ;
1553 //     if (j<k) l=i ;
1554 //     if (k<i) m=j ;
1555     
1556 //   }
1557 //   return arr[k] ;
1558 // }
1559
1560 TGraphErrors * GetGraphRej(TGraphErrors * gr, TList * rejRunList, const char * reason, Float_t &mean, Bool_t doDraw) {
1561
1562   //Returns a new graph containing only rejected points
1563
1564   const Double_t nsigmaCut = 3;
1565
1566   int *rejList = new Int_t[gr->GetN()];
1567   int nrej = 0;
1568
1569   Double_t * array = new Double_t[gr->GetN()];
1570   Int_t * correspondenceFullArray = new Int_t[gr->GetN()];
1571   Int_t npoint = 0; 
1572   //exclude from the array all the -1
1573   for(Int_t ipoint = 0; ipoint < gr->GetN(); ipoint++){
1574     if (TMath::Abs(gr->GetY()[ipoint]+1)>0.001) { // skip points for which there is no file (==-1)
1575       array[npoint] = gr->GetY()[ipoint];
1576       correspondenceFullArray[npoint] = ipoint;
1577       npoint++;
1578     } 
1579   }
1580
1581   cout<<"calling meanMed"<<endl;
1582   mean = meanMed(array,npoint,nsigmaCut, nrej, rejList);
1583
1584   cout<<"nrej="<<nrej<<"  mean="<<mean<<endl;
1585   
1586  
1587     
1588   TGraphErrors *grrej = new TGraphErrors(nrej);
1589   for (int i=0;i<nrej;i++) {
1590     grrej->SetPoint(i, gr->GetX()[correspondenceFullArray[rejList[i]]], gr->GetY()[correspondenceFullArray[rejList[i]]]);
1591     grrej->SetPointError(i, gr->GetEX()[correspondenceFullArray[rejList[i]]], gr->GetEY()[correspondenceFullArray[rejList[i]]]);
1592     if(!knownProblems.Contains(Form("%d",(int)gr->GetX()[correspondenceFullArray[rejList[i]]])))
1593       rejRunList->Add(new TObjString(Form("[%d], %s",  (int)gr->GetX()[correspondenceFullArray[rejList[i]]], reason)));
1594   }
1595   grrej->SetMarkerColor(kRed);
1596   //grrej->SetMarkerStyle(gr->GetMarkerStyle());
1597   grrej->SetMarkerStyle(29);
1598   grrej->SetMarkerSize(1.5);
1599
1600
1601   delete rejList;
1602
1603   if(doDraw) {
1604     Float_t minXDraw = gr->GetXaxis()->GetBinLowEdge(1);
1605     Float_t maxXDraw = gr->GetXaxis()->GetBinLowEdge(gr->GetXaxis()->GetNbins());
1606
1607     grrej->Draw("P");
1608     TLine * l = new TLine (minXDraw, mean,maxXDraw, mean);
1609     l->SetLineStyle(kDashed);
1610     l->Draw();
1611
1612
1613   }
1614
1615   return grrej;
1616
1617
1618
1619
1620
1621 void loadlibs()
1622 {
1623   gSystem->Load("libVMC");
1624   gSystem->Load("libTree");
1625   gSystem->Load("libSTEERBase");
1626   gSystem->Load("libESD");
1627   gSystem->Load("libAOD");
1628   gSystem->Load("libANALYSIS");
1629   gSystem->Load("libANALYSISalice");
1630   gSystem->Load("libCORRFW");
1631   gSystem->Load("libMinuit");
1632   gSystem->Load("libPWG2spectra");
1633   gSystem->Load("libPWG0base"); 
1634 }
1635 void GetHisto(TGraphErrors * gr, TH1F *ftemp)
1636 {
1637
1638   for(Int_t ipoint = 0; ipoint < gr->GetN(); ipoint++){
1639   //for(Int_t ipoint = 0; ipoint < gr->GetN(); ipoint++){
1640     ftemp->Fill(gr->GetY()[ipoint]);
1641   }
1642   
1643
1644   ftemp->Sumw2();
1645   ftemp->SetMarkerColor(kRed+2);
1646   ftemp->SetLineColor(kRed+2);
1647   ftemp->SetMarkerStyle(30);
1648   ftemp->GetYaxis()->SetTitle("Entries");
1649   ftemp->GetXaxis()->SetLabelSize(0.07);
1650   ftemp->GetXaxis()->SetTitleSize(0.09);
1651   ftemp->GetYaxis()->SetLabelSize(0.04);
1652   ftemp->GetYaxis()->SetTitleSize(0.05);
1653   ftemp->GetYaxis()->SetTitleOffset(0.7);
1654   ftemp->GetYaxis()->CenterTitle(0);
1655   ftemp->GetYaxis()->SetLabelFont(42);
1656   ftemp->GetYaxis()->SetTitleFont(42);
1657   ftemp->GetYaxis()->SetNoExponent(kTRUE);
1658   ftemp->GetXaxis()->SetLabelFont(42);
1659   ftemp->GetXaxis()->SetTitleFont(42);
1660   ftemp->GetXaxis()->SetNdivisions(5);
1661
1662
1663  
1664   return ftemp;
1665  
1666 }