]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/analysisQA/processMakeQA2pc.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGPP / analysisQA / processMakeQA2pc.C
CommitLineData
948b38b2 1const char * tag = "_Hadrons_QA_PbPb";
2Float_t gpTMin = 0.51;
3Float_t gpTMax = 49.99;
4const char* lastFileName = 0;
5void* cacheSameEvent = 0;
6void* cacheMixedEvent = 0;
7
8void processMakeQA2pc(const char * filename="AnalysisResults", //file name without ".root"
9 TString suffix = "eps",
10 const char *outfile="MakeQA2pc_output.root"){
11
12 loadlibs();
13 if (!gGrid && TString(filename).BeginsWith("alien://"))
14 TGrid::Connect("alien://");
15
16 //fill CFContainers
17 FillParentTHnSparse(Form("%s.root",filename),kFALSE,tag);
18
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};
25
26
27
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()));
32 }
33
34 TCanvas *ccorr=new TCanvas("ccorr","ccorr",1200,1200);
35 DrawCorrelation(Form("%s_zvtx.root",filename),ccorr,outfile);
36
37
38 ccorr->SaveAs(Form("fig_cf_ccorr.%s",suffix.Data()));
39
40}
41
42void SetupRanges(void* obj)
43{
44 if (!obj)
45 return;
46 ((AliUEHistograms*) obj)->SetEtaRange(0, 0);
47 ((AliUEHistograms*) obj)->SetPtRange(gpTMin, gpTMax);
48 ((AliUEHistograms*) obj)->SetCombineMinMax(kTRUE);
49}
50
51void DrawCorrelation(const char* fileName,TCanvas *c,const char *outfile){
52
53 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
54 c->Divide(1,3);
55 c->cd(1);
56 gPad->SetLogz();
57 h->((TH2F*)h->GetCorrelationpT())->DrawCopy("colz")->GetYaxis()->SetRangeUser(0.,20.);
58 c->cd(2);
59 h->((TH2F*)h->GetCorrelationEta())->DrawCopy("colz")->GetYaxis()->SetRangeUser(-1.5,1.5);
60 c->cd(3);
61 h->((TH2F*)h->GetCorrelationPhi())->DrawCopy("colz");
62
63 //Added by sjena
64 TFile *fout = TFile::Open(outfile,"UPDATE");
65 fout->ls();
66
67 TDirectoryFile *cdd = NULL;
68 cdd = (TDirectoryFile*)fout->Get("CF");
69 if(!cdd) {
70 Printf("Warning: CF <dir> doesn't exist, creating a new one");
71 cdd = (TDirectoryFile*)fout->mkdir("CF");
72 }
73 cdd->cd();
74 cdd->ls();
75
76
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();
80 h1->Write();
81 h2->Write();
82 h3->Write();
83 fout->Close();
84
85}
86
87
88void 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)
89{
90 c->Divide(3, 3);
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));
98
99 loadlibs();
100
101 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
102 hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
103
104 gpTMin=ptAmin;
105 gpTMax=ptAmax;
106
107 SetupRanges(h);
108 SetupRanges(hMixed);
109
110 TH1* hist1 = 0;
111 TH1* hist2 = 0;
112 GetDistAndFlow(h, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
113
114 NormalizeToBinWidth(hist1);
115
116 c->cd(1);
117 gPad->SetLeftMargin(0.15);
118 hist1->SetTitle("");
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");
126 paveText->Draw();
127 c->cd(4);
128 ((TH2*) hist1)->ProjectionX()->DrawCopy();
129 c->cd(7);
130 ((TH2*) hist1)->ProjectionY()->DrawCopy();
131
132 hist2 = hist1;
133
134 GetDistAndFlow(hMixed, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
135 NormalizeToBinWidth(hist1);
136
137 c->cd(2);
138 gPad->SetLeftMargin(0.15);
139 hist1->SetTitle("");
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");
147 c->cd(5);
148 ((TH2*) hist1)->ProjectionX()->DrawCopy();
149 c->cd(8);
150 ((TH2*) hist1)->ProjectionY()->DrawCopy();
151
152 c->cd(3);
153 gPad->SetLeftMargin(0.15);
154 hist2->GetZaxis()->SetTitle("same/mixed event pairs (a.u.)");
155 hist2->Divide(hist1);
156 hist2->DrawCopy("SURF1");
157 c->cd(6);
158 ((TH2*) hist2)->ProjectionX()->DrawCopy();
159 c->cd(9);
160 ((TH2*) hist2)->ProjectionY()->DrawCopy();
161
162}
163
164
165void 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)
166{
167 c->Divide(3, 3);
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));
175
176 loadlibs();
177
178 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName);
179 hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE);
180
181 gpTMin=ptAmin;
182 gpTMax=ptAmax;
183
184 SetupRanges(h);
185 SetupRanges(hMixed);
186
187 TH1* hist1 = 0;
188 TH1* hist2 = 0;
189 GetDistAndFlow(h, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
190
191 NormalizeToBinWidth(hist1);
192
193 c->cd(1);
194 gPad->SetLeftMargin(0.15);
195 hist1->SetTitle("");
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");
203
204 //added by sjena
205 TFile *fout = TFile::Open(outfile,"UPDATE");
206 fout->ls();
207
208 TDirectoryFile *cdd = NULL;
209 cdd = (TDirectoryFile*)fout->Get("CF");
210 if(!cdd) {
211 Printf("Warning: CF <dir> doesn't exist, creating a new one");
212 cdd = (TDirectoryFile*)fout->mkdir("CF");
213 }
214 cdd->cd();
215 cdd->ls();
216
217
218 TH1D *h1 = (TH1D*)hist1->Clone();
219 h1->SetName(Form("fig_cf_cr1_%d",key));
220 h1->SetTitle(hist1->GetName());
221 h1->Write();
222
223
224 paveText->Draw();
225 c->cd(4);
226 ((TH2*) hist1)->ProjectionX()->DrawCopy();
227
228 TH2D *h2 = (TH2D*)((TH2*) hist1)->ProjectionX();
229 h2->SetTitle(h2->GetName());
230 h2->SetName(Form("fig_cf_cr2_%d", key));
231 h2->Write();
232
233 c->cd(7);
234 ((TH2*) hist1)->ProjectionY()->DrawCopy();
235 //ofile->cd();
236 TH2D *h3 = (TH2D*)((TH2*) hist1)->ProjectionY();
237 h3->SetTitle(h3->GetName());
238 h3->SetName(Form("fig_cf_cr3_%d",key));
239 h3->Write();
240
241
242
243
244 hist2 = hist1;
245
246 GetDistAndFlow(hMixed, &hist1, step, centBegin, centEnd, ptTmin, ptTmax);
247 NormalizeToBinWidth(hist1);
248
249 c->cd(2);
250 gPad->SetLeftMargin(0.15);
251 hist1->SetTitle("");
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");
259 //ofile->cd();
260 TH1D *h4 = (TH1D*)hist1->Clone();
261 h4->SetTitle(hist1->GetName());
262 h4->SetName(Form("fig_cf_cr4_%d",key));
263 h4->Write();
264
265
266
267
268
269 c->cd(5);
270 ((TH2*) hist1)->ProjectionX()->DrawCopy();
271 //ofile->cd();
272 TH2D *h5 = (TH2D*)((TH2*) hist1)->ProjectionX();
273 h5->SetTitle(h5->GetName());
274 h5->SetName(Form("fig_cf_cr5_%d",key));
275 h5->Write();
276
277
278
279
280 c->cd(8);
281 ((TH2*) hist1)->ProjectionY()->DrawCopy();
282 //ofile->cd();
283 TH2D *h6 = (TH2D*)((TH2*) hist1)->ProjectionY();
284 h6->SetTitle(h6->GetName());
285 h6->SetName(Form("fig_cf_cr6_%d",key));
286 h6->Write();
287
288
289 c->cd(3);
290 gPad->SetLeftMargin(0.15);
291 hist2->GetZaxis()->SetTitle("same/mixed event pairs (a.u.)");
292 hist2->Divide(hist1);
293 hist2->DrawCopy("SURF1");
294 //ofile->cd();
295
296 TH1D *h7 = (TH1D*)hist2->Clone();
297 h7->SetTitle(hist2->GetName());
298 h7->SetName(Form("fig_cf_cr7_%d",key));
299 h7->Write();
300
301
302 c->cd(6);
303 ((TH2*) hist2)->ProjectionX()->DrawCopy();
304 //ofile->cd();
305 TH2D *h8 = (TH2D*)((TH2*) hist2)->ProjectionX();
306 h8->SetTitle(h8->GetName());
307 h8->SetName(Form("fig_cf_cr8_%d",key));
308 h8->Write();
309
310
311 c->cd(9);
312 ((TH2*) hist2)->ProjectionY()->DrawCopy();
313 //ofile->cd();
314 TH2D *h9 = (TH2D*)((TH2*) hist2)->ProjectionY();
315 h9->SetTitle(h9->GetName());
316 h9->SetName(Form("fig_cf_cr9_%d",key));
317 h9->Write();
318
319 fout->Close();
320}
321
322
323void loadlibs()
324{
325 gSystem->Load("libANALYSIS");
326 gSystem->Load("libANALYSISalice");
327 gSystem->Load("libCORRFW");
328 gSystem->Load("libPWGTools");
329 gSystem->Load("libPWGCFCorrelationsBase");
330}
331
332void FillParentTHnSparse(const char* fileName, Bool_t reduce = kFALSE, const char* tag = "")
333{
334 if (TString(fileName).BeginsWith("alien:"))
335 TGrid::Connect("alien:");
336
337 loadlibs();
338
339 TList* list = 0;
340
341 AliUEHistograms* h = (AliUEHistograms*) GetUEHistogram(fileName, &list, kFALSE, tag);
342
343
344 Printf("We have %d axes", ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0)->GetNVar()));
345
346 if (reduce)
347 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->ReduceAxis();
348 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->FillParent();
349 ((AliTHn*) h->GetUEHist(2)->GetTrackHist(0))->DeleteContainers();
350
351 AliUEHistograms* hMixed = (AliUEHistograms*) GetUEHistogram(fileName, 0, kTRUE, tag);
352 if (reduce)
353 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->ReduceAxis();
354 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->FillParent();
355 ((AliTHn*) hMixed->GetUEHist(2)->GetTrackHist(0))->DeleteContainers();
356
357 TString newFileName(fileName);
358
359 if (TString(fileName).BeginsWith("alien:"))
360 newFileName = gSystem->BaseName(newFileName);
361
362 newFileName.ReplaceAll(".root", "");
363 if (reduce)
364 newFileName += "_.root";
365 else
366 newFileName += "_zvtx.root";
367
368 file3 = TFile::Open(newFileName, "RECREATE");
369 file3->mkdir("PWG4_PhiCorrelations");
370 file3->cd("PWG4_PhiCorrelations");
371 list->Write("histosPhiCorrelations", TObject::kSingleKey);
372 file3->Close();
373}
374
375void* GetUEHistogram(const char* fileName, TList** listRef = 0, Bool_t mixed = kFALSE, const char* tag = "")
376{
377 if (!lastFileName || strcmp(lastFileName, fileName) != 0)
378 {
379 lastFileName = fileName;
380 file = TFile::Open(fileName);
381 if (!file)
382 return 0;
383
384 list = (TList*) gFile->Get("PWG4_LeadingTrackUE/histosLeadingTrackUE");
385 if (!list)
386 list = (TList*) gFile->Get(Form("PWG4_PhiCorrelations/histosPhiCorrelations%s", tag));
387 if (!list)
388 list = (TList*) gFile->Get("PWG4_PhiCorrelations/histosPhiCorrelations_Syst");
389
390 if (!list)
391 return 0;
392
393 if (listRef)
394 *listRef = list;
395
396 cacheMixedEvent = list->FindObject("AliUEHistogramsMixed");
397 cacheSameEvent = list->FindObject("AliUEHistogramsSame");
398
399 if (mixed)
400 return cacheMixedEvent;
401
402 if (list->FindObject("AliUEHistograms"))
403 return list->FindObject("AliUEHistograms");
404
405 return cacheSameEvent;
406 }
407 else
408 {
409 Printf("GetUEHistogram --> Using cache for %s", fileName);
410
411 if (mixed)
412 return cacheMixedEvent;
413 else
414 return cacheSameEvent;
415 }
416}
417
418
419Int_t gHistCount = 0;
420
421void GetDistAndFlow(void* hVoid, TH1** hist, Int_t step, Int_t centralityBegin, Int_t centralityEnd, Float_t ptBegin, Float_t ptEnd)
422{
423 h = (AliUEHistograms*) hVoid;
424
425 Int_t centralityBeginBin = 0;
426 Int_t centralityEndBin = -1;
427
428 if (centralityEnd >= centralityBegin)
429 {
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);
432 }
433
434 // 2d same and mixed event
435 TH2* sameTwoD = h->GetUEHist(2)->GetUEHist(step, 0, ptBegin, ptEnd, centralityBeginBin, centralityEndBin, 1, kFALSE);
436
437 TString histName;
438 histName.Form("GetDistAndFlow%d", gHistCount++);
439
440 *hist = sameTwoD;
441
442 TString str;
443 str.Form("%.1f < p_{T,trig} < %.1f", ptBegin - 0.01, ptEnd + 0.01);
444
445 TString str2;
446 str2.Form("%.2f < p_{T,assoc} < %.2f", gpTMin - 0.01, gpTMax + 0.01);
447
448 TString newTitle;
449 newTitle.Form("%s - %s - %d-%d%%", str.Data(), str2.Data(), centralityBegin, centralityEnd);
450 (*hist)->SetTitle(newTitle);
451
452}
453
454void NormalizeToBinWidth(TH1* hist)
455{
456 //
457 // normalizes a 1-d histogram to its bin width
458 //
459
460 if (hist->GetDimension() == 1)
461 {
462 for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
463 {
464 hist->SetBinContent(i, hist->GetBinContent(i) / hist->GetBinWidth(i));
465 hist->SetBinError(i, hist->GetBinError(i) / hist->GetBinWidth(i));
466 }
467 }
468 else if (hist->GetDimension() == 2)
469 {
470 for (Int_t i=1; i<=hist->GetNbinsX(); ++i)
471 {
472 for (Int_t j=1; j<=hist->GetNbinsY(); ++j)
473 {
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));
476 }
477 }
478 }
479}