1 #if !defined(__CINT__) || defined(__MAKECINT__)
9 #include <TDirectoryFile.h>
13 #include <TPaveText.h>
16 #include <TDatabasePDG.h>
17 #include <TParameter.h>
18 #include <AliCounterCollection.h>
19 #include <AliRDHFCuts.h>
24 //read the file and take list and stat
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);
31 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename, TString dirname){
33 TString hstatname="nEntriesQA", cutobjname="";
34 filename.Prepend(path);
38 TFile* f=new TFile(filename.Data());
40 cout<<filename.Data()<<" not found"<<endl;
43 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
45 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
50 list=(TList*)dir->Get(listname);
52 cout<<"List "<<listname.Data()<<" not found"<<endl;
57 hstat=(TH1F*)dir->Get(hstatname);
59 cout<<hstatname.Data()<<" not found"<<endl;
66 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path,TString filename,TString dirname){
68 TString hstatname="nEntriesQA", cutobjname="";
69 filename.Prepend(path);
73 if(partname.Contains("Dplus")) cutobjname="AnalysisCuts";//"DplustoKpipiCutsStandard";
75 if(partname.Contains("D0")) cutobjname="D0toKpiCutsStandard";//"D0toKpiCuts"
77 if(partname.Contains("Dstar")) cutobjname="DStartoKpipiCuts";
79 if(partname.Contains("Ds")) cutobjname="DstoKKpiCuts";
81 if(partname.Contains("D04")) cutobjname="D0toKpipipiCuts";
83 if(partname.Contains("Lc")) cutobjname="LctopKpiAnalysisCuts";
90 TFile* f=new TFile(filename.Data());
92 cout<<filename.Data()<<" not found"<<endl;
95 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
97 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
101 list=(TList*)dir->Get(listname);
103 cout<<"List "<<listname.Data()<<" not found"<<endl;
108 hstat=(TH1F*)dir->Get(hstatname);
110 cout<<hstatname.Data()<<" not found"<<endl;
114 cutobj=(AliRDHFCuts*)dir->Get(cutobjname);
116 cout<<cutobjname.Data()<<" not found"<<endl;
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);
130 TString listname="outputTrack",name1="",name2="",path2="",filename2="PWG3histograms.root";
134 cout<<"Enter the names:\n>";
138 cout<<"Are they in the same output file? (y/n)"<<endl;
144 cout<<"Filename: "<<endl;
153 TString dirname="PWG3_D2H_QA";
155 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
158 cout<<":-( null pointers..."<<endl;
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);
169 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
171 if(!llist || !hhstat){
172 cout<<":-( null pointers..."<<endl;
175 TText *redtext=pvtxt->AddText(name2);
176 redtext->SetTextColor(kRed);
177 hhstat->Scale(hstat->Integral()/hhstat->Integral());
181 for(Int_t i=0;i<list->GetEntries();i++){
182 TH1F* h=(TH1F*)list->At(i);
186 hh=(TH1F*)llist->At(i);
187 hr=(TH1F*)hh->Clone(Form("%s_ratio",hh->GetName()));
188 hh->Scale(h->Integral()/hh->Integral());
190 if(!h || (superimpose && !hh)){
191 cout<<"Histogram "<<i<<" not found"<<endl;
195 hh->Scale(h->Integral()/hh->Integral());
196 hhstat->SetLineColor(kRed);
197 hh->SetLineColor(kRed);
201 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
204 TString hname=h->GetName();
205 if(!hname.Contains("nCls")){
207 if(hname.Contains("Layer")){
208 for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
209 h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
211 h->GetXaxis()->SetLabelSize(0.06);
212 h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
219 TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
223 c2->SaveAs(Form("%s%s%s%sRatio.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
228 if(superimpose)hh->Draw("htext0sames");
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()));
236 TCanvas* cst=new TCanvas("cst","Stat");
239 hstat->Draw("htext0");
241 hhstat->Draw("htext0sames");
244 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
245 cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
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);
258 Int_t period=2 ,set=0;
260 cout<<"Choose period: \n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
263 cout<<"Choose set: "<<endl;
264 if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
269 TString listname="outputPid";
270 TString dirname="PWG3_D2H_QA";
275 //needed only for mode 1
278 Double_t nsigmaTOF=0;
279 Double_t nsigmaTPC[3]={},plimTPC[2]={};
282 Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path,filename,dirname);
285 cout<<":-( null pointers..."<<endl;
288 aodpid=(AliAODPidHF*)cutobj->GetPidHF();
290 cout<<"PidHF object not found! cannot get the nsigma values"<<endl;
293 nsigmaTOF=aodpid->GetSigma(3);
295 nsigmaTPC[0]=aodpid->GetSigma(0);
296 nsigmaTPC[1]=aodpid->GetSigma(1);
297 nsigmaTPC[2]=aodpid->GetSigma(2);
298 aodpid->GetPLimit(plimTPC);
301 Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
304 cout<<":-( null pointers..."<<endl;
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));
315 lTOF.SetLineColor(kMagenta+1);
316 lTOF.SetLineStyle(2);
317 lTOF.SetLineWidth(3);
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]));
327 lTPC.SetLineColor(kMagenta+1);
328 lTPC.SetLineStyle(2);
329 lTPC.SetLineWidth(3);
331 // TCanvas *ctest=new TCanvas("text","Test text");
333 // txtsigmaTPC->Draw();
334 // txtsigmaTOF->Draw();
337 for(Int_t i=0;i<list->GetEntries();i++){
338 TClass* objtype=list->At(i)->IsA();
339 TString tpname=objtype->GetName();
342 TH1F* h=(TH1F*)list->At(i);
345 cout<<"Histogram "<<i<<" not found"<<endl;
348 //h->Scale(1./h->Integral("width"));
349 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
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");
363 TH2F* h=(TH2F*)list->At(i);
366 cout<<"Histogram "<<i<<" not found"<<endl;
369 TString hname=h->GetName();
371 if(h->Integral("width")==0) {cout<<"Empty histogram, skip\n"; continue;}
372 h->Scale(1./h->Integral("width"));
374 Double_t maxzaxis=h->GetBinContent(h->GetMaximumBin());
375 Double_t minzaxis=h->GetBinContent(h->GetMinimumBin());
377 TH2F* hallzrange=(TH2F*)h->Clone(Form("%swholez",hname.Data()));
378 hallzrange->SetAxisRange(1e-07,maxzaxis,"Z");
380 TCanvas* cwholez=new TCanvas(Form("c%swholez",hname.Data()),Form("%s down to lowest z",hname.Data()));
382 hallzrange->Draw("colz");
383 cwholez->SaveAs(Form("%swholez.png",h->GetName()));
384 cwholez->SaveAs(Form("%swholez.eps",h->GetName()));
386 if(hname.Contains("hTOFtimeKaonHyptime")){
387 TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
389 TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
391 hz->SetAxisRange(-1500,1500,"Y");
392 hz->SetAxisRange(0.,5.,"X");
394 cz->SaveAs(Form("%szoom.png",h->GetName()));
395 cz->SaveAs(Form("%szoom.eps",h->GetName()));
398 TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
401 TCanvas* c2=new TCanvas(Form("c2%s",hname.Data()),hname.Data());
405 h->DrawClone("colz");
407 if (hname.Contains("Sig") || hname.Contains("sigma"))h->SetAxisRange(-5,5,"Y");
409 //if (hname.Contains("TOFtime"))h->SetAxisRange(-1500,1500,"Y");
410 h->SetAxisRange(0.,5.,"X");
414 //TCanvas *test=new TCanvas("test","test");
416 //mean and pull, code from Jens Wiechula
417 TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
422 fg.SetParameters(1,0,1);
423 h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
425 TH1 *hM=(TH1*)arr.At(1);
426 hM->SetMarkerStyle(20);
427 hM->SetMarkerSize(.5);
428 hM->DrawClone("sames");
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");
437 l.SetLineColor(kBlack);
438 l.DrawLine(.2,0,20,0);
439 l.SetLineColor(kRed);
440 l.DrawLine(.2,1,20,1);
444 if(hname.Contains("TOFsigma")) {
448 lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
449 lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
454 if(hname.Contains("TPCsigma")){
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]);
466 if(hname.Contains("TPCsigvsp")){
467 SuperimposeBBToTPCSignal(period,c,set);
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));
477 TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
485 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
487 TFile* fBethe=new TFile("BetheBlochTPC.root");
488 if(!fBethe->IsOpen()){
490 fBethe=new TFile("BetheBlochTPC.root");
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);
503 //cpid->SaveAs(Form("%sBB.png",hname.Data()));
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);
511 AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
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*/;
522 periodsname=new TString[nsets];
523 cout<<"Creating the file of the Bethe Bloch"<<endl;
524 TFile* fout=new TFile("BetheBlochTPC.root","recreate");
526 for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
527 cout<<"Period "<<iperiod<<" : ";
528 if(iperiod==0){ //LHC10bc
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";
537 if(iperiod==1){ //LHC10de,low energy
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";
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";
556 if(iperiod==2){//LHC10h
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";
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";
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";
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";
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";
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";
612 //cout<<periodsname[iperiod]<<endl;
613 tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
615 for(Int_t ipart=0;ipart<npart;ipart++){
618 Double_t p[n],bethe[n];
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
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);
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);
638 if(iperiod==0 && ipart==0)gr->DrawClone("AL");
639 else gr->DrawClone("L");
646 TParameter<int> sett;
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);
660 TString listname="outputCentrCheck",name1="",name2="",path2="",filename2="PWG3histograms.root";
663 // cout<<"Enter the names:\n>";
668 // TString listname="outputTrack",name1="",name2="";
672 cout<<"Enter the names:\n>";
676 cout<<"Are they in the same output file? (y/n)"<<endl;
682 cout<<"Filename: "<<endl;
689 // TString *name=0x0;
691 // cout<<"Number of histogram to superimpose: ";
693 // name=new TString[nhist];
694 // for (Int_t j=0;j<nhist;j++){
703 TString dirname="PWG3_D2H_QA";
706 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
709 cout<<":-( null pointers..."<<endl;
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);
721 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
723 if(!llist || !hhstat){
724 cout<<":-( null pointers..."<<endl;
727 TText *redtext=pvtxt->AddText(name2);
728 redtext->SetTextColor(kRed);
733 TCanvas* cst=new TCanvas("cst","Stat");
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;
742 //TCanvas *spare=new TCanvas("sparecv","Spare");
744 for(Int_t i=0;i<list->GetEntries();i++){
746 TClass* objtype=list->At(i)->IsA();
747 TString tpname=objtype->GetName();
751 TH1F* h=(TH1F*)list->At(i);
754 hh=(TH1F*)llist->At(i);
756 if(!h || (superimpose && !hh)){
757 cout<<"Histogram "<<i<<" not found"<<endl;
761 hhstat->SetLineColor(kRed);
762 hh->SetLineColor(kRed);
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);
773 Int_t entries=h->Integral();
774 pvtxt2->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
781 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
782 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
785 TH2F* h=(TH2F*)list->At(i);
787 cout<<"Histogram "<<i<<" not found"<<endl;
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);
797 Int_t entries=h->Integral();
798 pvtxt->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
802 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
803 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
808 listname="countersCentrality";
810 isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,dirname);
813 cout<<":-( null pointers..."<<endl;
819 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,dirname);
821 if(!llist || !hhstat){
822 cout<<":-( null pointers..."<<endl;
825 TText *redtext=pvtxt->AddText(name2);
826 redtext->SetTextColor(kRed);
832 cout<<"normalizing to 0-80% as a check"<<endl;
833 Int_t ncentr=10;//check this
839 TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
840 cvnocnt->Divide(2,1);
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
857 TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
859 if(hbad) hbad->Draw();
861 ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
867 for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
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));
872 hallcntr=(TH1F*)h->Clone("hallcntr");
878 nevents080+=h->Integral();
881 hh=(TH1F*)colle->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
882 hh->SetName(Form("hh%d%d",i,ic));
884 hhallcntr=(TH1F*)hh->Clone("hhallcntr");
886 }else hhallcntr->Add(hh);
887 nnevents080+=hh->Integral();
892 for(Int_t ic=0;ic<ncentr;ic++){
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));
898 if(ic>=0 && ic<=1){ //0-20
900 h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
901 h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
903 hh020=(TH1F*)hh->Clone(Form("hh020%s",coll->GetName()));
904 hh020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
909 if(superimpose)hh020->Add(hh);
912 if(ic>=2 && ic<=7){ //20-80
914 h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
915 h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
917 hh2080=(TH1F*)hh->Clone(Form("hh2080%s",coll->GetName()));
918 hh2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
923 if(superimpose)hh2080->Add(hh);
932 h->GetYaxis()->SetLabelSize(0.05);
933 h->GetYaxis()->SetTitleOffset(1.5);
935 //h->GetYaxis()->SetRangeUser(0.,0.15);
945 // h->SetLineColor(ic+1);
946 // if(ic==0)h->DrawClone();
947 // else h->DrawClone("sames");
949 /*//draw 0-20 and 20-80 in the multi pad canvas (increase divisions before uncommenting)
951 h020->Divide(hallcntr);
954 hh020->Divide(hhallcntr);
955 hh020->SetLineColor(2);
956 hh020->SetMarkerColor(2);
957 hh020->DrawClone("sames");
960 TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
963 h020->GetYaxis()->SetRangeUser(0.,1.);
965 if(superimpose)hh020->DrawClone("sames");
966 cv020->SaveAs(Form("cv020-%d.pdf",i));
967 cv020->SaveAs(Form("cv020-%d.eps",i));
970 h2080->Divide(hallcntr);
973 hh2080->Divide(hhallcntr);
974 hh2080->SetLineColor(2);
975 hh2080->SetMarkerColor(2);
976 hh2080->DrawClone("sames");
979 TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
982 h2080->GetYaxis()->SetRangeUser(0.,1.);
984 if(superimpose)hh2080->DrawClone("sames");
985 cv2080->SaveAs(Form("cv2080-%d.pdf",i));
986 cv2080->SaveAs(Form("cv2080-%d.eps",i));
988 ccent->SaveAs(Form("%s%s.pdf",ccent->GetName(),textleg.Data()));
989 ccent->SaveAs(Form("%s%s.eps",ccent->GetName(),textleg.Data()));
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);
1000 TString listname="outputCentrCheck";
1001 TString dirname="PWG3_D2H_QA";
1007 Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1009 if(!list || !hstat){
1010 cout<<":-( null pointers..."<<endl;
1013 Double_t nevents=hstat->GetBinContent(5); //ev good vertex
1015 TH2F* h2=(TH2F*)list->FindObject(h2dname);
1017 cout<<h2dname.Data()<<" not found"<<endl;
1020 TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
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");
1033 if(direction=="X") nsteps=h2->GetNbinsY();
1034 if(direction=="Y") nsteps=h2->GetNbinsX();
1037 if(direction=="X") kbins=h2->GetNbinsY()/nsteps;
1038 if(direction=="Y") kbins=h2->GetNbinsX()/nsteps;
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];
1048 for(Int_t i=0;i<nsteps;i++){
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;
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]));
1060 h->GetXaxis()->SetRangeUser(0,maxx[i]);
1066 cvpj->SaveAs(Form("cvpj%s%s.pdf",direction.Data(),h2dname.Data()));
1067 cvpj->SaveAs(Form("cvpj%s%s.eps",direction.Data(),h2dname.Data()));
1071 cv2d->SaveAs(Form("%s.pdf",h2->GetName()));
1072 cv2d->SaveAs(Form("%s.eps",h2->GetName()));
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);
1083 TString listname="outputEvSel";
1084 TString dirname="PWG3_D2H_QA";
1090 Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1092 if(!list || !hstat){
1093 cout<<":-( null pointers..."<<endl;
1096 //Double_t neventsgv=hstat->Integral(5,5); //ev good vertex
1098 for(Int_t i=0;i<list->GetEntries();i++){
1100 TClass* objtype=list->At(i)->IsA();
1101 TString tpname=objtype->GetName();
1104 TH1F* htmp=(TH1F*)list->At(i);
1105 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1108 c->SaveAs(Form("%s.pdf",htmp->GetName()));
1109 c->SaveAs(Form("%s.eps",htmp->GetName()));
1113 TH2F* htmp=(TH2F*)list->At(i);
1114 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()),1200,800);
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()));
1123 AliCounterCollection* coll=(AliCounterCollection*)list->FindObject("trigCounter");
1125 cout<<"Trigger counter not found"<<endl;
1129 coll->SortRubric("run");//sort by run number
1131 TString collname=coll->GetName();
1133 TString keywords=coll->GetKeyWords("triggertype");
1135 Int_t nkeys=keywords.CountChar(',')+1;
1137 TString words[nkeys];
1138 for(Int_t k=0;k<nkeys;k++) words[k]="";
1139 printf("Keywords: ");
1141 for(Int_t l=0;l<keywords.Length();l++){
1142 if(keywords[l] != ',') words[count]+=keywords[l];
1144 printf("%s ",words[count].Data());
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);
1163 legtr->AddEntry(htrig[k],Form("%s",words[k].Data()),"P");
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);
1171 ctrigfraction->cd();
1172 if(k>0)htrignorm[k]->Draw("PEsames");
1173 else htrignorm[k]->Draw("PE");
1176 ctrigfraction->cd();
1178 ctrigfraction->SaveAs("TrgFractionOverANY.pdf");
1179 ctrigfraction->SaveAs("TrgFractionOverANY.eps");