]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/macros/DrawQAoutput.C
Updated macro for plotting HF QA results (ChiaraB)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / macros / DrawQAoutput.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <Riostream.h>
3 #include <TFile.h>
4 #include <TString.h>
5 #include <TH2F.h>
6 #include <TH1F.h>
7 #include <TF1.h>
8 #include <TGraph.h>
9 #include <TDirectoryFile.h>
10 #include <TList.h>
11 #include <TCanvas.h>
12 #include <TLegend.h>
13 #include <TPaveText.h>
14 #include <TStyle.h>
15 #include <TClass.h>
16 #include <TDatabasePDG.h>
17 #include <TParameter.h>
18 #include <AliCounterCollection.h>
19 #include <AliRDHFCuts.h>
20 #endif
21
22 TString *periodsname;
23
24 //read the file and take list and stat
25
26 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root", TString dirname="PWG3_D2H_QA");
27 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root", TString dirname="PWG3_D2H_QA");
28 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid, Int_t set);
29 void TPCBetheBloch(Int_t set);
30
31 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename, TString dirname){
32
33   TString hstatname="nEntriesQA", cutobjname="";
34   filename.Prepend(path);
35   listname+=partname;
36   hstatname+=partname;
37
38   TFile* f=new TFile(filename.Data());
39   if(!f->IsOpen()){
40     cout<<filename.Data()<<" not found"<<endl;
41     return kFALSE;
42   }
43   TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
44   if(!dir){
45     cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
46     f->ls();
47     return kFALSE;
48   }
49
50   list=(TList*)dir->Get(listname);
51   if(!list){
52     cout<<"List "<<listname.Data()<<" not found"<<endl;
53     dir->ls();
54     return kFALSE;
55   }
56
57   hstat=(TH1F*)dir->Get(hstatname);
58   if(!hstat){
59     cout<<hstatname.Data()<<" not found"<<endl;
60     return kFALSE;
61   }
62
63   return kTRUE;
64 }
65
66 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path,TString filename,TString dirname){
67
68   TString hstatname="nEntriesQA", cutobjname="";
69   filename.Prepend(path);
70   listname+=partname;
71   hstatname+=partname;
72
73   if(partname.Contains("Dplus")) cutobjname="AnalysisCuts";//"DplustoKpipiCutsStandard";
74   else{
75     if(partname.Contains("D0")) cutobjname="D0toKpiCutsStandard";//"D0toKpiCuts"
76     else{
77       if(partname.Contains("Dstar")) cutobjname="DStartoKpipiCuts";
78       else{
79         if(partname.Contains("Ds")) cutobjname="DstoKKpiCuts";
80         else{
81           if(partname.Contains("D04")) cutobjname="D0toKpipipiCuts";
82           else{
83             if(partname.Contains("Lc")) cutobjname="LctopKpiAnalysisCuts";
84           }
85         }
86       }
87     }
88   }
89
90   TFile* f=new TFile(filename.Data());
91   if(!f->IsOpen()){
92     cout<<filename.Data()<<" not found"<<endl;
93     return kFALSE;
94   }
95   TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
96   if(!dir){
97     cout<<dirname.Data()<<" not found  in "<<filename.Data()<<endl;
98     return kFALSE;
99   }
100
101   list=(TList*)dir->Get(listname);
102   if(!list){
103     cout<<"List "<<listname.Data()<<" not found"<<endl;
104     dir->ls();
105     return kFALSE;
106   }
107
108   hstat=(TH1F*)dir->Get(hstatname);
109   if(!hstat){
110     cout<<hstatname.Data()<<" not found"<<endl;
111     return kFALSE;
112   }
113
114   cutobj=(AliRDHFCuts*)dir->Get(cutobjname);
115   if(!cutobj){
116     cout<<cutobjname.Data()<<" not found"<<endl;
117     return kFALSE;
118   }
119
120   return kTRUE;
121 }
122
123 //draw "track related" histograms (list "outputTrack")
124 void DrawOutputTrack(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE, TString suffixdir="",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root"){
125   gStyle->SetCanvasColor(0);
126   gStyle->SetTitleFillColor(0);
127   gStyle->SetStatColor(0);
128   gStyle->SetPalette(1);
129
130   TString listname="outputTrack",name1="",name2="",path2="",filename2="PWG3histograms.root";
131   TString tmp="y";
132
133   if(superimpose){
134     cout<<"Enter the names:\n>";
135     cin>>name1;
136     cout<<">";
137     cin>>name2;
138     cout<<"Are they in the same output file? (y/n)"<<endl;
139     cin>>tmp;
140     if(tmp=="n"){
141       cout<<"Path: \n";
142       cout<<">";
143       cin>>path2;
144       cout<<"Filename: "<<endl;
145       cout<<">";
146       cin>>filename2;
147     }
148     
149   }
150
151   TList* list;
152   TH1F * hstat;
153   TString dirname="PWG3_D2H_QA";
154   dirname+=suffixdir;
155   Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
156   if(!isRead) return;
157   if(!list || !hstat){
158     cout<<":-( null pointers..."<<endl;
159     return;
160   }
161   TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
162   pvtxt->SetBorderSize(0);
163   pvtxt->SetFillStyle(0);
164   pvtxt->AddText(name1);
165
166   TList* llist;
167   TH1F* hhstat;
168   if(superimpose){
169     isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
170     if(!isRead) return;
171     if(!llist || !hhstat){
172       cout<<":-( null pointers..."<<endl;
173       return;
174     }
175     TText *redtext=pvtxt->AddText(name2);
176     redtext->SetTextColor(kRed);
177     hhstat->Scale(hstat->Integral()/hhstat->Integral());
178
179   }
180
181   for(Int_t i=0;i<list->GetEntries();i++){
182     TH1F* h=(TH1F*)list->At(i);
183     TH1F* hh=0x0;
184     TH1F* hr=0x0;
185     if(superimpose){
186       hh=(TH1F*)llist->At(i);
187       hr=(TH1F*)hh->Clone(Form("%s_ratio",hh->GetName()));
188       hh->Scale(h->Integral()/hh->Integral());
189     }
190     if(!h || (superimpose && !hh)){
191       cout<<"Histogram "<<i<<" not found"<<endl;
192       continue;
193     }
194     if(superimpose){
195       hh->Scale(h->Integral()/hh->Integral());
196       hhstat->SetLineColor(kRed);
197       hh->SetLineColor(kRed);
198       hr->Divide(h);
199     }
200
201     TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
202     c->cd();
203     c->SetGrid();
204     TString hname=h->GetName();
205     if(!hname.Contains("nCls")){
206       c->SetLogy();
207       if(hname.Contains("Layer")){
208         for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
209           h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
210         }
211         h->GetXaxis()->SetLabelSize(0.06);
212         h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
213       }
214       //h->SetMinimum(1);
215       h->Draw();
216       if(superimpose) 
217         {
218           hh->Draw("sames");
219           TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
220           c2->cd();
221           c2->SetGrid();
222           hr->Draw();
223           c2->SaveAs(Form("%s%s%s%sRatio.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
224
225         }
226     } else {
227       h->Draw("htext0");
228       if(superimpose)hh->Draw("htext0sames");
229     }
230     c->cd();
231     pvtxt->Draw();
232     c->SaveAs(Form("%s%s%s%s.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
233     c->SaveAs(Form("%s%s%s%s.eps",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
234   }
235   
236   TCanvas* cst=new TCanvas("cst","Stat");
237   cst->SetGridy();
238   cst->cd();
239   hstat->Draw("htext0");
240   if(superimpose) {
241     hhstat->Draw("htext0sames");
242     pvtxt->Draw();
243   }
244   cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
245   cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
246
247
248 }
249
250 //draw "pid related" histograms (list "outputPID")
251 //period=-999 to draw the pull instead of the cut
252 void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsigma*/,TString textleg="",TString path="./",TString suffixdir="", TString filename="AnalysisResults.root"){
253   gStyle->SetCanvasColor(0);
254   gStyle->SetTitleFillColor(0);
255   gStyle->SetOptStat(0);
256   gStyle->SetPalette(1);
257
258   Int_t period=2 ,set=0;
259   if(mode==1){
260     cout<<"Choose period: \n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
261     cin>>period;
262     if(period>0){
263       cout<<"Choose set: "<<endl;
264       if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
265       cin>>set;
266     }
267   }
268
269   TString listname="outputPid";
270   TString dirname="PWG3_D2H_QA";
271   dirname+=suffixdir;
272
273   TList* list;
274   TH1F * hstat;
275   //needed only for mode 1
276   AliRDHFCuts* cutobj;
277   AliAODPidHF* aodpid;
278   Double_t nsigmaTOF=0;
279   Double_t nsigmaTPC[3]={},plimTPC[2]={};
280
281   if(mode==1){
282     Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path,filename,dirname);
283     if(!isRead) return;
284     if(!list || !hstat){
285       cout<<":-( null pointers..."<<endl;
286       return;
287     }
288     aodpid=(AliAODPidHF*)cutobj->GetPidHF();
289     if(!aodpid){
290       cout<<"PidHF object not found! cannot get the nsigma values"<<endl;
291       return;
292     }
293     nsigmaTOF=aodpid->GetSigma(3);
294   
295     nsigmaTPC[0]=aodpid->GetSigma(0);
296     nsigmaTPC[1]=aodpid->GetSigma(1);
297     nsigmaTPC[2]=aodpid->GetSigma(2);
298     aodpid->GetPLimit(plimTPC);
299
300   }else{
301     Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
302     if(!isRead) return;
303     if(!list || !hstat){
304       cout<<":-( null pointers..."<<endl;
305       return;
306     }
307   }
308
309
310   TPaveText *txtsigmaTOF=new TPaveText(0.1,0.65,0.5,0.9,"NDC");
311   txtsigmaTOF->SetBorderSize(0);
312   txtsigmaTOF->SetFillStyle(0);
313   txtsigmaTOF->AddText(Form("nsigmacut from cutobj = %.1f",nsigmaTOF));
314   TLine lTOF;
315   lTOF.SetLineColor(kMagenta+1);
316   lTOF.SetLineStyle(2);
317   lTOF.SetLineWidth(3);
318
319   TPaveText *txtsigmaTPC=new TPaveText(0.3,0.6,0.6,0.9,"NDC");
320   txtsigmaTPC->SetBorderSize(0);
321   txtsigmaTPC->SetFillStyle(0);
322   txtsigmaTPC->AddText("nsigmacut from cutobj \n");
323   txtsigmaTPC->AddText(Form("p < %.1f : %.1f \n",plimTPC[0],nsigmaTPC[0]));
324   txtsigmaTPC->AddText(Form("%.1f < p < %.1f : %.1f \n",plimTPC[0],plimTPC[1],nsigmaTPC[1]));
325   txtsigmaTPC->AddText(Form("p > %.1f : %.1f \n",plimTPC[1],nsigmaTPC[2]));
326   TLine lTPC;
327   lTPC.SetLineColor(kMagenta+1);
328   lTPC.SetLineStyle(2);
329   lTPC.SetLineWidth(3);
330
331   // TCanvas *ctest=new TCanvas("text","Test text");
332   // ctest->cd();
333   // txtsigmaTPC->Draw();
334   // txtsigmaTOF->Draw();
335
336
337   for(Int_t i=0;i<list->GetEntries();i++){
338     TClass* objtype=list->At(i)->IsA();
339     TString tpname=objtype->GetName();
340
341     if(tpname=="TH1F"){
342       TH1F* h=(TH1F*)list->At(i);
343
344       if(!h){
345         cout<<"Histogram "<<i<<" not found"<<endl;
346         continue;
347       }
348       //h->Scale(1./h->Integral("width"));
349       TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
350       c->SetLogz();
351       c->cd();
352       h->Draw();
353     
354       //write
355       c->SaveAs(Form("%s%s.png",h->GetName(),textleg.Data()));
356       c->SaveAs(Form("%s%s.eps",h->GetName(),textleg.Data()));
357       TFile* fout=new TFile(Form("%s.root",h->GetName()),"recreate");
358       fout->cd();
359       c->Write();
360     }
361   
362     if(tpname=="TH2F"){
363       TH2F* h=(TH2F*)list->At(i);
364       
365       if(!h){
366         cout<<"Histogram "<<i<<" not found"<<endl;
367         continue;
368       }
369       TString hname=h->GetName();
370       h->Sumw2();
371       if(h->Integral("width")==0) {cout<<"Empty histogram, skip\n"; continue;}
372       h->Scale(1./h->Integral("width"));
373
374       Double_t maxzaxis=h->GetBinContent(h->GetMaximumBin());
375       Double_t minzaxis=h->GetBinContent(h->GetMinimumBin());
376
377       TH2F* hallzrange=(TH2F*)h->Clone(Form("%swholez",hname.Data()));
378       hallzrange->SetAxisRange(1e-07,maxzaxis,"Z");
379
380       TCanvas* cwholez=new TCanvas(Form("c%swholez",hname.Data()),Form("%s down to lowest z",hname.Data()));
381       cwholez->SetLogz();
382       hallzrange->Draw("colz");
383       cwholez->SaveAs(Form("%swholez.png",h->GetName()));
384       cwholez->SaveAs(Form("%swholez.eps",h->GetName()));
385
386       if(hname.Contains("hTOFtimeKaonHyptime")){
387         TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
388         cz->SetLogz();
389         TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
390         hz->Draw("colz");
391         hz->SetAxisRange(-1500,1500,"Y");
392         hz->SetAxisRange(0.,5.,"X");
393         //write
394         cz->SaveAs(Form("%szoom.png",h->GetName()));
395         cz->SaveAs(Form("%szoom.eps",h->GetName()));
396       }
397
398       TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
399       c->SetLogz();
400       //c->SetLogx();
401       TCanvas* c2=new TCanvas(Form("c2%s",hname.Data()),hname.Data());
402       c2->SetLogz();
403
404       c->cd();
405       h->DrawClone("colz");
406
407       if (hname.Contains("Sig") || hname.Contains("sigma"))h->SetAxisRange(-5,5,"Y");
408       c2->cd();
409       //if (hname.Contains("TOFtime"))h->SetAxisRange(-1500,1500,"Y");
410       h->SetAxisRange(0.,5.,"X");
411      
412       h->Draw("colz");
413      
414       //TCanvas *test=new TCanvas("test","test");
415       if(mode==0){
416         //mean and pull, code from Jens Wiechula
417         TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
418         TLine l;
419         TObjArray arr;
420
421         //h->Draw("colz");
422         fg.SetParameters(1,0,1);
423         h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
424
425         TH1 *hM=(TH1*)arr.At(1);
426         hM->SetMarkerStyle(20);
427         hM->SetMarkerSize(.5);
428         hM->DrawClone("sames");
429
430         TH1 *hS=(TH1*)arr.At(2);
431         hS->SetMarkerStyle(20);
432         hS->SetMarkerSize(.5);
433         hS->SetMarkerColor(kRed);
434         hS->SetLineColor(kRed);
435         hS->DrawClone("same");
436
437         l.SetLineColor(kBlack);
438         l.DrawLine(.2,0,20,0);
439         l.SetLineColor(kRed);
440         l.DrawLine(.2,1,20,1);
441         
442       }else{ //mode 1
443
444         if(hname.Contains("TOFsigma")) {
445
446           c->cd();
447           txtsigmaTOF->Draw();
448           lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
449           lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
450
451         }
452       
453
454         if(hname.Contains("TPCsigma")){
455
456           c->cd();
457           txtsigmaTPC->Draw();
458           lTPC.DrawLine(0.,nsigmaTPC[0],plimTPC[0],nsigmaTPC[0]);
459           lTPC.DrawLine(plimTPC[0],nsigmaTPC[1],plimTPC[1],nsigmaTPC[1]);
460           lTPC.DrawLine(plimTPC[1],nsigmaTPC[2],4,nsigmaTPC[2]);
461           lTPC.DrawLine(0.,-1*nsigmaTPC[0],plimTPC[0],-1*nsigmaTPC[0]);
462           lTPC.DrawLine(plimTPC[0],-1*nsigmaTPC[1],plimTPC[1],-1*nsigmaTPC[1]);
463           lTPC.DrawLine(plimTPC[1],-1*nsigmaTPC[2],4,-1*nsigmaTPC[2]);
464         }
465
466         if(hname.Contains("TPCsigvsp")){
467           SuperimposeBBToTPCSignal(period,c,set);
468         }
469       }
470         
471       //write
472       c->SaveAs(Form("%s%d.png",h->GetName(),mode));
473       c->SaveAs(Form("%s%d.eps",h->GetName(),mode));
474       c2->SaveAs(Form("%s2%d.png",h->GetName(),mode));
475       c2->SaveAs(Form("%s2%d.eps",h->GetName(),mode));
476
477       TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
478       fout->cd();
479       c->Write();
480       c2->Write();
481     }
482   }
483 }
484
485 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
486
487   TFile* fBethe=new TFile("BetheBlochTPC.root");
488   if(!fBethe->IsOpen()){
489     TPCBetheBloch(set);
490     fBethe=new TFile("BetheBlochTPC.root");
491   }
492   const Int_t npart=4;
493   TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
494   for(Int_t ipart=0;ipart<npart;ipart++){
495     TString grname=Form("%sP%d",partnames[ipart].Data(),period);
496     TGraph* gr=(TGraph*)fBethe->Get(grname);
497     cpid->cd();
498     gr->SetLineColor(1);
499     gr->SetLineWidth(2);
500     gr->Draw("L");
501   }
502
503   //cpid->SaveAs(Form("%sBB.png",hname.Data()));
504 }
505
506 //draw and save Bethe Bloch from TPC in different periods
507 void TPCBetheBloch(Int_t set){
508   gStyle->SetOptTitle(0);
509   gStyle->SetCanvasColor(0);
510
511   AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
512
513   const Int_t npart=4;
514   //Double_t masses[npart]={TDatabasePDG::Instance()->GetParticle(321)->Mass()/*Kaon*/,TDatabasePDG::Instance()->GetParticle(211)->Mass()/*Pion*/,TDatabasePDG::Instance()->GetParticle(11)->Mass()/*Electron*/,TDatabasePDG::Instance()->GetParticle(2212)->Mass()/*Proton*/};
515   TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
516   //printf("%s = %.4f,%s = %.4f,%s = %.4f\n",partnames[0].Data(),masses[0],partnames[1].Data(),masses[1],partnames[2].Data(),masses[2]);
517   TCanvas *cBethe=new TCanvas("cBethe","Bethe Bloch K pi e p");
518   Int_t nperiods=4; //LHC10b+c, LHC10d, LHC10h, MC
519   Double_t alephParameters[5]={};
520   Int_t nsets=1/*LHC10bc*/+2/*LHC10de*/+2/*LHC10h*/+3/*MC*/;
521
522   periodsname=new TString[nsets];
523   cout<<"Creating the file of the Bethe Bloch"<<endl;
524   TFile* fout=new TFile("BetheBlochTPC.root","recreate");
525
526   for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
527     cout<<"Period "<<iperiod<<" : ";
528     if(iperiod==0){ //LHC10bc
529       
530       alephParameters[0] = 0.0283086/0.97;
531       alephParameters[1] = 2.63394e+01;
532       alephParameters[2] = 5.04114e-11;
533       alephParameters[3] = 2.12543e+00;
534       alephParameters[4] = 4.88663e+00;
535       periodsname[0]="dataLHC10bc";  
536     }
537     if(iperiod==1){ //LHC10de,low energy
538       if(set==0){   
539         alephParameters[0] = 1.63246/50.;
540         alephParameters[1] = 2.20028e+01;
541         alephParameters[2] = TMath::Exp(-2.48879e+01);
542         alephParameters[3] = 2.39804e+00;
543         alephParameters[4] = 5.12090e+00;
544         periodsname[1]="dataLHC10deold"; 
545       }
546       if(set==1){
547         alephParameters[0] = 1.34490e+00/50.;
548         alephParameters[1] =  2.69455e+01;
549         alephParameters[2] =  TMath::Exp(-2.97552e+01);
550         alephParameters[3] = 2.35339e+00;
551         alephParameters[4] = 5.98079e+00;
552         periodsname[2]="dataLHC10denew";
553       }
554     }
555
556     if(iperiod==2){//LHC10h
557       if(set==0){//pass1 
558         alephParameters[0]=1.25202/50.;
559         alephParameters[1]=2.74992e+01;
560         alephParameters[2]=TMath::Exp(-3.31517e+01);
561         alephParameters[3]=2.46246;
562         alephParameters[4]=6.78938;
563         periodsname[3]="dataLHC10hpass1";
564       }
565       if (set==1){//pass2 (AOD044)
566         alephParameters[0]=1.25202/50.;
567         alephParameters[1]=2.74992e+01;
568         alephParameters[2]=TMath::Exp(-3.31517e+01);
569         alephParameters[3]=2.46246;
570         alephParameters[4]=6.78938;
571         periodsname[4]="dataLHC10hpass2";
572       }
573     }
574     if(iperiod==3){ //MC
575       if(set==0){
576         alephParameters[0] = 2.15898e+00/50.;
577         alephParameters[1] = 1.75295e+01;
578         alephParameters[2] = 3.40030e-09;
579         alephParameters[3] = 1.96178e+00;
580         alephParameters[4] = 3.91720e+00;
581         periodsname[5]="MCold";
582       }
583       if(set==1){ //new
584         alephParameters[0] = 1.44405/50;
585         alephParameters[1] = 2.35409e+01;
586         alephParameters[2] = TMath::Exp(-2.90330e+01);
587         alephParameters[3] = 2.10681;
588         alephParameters[4] = 4.62254;
589         periodsname[6]="MCnew";
590       }
591
592       if(set==2){ //new BB from Francesco
593         alephParameters[0] = 0.029021;
594         alephParameters[1] = 25.4181;
595         alephParameters[2] = 4.66596e-08;
596         alephParameters[3] = 1.90008;
597         alephParameters[4] = 4.63783;
598         periodsname[7]="MCBBFrancesco";
599       }
600
601       if(set==3){ //low energy 2011
602         alephParameters[0] = 0.0207667;
603         alephParameters[1] = 29.9936;
604         alephParameters[2] = 3.87866e-11;
605         alephParameters[3] = 2.17291;
606         alephParameters[4] = 7.1623;
607         //periodsname[8]="MClowen2011";
608       }
609
610
611     }
612     //cout<<periodsname[iperiod]<<endl;
613     tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
614     cout<<"here"<<endl;
615     for(Int_t ipart=0;ipart<npart;ipart++){
616
617       const Int_t n=1000;
618       Double_t p[n],bethe[n];
619
620       for(Int_t k=0;k<n;k++){ //loop on the momentum steps
621         p[k]=0.0001+k*4./n; //limits 0.-4. GeV/c
622         //cout<<p[k]<<"\t";
623         //bethe[k]=-tpcResp->Bethe(p[k]/masses[ipart]);
624         AliPID::EParticleType ptype=AliPID::kKaon;
625         if(ipart==1) ptype=AliPID::kPion;
626         if(ipart==2) ptype=AliPID::kElectron;
627         if(ipart==3) ptype=AliPID::kProton;
628         bethe[k]=tpcResp->GetExpectedSignal(p[k],ptype);
629       }
630       //cout<<endl;
631       TGraph *gr=new TGraph(n,p,bethe);
632       gr->SetName(Form("%sP%d",partnames[ipart].Data(),iperiod));
633       gr->SetTitle(Form("%sP%d;p (GeV/c);",partnames[ipart].Data(),iperiod));
634       gr->SetLineColor(ipart+1);
635       gr->SetMarkerColor(ipart+1);
636       gr->GetYaxis()->SetRangeUser(35,100);
637       cBethe->cd();
638       if(iperiod==0 && ipart==0)gr->DrawClone("AL");
639       else gr->DrawClone("L");
640
641       fout->cd();
642       gr->Write();
643     }
644
645   }
646   TParameter<int> sett;
647   sett.SetVal(set);
648   fout->cd();
649   sett.Write();
650
651   fout->Close();
652 }
653
654 void DrawOutputCentrality(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE,TString suffixdir="",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root"){
655   gStyle->SetCanvasColor(0);
656   gStyle->SetTitleFillColor(0);
657   gStyle->SetStatColor(0);
658   gStyle->SetPalette(1);
659
660   TString listname="outputCentrCheck",name1="",name2="",path2="",filename2="PWG3histograms.root";
661
662   // if(superimpose){
663   //   cout<<"Enter the names:\n>";
664   //   cin>>name1;
665   //   cout<<">";
666   //   cin>>name2;
667   // }
668   // TString listname="outputTrack",name1="",name2="";
669   TString tmp="y";
670
671   if(superimpose){
672     cout<<"Enter the names:\n>";
673     cin>>name1;
674     cout<<">";
675     cin>>name2;
676     cout<<"Are they in the same output file? (y/n)"<<endl;
677     cin>>tmp;
678     if(tmp=="n"){
679       cout<<"Path: \n";
680       cout<<">";
681       cin>>path2;
682       cout<<"Filename: "<<endl;
683       cout<<">";
684       cin>>filename2;
685     }
686     
687   }
688   // Int_t nhist=1;
689   // TString *name=0x0;
690   // if(superimpose){
691   //   cout<<"Number of histogram to superimpose: ";
692   //   cin>>nhist;
693   //   name=new TString[nhist];
694   //   for (Int_t j=0;j<nhist;j++){
695   //     cout<<">";
696   //     cin>>name[j];
697   //   }
698   // }
699
700   TList* list;
701   TH1F * hstat;
702
703   TString dirname="PWG3_D2H_QA";
704   dirname+=suffixdir;
705
706   Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
707   if(!isRead) return;
708   if(!list || !hstat){
709     cout<<":-( null pointers..."<<endl;
710     return;
711   }
712
713   TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
714   pvtxt->SetBorderSize(0);
715   pvtxt->SetFillStyle(0);
716   pvtxt->AddText(name1);
717
718   TList* llist;
719   TH1F* hhstat;
720   if(superimpose){
721     isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
722     if(!isRead) return;
723     if(!llist || !hhstat){
724       cout<<":-( null pointers..."<<endl;
725       return;
726     }
727     TText *redtext=pvtxt->AddText(name2);
728     redtext->SetTextColor(kRed);
729
730   }
731
732
733   TCanvas* cst=new TCanvas("cst","Stat");
734   cst->SetGridy();
735   cst->cd();
736   Int_t nevents=hstat->GetBinContent(1);
737   hstat->Draw("htext0");
738   cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
739   cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
740   Int_t nevents080=1,nnevents080=1;
741
742   //TCanvas *spare=new TCanvas("sparecv","Spare");
743
744   for(Int_t i=0;i<list->GetEntries();i++){
745
746     TClass* objtype=list->At(i)->IsA();
747     TString tpname=objtype->GetName();
748
749     if(tpname=="TH1F"){
750
751       TH1F* h=(TH1F*)list->At(i);
752       TH1F* hh=0x0;
753       if(superimpose){
754         hh=(TH1F*)llist->At(i);
755       }
756       if(!h || (superimpose && !hh)){
757         cout<<"Histogram "<<i<<" not found"<<endl;
758         continue;
759       }
760       if(superimpose){
761         hhstat->SetLineColor(kRed);
762         hh->SetLineColor(kRed);
763       }
764
765       TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
766       TPaveText *pvtxt2=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
767       pvtxt2->SetBorderSize(0);
768       pvtxt2->SetFillStyle(0);
769
770       c->cd();
771       c->SetGrid();
772       c->SetLogy();
773       Int_t entries=h->Integral();
774       pvtxt2->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
775       h->Draw();
776       if(superimpose) {
777         hh->Draw("sames");
778         pvtxt->Draw();
779       }
780       pvtxt2->Draw();
781       c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
782       c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
783     }
784     if(tpname=="TH2F"){
785       TH2F* h=(TH2F*)list->At(i);
786       if(!h){
787         cout<<"Histogram "<<i<<" not found"<<endl;
788         continue;
789       }
790       TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
791       TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
792       pvtxt->SetBorderSize(0);
793       pvtxt->SetFillStyle(0);
794
795       c->cd();
796       c->SetGrid();
797       Int_t entries=h->Integral();
798       pvtxt->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
799       h->Draw("colz");
800       c->SetLogz();
801       pvtxt->Draw();
802       c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
803       c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
804     }
805   }
806   
807   
808   listname="countersCentrality";
809
810   isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
811   if(!isRead) return;
812   if(!list || !hstat){
813     cout<<":-( null pointers..."<<endl;
814     return;
815   }
816
817
818   if(superimpose){
819     isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
820     if(!isRead) return;
821     if(!llist || !hhstat){
822       cout<<":-( null pointers..."<<endl;
823       return;
824     }
825     TText *redtext=pvtxt->AddText(name2);
826     redtext->SetTextColor(kRed);
827
828   }
829
830   TH1F* hallcntr=0x0;
831   TH1F* hhallcntr=0x0;
832   cout<<"normalizing to 0-80% as a check"<<endl;
833   Int_t ncentr=10;//check this
834   TH1F* h020=0x0;
835   TH1F* h2080=0x0;
836   TH1F* hh020=0x0;
837   TH1F* hh2080=0x0;
838
839   TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
840   cvnocnt->Divide(2,1);
841   TCanvas *ccent=0x0;
842
843   for(Int_t i=0;i<list->GetEntries();i++){
844     AliCounterCollection* coll=(AliCounterCollection*)list->At(i);
845     AliCounterCollection* colle=0x0;
846     if(superimpose) colle=(AliCounterCollection*)llist->At(i);
847     coll->SortRubric("run");//sort by run number
848
849     h020=0x0;
850     h2080=0x0;
851     hh020=0x0;
852     hh2080=0x0;
853     
854     hallcntr=0x0; 
855     hhallcntr=0x0; 
856
857     TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
858     cvnocnt->cd(i+1);
859     if(hbad) hbad->Draw();
860
861     ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
862     ccent->SetTicky();
863     ccent->Divide(4,2);
864     
865     TH1F* hh=0x0;
866
867     for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
868
869       TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
870       h->SetName(Form("h%d%d",i,ic));
871       if(!hallcntr) {
872         hallcntr=(TH1F*)h->Clone("hallcntr");
873         hallcntr->Sumw2();
874       } else {
875         hallcntr->Add(h);
876       }
877       
878       nevents080+=h->Integral();
879
880       if(superimpose){
881         hh=(TH1F*)colle->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
882         hh->SetName(Form("hh%d%d",i,ic));
883         if(!hhallcntr) {
884           hhallcntr=(TH1F*)hh->Clone("hhallcntr");
885           hhallcntr->Sumw2();
886         }else hhallcntr->Add(hh);
887         nnevents080+=hh->Integral();
888         
889       }
890     }
891
892     for(Int_t ic=0;ic<ncentr;ic++){
893
894       TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
895       h->SetName(Form("h%d%d",i,ic));
896       h->Sumw2();
897       
898       if(ic>=0 && ic<=1){ //0-20
899         if(!h020) {
900           h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
901           h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
902           if(superimpose){
903             hh020=(TH1F*)hh->Clone(Form("hh020%s",coll->GetName()));
904             hh020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
905           }
906         }
907         else {
908           h020->Add(h);
909           if(superimpose)hh020->Add(hh);
910         }
911       }
912       if(ic>=2 && ic<=7){ //20-80
913         if(!h2080) {
914           h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
915           h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
916           if(superimpose){
917             hh2080=(TH1F*)hh->Clone(Form("hh2080%s",coll->GetName()));
918             hh2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
919           }
920         }
921         else {
922           h2080->Add(h);
923           if(superimpose)hh2080->Add(hh);
924         }
925         
926       }
927
928       h->Divide(hallcntr);
929
930       if(ic<8){
931         ccent->cd(ic+1);
932         h->GetYaxis()->SetLabelSize(0.05);
933         h->GetYaxis()->SetTitleOffset(1.5);
934         h->SetMinimum(0);
935         //h->GetYaxis()->SetRangeUser(0.,0.15);
936         h->DrawClone();
937       }
938       /*
939         if(ic==0&&i==0){
940         spare->cd();
941         h->Draw();
942         }
943       */
944       // ccent->cd(1);
945       // h->SetLineColor(ic+1);
946       // if(ic==0)h->DrawClone();
947       // else h->DrawClone("sames");
948     }
949     /*//draw 0-20 and 20-80 in the multi pad canvas (increase divisions before uncommenting)
950     ccent->cd(ncentr+1);
951     h020->Divide(hallcntr);
952     h020->DrawClone();
953     if(superimpose){
954       hh020->Divide(hhallcntr);
955       hh020->SetLineColor(2);
956       hh020->SetMarkerColor(2);
957       hh020->DrawClone("sames");
958     }
959     */
960     TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
961     cv020->cd();
962     cv020->SetTicky();
963     h020->GetYaxis()->SetRangeUser(0.,1.);
964     h020->DrawClone();
965     if(superimpose)hh020->DrawClone("sames");
966     cv020->SaveAs(Form("cv020-%d.pdf",i));
967     cv020->SaveAs(Form("cv020-%d.eps",i));
968
969     ccent->cd(ncentr+2);
970     h2080->Divide(hallcntr);
971     h2080->DrawClone();
972     if(superimpose){
973       hh2080->Divide(hhallcntr);
974       hh2080->SetLineColor(2);
975       hh2080->SetMarkerColor(2);
976       hh2080->DrawClone("sames");
977     }
978
979     TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
980     cv2080->cd();
981     cv2080->SetTicky();
982     h2080->GetYaxis()->SetRangeUser(0.,1.);
983     h2080->DrawClone();
984     if(superimpose)hh2080->DrawClone("sames");
985     cv2080->SaveAs(Form("cv2080-%d.pdf",i));
986     cv2080->SaveAs(Form("cv2080-%d.eps",i));
987
988     ccent->SaveAs(Form("%s%s.pdf",ccent->GetName(),textleg.Data()));
989     ccent->SaveAs(Form("%s%s.eps",ccent->GetName(),textleg.Data()));
990   }
991   
992 }
993
994 void DrawProjections(TString partname="D0",TString h2dname="hMultvsPercentile",Int_t nsteps=0,TString direction="X",TString path="./",TString suffixdir="", TString filename="AnalysisResults.root"){
995   gStyle->SetCanvasColor(0);
996   gStyle->SetTitleFillColor(0);
997   gStyle->SetStatColor(0);
998   gStyle->SetPalette(1);
999
1000   TString listname="outputCentrCheck";
1001   TString dirname="PWG3_D2H_QA";
1002   dirname+=suffixdir;
1003
1004   TList* list;
1005   TH1F * hstat;
1006
1007   Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1008   if(!isRead) return;
1009   if(!list || !hstat){
1010     cout<<":-( null pointers..."<<endl;
1011     return;
1012   }
1013   Double_t nevents=hstat->GetBinContent(5); //ev good vertex
1014
1015   TH2F* h2=(TH2F*)list->FindObject(h2dname);
1016   if(!h2){
1017     cout<<h2dname.Data()<<" not found"<<endl;
1018     return;
1019   }
1020   TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
1021   cv2d->cd();
1022   cv2d->SetLogz();
1023   cv2d->SetGrid();
1024   h2->Draw("colz");
1025   TPaveText *pvst=new TPaveText(0.6,0.2,0.9,0.7,"NDC");
1026   pvst->SetBorderSize(0);
1027   pvst->SetFillStyle(0);
1028   pvst->AddText("Bin -> Cont/nEvVtx");
1029
1030
1031   Int_t kbins=1;
1032   if(nsteps==0){
1033     if(direction=="X") nsteps=h2->GetNbinsY();
1034     if(direction=="Y") nsteps=h2->GetNbinsX();
1035   }
1036   else{
1037     if(direction=="X") kbins=h2->GetNbinsY()/nsteps;
1038     if(direction=="Y") kbins=h2->GetNbinsX()/nsteps;
1039   }
1040
1041   TCanvas *cvpj=new TCanvas(Form("cvpj%s%s",direction.Data(),h2dname.Data()),Form("cvpj%s",direction.Data()),1200,800);
1042   cvpj->Divide((Int_t)(nsteps/3)+1,3);
1043   TFile* fout=new TFile(Form("proj%s%s.root",direction.Data(),h2dname.Data()), "recreate");
1044   //Float_t maxx[nsteps];
1045   Float_t maxx[12]={9000,9000,6000,4000,2000,1400,800,500,200,100,40,25};
1046   Double_t integralpernev[nsteps];
1047
1048   for(Int_t i=0;i<nsteps;i++){
1049     TH1F* h=0x0;
1050     if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),i+kbins,i+2*kbins);
1051     if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),i+kbins,i+2*kbins);
1052     integralpernev[i]=h->Integral()/nevents;
1053
1054     TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
1055     pvtxt->SetBorderSize(0);
1056     pvtxt->SetFillStyle(0);
1057     pvtxt->AddText(Form("%.0f - %.0f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins))));
1058     pvst->AddText(Form("%.0f - %.0f -> %.2f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins)),integralpernev[i]));
1059     cvpj->cd(i+1);
1060     h->GetXaxis()->SetRangeUser(0,maxx[i]);
1061     h->Draw();
1062     pvtxt->Draw();
1063     fout->cd();
1064     h->Write();
1065   }
1066   cvpj->SaveAs(Form("cvpj%s%s.pdf",direction.Data(),h2dname.Data()));
1067   cvpj->SaveAs(Form("cvpj%s%s.eps",direction.Data(),h2dname.Data()));
1068
1069   cv2d->cd();
1070   pvst->Draw();
1071   cv2d->SaveAs(Form("%s.pdf",h2->GetName()));
1072   cv2d->SaveAs(Form("%s.eps",h2->GetName()));
1073
1074 }
1075
1076 void DrawEventSelection(TString partname="D0", TString path="./",TString suffixdir="",TString filename="AnalysisResults.root"){
1077   gStyle->SetCanvasColor(0);
1078   gStyle->SetTitleFillColor(0);
1079   gStyle->SetStatColor(0);
1080   gStyle->SetPalette(1);
1081   gStyle->SetOptStat(0);
1082
1083   TString listname="outputEvSel";
1084   TString dirname="PWG3_D2H_QA";
1085   dirname+=suffixdir;
1086
1087   TList* list;
1088   TH1F * hstat;
1089
1090   Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1091   if(!isRead) return;
1092   if(!list || !hstat){
1093     cout<<":-( null pointers..."<<endl;
1094     return;
1095   }
1096   //Double_t neventsgv=hstat->Integral(5,5); //ev good vertex
1097
1098   for(Int_t i=0;i<list->GetEntries();i++){
1099
1100     TClass* objtype=list->At(i)->IsA();
1101     TString tpname=objtype->GetName();
1102
1103     if(tpname=="TH1F"){
1104       TH1F* htmp=(TH1F*)list->At(i);
1105       TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1106       c->cd();
1107       htmp->Draw();
1108       c->SaveAs(Form("%s.pdf",htmp->GetName()));
1109       c->SaveAs(Form("%s.eps",htmp->GetName()));
1110     }
1111
1112     if(tpname=="TH2F"){
1113       TH2F* htmp=(TH2F*)list->At(i);
1114       TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()),1200,800);
1115       c->cd();
1116       htmp->SetMarkerSize(1.3);
1117       htmp->Draw("colzhtext45");
1118       c->SaveAs(Form("%s.pdf",htmp->GetName()));
1119       c->SaveAs(Form("%s.eps",htmp->GetName()));
1120     }
1121   }
1122
1123   AliCounterCollection* coll=(AliCounterCollection*)list->FindObject("trigCounter");
1124   if(!coll) {
1125     cout<<"Trigger counter not found"<<endl;
1126     return;
1127   }
1128   
1129   coll->SortRubric("run");//sort by run number
1130
1131   TString collname=coll->GetName();
1132
1133   TString keywords=coll->GetKeyWords("triggertype");
1134
1135   Int_t nkeys=keywords.CountChar(',')+1;
1136
1137   TString words[nkeys];
1138   for(Int_t k=0;k<nkeys;k++) words[k]="";
1139   printf("Keywords: ");
1140   Int_t count=0;
1141   for(Int_t l=0;l<keywords.Length();l++){
1142     if(keywords[l] != ',') words[count]+=keywords[l];
1143     else {
1144       printf("%s ",words[count].Data());
1145       count++;
1146     }
1147   }
1148   cout<<endl;
1149
1150   TH1D** htrig=new TH1D*[nkeys]; //each trigger type in one histogram of counts vs run
1151   TH1D** htrignorm=new TH1D*[nkeys]; //normalized to the counts in kAny
1152   TCanvas* ctrigfraction=new TCanvas("cvtrigfrac","Fraction of given trigger type vs run",1400,800);
1153   TLegend* legtr=new TLegend(0.15,0.5,0.35,0.8);
1154   legtr->SetBorderSize(0);
1155   legtr->SetFillStyle(0);
1156   for(Int_t k=0;k<nkeys;k++){
1157     htrig[k]=coll->Get("run",Form("triggertype:%s",words[k].Data()));
1158     htrig[k]->SetName(Form("h%s",words[k].Data()));
1159     htrig[k]->SetTitle("Trigger type;RUN; counts");
1160     htrig[k]->SetMarkerColor(k+1);
1161     htrig[k]->SetMarkerStyle(k+20);
1162     htrig[k]->Sumw2();
1163     legtr->AddEntry(htrig[k],Form("%s",words[k].Data()),"P");
1164     //drawings
1165     //1) counts of a given trigger over counts in kAny
1166     htrignorm[k]=(TH1D*)htrig[k]->Clone(Form("h%snormAny",words[k].Data()));
1167     htrignorm[k]->SetTitle("Trigger type over ANY trigger;RUN; counts/countsANY");
1168     htrignorm[k]->Divide(htrig[k],htrig[0],1.,1.,"B");
1169     htrignorm[k]->GetXaxis()->SetRangeUser(0,1.1);
1170     
1171     ctrigfraction->cd();
1172     if(k>0)htrignorm[k]->Draw("PEsames");
1173     else htrignorm[k]->Draw("PE");
1174   } 
1175   
1176   ctrigfraction->cd();
1177   legtr->Draw();
1178   ctrigfraction->SaveAs("TrgFractionOverANY.pdf");
1179   ctrigfraction->SaveAs("TrgFractionOverANY.eps");
1180     
1181 }