8 #include <TDirectoryFile.h>
12 #include <TPaveText.h>
15 #include <TDatabasePDG.h>
16 #include <TParameter.h>
17 #include <AliCounterCollection.h>
18 #include <AliRDHFCuts.h>
22 //read the file and take list and stat
24 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root");
25 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root");
26 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid, Int_t set);
27 void TPCBetheBloch(Int_t set);
29 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename){
31 TString hstatname="nEntriesQA",dirname="PWG3_D2H_QA", cutobjname="";
32 filename.Prepend(path);
36 TFile* f=new TFile(filename.Data());
38 cout<<filename.Data()<<" not found"<<endl;
41 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
43 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
47 list=(TList*)dir->Get(listname);
49 cout<<"List "<<listname.Data()<<" not found"<<endl;
54 hstat=(TH1F*)dir->Get(hstatname);
56 cout<<hstatname.Data()<<" not found"<<endl;
63 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path,TString filename){
65 TString hstatname="nEntriesQA",dirname="PWG3_D2H_QA", cutobjname="";
66 filename.Prepend(path);
70 if(partname.Contains("Dplus")) cutobjname="AnalysisCuts";//"DplustoKpipiCutsStandard";
72 if(partname.Contains("D0")) cutobjname="D0toKpiCutsStandard";//"D0toKpiCuts"
74 if(partname.Contains("Dstar")) cutobjname="DStartoKpipiCuts";
76 if(partname.Contains("Ds")) cutobjname="DstoKKpiCuts";
78 if(partname.Contains("D04")) cutobjname="D0toKpipipiCuts";
80 if(partname.Contains("Lc")) cutobjname="LctopKpiAnalysisCuts";
87 TFile* f=new TFile(filename.Data());
89 cout<<filename.Data()<<" not found"<<endl;
92 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
94 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
98 list=(TList*)dir->Get(listname);
100 cout<<"List "<<listname.Data()<<" not found"<<endl;
105 hstat=(TH1F*)dir->Get(hstatname);
107 cout<<hstatname.Data()<<" not found"<<endl;
111 cutobj=(AliRDHFCuts*)dir->Get(cutobjname);
113 cout<<cutobjname.Data()<<" not found"<<endl;
120 //draw "track related" histograms (list "outputTrack")
121 void DrawOutputTrack(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE){
122 gStyle->SetCanvasColor(0);
123 gStyle->SetTitleFillColor(0);
124 gStyle->SetStatColor(0);
125 gStyle->SetPalette(1);
127 TString listname="outputTrack",name1="",name2="",path2="",filename=/*"AnalysisResults.root"*/"PWG3histograms.root",filename2="PWG3histograms.root";
131 cout<<"Enter the names:\n>";
135 cout<<"Are they in the same output file? (y/n)"<<endl;
141 cout<<"Filename: "<<endl;
151 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename);
154 cout<<":-( null pointers..."<<endl;
157 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
158 pvtxt->SetBorderSize(0);
159 pvtxt->SetFillStyle(0);
160 pvtxt->AddText(name1);
165 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2);
167 if(!llist || !hhstat){
168 cout<<":-( null pointers..."<<endl;
171 TText *redtext=pvtxt->AddText(name2);
172 redtext->SetTextColor(kRed);
173 hhstat->Scale(hstat->Integral()/hhstat->Integral());
177 for(Int_t i=0;i<list->GetEntries();i++){
178 TH1F* h=(TH1F*)list->At(i);
182 hh=(TH1F*)llist->At(i);
183 hr=(TH1F*)hh->Clone(Form("%s_ratio",hh->GetName()));
184 hh->Scale(h->Integral()/hh->Integral());
186 if(!h || (superimpose && !hh)){
187 cout<<"Histogram "<<i<<" not found"<<endl;
191 hh->Scale(h->Integral()/hh->Integral());
192 hhstat->SetLineColor(kRed);
193 hh->SetLineColor(kRed);
197 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
200 TString hname=h->GetName();
201 if(!hname.Contains("nCls")){
203 if(hname.Contains("Layer")){
204 for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
205 h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
207 h->GetXaxis()->SetLabelSize(0.06);
208 h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
215 TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
219 c2->SaveAs(Form("%s%s%s%sRatio.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
224 if(superimpose)hh->Draw("htext0sames");
228 c->SaveAs(Form("%s%s%s%s.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
229 c->SaveAs(Form("%s%s%s%s.eps",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
232 TCanvas* cst=new TCanvas("cst","Stat");
235 hstat->Draw("htext0");
237 hhstat->Draw("htext0sames");
240 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
241 cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
246 //draw "pid related" histograms (list "outputPID")
247 //period=-999 to draw the pull instead of the cut
248 void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsigma*/,TString textleg="",TString path="./"){
249 gStyle->SetCanvasColor(0);
250 gStyle->SetTitleFillColor(0);
251 gStyle->SetStatColor(0);
252 gStyle->SetPalette(1);
254 Int_t period=2 ,set=0;
256 cout<<"Choose period: \n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
259 cout<<"Choose set: "<<endl;
260 if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
265 TString listname="outputPid";
269 //needed only for mode 1
272 Double_t nsigmaTOF=0;
273 Double_t nsigmaTPC[3]={},plimTPC[2]={};
276 Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path);
279 cout<<":-( null pointers..."<<endl;
282 aodpid=(AliAODPidHF*)cutobj->GetPidHF();
284 cout<<"PidHF object not found! cannot get the nsigma values"<<endl;
287 nsigmaTOF=aodpid->GetSigma(3);
289 nsigmaTPC[0]=aodpid->GetSigma(0);
290 nsigmaTPC[1]=aodpid->GetSigma(1);
291 nsigmaTPC[2]=aodpid->GetSigma(2);
292 aodpid->GetPLimit(plimTPC);
295 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
298 cout<<":-( null pointers..."<<endl;
304 TPaveText *txtsigmaTOF=new TPaveText(0.1,0.65,0.5,0.9,"NDC");
305 txtsigmaTOF->SetBorderSize(0);
306 txtsigmaTOF->SetFillStyle(0);
307 txtsigmaTOF->AddText(Form("nsigmacut from cutobj = %.1f",nsigmaTOF));
309 lTOF.SetLineColor(kMagenta+1);
310 lTOF.SetLineStyle(2);
311 lTOF.SetLineWidth(3);
313 TPaveText *txtsigmaTPC=new TPaveText(0.3,0.6,0.6,0.9,"NDC");
314 txtsigmaTPC->SetBorderSize(0);
315 txtsigmaTPC->SetFillStyle(0);
316 txtsigmaTPC->AddText("nsigmacut from cutobj \n");
317 txtsigmaTPC->AddText(Form("p < %.1f : %.1f \n",plimTPC[0],nsigmaTPC[0]));
318 txtsigmaTPC->AddText(Form("%.1f < p < %.1f : %.1f \n",plimTPC[0],plimTPC[1],nsigmaTPC[1]));
319 txtsigmaTPC->AddText(Form("p > %.1f : %.1f \n",plimTPC[1],nsigmaTPC[2]));
321 lTPC.SetLineColor(kMagenta+1);
322 lTPC.SetLineStyle(2);
323 lTPC.SetLineWidth(3);
325 // TCanvas *ctest=new TCanvas("text","Test text");
327 // txtsigmaTPC->Draw();
328 // txtsigmaTOF->Draw();
331 for(Int_t i=0;i<list->GetEntries();i++){
332 TClass* objtype=list->At(i)->IsA();
333 TString tpname=objtype->GetName();
336 TH1F* h=(TH1F*)list->At(i);
339 cout<<"Histogram "<<i<<" not found"<<endl;
342 //h->Scale(1./h->Integral("width"));
343 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
349 c->SaveAs(Form("%s%s.png",h->GetName(),textleg.Data()));
350 c->SaveAs(Form("%s%s.eps",h->GetName(),textleg.Data()));
351 TFile* fout=new TFile(Form("%s.root",h->GetName()),"recreate");
357 TH2F* h=(TH2F*)list->At(i);
360 cout<<"Histogram "<<i<<" not found"<<endl;
364 h->Scale(1./h->Integral("width"));
365 TString hname=h->GetName();
367 if(hname.Contains("hTOFtimeKaonHyptime")){
368 TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
370 TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
372 hz->SetAxisRange(-1500,1500,"Y");
373 hz->SetAxisRange(0.,5.,"X");
375 cz->SaveAs(Form("%szoom.png",h->GetName()));
376 cz->SaveAs(Form("%szoom.eps",h->GetName()));
379 TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
384 if (hname.Contains("Sig") || hname.Contains("sigma"))h->SetAxisRange(-5,5,"Y");
385 //if (hname.Contains("TOFtime"))h->SetAxisRange(-1500,1500,"Y");
386 h->SetAxisRange(0.,5.,"X");
390 //TCanvas *test=new TCanvas("test","test");
392 //mean and pull, code from Jens Wiechula
393 TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
398 fg.SetParameters(1,0,1);
399 h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
401 TH1 *hM=(TH1*)arr.At(1);
402 hM->SetMarkerStyle(20);
403 hM->SetMarkerSize(.5);
404 hM->DrawClone("sames");
406 TH1 *hS=(TH1*)arr.At(2);
407 hS->SetMarkerStyle(20);
408 hS->SetMarkerSize(.5);
409 hS->SetMarkerColor(kRed);
410 hS->SetLineColor(kRed);
411 hS->DrawClone("same");
413 l.SetLineColor(kBlack);
414 l.DrawLine(.2,0,20,0);
415 l.SetLineColor(kRed);
416 l.DrawLine(.2,1,20,1);
420 if(hname.Contains("TOFsigma")) {
424 lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
425 lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
430 if(hname.Contains("TPCsigma")){
434 lTPC.DrawLine(0.,nsigmaTPC[0],plimTPC[0],nsigmaTPC[0]);
435 lTPC.DrawLine(plimTPC[0],nsigmaTPC[1],plimTPC[1],nsigmaTPC[1]);
436 lTPC.DrawLine(plimTPC[1],nsigmaTPC[2],4,nsigmaTPC[2]);
437 lTPC.DrawLine(0.,-1*nsigmaTPC[0],plimTPC[0],-1*nsigmaTPC[0]);
438 lTPC.DrawLine(plimTPC[0],-1*nsigmaTPC[1],plimTPC[1],-1*nsigmaTPC[1]);
439 lTPC.DrawLine(plimTPC[1],-1*nsigmaTPC[2],4,-1*nsigmaTPC[2]);
442 if(hname.Contains("TPCsigvsp")){
443 SuperimposeBBToTPCSignal(period,c,set);
448 c->SaveAs(Form("%s%d.png",h->GetName(),mode));
449 c->SaveAs(Form("%s%d.eps",h->GetName(),mode));
450 TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
457 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
459 TFile* fBethe=new TFile("BetheBlochTPC.root");
460 if(!fBethe->IsOpen()){
462 fBethe=new TFile("BetheBlochTPC.root");
465 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
466 for(Int_t ipart=0;ipart<npart;ipart++){
467 TString grname=Form("%sP%d",partnames[ipart].Data(),period);
468 TGraph* gr=(TGraph*)fBethe->Get(grname);
475 //cpid->SaveAs(Form("%sBB.png",hname.Data()));
478 //draw and save Bethe Bloch from TPC in different periods
479 void TPCBetheBloch(Int_t set){
480 gStyle->SetOptTitle(0);
481 gStyle->SetCanvasColor(0);
483 AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
486 //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*/};
487 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
488 //printf("%s = %.4f,%s = %.4f,%s = %.4f\n",partnames[0].Data(),masses[0],partnames[1].Data(),masses[1],partnames[2].Data(),masses[2]);
489 TCanvas *cBethe=new TCanvas("cBethe","Bethe Bloch K pi e p");
490 Int_t nperiods=4; //LHC10b+c, LHC10d, LHC10h, MC
491 Double_t alephParameters[5]={};
492 Int_t nsets=1/*LHC10bc*/+2/*LHC10de*/+2/*LHC10h*/+3/*MC*/;
494 periodsname=new TString[nsets];
495 cout<<"Creating the file of the Bethe Bloch"<<endl;
496 TFile* fout=new TFile("BetheBlochTPC.root","recreate");
498 for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
499 cout<<"Period "<<iperiod<<" : ";
500 if(iperiod==0){ //LHC10bc
502 alephParameters[0] = 0.0283086/0.97;
503 alephParameters[1] = 2.63394e+01;
504 alephParameters[2] = 5.04114e-11;
505 alephParameters[3] = 2.12543e+00;
506 alephParameters[4] = 4.88663e+00;
507 periodsname[0]="dataLHC10bc";
509 if(iperiod==1){ //LHC10de,low energy
511 alephParameters[0] = 1.63246/50.;
512 alephParameters[1] = 2.20028e+01;
513 alephParameters[2] = TMath::Exp(-2.48879e+01);
514 alephParameters[3] = 2.39804e+00;
515 alephParameters[4] = 5.12090e+00;
516 periodsname[1]="dataLHC10deold";
519 alephParameters[0] = 1.34490e+00/50.;
520 alephParameters[1] = 2.69455e+01;
521 alephParameters[2] = TMath::Exp(-2.97552e+01);
522 alephParameters[3] = 2.35339e+00;
523 alephParameters[4] = 5.98079e+00;
524 periodsname[2]="dataLHC10denew";
528 if(iperiod==2){//LHC10h
530 alephParameters[0]=1.25202/50.;
531 alephParameters[1]=2.74992e+01;
532 alephParameters[2]=TMath::Exp(-3.31517e+01);
533 alephParameters[3]=2.46246;
534 alephParameters[4]=6.78938;
535 periodsname[3]="dataLHC10hpass1";
537 if (set==1){//pass2 (AOD044)
538 alephParameters[0]=1.25202/50.;
539 alephParameters[1]=2.74992e+01;
540 alephParameters[2]=TMath::Exp(-3.31517e+01);
541 alephParameters[3]=2.46246;
542 alephParameters[4]=6.78938;
543 periodsname[4]="dataLHC10hpass2";
548 alephParameters[0] = 2.15898e+00/50.;
549 alephParameters[1] = 1.75295e+01;
550 alephParameters[2] = 3.40030e-09;
551 alephParameters[3] = 1.96178e+00;
552 alephParameters[4] = 3.91720e+00;
553 periodsname[5]="MCold";
556 alephParameters[0] = 1.44405/50;
557 alephParameters[1] = 2.35409e+01;
558 alephParameters[2] = TMath::Exp(-2.90330e+01);
559 alephParameters[3] = 2.10681;
560 alephParameters[4] = 4.62254;
561 periodsname[6]="MCnew";
564 if(set==2){ //new BB from Francesco
565 alephParameters[0] = 0.029021;
566 alephParameters[1] = 25.4181;
567 alephParameters[2] = 4.66596e-08;
568 alephParameters[3] = 1.90008;
569 alephParameters[4] = 4.63783;
570 periodsname[7]="MCBBFrancesco";
573 if(set==3){ //low energy 2011
574 alephParameters[0] = 0.0207667;
575 alephParameters[1] = 29.9936;
576 alephParameters[2] = 3.87866e-11;
577 alephParameters[3] = 2.17291;
578 alephParameters[4] = 7.1623;
579 //periodsname[8]="MClowen2011";
584 //cout<<periodsname[iperiod]<<endl;
585 tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
587 for(Int_t ipart=0;ipart<npart;ipart++){
590 Double_t p[n],bethe[n];
592 for(Int_t k=0;k<n;k++){ //loop on the momentum steps
593 p[k]=0.0001+k*4./n; //limits 0.-4. GeV/c
595 //bethe[k]=-tpcResp->Bethe(p[k]/masses[ipart]);
596 AliPID::EParticleType ptype=AliPID::kKaon;
597 if(ipart==1) ptype=AliPID::kPion;
598 if(ipart==2) ptype=AliPID::kElectron;
599 if(ipart==3) ptype=AliPID::kProton;
600 bethe[k]=tpcResp->GetExpectedSignal(p[k],ptype);
603 TGraph *gr=new TGraph(n,p,bethe);
604 gr->SetName(Form("%sP%d",partnames[ipart].Data(),iperiod));
605 gr->SetTitle(Form("%sP%d;p (GeV/c);",partnames[ipart].Data(),iperiod));
606 gr->SetLineColor(ipart+1);
607 gr->SetMarkerColor(ipart+1);
608 gr->GetYaxis()->SetRangeUser(35,100);
610 if(iperiod==0 && ipart==0)gr->DrawClone("AL");
611 else gr->DrawClone("L");
618 TParameter<int> sett;
626 void DrawOutputCentrality(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE){
627 gStyle->SetCanvasColor(0);
628 gStyle->SetTitleFillColor(0);
629 gStyle->SetStatColor(0);
630 gStyle->SetPalette(1);
632 TString listname="outputCentrCheck",name1="",name2="",path2="",filename=/*"AnalysisResults.root"*/"PWG3histograms.root",filename2="PWG3histograms.root";
635 // cout<<"Enter the names:\n>";
640 // TString listname="outputTrack",name1="",name2="";
644 cout<<"Enter the names:\n>";
648 cout<<"Are they in the same output file? (y/n)"<<endl;
654 cout<<"Filename: "<<endl;
661 // TString *name=0x0;
663 // cout<<"Number of histogram to superimpose: ";
665 // name=new TString[nhist];
666 // for (Int_t j=0;j<nhist;j++){
675 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path);
678 cout<<":-( null pointers..."<<endl;
682 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
683 pvtxt->SetBorderSize(0);
684 pvtxt->SetFillStyle(0);
685 pvtxt->AddText(name1);
690 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2);
692 if(!llist || !hhstat){
693 cout<<":-( null pointers..."<<endl;
696 TText *redtext=pvtxt->AddText(name2);
697 redtext->SetTextColor(kRed);
702 TCanvas* cst=new TCanvas("cst","Stat");
705 Int_t nevents=hstat->GetBinContent(1);
706 hstat->Draw("htext0");
707 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
708 cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
709 Int_t nevents080=1,nnevents080=1;
711 //TCanvas *spare=new TCanvas("sparecv","Spare");
713 for(Int_t i=0;i<list->GetEntries();i++){
715 TClass* objtype=list->At(i)->IsA();
716 TString tpname=objtype->GetName();
720 TH1F* h=(TH1F*)list->At(i);
723 hh=(TH1F*)llist->At(i);
725 if(!h || (superimpose && !hh)){
726 cout<<"Histogram "<<i<<" not found"<<endl;
730 hhstat->SetLineColor(kRed);
731 hh->SetLineColor(kRed);
734 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
735 TPaveText *pvtxt2=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
736 pvtxt2->SetBorderSize(0);
737 pvtxt2->SetFillStyle(0);
742 Int_t entries=h->Integral();
743 pvtxt2->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
750 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
751 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
754 TH2F* h=(TH2F*)list->At(i);
756 cout<<"Histogram "<<i<<" not found"<<endl;
759 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
760 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
761 pvtxt->SetBorderSize(0);
762 pvtxt->SetFillStyle(0);
766 Int_t entries=h->Integral();
767 pvtxt->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
771 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
772 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
777 listname="countersCentrality";
779 isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path);
782 cout<<":-( null pointers..."<<endl;
788 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2);
790 if(!llist || !hhstat){
791 cout<<":-( null pointers..."<<endl;
794 TText *redtext=pvtxt->AddText(name2);
795 redtext->SetTextColor(kRed);
801 cout<<"normalizing to 0-80% as a check"<<endl;
802 Int_t ncentr=10;//check this
808 TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
809 cvnocnt->Divide(2,1);
812 for(Int_t i=0;i<list->GetEntries();i++){
813 AliCounterCollection* coll=(AliCounterCollection*)list->At(i);
814 AliCounterCollection* colle=0x0;
815 if(superimpose) colle=(AliCounterCollection*)llist->At(i);
816 coll->SortRubric("run");//sort by run number
817 TString collname=coll->GetName();
819 if(!collname.Contains("Estimator")){
820 if(collname!="trigCounter") {
821 printf("Unexpected counter named %s. Check! I exit...\n",collname.Data());
824 TString keywords=coll->GetKeyWords("triggertype");
826 Int_t nkeys=keywords.CountChar(',')+1;
828 TString words[nkeys];
829 for(Int_t k=0;k<nkeys;k++) words[k]="";
830 printf("Keywords: ");
832 for(Int_t l=0;l<keywords.Length();l++){
833 if(keywords[l] != ',') words[count]+=keywords[l];
835 printf("%s ",words[count].Data());
841 TH1D** htrig=new TH1D*[nkeys]; //each trigger type in one histogram of counts vs run
842 TH1D** htrignorm=new TH1D*[nkeys]; //normalized to the counts in kAny
843 TCanvas* ctrigfraction=new TCanvas("cvtrigfrac","Fraction of given trigger type vs run",1400,800);
844 TLegend* legtr=new TLegend(0.15,0.5,0.35,0.8);
845 legtr->SetBorderSize(0);
846 legtr->SetFillStyle(0);
847 for(Int_t k=0;k<nkeys;k++){
848 htrig[k]=coll->Get("run",Form("triggertype:%s",words[k].Data()));
849 htrig[k]->SetName(Form("h%s",words[k].Data()));
850 htrig[k]->SetTitle("Trigger type;RUN; counts");
851 htrig[k]->SetMarkerColor(k+1);
852 htrig[k]->SetMarkerStyle(k+20);
854 legtr->AddEntry(htrig[k],Form("%s",words[k].Data()),"P");
856 //1) counts of a given trigger over counts in kAny
857 htrignorm[k]=(TH1D*)htrig[k]->Clone(Form("h%snormAny",words[k].Data()));
858 htrignorm[k]->SetTitle("Trigger type over ANY trigger;RUN; counts/countsANY");
859 htrignorm[k]->Divide(htrig[k],htrig[0],1.,1.,"B");
860 htrignorm[k]->GetXaxis()->SetRangeUser(0,1.1);
863 if(k>0)htrignorm[k]->Draw("PEsames");
864 else htrignorm[k]->Draw("PE");
879 TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
881 if(hbad) hbad->Draw();
883 ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
888 for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
890 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
891 h->SetName(Form("h%d%d",i,ic));
893 hallcntr=(TH1F*)h->Clone("hallcntr");
899 nevents080+=h->Integral();
902 hh=(TH1F*)colle->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
903 hh->SetName(Form("hh%d%d",i,ic));
905 hhallcntr=(TH1F*)hh->Clone("hhallcntr");
907 }else hhallcntr->Add(hh);
908 nnevents080+=hh->Integral();
913 for(Int_t ic=0;ic<ncentr;ic++){
915 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
916 h->SetName(Form("h%d%d",i,ic));
919 if(ic>=0 && ic<=1){ //0-20
921 h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
922 h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
924 hh020=(TH1F*)hh->Clone(Form("hh020%s",coll->GetName()));
925 hh020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
930 if(superimpose)hh020->Add(hh);
933 if(ic>=2 && ic<=7){ //20-80
935 h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
936 h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
938 hh2080=(TH1F*)hh->Clone(Form("hh2080%s",coll->GetName()));
939 hh2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
944 if(superimpose)hh2080->Add(hh);
952 h->GetYaxis()->SetRangeUser(0.,0.15);
961 // h->SetLineColor(ic+1);
962 // if(ic==0)h->DrawClone();
963 // else h->DrawClone("sames");
967 h020->Divide(hallcntr);
970 hh020->Divide(hhallcntr);
971 hh020->SetLineColor(2);
972 hh020->SetMarkerColor(2);
973 hh020->DrawClone("sames");
975 TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
977 h020->GetYaxis()->SetRangeUser(0.,1.);
979 if(superimpose)hh020->DrawClone("sames");
980 cv020->SaveAs(Form("cv020-%d.pdf",i));
981 cv020->SaveAs(Form("cv020-%d.eps",i));
984 h2080->Divide(hallcntr);
987 hh2080->Divide(hhallcntr);
988 hh2080->SetLineColor(2);
989 hh2080->SetMarkerColor(2);
990 hh2080->DrawClone("sames");
993 TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
995 h2080->GetYaxis()->SetRangeUser(0.,1.);
997 if(superimpose)hh2080->DrawClone("sames");
998 cv2080->SaveAs(Form("cv2080-%d.pdf",i));
999 cv2080->SaveAs(Form("cv2080-%d.eps",i));
1001 ccent->SaveAs(Form("%s%s.pdf",ccent->GetName(),textleg.Data()));
1002 ccent->SaveAs(Form("%s%s.eps",ccent->GetName(),textleg.Data()));
1007 void DrawProjections(TString partname="D0",TString h2dname="hMultvsPercentile",Int_t nsteps=0,TString direction="X",TString path="./"){
1008 gStyle->SetCanvasColor(0);
1009 gStyle->SetTitleFillColor(0);
1010 gStyle->SetStatColor(0);
1011 gStyle->SetPalette(1);
1013 TString listname="outputCentrCheck";
1018 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
1020 if(!list || !hstat){
1021 cout<<":-( null pointers..."<<endl;
1024 Double_t nevents=hstat->GetBinContent(5); //ev good vertex
1026 TH2F* h2=(TH2F*)list->FindObject(h2dname);
1028 cout<<h2dname.Data()<<" not found"<<endl;
1031 TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
1036 TPaveText *pvst=new TPaveText(0.6,0.2,0.9,0.7,"NDC");
1037 pvst->SetBorderSize(0);
1038 pvst->SetFillStyle(0);
1039 pvst->AddText("Bin -> Cont/nEvVtx");
1044 if(direction=="X") nsteps=h2->GetNbinsY();
1045 if(direction=="Y") nsteps=h2->GetNbinsX();
1048 if(direction=="X") kbins=h2->GetNbinsY()/nsteps;
1049 if(direction=="Y") kbins=h2->GetNbinsX()/nsteps;
1052 TCanvas *cvpj=new TCanvas(Form("cvpj%s%s",direction.Data(),h2dname.Data()),Form("cvpj%s",direction.Data()),1200,800);
1053 cvpj->Divide((Int_t)(nsteps/3)+1,3);
1054 TFile* fout=new TFile(Form("proj%s%s.root",direction.Data(),h2dname.Data()), "recreate");
1055 //Float_t maxx[nsteps];
1056 Float_t maxx[12]={9000,9000,6000,4000,2000,1400,800,500,200,100,40,25};
1057 Double_t integralpernev[nsteps];
1059 for(Int_t i=0;i<nsteps;i++){
1061 if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),i+kbins,i+2*kbins);
1062 if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),i+kbins,i+2*kbins);
1063 integralpernev[i]=h->Integral()/nevents;
1065 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
1066 pvtxt->SetBorderSize(0);
1067 pvtxt->SetFillStyle(0);
1068 pvtxt->AddText(Form("%.0f - %.0f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins))));
1069 pvst->AddText(Form("%.0f - %.0f -> %.2f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins)),integralpernev[i]));
1071 h->GetXaxis()->SetRangeUser(0,maxx[i]);
1077 cvpj->SaveAs(Form("cvpj%s%s.pdf",direction.Data(),h2dname.Data()));
1078 cvpj->SaveAs(Form("cvpj%s%s.eps",direction.Data(),h2dname.Data()));
1082 cv2d->SaveAs(Form("%s.pdf",h2->GetName()));
1083 cv2d->SaveAs(Form("%s.eps",h2->GetName()));
1087 void DrawEventSelection(TString partname="D0", TString path="./"){
1088 gStyle->SetCanvasColor(0);
1089 gStyle->SetTitleFillColor(0);
1090 gStyle->SetStatColor(0);
1091 gStyle->SetPalette(1);
1092 gStyle->SetOptStat(0);
1094 TString listname="outputEvSel";
1099 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
1101 if(!list || !hstat){
1102 cout<<":-( null pointers..."<<endl;
1105 //Double_t neventsgv=hstat->Integral(5,5); //ev good vertex
1107 for(Int_t i=0;i<list->GetEntries();i++){
1109 TClass* objtype=list->At(i)->IsA();
1110 TString tpname=objtype->GetName();
1113 TH1F* htmp=(TH1F*)list->At(i);
1114 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1117 c->SaveAs(Form("%s.pdf",htmp->GetName()));
1118 c->SaveAs(Form("%s.eps",htmp->GetName()));
1122 TH2F* htmp=(TH2F*)list->At(i);
1123 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1125 htmp->SetMarkerSize(1.3);
1126 htmp->Draw("text0colz");
1127 c->SaveAs(Form("%s.pdf",htmp->GetName()));
1128 c->SaveAs(Form("%s.eps",htmp->GetName()));