1 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <TDirectoryFile.h>
14 #include <TPaveText.h>
15 #include <TPaveStats.h>
18 #include <TDatabasePDG.h>
19 #include <TParameter.h>
20 #include <AliCounterCollection.h>
21 #include <AliRDHFCuts.h>
28 //read the file and take list and stat
30 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path="./",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root", TString dirname="PWG3_D2H_QA");
31 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");
32 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid, Int_t set);
33 void TPCBetheBloch(Int_t set);
34 Bool_t ReadFilesForCompilation(TString inputtextfile, TList**& lists, Int_t&numb, TString*& legend);
35 void CompilationEvSelection(Int_t n,TList** lists, TString* legend);
36 void CompilationTrackSelection(Int_t n,TList** lists, TString* legend);
38 Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename, TString dirname){
40 TString hstatname="nEntriesQA", cutobjname="";
41 filename.Prepend(path);
45 TFile* f=new TFile(filename.Data());
47 cout<<filename.Data()<<" not found"<<endl;
50 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
52 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
57 list=(TList*)dir->Get(listname);
59 cout<<"List "<<listname.Data()<<" not found"<<endl;
64 hstat=(TH1F*)dir->Get(hstatname);
66 cout<<hstatname.Data()<<" not found"<<endl;
73 Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path,TString filename,TString dirname){
75 TString hstatname="nEntriesQA", cutobjname="";
76 filename.Prepend(path);
80 if(partname.Contains("Dplus")) cutobjname="AnalysisCuts";//"DplustoKpipiCutsStandard";
82 if(partname.Contains("D0")) cutobjname="D0toKpiCutsStandard";//"D0toKpiCuts"
84 if(partname.Contains("Dstar")) cutobjname="DStartoKpipiCuts";
86 if(partname.Contains("Ds")) cutobjname="DstoKKpiCuts";
88 if(partname.Contains("D04")) cutobjname="D0toKpipipiCuts";
90 if(partname.Contains("Lc")) cutobjname="LctopKpiAnalysisCuts";
97 TFile* f=new TFile(filename.Data());
99 cout<<filename.Data()<<" not found"<<endl;
102 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
104 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
108 list=(TList*)dir->Get(listname);
110 cout<<"List "<<listname.Data()<<" not found"<<endl;
115 hstat=(TH1F*)dir->Get(hstatname);
117 cout<<hstatname.Data()<<" not found"<<endl;
121 cutobj=(AliRDHFCuts*)dir->Get(cutobjname);
123 cout<<cutobjname.Data()<<" not found"<<endl;
130 //draw "track related" histograms (list "outputTrack")
131 void DrawOutputTrack(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE, TString suffixdir="",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root", Bool_t normint=kTRUE /*normalize at integral, or at nevents*/){
132 gStyle->SetCanvasColor(0);
133 gStyle->SetTitleFillColor(0);
134 gStyle->SetStatColor(0);
135 gStyle->SetPalette(1);
137 TString listname="outputTrack",name1="",name2="",path2="",filename2="PWG3histograms.root",legtext1="",legtext2="",suffixdir2="";
141 cout<<"Enter the names:\n>";
145 cout<<"Are they in the same output file? (y/n)"<<endl;
151 cout<<"Filename: "<<endl;
154 cout<<"Suffix in the dir name, if any (otherwhise write no)\n>";
156 if(suffixdir2=="no") suffixdir2="";
157 cout<<"Text in the legend:\n 1)";
165 Float_t nevents,nevents2;
168 TString dirname="PWG3_D2H_QA";
169 //dirname+=suffixdir;
170 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename,Form("%s%s",dirname.Data(),suffixdir.Data()));
173 cout<<":-( null pointers..."<<endl;
176 nevents=hstat->GetBinContent(1);
177 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
178 pvtxt->SetBorderSize(0);
179 pvtxt->SetFillStyle(0);
180 pvtxt->AddText(legtext1);
185 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2,Form("%s%s",dirname.Data(),suffixdir2.Data()));
187 if(!llist || !hhstat){
188 cout<<":-( null pointers..."<<endl;
191 nevents2=hhstat->GetBinContent(1);
192 TText *redtext=pvtxt->AddText(legtext2);
193 redtext->SetTextColor(kRed);
194 hhstat->Scale(hstat->Integral()/hhstat->Integral());
198 for(Int_t i=0;i<list->GetEntries();i++){
199 TH1F* h=(TH1F*)list->At(i);
203 hh=(TH1F*)llist->At(i);
204 hr=(TH1F*)hh->Clone(Form("%s_ratio",hh->GetName()));
205 if(hh && TMath::Abs(hh->Integral()) > 1e-6)hh->Scale(h->Integral()/hh->Integral());
207 if(!h || (superimpose && !hh)){
208 cout<<"Histogram "<<i<<" not found"<<endl;
212 if(normint) hh->Scale(h->Integral()/hh->Integral());
213 else hh->Scale(nevents/nevents2);
214 hhstat->SetLineColor(kRed);
215 hh->SetLineColor(kRed);
219 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
222 TString hname=h->GetName();
223 if(!hname.Contains("nCls")){
225 if(hname.Contains("Layer")){
226 for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
227 h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
229 h->GetXaxis()->SetLabelSize(0.06);
230 h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
237 TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
241 c2->SaveAs(Form("%s%s%s%sRatio.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
246 if(superimpose)hh->Draw("htext0sames");
250 c->SaveAs(Form("%s%s%s%s.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
251 c->SaveAs(Form("%s%s%s%s.eps",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
254 TCanvas* cst=new TCanvas("cst","Stat");
257 hstat->Draw("htext0");
259 hhstat->Draw("htext0sames");
262 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
263 cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
265 TH1F* hd0fb4=(TH1F*)list->FindObject("hd0TracksFilterBit4");
266 TH1F* hd0SPD1=(TH1F*)list->FindObject("hd0TracksSPDin");
267 TH1F* hd0SPDany=(TH1F*)list->FindObject("hd0TracksSPDany");
268 TH1F* hd0TPCITScuts=(TH1F*)list->FindObject("hd0TracksTPCITSSPDany");
269 TH1F* hhd0fb4=0x0; TH1F* hhd0SPD1=0x0; TH1F* hhd0SPDany=0x0; TH1F* hhd0TPCITScuts=0x0;
271 hhd0fb4=(TH1F*)llist->FindObject("hd0TracksFilterBit4");
272 hhd0SPD1=(TH1F*)llist->FindObject("hd0TracksSPDin");
273 hhd0SPDany=(TH1F*)llist->FindObject("hd0TracksSPDany");
274 hhd0TPCITScuts=(TH1F*)llist->FindObject("hd0TracksTPCITSSPDany");
277 if(hd0fb4 && hd0SPD1 && hd0SPDany && hd0TPCITScuts){
278 TCanvas* ctrsel=new TCanvas("ctrsel","Track Sel");
280 hd0SPD1->SetLineColor(kCyan+3);
283 TPaveStats *st1=(TPaveStats*)hd0SPD1->GetListOfFunctions()->FindObject("stats");
284 st1->SetTextColor(kCyan+3);
287 hd0SPDany->SetLineColor(4);
288 hd0SPDany->Draw("sames");
290 TPaveStats *st2=(TPaveStats*)hd0SPDany->GetListOfFunctions()->FindObject("stats");
293 st2->SetTextColor(4);
294 hd0fb4->SetLineColor(2);
295 hd0fb4->Draw("sames");
297 TPaveStats *st3=(TPaveStats*)hd0fb4->GetListOfFunctions()->FindObject("stats");
300 st3->SetTextColor(2);
301 hd0TPCITScuts->SetLineColor(kGreen+1);
302 hd0TPCITScuts->Draw("sames");
304 TPaveStats *st4=(TPaveStats*)hd0TPCITScuts->GetListOfFunctions()->FindObject("stats");
309 st4->SetTextColor(kGreen+1);
311 TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
312 leg->SetFillStyle(0);
313 leg->SetBorderSize(0);
314 leg->AddEntry(hd0SPD1,"kITSrefit+SPD inner","L");
315 leg->AddEntry(hd0SPDany,"kITSrefit+SPD any","L");
316 leg->AddEntry(hd0TPCITScuts,"TPC+ITS cuts+SPD any","L");
317 leg->AddEntry(hd0fb4,"Filter Bit 4","L");
320 if(superimpose && hhd0fb4 && hhd0SPD1 && hhd0SPDany && hhd0TPCITScuts){
321 hhd0SPD1->SetLineColor(kCyan+3);
322 hhd0SPD1->SetStats(0);
323 hhd0SPD1->SetLineStyle(3);
324 hhd0SPDany->SetLineColor(4);
325 hhd0SPDany->SetStats(0);
326 hhd0SPDany->SetLineStyle(3);
327 hhd0TPCITScuts->SetLineColor(kGreen+1);
328 hhd0TPCITScuts->SetStats(0);
329 hhd0TPCITScuts->SetLineStyle(3);
330 hhd0fb4->SetLineColor(2);
331 hhd0fb4->SetStats(0);
332 hhd0fb4->SetLineStyle(3);
334 hhd0SPD1->Draw("sames");
335 hhd0SPDany->Draw("sames");
336 hhd0TPCITScuts->Draw("sames");
337 hhd0fb4->Draw("sames");
340 ctrsel->SaveAs("ImpactParameterTrackSel.eps");
341 ctrsel->SaveAs("ImpactParameterTrackSel.png");
346 //draw "pid related" histograms (list "outputPID")
347 //period=-999 to draw the pull instead of the cut
348 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"){
349 gStyle->SetCanvasColor(0);
350 gStyle->SetTitleFillColor(0);
351 gStyle->SetOptStat(0);
352 gStyle->SetPalette(1);
354 Int_t period=2 ,set=0;
356 cout<<"Choose period: \n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
359 cout<<"Choose set: "<<endl;
360 if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
365 TString listname="outputPid";
366 TString dirname="PWG3_D2H_QA";
371 //needed only for mode 1
374 Double_t nsigmaTOF=0;
375 Double_t nsigmaTPC[3]={},plimTPC[2]={};
378 Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname+suffixdir,path,filename,dirname);
381 cout<<":-( null pointers..."<<endl;
384 aodpid=(AliAODPidHF*)cutobj->GetPidHF();
386 cout<<"PidHF object not found! cannot get the nsigma values"<<endl;
389 nsigmaTOF=aodpid->GetSigma(3);
391 nsigmaTPC[0]=aodpid->GetSigma(0);
392 nsigmaTPC[1]=aodpid->GetSigma(1);
393 nsigmaTPC[2]=aodpid->GetSigma(2);
394 aodpid->GetPLimit(plimTPC);
397 Bool_t isRead=ReadFile(list,hstat,listname,partname+suffixdir,path,filename,dirname);
400 cout<<":-( null pointers..."<<endl;
406 TPaveText *txtsigmaTOF=new TPaveText(0.1,0.65,0.5,0.9,"NDC");
407 txtsigmaTOF->SetBorderSize(0);
408 txtsigmaTOF->SetFillStyle(0);
409 txtsigmaTOF->AddText(Form("nsigmacut from cutobj = %.1f",nsigmaTOF));
411 lTOF.SetLineColor(kMagenta+1);
412 lTOF.SetLineStyle(2);
413 lTOF.SetLineWidth(3);
415 TPaveText *txtsigmaTPC=new TPaveText(0.3,0.6,0.6,0.9,"NDC");
416 txtsigmaTPC->SetBorderSize(0);
417 txtsigmaTPC->SetFillStyle(0);
418 txtsigmaTPC->AddText("nsigmacut from cutobj \n");
419 txtsigmaTPC->AddText(Form("p < %.1f : %.1f \n",plimTPC[0],nsigmaTPC[0]));
420 txtsigmaTPC->AddText(Form("%.1f < p < %.1f : %.1f \n",plimTPC[0],plimTPC[1],nsigmaTPC[1]));
421 txtsigmaTPC->AddText(Form("p > %.1f : %.1f \n",plimTPC[1],nsigmaTPC[2]));
423 lTPC.SetLineColor(kMagenta+1);
424 lTPC.SetLineStyle(2);
425 lTPC.SetLineWidth(3);
427 // TCanvas *ctest=new TCanvas("text","Test text");
429 // txtsigmaTPC->Draw();
430 // txtsigmaTOF->Draw();
433 for(Int_t i=0;i<list->GetEntries();i++){
434 TClass* objtype=list->At(i)->IsA();
435 TString tpname=objtype->GetName();
438 TH1F* h=(TH1F*)list->At(i);
441 cout<<"Histogram "<<i<<" not found"<<endl;
444 //h->Scale(1./h->Integral("width"));
445 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
451 c->SaveAs(Form("%s%s.png",h->GetName(),textleg.Data()));
452 c->SaveAs(Form("%s%s.eps",h->GetName(),textleg.Data()));
453 TFile* fout=new TFile(Form("%s.root",h->GetName()),"recreate");
459 TH2F* h=(TH2F*)list->At(i);
462 cout<<"Histogram "<<i<<" not found"<<endl;
465 TString hname=h->GetName();
467 if(h->Integral("width")==0) {cout<<"Empty histogram, skip\n"; continue;}
468 h->Scale(1./h->Integral("width"));
470 Double_t maxzaxis=h->GetBinContent(h->GetMaximumBin());
471 Double_t minzaxis=h->GetBinContent(h->GetMinimumBin());
472 printf("Minimum = %f, maximum = %f\n",minzaxis,maxzaxis);
473 TH2F* hallzrange=(TH2F*)h->Clone(Form("%swholez",hname.Data()));
474 hallzrange->SetAxisRange(1e-07,maxzaxis,"Z");
475 //hallzrange->SetAxisRange(minzaxis,maxzaxis,"Z");
477 TCanvas* cwholez=new TCanvas(Form("c%swholez",hname.Data()),Form("%s down to lowest z",hname.Data()));
479 hallzrange->Draw("colz");
480 cwholez->SaveAs(Form("%swholez.png",h->GetName()));
481 cwholez->SaveAs(Form("%swholez.eps",h->GetName()));
483 if(hname.Contains("hTOFtimeKaonHyptime")){
484 TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
486 TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
488 hz->SetAxisRange(-1500,1500,"Y");
489 hz->SetAxisRange(0.,5.,"X");
491 cz->SaveAs(Form("%szoom.png",h->GetName()));
492 cz->SaveAs(Form("%szoom.eps",h->GetName()));
495 TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
498 TCanvas* c2=new TCanvas(Form("c2%s",hname.Data()),hname.Data());
502 h->DrawClone("colz");
504 if (hname.Contains("Sig") || hname.Contains("sigma"))h->SetAxisRange(-5,5,"Y");
506 //if (hname.Contains("TOFtime"))h->SetAxisRange(-1500,1500,"Y");
507 h->SetAxisRange(0.,5.,"X");
511 //TCanvas *test=new TCanvas("test","test");
513 //mean and pull, code from Jens Wiechula
514 TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
519 fg.SetParameters(1,0,1);
520 h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
522 TH1 *hM=(TH1*)arr.At(1);
523 hM->SetMarkerStyle(20);
524 hM->SetMarkerSize(.5);
525 hM->DrawClone("sames");
527 TH1 *hS=(TH1*)arr.At(2);
528 hS->SetMarkerStyle(20);
529 hS->SetMarkerSize(.5);
530 hS->SetMarkerColor(kRed);
531 hS->SetLineColor(kRed);
532 hS->DrawClone("same");
534 l.SetLineColor(kBlack);
535 l.DrawLine(.2,0,20,0);
536 l.SetLineColor(kRed);
537 l.DrawLine(.2,1,20,1);
541 if(hname.Contains("TOFsigma")) {
545 lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
546 lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
551 if(hname.Contains("TPCsigma")){
555 lTPC.DrawLine(0.,nsigmaTPC[0],plimTPC[0],nsigmaTPC[0]);
556 lTPC.DrawLine(plimTPC[0],nsigmaTPC[1],plimTPC[1],nsigmaTPC[1]);
557 lTPC.DrawLine(plimTPC[1],nsigmaTPC[2],4,nsigmaTPC[2]);
558 lTPC.DrawLine(0.,-1*nsigmaTPC[0],plimTPC[0],-1*nsigmaTPC[0]);
559 lTPC.DrawLine(plimTPC[0],-1*nsigmaTPC[1],plimTPC[1],-1*nsigmaTPC[1]);
560 lTPC.DrawLine(plimTPC[1],-1*nsigmaTPC[2],4,-1*nsigmaTPC[2]);
563 if(hname.Contains("TPCsigvsp")){
564 SuperimposeBBToTPCSignal(period,c,set);
569 c->SaveAs(Form("%s%d.png",h->GetName(),mode));
570 c->SaveAs(Form("%s%d.eps",h->GetName(),mode));
571 c2->SaveAs(Form("%s2%d.png",h->GetName(),mode));
572 c2->SaveAs(Form("%s2%d.eps",h->GetName(),mode));
574 TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
582 void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
584 TFile* fBethe=new TFile("BetheBlochTPC.root");
585 if(!fBethe->IsOpen()){
587 fBethe=new TFile("BetheBlochTPC.root");
590 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
591 for(Int_t ipart=0;ipart<npart;ipart++){
592 TString grname=Form("%sP%d",partnames[ipart].Data(),period);
593 TGraph* gr=(TGraph*)fBethe->Get(grname);
600 //cpid->SaveAs(Form("%sBB.png",hname.Data()));
603 //draw and save Bethe Bloch from TPC in different periods
604 void TPCBetheBloch(Int_t set){
605 gStyle->SetOptTitle(0);
606 gStyle->SetCanvasColor(0);
608 AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
611 //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*/};
612 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
613 //printf("%s = %.4f,%s = %.4f,%s = %.4f\n",partnames[0].Data(),masses[0],partnames[1].Data(),masses[1],partnames[2].Data(),masses[2]);
614 TCanvas *cBethe=new TCanvas("cBethe","Bethe Bloch K pi e p");
615 Int_t nperiods=4; //LHC10b+c, LHC10d, LHC10h, MC
616 Double_t alephParameters[5]={};
617 Int_t nsets=1/*LHC10bc*/+2/*LHC10de*/+2/*LHC10h*/+3/*MC*/;
619 periodsname=new TString[nsets];
620 cout<<"Creating the file of the Bethe Bloch"<<endl;
621 TFile* fout=new TFile("BetheBlochTPC.root","recreate");
623 for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
624 cout<<"Period "<<iperiod<<" : ";
625 if(iperiod==0){ //LHC10bc
627 alephParameters[0] = 0.0283086/0.97;
628 alephParameters[1] = 2.63394e+01;
629 alephParameters[2] = 5.04114e-11;
630 alephParameters[3] = 2.12543e+00;
631 alephParameters[4] = 4.88663e+00;
632 periodsname[0]="dataLHC10bc";
634 if(iperiod==1){ //LHC10de,low energy
636 alephParameters[0] = 1.63246/50.;
637 alephParameters[1] = 2.20028e+01;
638 alephParameters[2] = TMath::Exp(-2.48879e+01);
639 alephParameters[3] = 2.39804e+00;
640 alephParameters[4] = 5.12090e+00;
641 periodsname[1]="dataLHC10deold";
644 alephParameters[0] = 1.34490e+00/50.;
645 alephParameters[1] = 2.69455e+01;
646 alephParameters[2] = TMath::Exp(-2.97552e+01);
647 alephParameters[3] = 2.35339e+00;
648 alephParameters[4] = 5.98079e+00;
649 periodsname[2]="dataLHC10denew";
653 if(iperiod==2){//LHC10h
655 alephParameters[0]=1.25202/50.;
656 alephParameters[1]=2.74992e+01;
657 alephParameters[2]=TMath::Exp(-3.31517e+01);
658 alephParameters[3]=2.46246;
659 alephParameters[4]=6.78938;
660 periodsname[3]="dataLHC10hpass1";
662 if (set==1){//pass2 (AOD044)
663 alephParameters[0]=1.25202/50.;
664 alephParameters[1]=2.74992e+01;
665 alephParameters[2]=TMath::Exp(-3.31517e+01);
666 alephParameters[3]=2.46246;
667 alephParameters[4]=6.78938;
668 periodsname[4]="dataLHC10hpass2";
673 alephParameters[0] = 2.15898e+00/50.;
674 alephParameters[1] = 1.75295e+01;
675 alephParameters[2] = 3.40030e-09;
676 alephParameters[3] = 1.96178e+00;
677 alephParameters[4] = 3.91720e+00;
678 periodsname[5]="MCold";
681 alephParameters[0] = 1.44405/50;
682 alephParameters[1] = 2.35409e+01;
683 alephParameters[2] = TMath::Exp(-2.90330e+01);
684 alephParameters[3] = 2.10681;
685 alephParameters[4] = 4.62254;
686 periodsname[6]="MCnew";
689 if(set==2){ //new BB from Francesco
690 alephParameters[0] = 0.029021;
691 alephParameters[1] = 25.4181;
692 alephParameters[2] = 4.66596e-08;
693 alephParameters[3] = 1.90008;
694 alephParameters[4] = 4.63783;
695 periodsname[7]="MCBBFrancesco";
698 if(set==3){ //low energy 2011
699 alephParameters[0] = 0.0207667;
700 alephParameters[1] = 29.9936;
701 alephParameters[2] = 3.87866e-11;
702 alephParameters[3] = 2.17291;
703 alephParameters[4] = 7.1623;
704 //periodsname[8]="MClowen2011";
709 //cout<<periodsname[iperiod]<<endl;
710 tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
712 for(Int_t ipart=0;ipart<npart;ipart++){
715 Double_t p[n],bethe[n];
717 for(Int_t k=0;k<n;k++){ //loop on the momentum steps
718 p[k]=0.0001+k*4./n; //limits 0.-4. GeV/c
720 //bethe[k]=-tpcResp->Bethe(p[k]/masses[ipart]);
721 AliPID::EParticleType ptype=AliPID::kKaon;
722 if(ipart==1) ptype=AliPID::kPion;
723 if(ipart==2) ptype=AliPID::kElectron;
724 if(ipart==3) ptype=AliPID::kProton;
725 bethe[k]=tpcResp->GetExpectedSignal(p[k],ptype);
728 TGraph *gr=new TGraph(n,p,bethe);
729 gr->SetName(Form("%sP%d",partnames[ipart].Data(),iperiod));
730 gr->SetTitle(Form("%sP%d;p (GeV/c);",partnames[ipart].Data(),iperiod));
731 gr->SetLineColor(ipart+1);
732 gr->SetMarkerColor(ipart+1);
733 gr->GetYaxis()->SetRangeUser(35,100);
735 if(iperiod==0 && ipart==0)gr->DrawClone("AL");
736 else gr->DrawClone("L");
743 TParameter<int> sett;
751 void DrawOutputCentrality(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE,TString suffixdir="",TString filename=/*"AnalysisResults.root"*/"PWG3histograms.root"){
752 gStyle->SetCanvasColor(0);
753 gStyle->SetTitleFillColor(0);
754 gStyle->SetStatColor(0);
755 gStyle->SetPalette(1);
757 TString listname="outputCentrCheck",partname2="",path2="",suffixdir2="",filename2="PWG3histograms.root";
760 // cout<<"Enter the names:\n>";
765 // TString listname="outputTrack",name1="",name2="";
769 cout<<"##Second file\n";
770 cout<<"Enter the name:\n";
773 cout<<"Are they in the same output file? (y/n)"<<endl;
782 cout<<"Filename: "<<endl;
789 // TString *name=0x0;
791 // cout<<"Number of histogram to superimpose: ";
793 // name=new TString[nhist];
794 // for (Int_t j=0;j<nhist;j++){
803 TString dirname="PWG3_D2H_QA",dirname2=dirname;
805 dirname2+=suffixdir2;
806 Bool_t isRead=ReadFile(list,hstat,listname,partname.Data(),path,filename,dirname);
809 cout<<":-( null pointers..."<<endl;
813 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
814 pvtxt->SetBorderSize(0);
815 pvtxt->SetFillStyle(0);
816 pvtxt->AddText(partname);
821 isRead=ReadFile(llist,hhstat,listname,partname2.Data(),path2,filename2,dirname2);
823 if(!llist || !hhstat){
824 cout<<":-( null pointers..."<<endl;
827 TText *redtext=pvtxt->AddText(partname2);
828 redtext->SetTextColor(kRed);
833 TCanvas* cst=new TCanvas("cst","Stat");
836 Int_t nevents=hstat->GetBinContent(1);
837 hstat->Draw("htext0");
838 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
839 cst->SaveAs(Form("%s%s.eps",hstat->GetName(),textleg.Data()));
840 Int_t nevents080=1,nnevents080=1;
842 //TCanvas *spare=new TCanvas("sparecv","Spare");
844 for(Int_t i=0;i<list->GetEntries();i++){
846 TClass* objtype=list->At(i)->IsA();
847 TString tpname=objtype->GetName();
851 TH1F* h=(TH1F*)list->At(i);
854 hh=(TH1F*)llist->At(i);
856 if(!h || (superimpose && !hh)){
857 cout<<"Histogram "<<i<<" not found"<<endl;
861 hhstat->SetLineColor(kRed);
862 hh->SetLineColor(kRed);
865 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
866 TPaveText *pvtxt2=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
867 pvtxt2->SetBorderSize(0);
868 pvtxt2->SetFillStyle(0);
873 Int_t entries=h->Integral();
874 pvtxt2->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
881 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
882 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
885 TH2F* hhh=(TH2F*)list->At(i);
887 cout<<"Histogram "<<i<<" not found"<<endl;
890 TCanvas* c=new TCanvas(Form("c%s",hhh->GetName()),hhh->GetName());
891 TPaveText *pvtxt3=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
892 pvtxt3->SetBorderSize(0);
893 pvtxt3->SetFillStyle(0);
897 Int_t entries=hhh->Integral();
898 pvtxt3->AddText(Form("%.1f %s of the events",(Double_t)entries/(Double_t)nevents*100,"%"));
902 c->SaveAs(Form("%s%s.pdf",c->GetName(),textleg.Data()));
903 c->SaveAs(Form("%s%s.eps",c->GetName(),textleg.Data()));
908 listname="countersCentrality";
910 isRead=ReadFile(list,hstat,listname,partname.Data(),path,filename,dirname);
913 cout<<":-( null pointers..."<<endl;
919 isRead=ReadFile(llist,hhstat,listname,partname2.Data(),path2,filename2,dirname2);
921 if(!llist || !hhstat){
922 cout<<":-( null pointers..."<<endl;
925 TText *redtext=pvtxt->AddText(partname2);
926 redtext->SetTextColor(kRed);
932 cout<<"normalizing to 0-80% as a check"<<endl;
933 Int_t ncentr=10;//check this
939 TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
940 cvnocnt->Divide(2,1);
943 for(Int_t i=0;i<list->GetEntries();i++){
944 AliCounterCollection* coll=(AliCounterCollection*)list->At(i);
945 AliCounterCollection* colle=0x0;
946 if(superimpose) colle=(AliCounterCollection*)llist->At(i);
947 coll->SortRubric("run");//sort by run number
957 TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
959 if(hbad) hbad->Draw();
961 ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
967 for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
969 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
970 h->SetName(Form("h%d%d",i,ic));
972 hallcntr=(TH1F*)h->Clone("hallcntr");
978 nevents080+=h->Integral();
981 hh=(TH1F*)colle->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
982 hh->SetName(Form("hh%d%d",i,ic));
984 hhallcntr=(TH1F*)hh->Clone("hhallcntr");
986 }else hhallcntr->Add(hh);
988 nnevents080+=hh->Integral();
993 for(Int_t ic=0;ic<ncentr;ic++){
995 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
996 h->SetName(Form("h%d%d",i,ic));
999 if(ic>=0 && ic<=1){ //0-20
1001 h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
1002 h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
1004 hh020=(TH1F*)hh->Clone(Form("hh020%s",coll->GetName()));
1005 hh020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
1010 if(superimpose)hh020->Add(hh);
1013 if(ic>=2 && ic<=7){ //20-80
1015 h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
1016 h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
1018 hh2080=(TH1F*)hh->Clone(Form("hh2080%s",coll->GetName()));
1019 hh2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
1024 if(superimpose)hh2080->Add(hh);
1029 h->Divide(hallcntr);
1033 h->GetYaxis()->SetLabelSize(0.05);
1034 h->GetYaxis()->SetTitleOffset(1.5);
1036 //h->GetYaxis()->SetRangeUser(0.,0.15);
1046 // h->SetLineColor(ic+1);
1047 // if(ic==0)h->DrawClone();
1048 // else h->DrawClone("sames");
1050 h020->Divide(hallcntr);
1052 hh020->Divide(hhallcntr);
1053 hh020->SetLineColor(2);
1054 hh020->SetMarkerColor(2);
1057 /*//draw 0-20 and 20-80 in the multi pad canvas (increase divisions before uncommenting)
1058 ccent->cd(ncentr+1);
1061 hh020->DrawClone("sames");
1064 TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
1067 h020->GetYaxis()->SetRangeUser(0.,1.);
1069 if(superimpose)hh020->DrawClone("sames");
1070 cv020->SaveAs(Form("cv020-%d.pdf",i));
1071 cv020->SaveAs(Form("cv020-%d.eps",i));
1073 h2080->Divide(hallcntr);
1075 hh2080->Divide(hhallcntr);
1076 hh2080->SetLineColor(2);
1077 hh2080->SetMarkerColor(2);
1081 ccent->cd(ncentr+2);
1085 hh2080->DrawClone("sames");
1088 TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
1091 h2080->GetYaxis()->SetRangeUser(0.,1.);
1093 if(superimpose)hh2080->DrawClone("sames");
1094 cv2080->SaveAs(Form("cv2080-%d.pdf",i));
1095 cv2080->SaveAs(Form("cv2080-%d.eps",i));
1097 ccent->SaveAs(Form("%s%s.pdf",ccent->GetName(),textleg.Data()));
1098 ccent->SaveAs(Form("%s%s.eps",ccent->GetName(),textleg.Data()));
1103 void DrawProjections(TString partname="D0",TString h2dname="hMultvsPercentile",Int_t groupnbins=5,Float_t fitmin=15,Float_t fitmax=50,TString direction="X",TString path="./",TString suffixdir="", TString filename="AnalysisResults.root", TString fitfunc="pol0"/*option "nofit" does not fit*/){
1104 gStyle->SetCanvasColor(0);
1105 gStyle->SetTitleFillColor(0);
1106 gStyle->SetStatColor(0);
1107 gStyle->SetPalette(1);
1109 TString listname="outputCentrCheck";
1110 TString dirname="PWG3_D2H_QA";
1116 Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1118 if(!list || !hstat){
1119 cout<<":-( null pointers..."<<endl;
1122 Double_t nevents=hstat->GetBinContent(5); //ev good vertex
1124 TH2F* h2=(TH2F*)list->FindObject(h2dname);
1126 cout<<h2dname.Data()<<" not found"<<endl;
1130 TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
1135 TPaveText *pvst=new TPaveText(0.6,0.2,0.9,0.7,"NDC");
1136 pvst->SetBorderSize(0);
1137 pvst->SetFillStyle(0);
1138 pvst->AddText("Bin -> Cont/nEvVtx");
1140 //nsteps=group bins in the Y(X) direction if projecting on the X(Y) direction
1143 if(direction=="X") nsteps=h2->GetNbinsY()/groupnbins;
1144 if(direction=="Y") nsteps=h2->GetNbinsX()/groupnbins;
1145 cout<<"Grouping bins by " <<groupnbins<<" I obtaine "<<nsteps<<" projections"<<endl;
1147 TCanvas *cvpj=new TCanvas(Form("cvpj%s%s",direction.Data(),h2dname.Data()),Form("cvpj%s",direction.Data()),1200,800);
1148 cvpj->Divide((Int_t)(nsteps/3)+1,3);
1149 TFile* fout=new TFile(Form("proj%s%s.root",direction.Data(),h2dname.Data()), "recreate");
1150 //Float_t maxx[nsteps];
1151 //Float_t maxx[12]={9000,9000,6000,4000,2000,1400,800,500,200,100,40,25};
1152 Double_t integralpernev[nsteps];
1154 Double_t minx=0,maxx=0;
1156 minx=h2->GetYaxis()->GetXmin();
1157 maxx=h2->GetYaxis()->GetXmax();
1160 minx=h2->GetXaxis()->GetXmin();
1161 maxx=h2->GetXaxis()->GetXmax();
1163 printf("Plotting from %.1f to %.1f\n",minx,maxx);
1164 TCanvas *cintegral=new TCanvas("cintegral","Integral of each projection");
1165 TH1F* hint=new TH1F("hint","Integral of each projection;Centrality (%);Entries",nsteps,minx,maxx);
1166 Double_t minint=999999999,maxint=0;
1168 for(Int_t i=0;i<nsteps;i++){
1170 // if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),i+kbins,i+2*kbins);
1171 // if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),i+kbins,i+2*kbins);
1172 if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),groupnbins*i+1,groupnbins*(i+1));
1173 if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),groupnbins*i+1,groupnbins*(i+1));
1174 Double_t projint=h->Integral();
1175 cout<<"Integral of projection "<<i<<" = "<<projint<<endl;
1176 hint->SetBinContent(i+1,projint);
1177 hint->SetBinError(i+1,TMath::Sqrt(projint));
1179 if(projint<1e-7) continue;
1180 if(minint>projint) minint=projint;
1181 if(projint>maxint) maxint=projint;
1182 integralpernev[i]=h->Integral()/nevents;
1184 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
1185 pvtxt->SetBorderSize(0);
1186 pvtxt->SetFillStyle(0);
1187 pvtxt->AddText(Form("%.0f - %.0f",h2->GetYaxis()->GetBinLowEdge(groupnbins*i+1),h2->GetYaxis()->GetBinLowEdge(groupnbins*(i+1))));
1188 pvst->AddText(Form("%.0f - %.0f -> %.2f",h2->GetYaxis()->GetBinLowEdge(groupnbins*i+1),h2->GetYaxis()->GetBinLowEdge((groupnbins*(i+1))),integralpernev[i]));
1191 //h->GetXaxis()->SetRangeUser(0,maxx[i]);
1197 cvpj->SaveAs(Form("cvpj%s%s.pdf",direction.Data(),h2dname.Data()));
1198 cvpj->SaveAs(Form("cvpj%s%s.eps",direction.Data(),h2dname.Data()));
1202 cv2d->SaveAs(Form("%s.pdf",h2->GetName()));
1203 cv2d->SaveAs(Form("%s.eps",h2->GetName()));
1206 hint->SetMarkerStyle(20);
1208 if(!fitfunc.Contains("nofit")){
1209 hint->Fit(fitfunc.Data(),"RL","PE",fitmin,fitmax);
1210 TF1* fpolfit=hint->GetFunction(fitfunc.Data());
1211 TPaveText *txtvar=new TPaveText(0.3,0.1,0.9,0.4,"NDC");
1212 txtvar->SetBorderSize(0);
1213 txtvar->SetFillStyle(0);
1214 //txtvar->AddText(Form("Full spread %.0f- %.0f",maxint,minint));
1215 txtvar->AddText(Form("Fit in %.1f-%.1f; ",fitmin,fitmax));
1216 for(Int_t ipar=0;ipar<fpolfit->GetNpar();ipar++){
1217 txtvar->AddText(Form("par%d = %.0f, ",ipar, fpolfit->GetParameter(ipar)));
1219 txtvar->AddText(Form("#tilde{#chi}^{2} = %.2f",fpolfit->GetChisquare()/fpolfit->GetNDF()));
1220 txtvar->AddText(Form("bin width = %.1f %s",hint->GetBinWidth(3),"%"));
1225 cintegral->SaveAs(Form("%s.pdf",hint->GetName()));
1226 cintegral->SaveAs(Form("%s.eps",hint->GetName()));
1229 void DrawEventSelection(TString partname="D0", TString path="./",TString suffixdir="",TString filename="AnalysisResults.root"){
1230 gStyle->SetCanvasColor(0);
1231 gStyle->SetTitleFillColor(0);
1232 gStyle->SetStatColor(0);
1233 gStyle->SetPalette(1);
1234 gStyle->SetOptStat(0);
1236 TString listname="outputEvSel";
1237 TString dirname="PWG3_D2H_QA";
1243 Bool_t isRead=ReadFile(list,hstat,listname,partname,path,filename,dirname);
1245 if(!list || !hstat){
1246 cout<<":-( null pointers..."<<endl;
1249 //Double_t neventsgv=hstat->Integral(5,5); //ev good vertex
1251 for(Int_t i=0;i<list->GetEntries();i++){
1253 TClass* objtype=list->At(i)->IsA();
1254 TString tpname=objtype->GetName();
1257 TH1F* htmp=(TH1F*)list->At(i);
1258 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1261 c->SaveAs(Form("%s.pdf",htmp->GetName()));
1262 c->SaveAs(Form("%s.eps",htmp->GetName()));
1266 TH2F* htmp=(TH2F*)list->At(i);
1267 TCanvas* c=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()),1200,800);
1269 htmp->SetMarkerSize(1.3);
1270 htmp->Draw("colzhtext45");
1271 c->SaveAs(Form("%s.pdf",htmp->GetName()));
1272 c->SaveAs(Form("%s.eps",htmp->GetName()));
1276 AliCounterCollection* coll=(AliCounterCollection*)list->FindObject("trigCounter");
1278 cout<<"Trigger counter not found"<<endl;
1282 coll->SortRubric("run");//sort by run number
1284 TString collname=coll->GetName();
1286 TString keywords=coll->GetKeyWords("triggertype");
1288 Int_t nkeys=keywords.CountChar(',')+1;
1290 TString *words = new TString[nkeys];
1291 for(Int_t k=0;k<nkeys;k++) words[k]="";
1292 printf("Keywords: ");
1294 for(Int_t l=0;l<keywords.Length();l++){
1295 if(keywords[l] != ',') words[count]+=keywords[l];
1297 printf("%s ",words[count].Data());
1303 TH1D** htrig=new TH1D*[nkeys]; //each trigger type in one histogram of counts vs run
1304 TH1D** htrignorm=new TH1D*[nkeys]; //normalized to the counts in kAny
1305 TCanvas* ctrigfraction=new TCanvas("cvtrigfrac","Fraction of given trigger type vs run",1400,800);
1306 TLegend* legtr=new TLegend(0.15,0.5,0.35,0.8);
1307 legtr->SetBorderSize(0);
1308 legtr->SetFillStyle(0);
1309 for(Int_t k=0;k<nkeys;k++){
1310 htrig[k]=coll->Get("run",Form("triggertype:%s",words[k].Data()));
1311 htrig[k]->SetName(Form("h%s",words[k].Data()));
1312 htrig[k]->SetTitle("Trigger type;RUN; counts");
1313 htrig[k]->SetMarkerColor(k+1);
1314 htrig[k]->SetMarkerStyle(k+20);
1316 legtr->AddEntry(htrig[k],Form("%s",words[k].Data()),"P");
1318 //1) counts of a given trigger over counts in kAny
1319 htrignorm[k]=(TH1D*)htrig[k]->Clone(Form("h%snormAny",words[k].Data()));
1320 htrignorm[k]->SetTitle("Trigger type over ANY trigger;RUN; counts/countsANY");
1321 htrignorm[k]->Divide(htrig[k],htrig[0],1.,1.,"B");
1322 htrignorm[k]->GetXaxis()->SetRangeUser(0,1.1);
1324 ctrigfraction->cd();
1325 if(k>0)htrignorm[k]->Draw("PEsames");
1326 else htrignorm[k]->Draw("PE");
1329 ctrigfraction->cd();
1331 ctrigfraction->SaveAs("TrgFractionOverANY.pdf");
1332 ctrigfraction->SaveAs("TrgFractionOverANY.eps");
1336 //draw number of events per trigger
1337 TH2F* hTrigMul=(TH2F*)list->FindObject("hTrigMul");
1339 TH1F *hnEvPerTrig=(TH1F*)hTrigMul->ProjectionX("hnEvPerTrig");
1340 hnEvPerTrig->SetTitle("Number of events per trigger");
1341 TCanvas* cnev=new TCanvas("cnev","Number of events",1400,800);
1343 hnEvPerTrig->Draw("htext0");
1344 cnev->SaveAs(Form("%s.pdf",cnev->GetName()));
1345 cnev->SaveAs(Form("%s.eps",cnev->GetName()));
1347 //draw number of events selected per trigger
1348 TH2F* hTrigMulSel=(TH2F*)list->FindObject("hTrigMulSel");
1350 TH1F *hnEvPerTrigSel=(TH1F*)hTrigMulSel->ProjectionX("hnEvPerTrigSel");
1351 hnEvPerTrigSel->SetTitle("Number of events selected per trigger");
1352 TCanvas* cnevs=new TCanvas("cnevs","Number of events selected",1400,800);
1354 hnEvPerTrigSel->Draw("htext0");
1355 cnevs->SaveAs(Form("%s%s.pdf",cnevs->GetName(),suffixdir.Data()));
1356 cnevs->SaveAs(Form("%s%s.eps",cnevs->GetName(),suffixdir.Data()));
1358 TH1F* hnEvSelPerc=(TH1F*)hnEvPerTrigSel->Clone("hnEvSelFrac");
1359 hnEvSelPerc->SetTitle("Fraction of event selected per trigger");
1360 hnEvSelPerc->Divide(hnEvPerTrig);
1361 TCanvas* cnevsp=new TCanvas("cnevsp","Fraction of events selected",1400,800);
1363 hnEvSelPerc->Draw("htext0");
1364 cnevsp->SaveAs(Form("%s%s.pdf",cnevsp->GetName(),suffixdir.Data()));
1365 cnevsp->SaveAs(Form("%s%s.eps",cnevsp->GetName(),suffixdir.Data()));
1368 void WriteTextFileForCompilation(TString inputtextfile, Int_t analysistype){
1369 //This method writes a text file with the name given in input containing the path of the QA output file, the directories and the lists of histograms to be read to perform a comparison of QA outputs
1370 // analysistype = 1 is the OutputTrack
1371 // analysistype = 2 is the OutputEventSelection
1372 // other outputs can be implemented
1374 // The paths and trigger type (or more in general the suffix of the directories to be read have to be set in this method)
1375 // The legend is set either equal to the trigger type if they are different, or it should be set manually
1376 // Run this methos before CompilationOfTriggeredEvents unless the text file has been already produced
1378 Printf("WARNING! Did you customize the parameters in the macro?");
1379 const Int_t n=8; //customize this
1380 TString prepath="/data/Work/HFQA/LHC12QATrainOutputs/";//"./";
1381 TString pathname[n]={"LHC12a/Train165/","LHC12b/Train166/","LHC12d/Train168/","LHC12e/Train170/","LHC12f/Train171/","LHC12g/Train172/"};
1384 TString listname[n];
1386 myfile.open(inputtextfile);
1389 TString filename="AnalysisResults.root";
1390 TString basedirname="PWG3_D2H_QA";
1391 TString trgnames[n];//={"INT7","EMC7","EMCJET7","EMCGAMMA7","INT8","EMC8","EMCJET8","EMCGAMMA8"}; //customize this
1392 TString baselistname="", partname="D00100";
1393 TString legend[n]={"LHC12a165","LHC12b166","LHC12d168","LHC12e170","LHC12f171","LHC12g172"}; //Customize this if want it to be different from trgnames
1394 if(analysistype==1) baselistname="outputTrack";
1395 if(analysistype==2) baselistname="outputEvSel";
1396 //... others could be added
1398 //All in the same directory on your computer
1399 for(Int_t i=0;i<n;i++){
1401 pathname[i]=prepath+pathname[i];//"./";
1403 dirname[i]=basedirname+trgnames[i];
1404 listname[i]=baselistname+partname+trgnames[i];
1405 if(legend[i]=="") legend[i]=trgnames[i];
1407 //Printf("Trigger name is %s",trgnames[i].Data());
1408 //Printf("Legend is %s",legend[i].Data());
1413 myfile<<pathname[i].Data()<<filename.Data()<<endl;
1414 myfile<<dirname[i].Data()<<endl;
1415 myfile<<listname[i].Data()<<endl;
1416 myfile<<legend[i].Data()<<endl;
1423 Bool_t ReadFilesForCompilation(TString inputtextfile, TList**& lists, Int_t& numb, TString*& legend){
1425 //Method to read the QA files indicated in the text file in input (to be written with WriteTextFileForCompilation() method)
1427 myfile.open(inputtextfile);
1428 if(!myfile.is_open()) Printf("No files found, did you make it correctly?");
1431 lists=new TList*[n];
1432 legend= new TString[n];
1441 //Printf("Filename = %s",filename.Data());
1442 TFile *fin=new TFile(filename);
1444 Printf("File %s not found",filename.Data());
1450 //Printf("Dirname = %s",dirname.Data());
1451 TDirectoryFile* dir=(TDirectoryFile*)fin->Get(dirname);
1453 Printf("Directory %s not found in %s",dirname.Data(),filename.Data());
1460 //Printf("Listname = %s",listname.Data());
1461 lists[k]=(TList*)dir->Get(listname);
1463 Printf("List %s not found in %s",listname.Data(),dirname.Data());
1471 Printf("Legend = %s",legend[k].Data());
1473 Printf("Legend %s not found",filename.Data());
1479 if(k==n)return kTRUE;// Needed as the while loop does not always realise the end is reached.
1484 void CompilationOfTriggeredEvents(TString inputtextfile,Int_t analysistype){
1485 //This method draws the histograms superimposed
1487 // analysistype = 1 is the OutputTrack
1488 // analysistype = 2 is the OutputEventSelection
1489 // other outputs can be implemented
1493 TString* legend=0x0;
1494 Bool_t okread=ReadFilesForCompilation(inputtextfile,lists,n,legend);
1496 Printf("Did you write %s with WriteTextFileForCompilation(%s)?",inputtextfile.Data(),inputtextfile.Data());
1500 if(analysistype==2){CompilationEvSelection(n,lists,legend);}
1501 if(analysistype==1){CompilationTrackSelection(n,lists,legend);}
1504 void CompilationEvSelection(Int_t n,TList** lists, TString* legend){
1505 // Specific method for EventSelection output (2)
1507 TCanvas *cnevs=new TCanvas("cnevs","Number of events selected",1400,800);
1508 TCanvas *cnevsp=new TCanvas("cnevsp","Fraction of events selected",1400,800);
1509 TH1F** hnEvPerTrig=new TH1F*[n];
1510 TH1F** hnEvPerTrigSel=new TH1F*[n];
1511 TH1F** hnEvSelPerc=new TH1F*[n];
1513 TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
1514 leg->SetFillStyle(0);
1515 leg->SetBorderSize(0);
1518 Int_t nentriesl=lists[0]->GetEntries();
1519 TCanvas** c=new TCanvas*[nentriesl];
1522 for(Int_t i=0;i<n;i++){
1524 TH2F* hTrigMul=(TH2F*)lists[i]->FindObject("hTrigMul");
1526 hnEvPerTrig[i]=(TH1F*)hTrigMul->ProjectionX(Form("hnEvPerTrig%d",i));
1527 hnEvPerTrig[i]->SetTitle("Number of events selected per trigger");
1530 TH2F* hTrigMulSel=(TH2F*)lists[i]->FindObject("hTrigMulSel");
1532 hnEvPerTrigSel[i]=(TH1F*)hTrigMulSel->ProjectionX(Form("hnEvPerTrigSel%d",i));
1533 hnEvPerTrigSel[i]->SetTitle("Number of events selected per trigger");
1534 hnEvPerTrigSel[i]->SetLineColor(i+1);
1535 hnEvPerTrigSel[i]->SetLineWidth(2);
1538 if(i==0) hnEvPerTrigSel[i]->Draw();
1539 else hnEvPerTrigSel[i]->Draw("sames");
1541 hnEvSelPerc[i]=(TH1F*)hnEvPerTrigSel[i]->Clone(Form("hnEvSelFrac%d",i));
1542 hnEvSelPerc[i]->SetTitle("Fraction of event selected per trigger");
1543 hnEvSelPerc[i]->SetLineColor(i+1);
1544 hnEvSelPerc[i]->SetLineWidth(2);
1545 hnEvSelPerc[i]->Divide(hnEvPerTrig[i]);
1547 if(i==0) hnEvSelPerc[i]->Draw("htext0");
1548 else hnEvSelPerc[i]->Draw("htext0sames");
1549 nth1f=0; //restart counting per each file
1552 leg->AddEntry(hnEvSelPerc[i],legend[i],"L");
1554 for(Int_t j=0; j<nentriesl; j++){
1555 TClass* objtype=lists[i]->At(j)->IsA();
1556 TString tpname=objtype->GetName();
1558 if (tpname=="TH1F"){
1559 TH1F* htmp=(TH1F*)lists[i]->At(j);
1561 htmp->SetLineColor(1+i);
1562 if(htmp->Integral()>0) htmp->Scale(1./htmp->Integral());
1565 c[nth1f]=new TCanvas(Form("c%s",htmp->GetName()),Form("c%s",htmp->GetName()));
1572 htmp->Draw("sames");
1582 for(Int_t j=0;j<nth1f;j++){
1585 c[j]->SaveAs(Form("%s.pdf",c[j]->GetName()));
1586 c[j]->SaveAs(Form("%s.eps",c[j]->GetName()));
1591 cnevs->SaveAs(Form("%s.eps",cnevs->GetName()));
1592 cnevs->SaveAs(Form("%s.pdf",cnevs->GetName()));
1596 cnevsp->SaveAs(Form("%s.eps",cnevsp->GetName()));
1597 cnevsp->SaveAs(Form("%s.pdf",cnevsp->GetName()));
1598 TCanvas *test=new TCanvas();
1599 test->cd(); leg->Draw();
1603 void CompilationTrackSelection(Int_t n,TList** lists,TString* legend)
1605 // Specific method for Track output (1)
1607 for(Int_t i=0;i<lists[0]->GetEntries();i++){
1608 TObjArray* plotseth=new TObjArray();
1609 TObjArray* plotsethr=new TObjArray();
1612 is2d = lists[0]->At(i)->InheritsFrom("TH2");
1615 for(Int_t j=0; j<n; j++){
1616 TH1F* temph=(TH1F*)lists[j]->At(i);
1618 TH1F * ploto=0x0; //0th plot to divide by
1620 // plot ratios and scale all plots to integral
1621 temphr= (TH1F*)temph->Clone(Form("%s_ratio",temph->GetName()));
1622 if(j==0)ploto = temphr;
1623 else ploto = (TH1F*)plotseth->At(0);
1624 temphr->Divide(ploto);
1625 if(temphr->Integral()>0){temphr-> Scale(1./temphr->Integral());}// take out for nonscaled ratios
1626 if(temph->Integral()>0){ temph-> Scale(1./temph->Integral());}
1628 plotseth->AddLast(new TH1F(*temph));
1629 plotsethr->AddLast(new TH1F(*temphr));
1633 TH1F *h = (TH1F*)plotseth->At(0);
1634 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
1637 TString hname=h->GetName();
1639 if(!hname.Contains("nCls")){
1641 if(hname.Contains("Layer")){
1642 for(Int_t ibin=1;ibin<=h->GetNbinsX();ibin++){
1643 h->GetXaxis()->SetBinLabel(ibin+1,Form("%d",ibin));
1645 h->GetXaxis()->SetLabelSize(0.06);
1646 h->GetXaxis()->SetRangeUser(0,6); //comment to see ntracks!
1651 TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
1652 leg->SetFillStyle(0);
1653 leg->SetBorderSize(0);
1654 leg->AddEntry(h,legend[0],"L");
1656 for(Int_t j=1; j<n; j++){
1657 TH1F * h2 = (TH1F*)plotseth->At(j);
1658 h2->SetLineColor(1+j);
1660 leg->AddEntry(h2,legend[j],"L");
1665 TCanvas* c2=new TCanvas(Form("c2%s",h->GetName()),h->GetName());
1668 TH1F *hr = (TH1F*)plotsethr->At(1);
1669 hr->SetLineColor(2);
1671 TLegend* leg2=new TLegend(0.15,0.5,0.45,0.78);
1672 leg2->SetFillStyle(0);
1673 leg2->SetBorderSize(0);
1676 ratioleg+=legend[1];
1678 ratioleg+=legend[0];
1680 leg2->AddEntry(hr,ratioleg,"L");
1682 for(Int_t j=2; j<n; j++){
1683 TH1F * hr2 = (TH1F*)plotsethr->At(j);
1684 hr2->SetLineColor(1+j);
1688 ratioleg2+=legend[j];
1690 ratioleg2+=legend[0];
1692 leg2->AddEntry(hr2,ratioleg2,"L");
1695 c2->SaveAs(Form("%s%s%sRatio.pdf",c->GetName(),legend[0].Data(), legend[n-1].Data()));
1696 c2->SaveAs(Form("%s%s%sRatio.eps",c->GetName(),legend[0].Data(), legend[n-1].Data()));
1701 TLegend* leg=new TLegend(0.15,0.5,0.45,0.78);
1702 leg->SetFillStyle(0);
1703 leg->SetBorderSize(0);
1704 leg->AddEntry(h,legend[0],"L");
1706 for(Int_t j=1; j<n; j++){
1707 TH1F * h2 = (TH1F*)plotseth->At(j);
1708 h2->SetLineColor(1+j);
1709 leg->AddEntry(h2,legend[j],"L");
1710 h2->Draw("htext0sames");
1716 c->SaveAs(Form("%s%s%s.eps",c->GetName(),legend[0].Data(), legend[n-1].Data()));
1717 c->SaveAs(Form("%s%s%s.pdf",c->GetName(),legend[0].Data(), legend[n-1].Data()));
1723 else cout<<"Warning: To many files for combinationplot, show only original"<<endl;
1724 TLegend* leg3=new TLegend(0.15,0.5,0.45,0.78);
1725 leg3->SetFillStyle(0);
1726 leg3->SetBorderSize(0);
1727 TCanvas* ctrsel=new TCanvas("ctrsel","Track Sel");
1729 for(Int_t i=0; i<maxfa; i++){
1730 TH1F* hd0fb4=(TH1F*)lists[i]->FindObject("hd0TracksFilterBit4");
1731 TH1F* hd0SPD1=(TH1F*)lists[i]->FindObject("hd0TracksSPDin");
1732 TH1F* hd0SPDany=(TH1F*)lists[i]->FindObject("hd0TracksSPDany");
1733 TH1F* hd0TPCITScuts=(TH1F*)lists[i]->FindObject("hd0TracksTPCITSSPDany");
1734 if(hd0fb4 && hd0SPD1 && hd0SPDany && hd0TPCITScuts){
1736 else{if(check==0)return;}
1738 hd0SPD1->SetLineColor(kCyan+3);
1739 hd0SPDany->SetLineColor(4);
1740 hd0TPCITScuts->SetLineColor(kGreen+1);
1741 hd0fb4->SetLineColor(2);
1745 TPaveStats *st1=(TPaveStats*)hd0SPD1->GetListOfFunctions()->FindObject("stats");
1746 st1->SetTextColor(kCyan+3);
1747 st1->SetY1NDC(0.71);
1749 hd0SPDany->Draw("sames");
1751 TPaveStats *st2=(TPaveStats*)hd0SPDany->GetListOfFunctions()->FindObject("stats");
1752 st2->SetY1NDC(0.51);
1754 st2->SetTextColor(4);
1755 hd0fb4->Draw("sames");
1757 TPaveStats *st3=(TPaveStats*)hd0fb4->GetListOfFunctions()->FindObject("stats");
1758 st3->SetY1NDC(0.31);
1760 st3->SetTextColor(2);
1761 hd0TPCITScuts->Draw("sames");
1763 TPaveStats *st4=(TPaveStats*)hd0TPCITScuts->GetListOfFunctions()->FindObject("stats");
1764 st4->SetY1NDC(0.71);
1766 st4->SetX1NDC(0.55);
1767 st4->SetX2NDC(0.75);
1768 st4->SetTextColor(kGreen+1);
1770 leg3->AddEntry(hd0SPD1,"kITSrefit+SPD inner","L");
1771 leg3->AddEntry(hd0SPDany,"kITSrefit+SPD any","L");
1772 leg3->AddEntry(hd0TPCITScuts,"TPC+ITS cuts+SPD any","L");
1773 leg3->AddEntry(hd0fb4,"Filter Bit 4","L");
1774 leg3->AddEntry(hd0SPD1, legend[i], "L");
1777 hd0SPD1->SetStats(0);
1778 hd0SPD1->SetLineStyle(i+1);
1779 hd0SPD1->Draw("sames");
1780 hd0SPDany->SetStats(0);
1781 hd0SPDany->SetLineStyle(i+1);
1782 hd0TPCITScuts->SetStats(0);
1783 hd0TPCITScuts->SetLineStyle(i+1);
1784 hd0fb4->SetStats(0);
1785 hd0fb4->SetLineStyle(i+1);
1787 hd0SPD1->Draw("sames");
1788 hd0SPDany->Draw("sames");
1789 hd0TPCITScuts->Draw("sames");
1790 hd0fb4->Draw("sames");
1791 leg3->AddEntry(hd0SPD1, legend[i], "L");
1797 ctrsel->SaveAs("ImpactParameterTrackSel.eps");
1798 ctrsel->SaveAs("ImpactParameterTrackSel.pdf");