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="D0toKpiCuts";//"D0toKpiCutsStandard"
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);
181 hh=(TH1F*)llist->At(i);
182 hh->Scale(h->Integral()/hh->Integral());
184 if(!h || (superimpose && !hh)){
185 cout<<"Histogram "<<i<<" not found"<<endl;
189 hhstat->SetLineColor(kRed);
190 hh->SetLineColor(kRed);
193 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
196 TString hname=h->GetName();
197 if(!hname.Contains("nCls")){
201 if(superimpose) hh->Draw("sames");
204 if(superimpose)hh->Draw("htext0sames");
207 c->SaveAs(Form("%s%s%s%s.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
210 TCanvas* cst=new TCanvas("cst","Stat");
213 hstat->Draw("htext0");
215 hhstat->Draw("htext0sames");
218 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
223 //draw "pid related" histograms (list "outputPID")
224 //period=-999 to draw the pull instead of the cut
225 void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsigma*/,TString textleg="",TString path="./"){
226 gStyle->SetCanvasColor(0);
227 gStyle->SetTitleFillColor(0);
228 gStyle->SetStatColor(0);
229 gStyle->SetPalette(1);
231 Int_t period=2 ,set=0;
233 cout<<"Choose period: \n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
236 cout<<"Choose set: "<<endl;
237 if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
242 TString listname="outputPid";
246 //needed only for mode 1
249 Double_t nsigmaTOF=0;
250 Double_t nsigmaTPC[3]={},plimTPC[2]={};
253 Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path);
256 cout<<":-( null pointers..."<<endl;
259 aodpid=(AliAODPidHF*)cutobj->GetPidHF();
261 cout<<"PidHF object not found! cannot get the nsigma values"<<endl;
264 nsigmaTOF=aodpid->GetSigma(3);
266 nsigmaTPC[0]=aodpid->GetSigma(0);
267 nsigmaTPC[1]=aodpid->GetSigma(1);
268 nsigmaTPC[2]=aodpid->GetSigma(2);
269 aodpid->GetPLimit(plimTPC);
273 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
276 cout<<":-( null pointers..."<<endl;
282 TPaveText *txtsigmaTOF=new TPaveText(0.1,0.65,0.5,0.9,"NDC");
283 txtsigmaTOF->SetBorderSize(0);
284 txtsigmaTOF->SetFillStyle(0);
285 txtsigmaTOF->AddText(Form("nsigmacut from cutobj = %.1f",nsigmaTOF));
287 lTOF.SetLineColor(kMagenta+1);
288 lTOF.SetLineStyle(2);
289 lTOF.SetLineWidth(3);
291 TPaveText *txtsigmaTPC=new TPaveText(0.3,0.6,0.6,0.9,"NDC");
292 txtsigmaTPC->SetBorderSize(0);
293 txtsigmaTPC->SetFillStyle(0);
294 txtsigmaTPC->AddText("nsigmacut from cutobj \n");
295 txtsigmaTPC->AddText(Form("p < %.1f : %.1f \n",plimTPC[0],nsigmaTPC[0]));
296 txtsigmaTPC->AddText(Form("%.1f < p < %.1f : %.1f \n",plimTPC[0],plimTPC[1],nsigmaTPC[1]));
297 txtsigmaTPC->AddText(Form("p > %.1f : %.1f \n",plimTPC[1],nsigmaTPC[2]));
299 lTPC.SetLineColor(kMagenta+1);
300 lTPC.SetLineStyle(2);
301 lTPC.SetLineWidth(3);
303 // TCanvas *ctest=new TCanvas("text","Test text");
305 // txtsigmaTPC->Draw();
306 // txtsigmaTOF->Draw();
309 for(Int_t i=0;i<list->GetEntries();i++){
310 TClass* objtype=list->At(i)->IsA();
311 TString tpname=objtype->GetName();
314 TH1F* h=(TH1F*)list->At(i);
317 cout<<"Histogram "<<i<<" not found"<<endl;
320 //h->Scale(1./h->Integral("width"));
321 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
327 c->SaveAs(Form("%s%s.png",h->GetName(),textleg.Data()));
328 TFile* fout=new TFile(Form("%s.root",h->GetName()),"recreate");
334 TH2F* h=(TH2F*)list->At(i);
337 cout<<"Histogram "<<i<<" not found"<<endl;
341 h->Scale(1./h->Integral("width"));
342 TString hname=h->GetName();
344 if(hname.Contains("hTOFtimeKaonHyptime")){
345 TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
347 TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
349 hz->SetAxisRange(-1500,1500,"Y");
351 cz->SaveAs(Form("%szoom.png",h->GetName()));
354 TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
361 //TCanvas *test=new TCanvas("test","test");
363 //mean and pull, code from Jens Wiechula
364 TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
369 fg.SetParameters(1,0,1);
370 h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
372 TH1 *hM=(TH1*)arr.At(1);
373 hM->SetMarkerStyle(20);
374 hM->SetMarkerSize(.5);
375 hM->DrawClone("sames");
377 TH1 *hS=(TH1*)arr.At(2);
378 hS->SetMarkerStyle(20);
379 hS->SetMarkerSize(.5);
380 hS->SetMarkerColor(kRed);
381 hS->SetLineColor(kRed);
382 hS->DrawClone("same");
384 l.SetLineColor(kBlack);
385 l.DrawLine(.2,0,20,0);
386 l.SetLineColor(kRed);
387 l.DrawLine(.2,1,20,1);
391 if(hname.Contains("TOFsigma")) {
395 lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
396 lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
401 if(hname.Contains("TPCsigma")){
405 lTPC.DrawLine(0.,nsigmaTPC[0],plimTPC[0],nsigmaTPC[0]);
406 lTPC.DrawLine(plimTPC[0],nsigmaTPC[1],plimTPC[1],nsigmaTPC[1]);
407 lTPC.DrawLine(plimTPC[1],nsigmaTPC[2],4,nsigmaTPC[2]);
408 lTPC.DrawLine(0.,-1*nsigmaTPC[0],plimTPC[0],-1*nsigmaTPC[0]);
409 lTPC.DrawLine(plimTPC[0],-1*nsigmaTPC[1],plimTPC[1],-1*nsigmaTPC[1]);
410 lTPC.DrawLine(plimTPC[1],-1*nsigmaTPC[2],4,-1*nsigmaTPC[2]);
413 if(hname.Contains("TPCsigvsp")){
414 SuperimposeBBToTPCSignal(period,c,set);
419 c->SaveAs(Form("%s%d.png",h->GetName(),mode));
420 TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
427 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
429 TFile* fBethe=new TFile("BetheBlochTPC.root");
430 if(!fBethe->IsOpen()){
432 fBethe=new TFile("BetheBlochTPC.root");
435 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
436 for(Int_t ipart=0;ipart<npart;ipart++){
437 TString grname=Form("%sP%d",partnames[ipart].Data(),period);
438 TGraph* gr=(TGraph*)fBethe->Get(grname);
445 //cpid->SaveAs(Form("%sBB.png",hname.Data()));
448 //draw and save Bethe Bloch from TPC in different periods
449 void TPCBetheBloch(Int_t set){
450 gStyle->SetOptTitle(0);
451 gStyle->SetCanvasColor(0);
453 AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
456 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*/};
457 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
458 //printf("%s = %.4f,%s = %.4f,%s = %.4f\n",partnames[0].Data(),masses[0],partnames[1].Data(),masses[1],partnames[2].Data(),masses[2]);
459 TCanvas *cBethe=new TCanvas("cBethe","Bethe Bloch K pi e p");
460 Int_t nperiods=4; //LHC10b+c, LHC10d, LHC10h, MC
461 Double_t alephParameters[5]={};
462 Int_t nsets=1/*LHC10bc*/+2/*LHC10de*/+2/*LHC10h*/+3/*MC*/;
464 periodsname=new TString[nsets];
465 cout<<"Creating the file of the Bethe Bloch"<<endl;
466 TFile* fout=new TFile("BetheBlochTPC.root","recreate");
468 for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
469 cout<<"Period "<<iperiod<<" : ";
470 if(iperiod==0){ //LHC10bc
472 alephParameters[0] = 0.0283086/0.97;
473 alephParameters[1] = 2.63394e+01;
474 alephParameters[2] = 5.04114e-11;
475 alephParameters[3] = 2.12543e+00;
476 alephParameters[4] = 4.88663e+00;
477 periodsname[0]="dataLHC10bc";
479 if(iperiod==1){ //LHC10de,low energy
481 alephParameters[0] = 1.63246/50.;
482 alephParameters[1] = 2.20028e+01;
483 alephParameters[2] = TMath::Exp(-2.48879e+01);
484 alephParameters[3] = 2.39804e+00;
485 alephParameters[4] = 5.12090e+00;
486 periodsname[1]="dataLHC10deold";
489 alephParameters[0] = 1.34490e+00/50.;
490 alephParameters[1] = 2.69455e+01;
491 alephParameters[2] = TMath::Exp(-2.97552e+01);
492 alephParameters[3] = 2.35339e+00;
493 alephParameters[4] = 5.98079e+00;
494 periodsname[2]="dataLHC10denew";
498 if(iperiod==2){//LHC10h
500 alephParameters[0]=1.25202/50.;
501 alephParameters[1]=2.74992e+01;
502 alephParameters[2]=TMath::Exp(-3.31517e+01);
503 alephParameters[3]=2.46246;
504 alephParameters[4]=6.78938;
505 periodsname[3]="dataLHC10hpass1";
507 if (set==1){//pass2 (AOD044)
508 alephParameters[0]=1.25202/50.;
509 alephParameters[1]=2.74992e+01;
510 alephParameters[2]=TMath::Exp(-3.31517e+01);
511 alephParameters[3]=2.46246;
512 alephParameters[4]=6.78938;
513 periodsname[4]="dataLHC10hpass2";
518 alephParameters[0] = 2.15898e+00/50.;
519 alephParameters[1] = 1.75295e+01;
520 alephParameters[2] = 3.40030e-09;
521 alephParameters[3] = 1.96178e+00;
522 alephParameters[4] = 3.91720e+00;
523 periodsname[5]="MCold";
526 alephParameters[0] = 1.44405/50;
527 alephParameters[1] = 2.35409e+01;
528 alephParameters[2] = TMath::Exp(-2.90330e+01);
529 alephParameters[3] = 2.10681;
530 alephParameters[4] = 4.62254;
531 periodsname[6]="MCnew";
534 if(set==2){ //new BB from Francesco
535 alephParameters[0] = 0.029021;
536 alephParameters[1] = 25.4181;
537 alephParameters[2] = 4.66596e-08;
538 alephParameters[3] = 1.90008;
539 alephParameters[4] = 4.63783;
540 periodsname[7]="MCBBFrancesco";
543 if(set==3){ //low energy 2011
544 alephParameters[0] = 0.0207667;
545 alephParameters[1] = 29.9936;
546 alephParameters[2] = 3.87866e-11;
547 alephParameters[3] = 2.17291;
548 alephParameters[4] = 7.1623;
549 //periodsname[8]="MClowen2011";
554 //cout<<periodsname[iperiod]<<endl;
555 tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
557 for(Int_t ipart=0;ipart<npart;ipart++){
560 Double_t p[n],bethe[n];
562 for(Int_t k=0;k<n;k++){ //loop on the momentum steps
563 p[k]=0.0001+k*4./n; //limits 0.-4. GeV/c
565 //bethe[k]=-tpcResp->Bethe(p[k]/masses[ipart]);
566 AliPID::EParticleType ptype=AliPID::kKaon;
567 if(ipart==1) ptype=AliPID::kPion;
568 if(ipart==2) ptype=AliPID::kElectron;
569 if(ipart==3) ptype=AliPID::kProton;
570 bethe[k]=tpcResp->GetExpectedSignal(p[k],ptype);
573 TGraph *gr=new TGraph(n,p,bethe);
574 gr->SetName(Form("%sP%d",partnames[ipart].Data(),iperiod));
575 gr->SetTitle(Form("%sP%d;p (GeV/c);",partnames[ipart].Data(),iperiod));
576 gr->SetLineColor(ipart+1);
577 gr->SetMarkerColor(ipart+1);
578 gr->GetYaxis()->SetRangeUser(35,100);
580 if(iperiod==0 && ipart==0)gr->DrawClone("AL");
581 else gr->DrawClone("L");
588 TParameter<int> sett;
596 void DrawOutputCentrality(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE){
597 gStyle->SetCanvasColor(0);
598 gStyle->SetTitleFillColor(0);
599 gStyle->SetStatColor(0);
600 gStyle->SetPalette(1);
602 TString listname="outputCentrCheck",name1="",name2="",path2="",filename=/*"AnalysisResults.root"*/"PWG3histograms.root",filename2="PWG3histograms.root";
605 // cout<<"Enter the names:\n>";
610 // TString listname="outputTrack",name1="",name2="";
614 cout<<"Enter the names:\n>";
618 cout<<"Are they in the same output file? (y/n)"<<endl;
624 cout<<"Filename: "<<endl;
631 // TString *name=0x0;
633 // cout<<"Number of histogram to superimpose: ";
635 // name=new TString[nhist];
636 // for (Int_t j=0;j<nhist;j++){
645 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path);
648 cout<<":-( null pointers..."<<endl;
652 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
653 pvtxt->SetBorderSize(0);
654 pvtxt->SetFillStyle(0);
655 pvtxt->AddText(name1);
660 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2);
662 if(!llist || !hhstat){
663 cout<<":-( null pointers..."<<endl;
666 TText *redtext=pvtxt->AddText(name2);
667 redtext->SetTextColor(kRed);
672 TCanvas* cst=new TCanvas("cst","Stat");
675 Int_t nevents=hstat->Integral(1,2);
676 hstat->Draw("htext0");
677 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
678 Int_t nevents080=1,nnevents080=1;
680 //TCanvas *spare=new TCanvas("sparecv","Spare");
682 for(Int_t i=0;i<list->GetEntries();i++){
684 TClass* objtype=list->At(i)->IsA();
685 TString tpname=objtype->GetName();
689 TH1F* h=(TH1F*)list->At(i);
692 hh=(TH1F*)llist->At(i);
694 if(!h || (superimpose && !hh)){
695 cout<<"Histogram "<<i<<" not found"<<endl;
699 hhstat->SetLineColor(kRed);
700 hh->SetLineColor(kRed);
703 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
704 TPaveText *pvtxt2=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
705 pvtxt2->SetBorderSize(0);
706 pvtxt2->SetFillStyle(0);
711 Int_t entries=h->Integral();
712 pvtxt2->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
719 c->SaveAs(Form("%s%s.png",c->GetName(),textleg.Data()));
722 TH2F* h=(TH2F*)list->At(i);
724 cout<<"Histogram "<<i<<" not found"<<endl;
727 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
728 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
729 pvtxt->SetBorderSize(0);
730 pvtxt->SetFillStyle(0);
734 Int_t entries=h->Integral();
735 pvtxt->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
739 c->SaveAs(Form("%s%s.png",c->GetName(),textleg.Data()));
744 listname="countersCentrality";
746 isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path);
749 cout<<":-( null pointers..."<<endl;
755 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2);
757 if(!llist || !hhstat){
758 cout<<":-( null pointers..."<<endl;
761 TText *redtext=pvtxt->AddText(name2);
762 redtext->SetTextColor(kRed);
768 cout<<"normalizing to 0-80% as a check"<<endl;
770 TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
771 cvnocnt->Divide(2,1);
773 for(Int_t i=0;i<list->GetEntries();i++){
774 AliCounterCollection* coll=(AliCounterCollection*)list->At(i);
775 AliCounterCollection* colle=0x0;
776 if(superimpose) colle=(AliCounterCollection*)llist->At(i);
777 coll->SortRubric("run");//sort by run number
778 //coll->PrintKeyWords();
779 Int_t ncentr=10;//check this
787 TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
789 if(hbad) hbad->Draw();
791 TCanvas *ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
796 for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
798 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
799 h->SetName(Form("h%d%d",i,ic));
801 hallcntr=(TH1F*)h->Clone("hallcntr");
807 nevents080+=h->Integral();
810 hh=(TH1F*)colle->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
811 hh->SetName(Form("hh%d%d",i,ic));
813 hhallcntr=(TH1F*)hh->Clone("hhallcntr");
815 }else hhallcntr->Add(hh);
816 nnevents080+=hh->Integral();
821 for(Int_t ic=0;ic<ncentr;ic++){
823 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
824 h->SetName(Form("h%d%d",i,ic));
827 if(ic>=0 && ic<=1){ //0-20
829 h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
830 h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
832 hh020=(TH1F*)hh->Clone(Form("hh020%s",coll->GetName()));
833 hh020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
838 if(superimpose)hh020->Add(hh);
841 if(ic>=2 && ic<=7){ //20-80
843 h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
844 h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
846 hh2080=(TH1F*)hh->Clone(Form("hh2080%s",coll->GetName()));
847 hh2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
852 if(superimpose)hh2080->Add(hh);
860 h->GetYaxis()->SetRangeUser(0.,0.15);
869 // h->SetLineColor(ic+1);
870 // if(ic==0)h->DrawClone();
871 // else h->DrawClone("sames");
875 h020->Divide(hallcntr);
878 hh020->Divide(hhallcntr);
879 hh020->SetLineColor(2);
880 hh020->SetMarkerColor(2);
881 hh020->DrawClone("sames");
883 TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
885 h020->GetYaxis()->SetRangeUser(0.,1.);
887 if(superimpose)hh020->DrawClone("sames");
888 cv020->SaveAs(Form("cv020-%d.png",i));
891 h2080->Divide(hallcntr);
894 hh2080->Divide(hhallcntr);
895 hh2080->SetLineColor(2);
896 hh2080->SetMarkerColor(2);
897 hh2080->DrawClone("sames");
900 TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
902 h2080->GetYaxis()->SetRangeUser(0.,1.);
904 if(superimpose)hh2080->DrawClone("sames");
905 cv2080->SaveAs(Form("cv2080-%d.png",i));
907 ccent->SaveAs(Form("%s%s.png",ccent->GetName(),textleg.Data()));
912 void DrawProjections(TString partname="D0",TString h2dname="hMultvsPercentile",Int_t nsteps=0,TString direction="X",TString path="./"){
913 gStyle->SetCanvasColor(0);
914 gStyle->SetTitleFillColor(0);
915 gStyle->SetStatColor(0);
916 gStyle->SetPalette(1);
918 TString listname="outputCentrCheck";
923 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
926 cout<<":-( null pointers..."<<endl;
929 Double_t nevents=hstat->Integral(5,6); //ev good vertex
931 TH2F* h2=(TH2F*)list->FindObject(h2dname);
933 cout<<h2dname.Data()<<" not found"<<endl;
936 TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
941 TPaveText *pvst=new TPaveText(0.6,0.2,0.9,0.7,"NDC");
942 pvst->SetBorderSize(0);
943 pvst->SetFillStyle(0);
944 pvst->AddText("Bin -> Cont/nEvVtx");
949 if(direction=="X") nsteps=h2->GetNbinsY();
950 if(direction=="Y") nsteps=h2->GetNbinsX();
953 if(direction=="X") kbins=h2->GetNbinsY()/nsteps;
954 if(direction=="Y") kbins=h2->GetNbinsX()/nsteps;
957 TCanvas *cvpj=new TCanvas(Form("cvpj%s%s",direction.Data(),h2dname.Data()),Form("cvpj%s",direction.Data()),1000,800);
958 cvpj->Divide((Int_t)(nsteps/3)+1,3);
959 TFile* fout=new TFile(Form("proj%s%s.root",direction.Data(),h2dname.Data()), "recreate");
960 //Float_t maxx[nsteps];
961 Float_t maxx[12]={9000,9000,6000,4000,2000,1400,800,500,200,100,40,25};
962 Double_t integralpernev[nsteps];
964 for(Int_t i=0;i<nsteps;i++){
966 if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),i+kbins,i+2*kbins);
967 if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),i+kbins,i+2*kbins);
968 integralpernev[i]=h->Integral()/nevents;
970 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
971 pvtxt->SetBorderSize(0);
972 pvtxt->SetFillStyle(0);
973 pvtxt->AddText(Form("%.0f - %.0f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins))));
974 pvst->AddText(Form("%.0f - %.0f -> %.2f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins)),integralpernev[i]));
976 h->GetXaxis()->SetRangeUser(0,maxx[i]);
982 cvpj->SaveAs(Form("cvpj%s%s.png",direction.Data(),h2dname.Data()));
986 cv2d->SaveAs(Form("%s.png",h2->GetName()));