1 const char * tag = "_Hadrons_QA_PbPb";
3 Float_t gpTMax = 49.99;
4 const char* lastFileName = 0;
5 void* cacheSameEvent = 0;
6 void* cacheMixedEvent = 0;
8 void processMakeQA2pc(const char * filename="AnalysisResults", //file name without ".root"
9 TString suffix = "eps",
10 const char *outfile="MakeQA2pc_output.root"){
13 if (!gGrid && TString(filename).BeginsWith("alien://"))
14 TGrid::Connect("alien://");
17 FillParentTHnSparse(Form("%s.root",filename),kFALSE,tag);
19 Double_t ptTmin[]={0.5,0.5,2.0,2.0};
20 Double_t ptTmax[]={1.0,1.0,4.0,4.0};
21 Double_t ptAmin[]={0.5,0.5,2.0,2.0};
22 Double_t ptAmax[]={1.0,1.0,4.0,4.0};
23 Int_t centBegin[]={ 0, 60, 0, 60};
24 Int_t centEnd[]={ 10, 90, 10, 90};
28 for(Int_t i=0;i<4;i++){
29 TCanvas *c=new TCanvas(Form("c%d",i),Form("c%d",i),1200,1200);
30 DrawSameMixedSV(Form("%s_zvtx.root",filename),ptTmin[i],ptTmax[i],ptAmin[i],ptAmax[i],centBegin[i],centEnd[i],8,c,i,outfile);
31 c->SaveAs(Form("fig_cf_c%d.%s",i,suffix.Data()));
34 TCanvas *ccorr=new TCanvas("ccorr","ccorr",1200,1200);
35 DrawCorrelation(Form("%s_zvtx.root",filename),ccorr,outfile);
38 ccorr->SaveAs(Form("fig_cf_ccorr.%s",suffix.Data()));
42 void SetupRanges(void* obj)
46 ((AliUEHistograms*) obj)->SetEtaRange(0, 0);
47 ((AliUEHistograms*) obj)->SetPtRange(gpTMin, gpTMax);
48 ((AliUEHistograms*) obj)->SetCombineMinMax(kTRUE);
51 void DrawCorrelation(const char* fileName,TCanvas *c,const char *outfile){
53 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
57 h->((TH2F*)h->GetCorrelationpT())->DrawCopy("colz")->GetYaxis()->SetRangeUser(0.,20.);
59 h->((TH2F*)h->GetCorrelationEta())->DrawCopy("colz")->GetYaxis()->SetRangeUser(-1.5,1.5);
61 h->((TH2F*)h->GetCorrelationPhi())->DrawCopy("colz");
64 TFile *fout = TFile::Open(outfile,"UPDATE");
67 TDirectoryFile *cdd = NULL;
68 cdd = (TDirectoryFile*)fout->Get("CF");
70 Printf("Warning: CF <dir> doesn't exist, creating a new one");
71 cdd = (TDirectoryFile*)fout->mkdir("CF");
77 TH2F *h1 = (TH2F*)h->((TH2F*)h->GetCorrelationpT())->Clone();
78 TH2F *h2 = (TH2F*)h->((TH2F*)h->GetCorrelationEta())->Clone();
79 TH2F *h3 = (TH2F*)h->((TH2F*)h->GetCorrelationPhi())->Clone();
88 void DrawSameMixed(const char* fileName,Double_t ptTmin,Double_t ptTmax,Double_t ptAmin,Double_t ptAmax,Int_t centBegin,Int_t centEnd,Int_t step = 8,TCanvas *c)
91 TPaveText* paveText = new TPaveText(0.2, 0.9, 1., 1., "BRNDC");
92 paveText->SetTextSize(0.04);
93 paveText->SetFillColor(0);
94 paveText->SetShadowColor(0);
95 paveText->SetBorderSize(0);
96 paveText->SetFillStyle(0);
97 paveText->AddText(Form("%.1f<p_{T,trig}<%.1f, %.1f<p_{T,ass}<%.1f, %d-%d %%",ptTmin,ptTmax,ptAmin,ptAmax,centBegin,centEnd));
101 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
102 hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
112 GetDistAndFlow(h, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
114 NormalizeToBinWidth(hist1);
117 gPad->SetLeftMargin(0.15);
119 hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
120 hist1->GetZaxis()->SetTitleOffset(1.8);
121 hist1->GetXaxis()->SetTitleOffset(1.5);
122 hist1->GetYaxis()->SetTitleOffset(2);
123 hist1->GetZaxis()->SetTitle("same event pairs (a.u.)");
124 hist1->SetStats(kFALSE);
125 hist1->DrawCopy("SURF1");
128 ((TH2*) hist1)->ProjectionX()->DrawCopy();
130 ((TH2*) hist1)->ProjectionY()->DrawCopy();
134 GetDistAndFlow(hMixed, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
135 NormalizeToBinWidth(hist1);
138 gPad->SetLeftMargin(0.15);
140 hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
141 hist1->GetZaxis()->SetTitleOffset(1.8);
142 hist1->GetXaxis()->SetTitleOffset(1.5);
143 hist1->GetYaxis()->SetTitleOffset(2);
144 hist1->GetZaxis()->SetTitle("mixed event pairs (a.u.)");
145 hist1->SetStats(kFALSE);
146 hist1->DrawCopy("SURF1");
148 ((TH2*) hist1)->ProjectionX()->DrawCopy();
150 ((TH2*) hist1)->ProjectionY()->DrawCopy();
153 gPad->SetLeftMargin(0.15);
154 hist2->GetZaxis()->SetTitle("same/mixed event pairs (a.u.)");
155 hist2->Divide(hist1);
156 hist2->DrawCopy("SURF1");
158 ((TH2*) hist2)->ProjectionX()->DrawCopy();
160 ((TH2*) hist2)->ProjectionY()->DrawCopy();
165 void DrawSameMixedSV(const char* fileName,Double_t ptTmin,Double_t ptTmax,Double_t ptAmin,Double_t ptAmax,Int_t centBegin,Int_t centEnd,Int_t step = 8,TCanvas *c, Int_t key, const char *outfile)
168 TPaveText* paveText = new TPaveText(0.2, 0.9, 1., 1., "BRNDC");
169 paveText->SetTextSize(0.04);
170 paveText->SetFillColor(0);
171 paveText->SetShadowColor(0);
172 paveText->SetBorderSize(0);
173 paveText->SetFillStyle(0);
174 paveText->AddText(Form("%.1f<p_{T,trig}<%.1f, %.1f<p_{T,ass}<%.1f, %d-%d %%",ptTmin,ptTmax,ptAmin,ptAmax,centBegin,centEnd));
178 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
179 hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
189 GetDistAndFlow(h, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
191 NormalizeToBinWidth(hist1);
194 gPad->SetLeftMargin(0.15);
196 hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
197 hist1->GetZaxis()->SetTitleOffset(1.8);
198 hist1->GetXaxis()->SetTitleOffset(1.5);
199 hist1->GetYaxis()->SetTitleOffset(2);
200 hist1->GetZaxis()->SetTitle("same event pairs (a.u.)");
201 hist1->SetStats(kFALSE);
202 hist1->DrawCopy("SURF1");
205 TFile *fout = TFile::Open(outfile,"UPDATE");
208 TDirectoryFile *cdd = NULL;
209 cdd = (TDirectoryFile*)fout->Get("CF");
211 Printf("Warning: CF <dir> doesn't exist, creating a new one");
212 cdd = (TDirectoryFile*)fout->mkdir("CF");
218 TH1D *h1 = (TH1D*)hist1->Clone();
219 h1->SetName(Form("fig_cf_cr1_%d",key));
220 h1->SetTitle(hist1->GetName());
226 ((TH2*) hist1)->ProjectionX()->DrawCopy();
228 TH2D *h2 = (TH2D*)((TH2*) hist1)->ProjectionX();
229 h2->SetTitle(h2->GetName());
230 h2->SetName(Form("fig_cf_cr2_%d", key));
234 ((TH2*) hist1)->ProjectionY()->DrawCopy();
236 TH2D *h3 = (TH2D*)((TH2*) hist1)->ProjectionY();
237 h3->SetTitle(h3->GetName());
238 h3->SetName(Form("fig_cf_cr3_%d",key));
246 GetDistAndFlow(hMixed, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
247 NormalizeToBinWidth(hist1);
250 gPad->SetLeftMargin(0.15);
252 hist1->GetYaxis()->SetRangeUser(-1.79, 1.79);
253 hist1->GetZaxis()->SetTitleOffset(1.8);
254 hist1->GetXaxis()->SetTitleOffset(1.5);
255 hist1->GetYaxis()->SetTitleOffset(2);
256 hist1->GetZaxis()->SetTitle("mixed event pairs (a.u.)");
257 hist1->SetStats(kFALSE);
258 hist1->DrawCopy("SURF1");
260 TH1D *h4 = (TH1D*)hist1->Clone();
261 h4->SetTitle(hist1->GetName());
262 h4->SetName(Form("fig_cf_cr4_%d",key));
270 ((TH2*) hist1)->ProjectionX()->DrawCopy();
272 TH2D *h5 = (TH2D*)((TH2*) hist1)->ProjectionX();
273 h5->SetTitle(h5->GetName());
274 h5->SetName(Form("fig_cf_cr5_%d",key));
281 ((TH2*) hist1)->ProjectionY()->DrawCopy();
283 TH2D *h6 = (TH2D*)((TH2*) hist1)->ProjectionY();
284 h6->SetTitle(h6->GetName());
285 h6->SetName(Form("fig_cf_cr6_%d",key));
290 gPad->SetLeftMargin(0.15);
291 hist2->GetZaxis()->SetTitle("same/mixed event pairs (a.u.)");
292 hist2->Divide(hist1);
293 hist2->DrawCopy("SURF1");
296 TH1D *h7 = (TH1D*)hist2->Clone();
297 h7->SetTitle(hist2->GetName());
298 h7->SetName(Form("fig_cf_cr7_%d",key));
303 ((TH2*) hist2)->ProjectionX()->DrawCopy();
305 TH2D *h8 = (TH2D*)((TH2*) hist2)->ProjectionX();
306 h8->SetTitle(h8->GetName());
307 h8->SetName(Form("fig_cf_cr8_%d",key));
312 ((TH2*) hist2)->ProjectionY()->DrawCopy();
314 TH2D *h9 = (TH2D*)((TH2*) hist2)->ProjectionY();
315 h9->SetTitle(h9->GetName());
316 h9->SetName(Form("fig_cf_cr9_%d",key));
325 gSystem->Load("libANALYSIS");
326 gSystem->Load("libANALYSISalice");
327 gSystem->Load("libCORRFW");
328 gSystem->Load("libPWGTools");
329 gSystem->Load("libPWGCFCorrelationsBase");
332 void FillParentTHnSparse(const char* fileName, Bool_t reduce = kFALSE, const char* tag = "")
334 if (TString(fileName).BeginsWith("alien:"))
335 TGrid::Connect("alien:");
341 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName, &list, kFALSE, tag);
344 Printf("We have %d axes", ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0)->GetNVar()));
347 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->ReduceAxis();
348 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->FillParent();
349 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->DeleteContainers();
351 AliUEHistograms* hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE, tag);
353 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->ReduceAxis();
354 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->FillParent();
355 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->DeleteContainers();
357 TString newFileName(fileName);
359 if (TString(fileName).BeginsWith("alien:"))
360 newFileName = gSystem->BaseName(newFileName);
362 newFileName.ReplaceAll(".root", "");
364 newFileName += "_.root";
366 newFileName += "_zvtx.root";
368 file3 = TFile::Open(newFileName, "RECREATE");
369 file3->mkdir("PWG4_PhiCorrelations");
370 file3->cd("PWG4_PhiCorrelations");
371 list->Write("histosPhiCorrelations", TObject::kSingleKey);
375 void* GetUEHistogram(const char* fileName, TList** listRef = 0, Bool_t mixed = kFALSE, const char* tag = "")
377 if (!lastFileName || strcmp(lastFileName, fileName) != 0)
379 lastFileName = fileName;
380 file = TFile::Open(fileName);
384 list = (TList*) gFile->Get("PWG4_LeadingTrackUE/histosLeadingTrackUE");
386 list = (TList*) gFile->Get(Form("PWG4_PhiCorrelations/histosPhiCorrelations%s", tag));
388 list = (TList*) gFile->Get("PWG4_PhiCorrelations/histosPhiCorrelations_Syst");
396 cacheMixedEvent = list->FindObject("AliUEHistogramsMixed");
397 cacheSameEvent = list->FindObject("AliUEHistogramsSame");
400 return cacheMixedEvent;
402 if (list->FindObject("AliUEHistograms"))
403 return list->FindObject("AliUEHistograms");
405 return cacheSameEvent;
409 Printf("GetUEHistogram --> Using cache for %s", fileName);
412 return cacheMixedEvent;
414 return cacheSameEvent;
419 Int_t gHistCount = 0;
421 void GetDistAndFlow(void* hVoid, TH1** hist, Int_t step, Int_t centralityBegin, Int_t centralityEnd, Float_t ptBegin, Float_t ptEnd)
423 h = (AliUEHistograms*) hVoid;
425 Int_t centralityBeginBin = 0;
426 Int_t centralityEndBin = -1;
428 if (centralityEnd >= centralityBegin)
430 centralityBeginBin = h->GetUEHist(2)->GetEventHist()->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(0.01 + centralityBegin);
431 centralityEndBin = h->GetUEHist(2)->GetEventHist()->GetGrid(step)->GetGrid()->GetAxis(1)->FindBin(-0.01 + centralityEnd);
434 // 2d same and mixed event
435 TH2* sameTwoD = h->GetUEHist(2)->GetUEHist(step, 0, ptBegin, ptEnd, centralityBeginBin, centralityEndBin, 1, kFALSE);
438 histName.Form("GetDistAndFlow%d", gHistCount++);
443 str.Form("%.1f < p_{T,trig} < %.1f", ptBegin - 0.01, ptEnd + 0.01);
446 str2.Form("%.2f < p_{T,assoc} < %.2f", gpTMin - 0.01, gpTMax + 0.01);
449 newTitle.Form("%s - %s - %d-%d%%", str.Data(), str2.Data(), centralityBegin, centralityEnd);
450 (*hist)->SetTitle(newTitle);
454 void NormalizeToBinWidth(TH1* hist)
457 // normalizes a 1-d histogram to its bin width
460 if (hist->GetDimension() == 1)
462 for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
464 hist->SetBinContent(i, hist->GetBinContent(i) / hist->GetBinWidth(i));
465 hist->SetBinError(i, hist->GetBinError(i) / hist->GetBinWidth(i));
468 else if (hist->GetDimension() == 2)
470 for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
472 for (Int_t j=1; j<=hist->GetNbinsY(); ++j)
474 hist->SetBinContent(i, j, hist->GetBinContent(i, j) / hist->GetXaxis()->GetBinWidth(i) / hist->GetYaxis()->GetBinWidth(j));
475 hist->SetBinError(i, j, hist->GetBinError(i) / hist->GetXaxis()->GetBinWidth(i) / hist->GetYaxis()->GetBinWidth(j));