]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/macros/DrawQAoutput.C
Update (Chiara Z)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / macros / DrawQAoutput.C
CommitLineData
9af24f46 1#include <Riostream.h>
2#include <TFile.h>
3#include <TString.h>
4#include <TH2F.h>
5#include <TH1F.h>
6#include <TF1.h>
1fc8d3c0 7#include <TGraph.h>
9af24f46 8#include <TDirectoryFile.h>
9#include <TList.h>
10#include <TCanvas.h>
11#include <TLegend.h>
12#include <TPaveText.h>
13#include <TStyle.h>
82f89d0d 14#include <TClass.h>
1fc8d3c0 15#include <TDatabasePDG.h>
16#include <TParameter.h>
82f89d0d 17#include <AliCounterCollection.h>
1fc8d3c0 18#include <AliRDHFCuts.h>
9af24f46 19
20//read the file and take list and stat
21
1fc8d3c0 22Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path="./",TString filename="AnalysisResults.root"/*"PWG3histograms.root"*/);
23Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path="./",TString filename="AnalysisResults.root"/*"PWG3histograms.root"*/);
f3e1ad2f 24void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h 3=MC*/,TCanvas* cpid, Int_t set);
1fc8d3c0 25void TPCBetheBloch(Int_t set);
9af24f46 26
1fc8d3c0 27Bool_t ReadFile(TList* &list,TH1F* &hstat, TString listname,TString partname,TString path,TString filename){
9af24f46 28
1fc8d3c0 29 TString hstatname="nEntriesQA",dirname="PWG3_D2H_QA", cutobjname="";
9af24f46 30 filename.Prepend(path);
31 listname+=partname;
32 hstatname+=partname;
33
34 TFile* f=new TFile(filename.Data());
35 if(!f){
36 cout<<filename.Data()<<" not found"<<endl;
37 return kFALSE;
38 }
39 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
40 if(!f){
41 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
42 return kFALSE;
43 }
44
45 list=(TList*)dir->Get(listname);
46 if(!list){
47 cout<<"List "<<listname.Data()<<" not found"<<endl;
48 dir->ls();
49 return kFALSE;
50 }
51
52 hstat=(TH1F*)dir->Get(hstatname);
53 if(!hstat){
54 cout<<hstatname.Data()<<" not found"<<endl;
55 return kFALSE;
56 }
1fc8d3c0 57
58 return kTRUE;
59}
60
61Bool_t ReadFileMore(TList* &list,TH1F* &hstat, AliRDHFCuts* &cutobj, TString listname,TString partname,TString path,TString filename){
62
63 TString hstatname="nEntriesQA",dirname="PWG3_D2H_QA", cutobjname="";
64 filename.Prepend(path);
65 listname+=partname;
66 hstatname+=partname;
67
f3e1ad2f 68 if(partname.Contains("Dplus")) cutobjname="AnalysisCuts";//"DplustoKpipiCutsStandard";
1fc8d3c0 69 else{
70 if(partname.Contains("D0")) cutobjname="D0toKpiCutsStandard";//"D0toKpiCuts";
71 else{
72 if(partname.Contains("Dstar")) cutobjname="DStartoKpipiCuts";
73 else{
74 if(partname.Contains("Ds")) cutobjname="DstoKKpiCuts";
75 else{
76 if(partname.Contains("D04")) cutobjname="D0toKpipipiCuts";
77 else{
78 if(partname.Contains("Lc")) cutobjname="LctopKpiAnalysisCuts";
79 }
80 }
81 }
82 }
83 }
84
85 TFile* f=new TFile(filename.Data());
86 if(!f){
87 cout<<filename.Data()<<" not found"<<endl;
88 return kFALSE;
89 }
90 TDirectoryFile* dir=(TDirectoryFile*)f->Get(dirname);
91 if(!f){
92 cout<<dirname.Data()<<" not found in "<<filename.Data()<<endl;
93 return kFALSE;
94 }
95
96 list=(TList*)dir->Get(listname);
97 if(!list){
98 cout<<"List "<<listname.Data()<<" not found"<<endl;
99 dir->ls();
100 return kFALSE;
101 }
102
103 hstat=(TH1F*)dir->Get(hstatname);
104 if(!hstat){
105 cout<<hstatname.Data()<<" not found"<<endl;
106 return kFALSE;
107 }
108
109 cutobj=(AliRDHFCuts*)dir->Get(cutobjname);
110 if(!cutobj){
111 cout<<cutobjname.Data()<<" not found"<<endl;
112 return kFALSE;
113 }
114
9af24f46 115 return kTRUE;
116}
117
118//draw "track related" histograms (list "outputTrack")
1fc8d3c0 119void DrawOutputTrack(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE){
9af24f46 120 gStyle->SetCanvasColor(0);
121 gStyle->SetTitleFillColor(0);
122 gStyle->SetStatColor(0);
123 gStyle->SetPalette(1);
124
f3e1ad2f 125 TString listname="outputTrack",name1="",name2="",path2="",filename="AnalysisResults.root"/*"PWG3histograms.root"*/,filename2="PWG3histograms.root";
1fc8d3c0 126 TString tmp="y";
127
128 if(superimpose){
129 cout<<"Enter the names:\n>";
130 cin>>name1;
131 cout<<">";
132 cin>>name2;
133 cout<<"Are they in the same output file? (y/n)"<<endl;
134 cin>>tmp;
135 if(tmp=="n"){
136 cout<<"Path: \t";
137 cin>>path2;
138 cout<<"Filename; "<<endl;
139 cin>>filename2;
140 }
141
142 }
9af24f46 143
144 TList* list;
145 TH1F * hstat;
146
1fc8d3c0 147 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path,filename);
9af24f46 148 if(!isRead) return;
149 if(!list || !hstat){
150 cout<<":-( null pointers..."<<endl;
151 return;
152 }
1fc8d3c0 153 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
154 pvtxt->SetBorderSize(0);
155 pvtxt->SetFillStyle(0);
156 pvtxt->AddText(name1);
157
158 TList* llist;
159 TH1F* hhstat;
160 if(superimpose){
161 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path2,filename2);
162 if(!isRead) return;
163 if(!llist || !hhstat){
164 cout<<":-( null pointers..."<<endl;
165 return;
166 }
167 TText *redtext=pvtxt->AddText(name2);
168 redtext->SetTextColor(kRed);
169
170 }
9af24f46 171
172 for(Int_t i=0;i<list->GetEntries();i++){
173 TH1F* h=(TH1F*)list->At(i);
1fc8d3c0 174 TH1F* hh=0x0;
175 if(superimpose){
176 hh=(TH1F*)llist->At(i);
177 }
178 if(!h || (superimpose && !hh)){
9af24f46 179 cout<<"Histogram "<<i<<" not found"<<endl;
180 continue;
181 }
1fc8d3c0 182 if(superimpose){
183 hhstat->SetLineColor(kRed);
184 hh->SetLineColor(kRed);
185 }
186
9af24f46 187 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
188 c->cd();
189 c->SetGrid();
190 TString hname=h->GetName();
f3e1ad2f 191 if(!hname.Contains("hn")){
9af24f46 192 c->SetLogy();
1fc8d3c0 193 //h->SetMinimum(1);
9af24f46 194 h->Draw();
1fc8d3c0 195 if(superimpose) hh->Draw("sames");
196 } else {
f3e1ad2f 197 if(hname.Contains("layer")){
198 Int_t ntracks=h->GetBinContent(1);
199 h->Scale(1./ntracks);
200 h->GetYaxis()->SetTitle("Fraction of tracks with point in layer x");
201 h->GetXaxis()->SetRangeUser(0.5,6.5);
202 }
1fc8d3c0 203 h->Draw("htext0");
204 if(superimpose)hh->Draw("htext0sames");
205 }
206 pvtxt->Draw();
207 c->SaveAs(Form("%s%s%s%s.png",c->GetName(),name1.Data(),name2.Data(),textleg.Data()));
9af24f46 208 }
209
210 TCanvas* cst=new TCanvas("cst","Stat");
211 cst->SetGridy();
212 cst->cd();
213 hstat->Draw("htext0");
1fc8d3c0 214 if(superimpose) {
215 hhstat->Draw("htext0sames");
216 pvtxt->Draw();
217 }
9af24f46 218 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
219
9af24f46 220
82f89d0d 221}
9af24f46 222
82f89d0d 223//draw "pid related" histograms (list "outputPID")
1fc8d3c0 224//period=-999 to draw the pull instead of the cut
225void DrawOutputPID(TString partname="D0", Int_t mode=0/*0=with pull, 1=with nsigma*/,TString textleg="",TString path="./"){
82f89d0d 226 gStyle->SetCanvasColor(0);
227 gStyle->SetTitleFillColor(0);
228 gStyle->SetStatColor(0);
229 gStyle->SetPalette(1);
230
1fc8d3c0 231 Int_t period=2 ,set=0;
232 if(mode==1){
f3e1ad2f 233 cout<<"Choose period: \n-MC -> 3;\n-LHC10h -> 2;\n-LHC10de -> 1;\n-LHC10bc -> 0"<<endl;
1fc8d3c0 234 cin>>period;
235 if(period>0){
236 cout<<"Choose set: "<<endl;
237 if(period==2) cout<<"-pass1 -> 0;\n-pass2 -> 1"<<endl;
238 cin>>set;
239 }
240 }
241
82f89d0d 242 TString listname="outputPid";
243
244 TList* list;
245 TH1F * hstat;
1fc8d3c0 246 //needed only for mode 1
247 AliRDHFCuts* cutobj;
248 AliAODPidHF* aodpid;
249 Double_t nsigmaTOF=0;
250 Double_t nsigmaTPC[3]={},plimTPC[2]={};
251
252 if(mode==1){
253 Bool_t isRead=ReadFileMore(list,hstat,cutobj,listname,partname,path);
254 if(!isRead) return;
255 if(!list || !hstat){
256 cout<<":-( null pointers..."<<endl;
257 return;
258 }
259 aodpid=(AliAODPidHF*)cutobj->GetPidHF();
260 nsigmaTOF=aodpid->GetSigma(3);
261
262 nsigmaTPC[0]=aodpid->GetSigma(0);
263 nsigmaTPC[1]=aodpid->GetSigma(1);
264 nsigmaTPC[2]=aodpid->GetSigma(2);
265 aodpid->GetPLimit(plimTPC);
266
267 }else{
268
269 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
270 if(!isRead) return;
271 if(!list || !hstat){
272 cout<<":-( null pointers..."<<endl;
273 return;
274 }
9af24f46 275 }
276
1fc8d3c0 277
278 TPaveText *txtsigmaTOF=new TPaveText(0.1,0.65,0.5,0.9,"NDC");
279 txtsigmaTOF->SetBorderSize(0);
280 txtsigmaTOF->SetFillStyle(0);
281 txtsigmaTOF->AddText(Form("nsigmacut from cutobj = %.1f",nsigmaTOF));
282 TLine lTOF;
283 lTOF.SetLineColor(kMagenta+1);
284 lTOF.SetLineStyle(2);
285 lTOF.SetLineWidth(3);
286
287 TPaveText *txtsigmaTPC=new TPaveText(0.3,0.6,0.6,0.9,"NDC");
288 txtsigmaTPC->SetBorderSize(0);
289 txtsigmaTPC->SetFillStyle(0);
290 txtsigmaTPC->AddText("nsigmacut from cutobj \n");
291 txtsigmaTPC->AddText(Form("p < %.1f : %.1f \n",plimTPC[0],nsigmaTPC[0]));
292 txtsigmaTPC->AddText(Form("%.1f < p < %.1f : %.1f \n",plimTPC[0],plimTPC[1],nsigmaTPC[1]));
293 txtsigmaTPC->AddText(Form("p > %.1f : %.1f \n",plimTPC[1],nsigmaTPC[2]));
294 TLine lTPC;
295 lTPC.SetLineColor(kMagenta+1);
296 lTPC.SetLineStyle(2);
297 lTPC.SetLineWidth(3);
298
299 // TCanvas *ctest=new TCanvas("text","Test text");
300 // ctest->cd();
301 // txtsigmaTPC->Draw();
302 // txtsigmaTOF->Draw();
303
304
82f89d0d 305 for(Int_t i=0;i<list->GetEntries();i++){
306 TClass* objtype=list->At(i)->IsA();
307 TString tpname=objtype->GetName();
308
309 if(tpname=="TH1F"){
310 TH1F* h=(TH1F*)list->At(i);
311
312 if(!h){
313 cout<<"Histogram "<<i<<" not found"<<endl;
314 continue;
315 }
316 //h->Scale(1./h->Integral("width"));
317 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
318 c->SetLogz();
319 c->cd();
320 h->Draw();
321
322 //write
1ff03d38 323 c->SaveAs(Form("%s%s.png",h->GetName(),textleg.Data()));
82f89d0d 324 TFile* fout=new TFile(Form("%s.root",h->GetName()),"recreate");
325 fout->cd();
326 c->Write();
327 }
328
329 if(tpname=="TH2F"){
330 TH2F* h=(TH2F*)list->At(i);
331
332 if(!h){
333 cout<<"Histogram "<<i<<" not found"<<endl;
334 continue;
335 }
ac0c2841 336 h->Sumw2();
82f89d0d 337 h->Scale(1./h->Integral("width"));
1fc8d3c0 338 TString hname=h->GetName();
339
340 if(hname.Contains("hTOFtimeKaonHyptime")){
341 TCanvas* cz=new TCanvas(Form("c%szoom",hname.Data()),Form("%szoom",hname.Data()));
342 cz->SetLogz();
343 TH2F* hz=(TH2F*)h->Clone(Form("%sz",hname.Data()));
344 hz->Draw("colz");
345 hz->SetAxisRange(-1500,1500,"Y");
346 //write
347 cz->SaveAs(Form("%szoom.png",h->GetName()));
348 }
349
350 TCanvas* c=new TCanvas(Form("c%s",hname.Data()),hname.Data());
82f89d0d 351 c->SetLogz();
ac0c2841 352 //c->SetLogx();
82f89d0d 353 c->cd();
354
355 h->Draw("colz");
1fc8d3c0 356
357 //TCanvas *test=new TCanvas("test","test");
358 if(mode==0){
359 //mean and pull, code from Jens Wiechula
360 TF1 fg("fg","gaus",-2.,2.); // fit range +- 2 sigma
361 TLine l;
362 TObjArray arr;
363
364 //h->Draw("colz");
365 fg.SetParameters(1,0,1);
366 h->FitSlicesY(&fg,0,-1,0,"NQR",&arr);
367
368 TH1 *hM=(TH1*)arr.At(1);
369 hM->SetMarkerStyle(20);
370 hM->SetMarkerSize(.5);
371 hM->DrawClone("sames");
372
373 TH1 *hS=(TH1*)arr.At(2);
374 hS->SetMarkerStyle(20);
375 hS->SetMarkerSize(.5);
376 hS->SetMarkerColor(kRed);
377 hS->SetLineColor(kRed);
378 hS->DrawClone("same");
379
380 l.SetLineColor(kBlack);
381 l.DrawLine(.2,0,20,0);
382 l.SetLineColor(kRed);
383 l.DrawLine(.2,1,20,1);
384
385 }else{ //mode 1
386
387 if(hname.Contains("TOFsigma")) {
388
389 c->cd();
390 txtsigmaTOF->Draw();
391 lTOF.DrawLine(.2,nsigmaTOF,20,nsigmaTOF);
392 lTOF.DrawLine(.2,-1*nsigmaTOF,4.,-1*nsigmaTOF);
ac0c2841 393
1fc8d3c0 394 }
395
ac0c2841 396
1fc8d3c0 397 if(hname.Contains("TPCsigma")){
398
399 c->cd();
400 txtsigmaTPC->Draw();
401 lTPC.DrawLine(0.,nsigmaTPC[0],plimTPC[0],nsigmaTPC[0]);
402 lTPC.DrawLine(plimTPC[0],nsigmaTPC[1],plimTPC[1],nsigmaTPC[1]);
403 lTPC.DrawLine(plimTPC[1],nsigmaTPC[2],4,nsigmaTPC[2]);
404 lTPC.DrawLine(0.,-1*nsigmaTPC[0],plimTPC[0],-1*nsigmaTPC[0]);
405 lTPC.DrawLine(plimTPC[0],-1*nsigmaTPC[1],plimTPC[1],-1*nsigmaTPC[1]);
406 lTPC.DrawLine(plimTPC[1],-1*nsigmaTPC[2],4,-1*nsigmaTPC[2]);
407 }
ac0c2841 408
1fc8d3c0 409 if(hname.Contains("TPCsigvsp")){
410 SuperimposeBBToTPCSignal(period,c,set);
411 }
412 }
413
82f89d0d 414 //write
f3e1ad2f 415 c->SaveAs(Form("%s%d.png",h->GetName(),mode));
416 TFile* fout=new TFile(Form("%s%d.root",h->GetName(),mode),"recreate");
82f89d0d 417 fout->cd();
418 c->Write();
1fc8d3c0 419 }
420 }
421}
422
423void SuperimposeBBToTPCSignal(Int_t period /*0=LHC10bc, 1=LHC10d, 2=LHC10h*/,TCanvas* cpid,Int_t set /*see below*/){
424
425 TFile* fBethe=new TFile("BetheBlochTPC.root");
426 if(!fBethe->IsOpen()){
427 TPCBetheBloch(set);
428 fBethe=new TFile("BetheBlochTPC.root");
429 }
430 const Int_t npart=4;
431 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
432 for(Int_t ipart=0;ipart<npart;ipart++){
433 TString grname=Form("%sP%d",partnames[ipart].Data(),period);
434 TGraph* gr=(TGraph*)fBethe->Get(grname);
435 cpid->cd();
436 gr->SetLineColor(1);
437 gr->SetLineWidth(2);
438 gr->Draw("L");
439 }
440
441 //cpid->SaveAs(Form("%sBB.png",hname.Data()));
442}
443
444//draw and save Bethe Bloch from TPC in different periods
445void TPCBetheBloch(Int_t set){
446 gStyle->SetOptTitle(0);
447 gStyle->SetCanvasColor(0);
448
449 AliTPCPIDResponse *tpcResp=new AliTPCPIDResponse();
450
451 const Int_t npart=4;
452 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*/};
453 TString partnames[npart]={"Kaon","Pion","Electron","Proton"};
454 //printf("%s = %.4f,%s = %.4f,%s = %.4f\n",partnames[0].Data(),masses[0],partnames[1].Data(),masses[1],partnames[2].Data(),masses[2]);
455 TCanvas *cBethe=new TCanvas("cBethe","Bethe Bloch K pi e p");
f3e1ad2f 456 Int_t nperiods=4; //LHC10b+c, LHC10d, LHC10h
1fc8d3c0 457 Double_t alephParameters[5]={};
458
459 TFile* fout=new TFile("BetheBlochTPC.root","recreate");
460
461 for(Int_t iperiod=0;iperiod<nperiods;iperiod++){
462 if(iperiod==2){//LHC10h
463 if(set==0){//pass1
464 alephParameters[0]=1.25202/50.;
465 alephParameters[1]=2.74992e+01;
466 alephParameters[2]=TMath::Exp(-3.31517e+01);
467 alephParameters[3]=2.46246;
468 alephParameters[4]=6.78938;
469 }
470 if (set==1){//pass2 (AOD044)
f3e1ad2f 471 alephParameters[0]=1.25202/50.;
472 alephParameters[1]=2.74992e+01;
473 alephParameters[2]=TMath::Exp(-3.31517e+01);
474 alephParameters[3]=2.46246;
475 alephParameters[4]=6.78938;
476
1fc8d3c0 477 }
478 }
f3e1ad2f 479 if(iperiod==1){ //LHC10de
1fc8d3c0 480 if(set==0){
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 }
487 if(set==1){
488 alephParameters[0] = 1.34490e+00/50.;
489 alephParameters[1] = 2.69455e+01;
490 alephParameters[2] = TMath::Exp(-2.97552e+01);
491 alephParameters[3] = 2.35339e+00;
492 alephParameters[4] = 5.98079e+00;
493 }
494 }
495 if(iperiod==0){ //LHC10bc
496
497 alephParameters[0] = 0.0283086/0.97;
498 alephParameters[1] = 2.63394e+01;
499 alephParameters[2] = 5.04114e-11;
500 alephParameters[3] = 2.12543e+00;
501 alephParameters[4] = 4.88663e+00;
502
503 }
f3e1ad2f 504 if(iperiod==3){ //MC
505 if(set==0){
506 alephParameters[0] = 2.15898e+00/50.;
507 alephParameters[1] = 1.75295e+01;
508 alephParameters[2] = 3.40030e-09;
509 alephParameters[3] = 1.96178e+00;
510 alephParameters[4] = 3.91720e+00;
511 }
512 if(set==1){ //new
513 alephParameters[0] = 1.44405/50;
514 alephParameters[1] = 2.35409e+01;
515 alephParameters[2] = TMath::Exp(-2.90330e+01);
516 alephParameters[3] = 2.10681;
517 alephParameters[4] = 4.62254;
518
519 }
520 }
1fc8d3c0 521 tpcResp->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
522
523 for(Int_t ipart=0;ipart<npart;ipart++){
ac0c2841 524
1fc8d3c0 525 const Int_t n=1000;
526 Double_t p[n],bethe[n];
527
528 for(Int_t k=0;k<n;k++){ //loop on the momentum steps
529 p[k]=0.0001+k*4./n; //limits 0.-4. GeV/c
530 //cout<<p[k]<<"\t";
531 //bethe[k]=-tpcResp->Bethe(p[k]/masses[ipart]);
532 AliPID::EParticleType ptype=AliPID::kKaon;
533 if(ipart==1) ptype=AliPID::kPion;
534 if(ipart==2) ptype=AliPID::kElectron;
535 if(ipart==3) ptype=AliPID::kProton;
536 bethe[k]=tpcResp->GetExpectedSignal(p[k],ptype);
537 }
538 //cout<<endl;
539 TGraph *gr=new TGraph(n,p,bethe);
540 gr->SetName(Form("%sP%d",partnames[ipart].Data(),iperiod));
541 gr->SetTitle(Form("%sP%d;p (GeV/c);",partnames[ipart].Data(),iperiod));
542 gr->SetLineColor(ipart+1);
543 gr->SetMarkerColor(ipart+1);
544 gr->GetYaxis()->SetRangeUser(35,100);
545 cBethe->cd();
546 if(iperiod==0 && ipart==0)gr->DrawClone("AL");
547 else gr->DrawClone("L");
548
549 fout->cd();
550 gr->Write();
82f89d0d 551 }
1fc8d3c0 552
9af24f46 553 }
1fc8d3c0 554 TParameter<int> sett;
555 sett.SetVal(set);
556 fout->cd();
557 sett.Write();
558
559 fout->Close();
9af24f46 560}
561
1fc8d3c0 562void DrawOutputCentrality(TString partname="D0",TString textleg="",TString path="./", Bool_t superimpose=kFALSE){
9af24f46 563 gStyle->SetCanvasColor(0);
564 gStyle->SetTitleFillColor(0);
565 gStyle->SetStatColor(0);
566 gStyle->SetPalette(1);
567
1fc8d3c0 568 TString listname="outputCentrCheck",name1="",name2="";
569
570 if(superimpose){
571 cout<<"Enter the names:\n>";
572 cin>>name1;
573 cout<<">";
574 cin>>name2;
575 }
576 // Int_t nhist=1;
577 // TString *name=0x0;
578 // if(superimpose){
579 // cout<<"Number of histogram to superimpose: ";
580 // cin>>nhist;
581 // name=new TString[nhist];
582 // for (Int_t j=0;j<nhist;j++){
583 // cout<<">";
584 // cin>>name[j];
585 // }
586 // }
9af24f46 587
588 TList* list;
589 TH1F * hstat;
590
1fc8d3c0 591 Bool_t isRead=ReadFile(list,hstat,listname,Form("%s%s",partname.Data(),name1.Data()),path);
9af24f46 592 if(!isRead) return;
593 if(!list || !hstat){
594 cout<<":-( null pointers..."<<endl;
595 return;
596 }
1ff03d38 597
1fc8d3c0 598 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
599 pvtxt->SetBorderSize(0);
600 pvtxt->SetFillStyle(0);
601 pvtxt->AddText(name1);
602
603 TList* llist;
604 TH1F* hhstat;
605 if(superimpose){
606 isRead=ReadFile(llist,hhstat,listname,Form("%s%s",partname.Data(),name2.Data()),path);
607 if(!isRead) return;
608 if(!llist || !hhstat){
609 cout<<":-( null pointers..."<<endl;
610 return;
611 }
612 TText *redtext=pvtxt->AddText(name2);
613 redtext->SetTextColor(kRed);
614
615 }
616
617
82f89d0d 618 TCanvas* cst=new TCanvas("cst","Stat");
619 cst->SetGridy();
620 cst->cd();
1ff03d38 621 Int_t nevents=hstat->Integral(1,2);
82f89d0d 622 hstat->Draw("htext0");
623 cst->SaveAs(Form("%s%s.png",hstat->GetName(),textleg.Data()));
1ff03d38 624 Int_t nevents080=1;
625
ac0c2841 626 //TCanvas *spare=new TCanvas("sparecv","Spare");
627
1ff03d38 628 for(Int_t i=0;i<list->GetEntries();i++){
629
630 TClass* objtype=list->At(i)->IsA();
631 TString tpname=objtype->GetName();
632
633 if(tpname=="TH1F"){
634
635 TH1F* h=(TH1F*)list->At(i);
1fc8d3c0 636 TH1F* hh=0x0;
637 if(superimpose){
638 hh=(TH1F*)llist->At(i);
639 }
640 if(!h || (superimpose && !hh)){
1ff03d38 641 cout<<"Histogram "<<i<<" not found"<<endl;
642 continue;
643 }
1fc8d3c0 644 if(superimpose){
645 hhstat->SetLineColor(kRed);
646 hh->SetLineColor(kRed);
647 }
648
1ff03d38 649 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
1fc8d3c0 650 TPaveText *pvtxt2=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
651 pvtxt2->SetBorderSize(0);
652 pvtxt2->SetFillStyle(0);
1ff03d38 653
654 c->cd();
655 c->SetGrid();
1fc8d3c0 656 c->SetLogy();
1ff03d38 657 Int_t entries=h->Integral();
1fc8d3c0 658 pvtxt2->AddText(Form("%.1f per cent of the events",(Double_t)entries/(Double_t)nevents));
1ff03d38 659 h->Draw();
1fc8d3c0 660 if(superimpose) {
661 hh->Draw("sames");
662 pvtxt->Draw();
663 }
664 pvtxt2->Draw();
1ff03d38 665 c->SaveAs(Form("%s%s.png",c->GetName(),textleg.Data()));
666 }
667 if(tpname=="TH2F"){
668 TH2F* h=(TH2F*)list->At(i);
669 if(!h){
670 cout<<"Histogram "<<i<<" not found"<<endl;
671 continue;
672 }
673 TCanvas* c=new TCanvas(Form("c%s",h->GetName()),h->GetName());
674 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
675 pvtxt->SetBorderSize(0);
676 pvtxt->SetFillStyle(0);
677
678 c->cd();
679 c->SetGrid();
680 Int_t entries=h->Integral();
681 pvtxt->AddText(Form("%.1f per cent of the events",(Double_t)entries/(Double_t)nevents));
682 h->Draw("colz");
683 c->SetLogz();
684 pvtxt->Draw();
685 c->SaveAs(Form("%s%s.png",c->GetName(),textleg.Data()));
686 }
687 }
688
82f89d0d 689
690 listname="countersCentrality";
691
692 isRead=ReadFile(list,hstat,listname,partname,path);
693 if(!isRead) return;
694 if(!list || !hstat){
695 cout<<":-( null pointers..."<<endl;
696 return;
697 }
1ff03d38 698
699 TH1F* hallcntr=0x0;
700 cout<<"normalizing to 0-80% as a check"<<endl;
701
702 TCanvas *cvnocnt=new TCanvas("cvnocnt","No Centrality estimation",800,400);
703 cvnocnt->Divide(2,1);
704
82f89d0d 705 for(Int_t i=0;i<list->GetEntries();i++){
706 AliCounterCollection* coll=(AliCounterCollection*)list->At(i);
707
708 coll->SortRubric("run");//sort by run number
709 //coll->PrintKeyWords();
710 Int_t ncentr=10;//check this
711 TH1F* h020=0x0;
712 TH1F* h2080=0x0;
1ff03d38 713 hallcntr=0x0;
714
715 TH1F* hbad=(TH1F*)coll->Get("run",Form("centralityclass:-990_-980"));
716 cvnocnt->cd(i+1);
717 if(hbad) hbad->Draw();
718
82f89d0d 719 TCanvas *ccent=new TCanvas(Form("ccent%s",coll->GetName()),Form("Centrality vs Run (%s)",coll->GetName()),1400,800);
720 ccent->Divide(5,3);
721
1ff03d38 722 for(Int_t ic=0;ic<8/*ncentr*/;ic++){ //normalizing to 0-80% as a check
723
724 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
725 h->SetName(Form("h%d%d",i,ic));
726 if(!hallcntr) {
727 hallcntr=(TH1F*)h->Clone("hallcntr");
728 hallcntr->Sumw2();
1fc8d3c0 729 } else hallcntr->Add(h);
730
1ff03d38 731 nevents080+=h->Integral();
732 }
733
82f89d0d 734 for(Int_t ic=0;ic<ncentr;ic++){
735
736 TH1F* h=(TH1F*)coll->Get("run",Form("centralityclass:%d_%d",ic*10,ic*10+10));
737 h->SetName(Form("h%d%d",i,ic));
1ff03d38 738 h->Sumw2();
739
82f89d0d 740 if(ic>=0 && ic<=1){ //0-20
741 if(!h020) {
742 h020=(TH1F*)h->Clone(Form("h020%s",coll->GetName()));
743 h020->SetTitle(Form("Centrality 0-20 %s",coll->GetName()));
744 }
745 else h020->Add(h);
746 }
747 if(ic>=2 && ic<=7){ //20-80
748 if(!h2080) {
749 h2080=(TH1F*)h->Clone(Form("h2080%s",coll->GetName()));
750 h2080->SetTitle(Form("Centrality 20-80 %s",coll->GetName()));
751 }
752 else h2080->Add(h);
753 }
754
1ff03d38 755 h->Divide(hallcntr);
756
82f89d0d 757 ccent->cd(ic+1);
1ff03d38 758 h->GetYaxis()->SetRangeUser(0.,0.15);
82f89d0d 759 h->DrawClone();
ac0c2841 760 /*
761 if(ic==0&&i==0){
762 spare->cd();
763 h->Draw();
764 }
765 */
82f89d0d 766 // ccent->cd(1);
767 // h->SetLineColor(ic+1);
768 // if(ic==0)h->DrawClone();
769 // else h->DrawClone("sames");
770 }
771
772 ccent->cd(ncentr+1);
1ff03d38 773 h020->Divide(hallcntr);
774 h020->DrawClone();
1fc8d3c0 775 TCanvas* cv020=new TCanvas(Form("cv020-%d",i),"0-20% vs run number",1400,600);
1ff03d38 776 cv020->cd();
777 h020->GetYaxis()->SetRangeUser(0.,1.);
82f89d0d 778 h020->DrawClone();
1ff03d38 779 cv020->SaveAs(Form("cv020-%d.png",i));
82f89d0d 780
781 ccent->cd(ncentr+2);
1ff03d38 782 h2080->Divide(hallcntr);
82f89d0d 783 h2080->DrawClone();
784
1fc8d3c0 785 TCanvas* cv2080=new TCanvas(Form("cv2080-%d",i),"20-80% vs run number",1400,600);
1ff03d38 786 cv2080->cd();
787 h2080->GetYaxis()->SetRangeUser(0.,1.);
788 h2080->DrawClone();
789 cv2080->SaveAs(Form("cv2080-%d.png",i));
790
82f89d0d 791 ccent->SaveAs(Form("%s%s.png",ccent->GetName(),textleg.Data()));
9af24f46 792 }
793
794}
1ff03d38 795
796void DrawProjections(TString partname="D0",TString h2dname="hMultvsPercentile",Int_t nsteps=0,TString direction="X",TString path="./"){
797 gStyle->SetCanvasColor(0);
798 gStyle->SetTitleFillColor(0);
799 gStyle->SetStatColor(0);
29df3603 800 gStyle->SetPalette(1);
1ff03d38 801
802 TString listname="outputCentrCheck";
803
804 TList* list;
805 TH1F * hstat;
806
807 Bool_t isRead=ReadFile(list,hstat,listname,partname,path);
808 if(!isRead) return;
809 if(!list || !hstat){
810 cout<<":-( null pointers..."<<endl;
811 return;
812 }
1fc8d3c0 813 Double_t nevents=hstat->Integral(5,6); //ev good vertex
1ff03d38 814
815 TH2F* h2=(TH2F*)list->FindObject(h2dname);
816 if(!h2){
817 cout<<h2dname.Data()<<" not found"<<endl;
818 return;
819 }
29df3603 820 TCanvas* cv2d=new TCanvas("cv2d",h2->GetName());
821 cv2d->cd();
822 cv2d->SetLogz();
1fc8d3c0 823 cv2d->SetGrid();
29df3603 824 h2->Draw("colz");
1fc8d3c0 825 TPaveText *pvst=new TPaveText(0.6,0.2,0.9,0.7,"NDC");
826 pvst->SetBorderSize(0);
827 pvst->SetFillStyle(0);
828 pvst->AddText("Bin -> Cont/nEvVtx");
829
29df3603 830
1ff03d38 831 Int_t kbins=1;
832 if(nsteps==0){
833 if(direction=="X") nsteps=h2->GetNbinsY();
834 if(direction=="Y") nsteps=h2->GetNbinsX();
835 }
836 else{
837 if(direction=="X") kbins=h2->GetNbinsY()/nsteps;
838 if(direction=="Y") kbins=h2->GetNbinsX()/nsteps;
839 }
840
841 TCanvas *cvpj=new TCanvas(Form("cvpj%s%s",direction.Data(),h2dname.Data()),Form("cvpj%s",direction.Data()),1000,800);
842 cvpj->Divide((Int_t)(nsteps/3)+1,3);
843 TFile* fout=new TFile(Form("proj%s%s.root",direction.Data(),h2dname.Data()), "recreate");
1fc8d3c0 844 //Float_t maxx[nsteps];
845 Float_t maxx[12]={9000,9000,6000,4000,2000,1400,800,500,200,100,40,25};
846 Double_t integralpernev[nsteps];
847
1ff03d38 848 for(Int_t i=0;i<nsteps;i++){
849 TH1F* h=0x0;
850 if(direction=="X")h=(TH1F*)h2->ProjectionX(Form("px%d",i),i+kbins,i+2*kbins);
851 if(direction=="Y")h=(TH1F*)h2->ProjectionY(Form("py%d",i),i+kbins,i+2*kbins);
1fc8d3c0 852 integralpernev[i]=h->Integral()/nevents;
ac0c2841 853
854 TPaveText *pvtxt=new TPaveText(0.6,0.6,0.9,0.9,"NDC");
855 pvtxt->SetBorderSize(0);
856 pvtxt->SetFillStyle(0);
1fc8d3c0 857 pvtxt->AddText(Form("%.0f - %.0f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins))));
858 pvst->AddText(Form("%.0f - %.0f -> %.2f",h2->GetYaxis()->GetBinLowEdge((i+kbins)),h2->GetYaxis()->GetBinLowEdge((i+2*kbins)),integralpernev[i]));
1ff03d38 859 cvpj->cd(i+1);
1fc8d3c0 860 h->GetXaxis()->SetRangeUser(0,maxx[i]);
1ff03d38 861 h->Draw();
ac0c2841 862 pvtxt->Draw();
1ff03d38 863 fout->cd();
864 h->Write();
865 }
866 cvpj->SaveAs(Form("cvpj%s%s.png",direction.Data(),h2dname.Data()));
867
1fc8d3c0 868 cv2d->cd();
869 pvst->Draw();
870 cv2d->SaveAs(Form("%s.png",h2->GetName()));
871
1ff03d38 872}