AliPhysics  vAN-20150429 (ffa5c54)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
DrawAnaCaloTrackQA.C
Go to the documentation of this file.
1 
17 
18 // Some global variables
19 TList *list = 0;
20 TFile *file = 0;
21 TString histoTag = "";
22 Int_t color[]={kBlack,kRed,kOrange+1,kYellow+1,kGreen+2,kBlue,kCyan+1,kViolet,kMagenta+2,kGray};
23 
24 //_______________________________________________________________________
35 //_______________________________________________________________________
36 void DrawAnaCaloTrackQA(TString listName = "Pi0IM_GammaTrackCorr_EMCAL_default",
37  TString fileName = "AnalysisResults.root",
38  Bool_t export = kFALSE)
39 {
40  printf("Open <%s>; Get List : <%s>; Export list? <%d>\n",fileName.Data(),listName.Data(),export);
41 
42  histoTag = listName;
43 
44  //Access the file and list of histograms, global variables
45  GetFileAndList(fileName, listName, export);
46 
47  gStyle->SetOptTitle(1);
48  gStyle->SetOptStat(0);
49  gStyle->SetOptFit(000000);
50  gStyle->SetPadRightMargin(0.15);
51  //gStyle->SetPadTopMargin(0.02);
52  //gStyle->SetPadLeftMargin(0.15);
53  gStyle->SetTitleFontSize(0.06);
54 
55  //Plot basic Calorimeter QA
56  CaloQA();
57 
58  //Plot basic Track QA
59  TrackQA();
60 
61  //Plot basic Pi0 QA
62  Pi0QA();
63 
64  //Plot basic correlation QA
65  CorrelationQA();
66 
67  // MC basic QA plots, cluster origins (only if it run on MC)
68  MCQA();
69 }
70 
71 //______________________________________
72 // Plot basic calorimeter QA histograms.
73 //______________________________________
74 void CaloQA()
75 {
76  TCanvas * ccalo = new TCanvas(Form("CaloHisto_%s",histoTag.Data()),"",1000,1000);
77  ccalo->Divide(2,2);
78 
79  ccalo->cd(1);
80  gPad->SetLogy();
81 
82  TH1F* hCellAmplitude = (TH1F*) GetHisto("QA_hAmplitude");
83  TH1F* hClusterEnergy = (TH1F*) GetHisto("QA_hE");
84 
85  hClusterEnergy->SetYTitle("entries");
86  hClusterEnergy->SetTitle("Cluster-cell energy spectra");
87  hClusterEnergy->Sumw2();
88  hClusterEnergy->SetMarkerColor(1);
89  hClusterEnergy->SetMarkerStyle(20);
90  hClusterEnergy->SetAxisRange(0.,50.,"X");
91  hClusterEnergy->Draw();
92 
93  hCellAmplitude->Sumw2();
94  hCellAmplitude->SetMarkerColor(4);
95  hCellAmplitude->SetMarkerStyle(25);
96  hCellAmplitude->Draw("same");
97 
98  TLegend l(0.25,0.7,0.83,0.85);
99  l.SetTextSize(0.04);
100  l.AddEntry(hClusterEnergy,"Cluster (no exotic+non lin.)","P");
101  l.AddEntry(hCellAmplitude,"Cell","P");
102  l.SetBorderSize(0);
103  l.SetFillColor(0);
104  l.Draw();
105 
106 
107  ccalo->cd(2);
108  //gPad->SetLogy();
109 
110  TH1F* hRaw = (TH1F*) GetHisto("AnaPhoton_hPt_Cut_0_Open");
111  TH1F* hCorr = (TH1F*) GetHisto("AnaPhoton_hPt_Cut_4_NCells");
112  TH1F* hTM = (TH1F*) GetHisto("AnaPhoton_hPt_Cut_7_Matching");
113  TH1F* hShSh = (TH1F*) GetHisto("AnaPhoton_hPt_Cut_9_PID");
114 
115  hRaw->Sumw2();
116 
117  hCorr->SetTitle("Ratio after cluster cuts application");
118  hCorr->SetYTitle("Selected clusters / Raw clusters");
119  hCorr->SetTitleOffset(1.5,"Y");
120  hCorr->Sumw2();
121  hCorr->SetMarkerColor(1);
122  hCorr->SetMarkerStyle(20);
123  hCorr->Divide(hRaw);
124  hCorr->SetAxisRange(0.,30.,"X");
125  hCorr->SetMaximum(1.1);
126  hCorr->SetMinimum(0);
127  hCorr->Draw();
128 
129  hTM ->Sumw2();
130  hTM ->SetMarkerColor(2);
131  hTM ->SetMarkerStyle(21);
132  hTM ->Divide(hRaw);
133  hTM ->Draw("same");
134 
135  hShSh->Sumw2();
136  hShSh->SetMarkerColor(4);
137  hShSh->SetMarkerStyle(22);
138  hShSh->Divide(hRaw);
139  hShSh->Draw("same");
140 
141  TLegend l2(0.45,0.8,0.95,0.93);
142  l2.SetTextSize(0.04);
143  l2.AddEntry(hCorr,"No Exotics + non lin.","P");
144  l2.AddEntry(hTM, "+ Track matching","P");
145  l2.AddEntry(hShSh,"+ #lambda^{2}_{0} < 0.4","P");
146  l2.SetBorderSize(0);
147  l2.SetFillColor(0);
148  l2.Draw();
149 
150 
151  // Plot track-matching residuals
152  // first test did not have this histogram, add protection
153  TH2F* hTrackMatchResEtaPhi = (TH2F*) GetHisto("QA_hTrackMatchedDEtaDPhi");
154  if(hTrackMatchResEtaPhi)
155  {
156  ccalo->cd(3);
157  gPad->SetLogz();
158 
159  hTrackMatchResEtaPhi->SetAxisRange(-0.025,0.025,"X");
160  hTrackMatchResEtaPhi->SetAxisRange(-0.025,0.025,"Y");
161  hTrackMatchResEtaPhi->SetTitleOffset(1.5,"Y");
162  hTrackMatchResEtaPhi->SetTitle("Track-cluster residual #Delta #phi vs #Delta #eta, E > 0.5 GeV");
163  hTrackMatchResEtaPhi->SetXTitle("#Delta #eta");
164  hTrackMatchResEtaPhi->SetYTitle("#Delta #phi");
165  hTrackMatchResEtaPhi->SetZTitle("entries");
166  hTrackMatchResEtaPhi->Draw("colz");
167 
168  ccalo->cd(4);
169  gPad->SetLogy();
170 
171  TH2F* h2TrackMatchResEtaNeg = (TH2F*) GetHisto("QA_hTrackMatchedDEta");
172  TH2F* h2TrackMatchResEtaPos = (TH2F*) GetHisto("QA_hTrackMatchedDEtaPos");
173  TH2F* h2TrackMatchResPhiNeg = (TH2F*) GetHisto("QA_hTrackMatchedDPhi");
174  TH2F* h2TrackMatchResPhiPos = (TH2F*) GetHisto("QA_hTrackMatchedDPhiPos");
175 
176  h2TrackMatchResEtaNeg->Add(h2TrackMatchResEtaPos,-1);
177  h2TrackMatchResPhiNeg->Add(h2TrackMatchResPhiPos,-1);
178 
179  Float_t binMin = hCorr->FindBin(0.5);
180  TH1F* hTrackMatchResEtaNeg = (TH1F*) h2TrackMatchResEtaNeg->ProjectionY("TMProjEtaNeg",binMin, 1000);
181  TH1F* hTrackMatchResEtaPos = (TH1F*) h2TrackMatchResEtaPos->ProjectionY("TMProjEtaPos",binMin, 1000);
182  TH1F* hTrackMatchResPhiNeg = (TH1F*) h2TrackMatchResPhiNeg->ProjectionY("TMProjPhiNeg",binMin, 1000);
183  TH1F* hTrackMatchResPhiPos = (TH1F*) h2TrackMatchResPhiPos->ProjectionY("TMProjPhiPos",binMin, 1000);
184 
185  hTrackMatchResEtaNeg->SetXTitle("#Delta #eta, #Delta #phi");
186  hTrackMatchResEtaNeg->SetYTitle("entries");
187  hTrackMatchResEtaNeg->SetTitle("Track-cluster residuals, E > 1 GeV");
188  hTrackMatchResEtaNeg->SetAxisRange(-0.05,0.05,"X");
189  hTrackMatchResEtaNeg->Sumw2();
190  hTrackMatchResEtaNeg->SetMarkerStyle(25);
191  hTrackMatchResEtaNeg->SetMarkerColor(2);
192  hTrackMatchResEtaNeg->Draw("");
193 
194  hTrackMatchResEtaPos->Sumw2();
195  hTrackMatchResEtaPos->SetMarkerStyle(25);
196  hTrackMatchResEtaPos->SetMarkerColor(4);
197  hTrackMatchResEtaPos->Draw("same");
198 
199  hTrackMatchResPhiNeg->Sumw2();
200  hTrackMatchResPhiNeg->SetMarkerStyle(24);
201  hTrackMatchResPhiNeg->SetMarkerColor(2);
202  hTrackMatchResPhiNeg->Draw("same");
203 
204  hTrackMatchResPhiPos->Sumw2();
205  hTrackMatchResPhiPos->SetMarkerStyle(24);
206  hTrackMatchResPhiPos->SetMarkerColor(4);
207  hTrackMatchResPhiPos->Draw("same");
208 
209  TLine l0(0,hTrackMatchResEtaNeg->GetMinimum(),0,hTrackMatchResEtaNeg->GetMaximum()*1.2);
210  l0.Draw("same");
211 
212  TLegend l3(0.55,0.7,0.83,0.85);
213  l3.SetTextSize(0.04);
214  l3.AddEntry(hTrackMatchResEtaNeg,"#Delta #eta, Negative","P");
215  l3.AddEntry(hTrackMatchResEtaPos,"#Delta #eta, Positive","P");
216  l3.AddEntry(hTrackMatchResPhiNeg,"#Delta #phi, Negative","P");
217  l3.AddEntry(hTrackMatchResPhiPos,"#Delta #phi, Positive","P");
218  l3.SetBorderSize(0);
219  l3.SetFillColor(0);
220  l3.Draw();
221  }
222  ccalo->Print(Form("%s_CaloHisto.eps",histoTag.Data()));
223 
224 
225  TCanvas * ccalo2 = new TCanvas(Form("CaloHisto2_%s",histoTag.Data()),"",500,500);
226  ccalo2->Divide(2,2);
227 
228  ccalo2->cd(3);
229 // gPad->SetLogz();
230 // TH2F* hCellAmpId = (TH2F*) GetHisto("QA_hAmpId");
231 // hCellAmpId->SetTitle("Cell Id vs energy");
232 // hCellAmpId->SetYTitle("Cell Id");
233 // //hCellAmpId->SetAxisRange(300.,900.,"Y");
234 // hCellAmpId->SetAxisRange(0.,30.,"X");
235 // hCellAmpId->SetTitleOffset(1.5,"Y");
236 // hCellAmpId->Draw("colz");
237 
238  gPad->SetLogz();
239 
240  TH2F* hClusterTime = (TH2F*) GetHisto("QA_hClusterTimeEnergy");
241  hClusterTime->SetTitle("Cluster energy vs time");
242  hClusterTime->SetYTitle("time (ns)");
243  hClusterTime->SetAxisRange(300.,900.,"Y");
244  hClusterTime->SetAxisRange(0.,30.,"X");
245  hClusterTime->SetTitleOffset(1.5,"Y");
246  hClusterTime->Draw("colz");
247 
248  ccalo2->cd(1);
249 
250  TH2F* hCellActivity = (TH2F*) GetHisto("QA_hGridCells");
251  hCellActivity->SetTitle("Hits per cell (E > 0.2 GeV)");
252  hCellActivity->SetTitleOffset(1.5,"Y");
253  hCellActivity->Draw("colz");
254 
255  ccalo2->cd(2);
256 
257  TH2F* hCellActivity = (TH2F*) GetHisto("QA_hGridCells");
258  TH2F* hCellActivityE = (TH2F*) GetHisto("QA_hGridCellsE");
259  hCellActivityE->SetTitle("Mean energy per cell (E > 0.2 GeV)");
260  hCellActivityE->Divide(hCellActivity);
261  hCellActivityE->SetTitleOffset(1.5,"Y");
262  hCellActivityE->Draw("colz");
263 
264  ccalo2->cd(4);
265  //gPad->SetLogz();
266  TH2F* hClusterActivity = (TH2F*) GetHisto("AnaPhoton_hEtaPhi");
267  hClusterActivity->SetTitle("Clusters activity (E > 0.5 GeV)");
268  hClusterActivity->SetTitleOffset(1.5,"Y");
269  hClusterActivity->Draw("colz");
270 
271  ccalo2->Print(Form("%s_CaloHisto2.eps",histoTag.Data()));
272 }
273 
274 //______________________________________
276 //______________________________________
277 void TrackQA()
278 {
279  TCanvas * ctrack = new TCanvas(Form("TrackHisto_%s",histoTag.Data()),"",1000,500);
280  ctrack->Divide(2,1);
281 
282  ctrack->cd(1);
283  //gPad->SetLogz();
284  TH2F * hTrackEtaPhi = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative");
285  hTrackEtaPhi ->Add((TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative"));
286  hTrackEtaPhi ->SetAxisRange(-0.9,0.9,"X");
287  hTrackEtaPhi ->SetTitle("Hybrid tracks #eta vs #phi (p_{T} > 0.2 GeV)");
288  hTrackEtaPhi ->Draw("colz");
289 
290  ctrack->cd(2);
291  //gPad->SetLogy();
292  TH2F * hTrackEtaPhiSPD = (TH2F*) GetHisto("AnaHadrons_hEtaPhiSPDRefitPt02");
293  TH2F * hTrackEtaPhiNoSPD = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNoSPDRefitPt02");
294 
295  TH1F* hPhiSPD = (TH1F*)hTrackEtaPhiSPD ->ProjectionY("hTrackPhiSPD" ,0,1000);
296  TH1F* hPhiNoSPD = (TH1F*)hTrackEtaPhiNoSPD->ProjectionY("hTrackPhiNoSPD",0,1000);
297  //TH1F* hPhi = (TH1F*)hTrackEtaPhi ->ProjectionY("hTrackPhi" ,0,1000);
298  TH1F* hPhi = hPhiSPD->Clone("hTrackPhi");
299  hPhi->Add(hPhiNoSPD);
300  hPhi ->SetTitle("Hybrid track in #phi, composition, p_{T} > 0.2 GeV");
301  hPhi ->SetLineColor(1);
302  hPhiSPD ->SetLineColor(2);
303  hPhiNoSPD->SetLineColor(4);
304 
305  hPhi ->SetMinimum(1);
306  hPhi ->SetMaximum(hPhi->GetMaximum()*1.2);
307 
308  hPhi ->Draw("H");
309  hPhiSPD ->Draw("Hsame");
310  hPhiNoSPD->Draw("Hsame");
311 
312  TLegend l(0.2,0.75,0.4,0.89);
313  l.SetTextSize(0.04);
314  l.AddEntry(hPhi,"Sum","L");
315  l.AddEntry(hPhiSPD ,"SPD+Refit","L");
316  l.AddEntry(hPhiNoSPD,"No SPD+Refit","L");
317  l.SetBorderSize(0);
318  l.SetFillColor(0);
319  l.Draw();
320 // ctrack->cd(3);
321 // gPad->SetLogz();
322 //
323 // TH2F* hPtDCAxy = (TH2F*) GetHisto("AnaHadrons_hPtDCAxy");
324 // hPtDCAxy->SetAxisRange(-1,1,"Y");
325 // hPtDCAxy->SetAxisRange(0,30,"X");
326 // hPtDCAxy->Draw("colz");
327 //
328 // ctrack->cd(4);
329 // gPad->SetLogz();
330 //
331 // TH2F* hPtDCAz = (TH2F*) GetHisto("AnaHadrons_hPtDCAz");
332 // hPtDCAz->SetAxisRange(-1,1,"Y");
333 // hPtDCAz->SetAxisRange(0,30,"X");
334 // hPtDCAz->Draw("colz");
335 
336  ctrack->Print(Form("%s_TrackHisto.eps",histoTag.Data()));
337 }
338 
339 //______________________________
340 // Plot basic invariant mass QA
341 //_____________________________
342 void Pi0QA()
343 {
344  TCanvas * cpi0 = new TCanvas(Form("Pi0Histo_%s",histoTag.Data()),"",500,500);
345  cpi0->Divide(2,2);
346 
347  TH2F* hMassE[10];
348  TH2F* hMixMassE[10];
349  for(Int_t icen = 0; icen < 10; icen++)
350  {
351  hMassE [icen] = (TH2F*) GetHisto(Form("AnaPi0_hRe_cen%d_pidbit0_asy1_dist1",icen));
352  hMixMassE[icen] = (TH2F*) GetHisto(Form("AnaPi0_hMi_cen%d_pidbit0_asy1_dist1",icen));
353  }
354 
355  // 2D Invariant mass vs E, in PbPb from 60 to 100 %, all in pp
356  cpi0->cd(1);
357  gPad->SetLogz();
358  TH2F* h2DMass;
359 
360  if(hMassE[1]) // Plot centrality from 60 to 100%
361  {
362  h2DMass = (TH2F*) hMassE[6]->Clone("h2DMass");
363  for(Int_t icen = 7; icen < 10; icen++) h2DMass->Add(hMassE[icen]);
364  h2DMass->SetTitle("Invariant mass vs pair E, Cen: 60-100%");
365  }
366  else
367  {
368  h2DMass = (TH2F*) hMassE[0]->Clone("hMassProj");
369  h2DMass->SetTitle("Invariant mass vs cluster pair E");
370  }
371 
372  h2DMass->SetTitleOffset(1.6,"Y");
373  h2DMass->SetAxisRange(0.0,0.7,"Y");
374  h2DMass->SetAxisRange(0,30,"X");
375  h2DMass->Draw("colz");
376 
377  // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
378  cpi0->cd(2);
379  TH1F* hMass [10];
380  TH1F* hMix [10];
381  TH1F* hMassEta[10];
382  TH1F* hMassPi0[10];
383 
384  //Init to 0
385  for(Int_t icen=0; icen<10; icen++ )
386  {
387  hMass [icen] = 0;
388  hMix [icen] = 0;
389  hMassEta[icen] = 0;
390  hMassPi0[icen] = 0;
391  }
392 
393  TH1F * hX = (TH1F*) hMassE[0]->ProjectionX("hEPairCen0",0,10000);
394  Int_t binmin = hX->FindBin(2); // Project histo from 2 GeV pairs
395  Int_t binmax = hX->FindBin(10); // Project histo up to 10 GeV pairs
396  Float_t maxPi0 = 0;
397  Float_t maxEta = 0;
398  for(Int_t icen = 0; icen < 6; icen++)
399  {
400  if(!hMassE[icen]) continue;
401 
402  hMass[icen] = (TH1F*) hMassE [icen]->ProjectionY(Form("hMassCen%d",icen),binmin,binmax);
403  hMix [icen] = (TH1F*) hMixMassE[icen]->ProjectionY(Form("hMixCen%d" ,icen),binmin,binmax);
404  hMass[icen]->Sumw2();
405  hMix [icen]->Sumw2();
406 
407  hMassPi0[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassPi0Cen%d",icen));
408  hMassEta[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassEtaCen%d",icen));
409 
410  hMassPi0[icen]->Divide(hMix[icen]);
411  hMassPi0[icen]->Fit("pol0","Q","",0.25,0.35);
412  Float_t scale = 1;
413  if(hMassPi0[icen]->GetFunction("pol0")) scale = hMassPi0[icen]->GetFunction("pol0")->GetParameter(0);
414  //printf("Scale factor %f for cen %d\n",scale,icen);
415  hMassPi0[icen]->Scale(1./scale);
416  hMassPi0[icen]->SetMarkerStyle(24);
417  hMassPi0[icen]->SetMarkerColor(color[icen]);
418  hMassPi0[icen]->SetLineColor(color[icen]);
419  hMassPi0[icen]->SetAxisRange(0.04,0.24);
420  hMassPi0[icen]->SetMarkerSize(0.5);
421 
422  hMassEta[icen]->Rebin(4);
423  hMix [icen]->Rebin(4);
424  hMassEta[icen]->Divide(hMix[icen]);
425  hMassEta[icen]->SetMarkerStyle(25);
426  hMassEta[icen]->SetMarkerColor(color[icen]);
427  hMassEta[icen]->SetLineColor(color[icen]);
428  hMassEta[icen]->SetAxisRange(0.4,0.9);
429  hMassEta[icen]->SetMarkerSize(0.5);
430  hMassEta[icen]->Scale(1./scale);
431 
432  if(maxEta < hMassEta[icen]->GetMaximum()) maxEta = hMassEta[icen]->GetMaximum();
433  if(maxPi0 < hMassPi0[icen]->GetMaximum()) maxPi0 = hMassPi0[icen]->GetMaximum();
434  }
435 
436  //gPad->SetLogy();
437  //gPad->SetGridy();
438  hMassPi0[0]->SetMinimum(0.8);
439  hMassPi0[0]->SetTitleOffset(1.6,"Y");
440  hMassPi0[0]->SetYTitle("Real / Mixed");
441  hMassPi0[0]->SetTitle("#pi^{0} peak, 2 < E_{pair}< 10 GeV");
442  hMassPi0[0]->Draw();
443 
444  if(hMass[1]) // PbPb
445  {
446  hMassPi0[0]->SetMaximum(maxPi0*1.2);
447  hMassPi0[5]->Draw("Hsame");
448  hMassPi0[4]->Draw("Hsame");
449  hMassPi0[3]->Draw("Hsame");
450  hMassPi0[2]->Draw("Hsame");
451  hMassPi0[1]->Draw("Hsame");
452  hMassPi0[0]->Draw("Hsame");
453  //hMass[6]->Draw("Hsame");
454  //hMass[7]->Draw("same");
455  //hMass[8]->Draw("same");
456  //hMass[9]->Draw("same");
457 
458  TLegend l(0.12,0.6,0.4,0.85);
459  l.SetTextSize(0.04);
460  l.AddEntry(hMassPi0[0],"0-10%","P");
461  l.AddEntry(hMassPi0[1],"10-20%","P");
462  l.AddEntry(hMassPi0[2],"20-30%","P");
463  l.AddEntry(hMassPi0[3],"30-40%","P");
464  l.AddEntry(hMassPi0[4],"40-70%","P");
465  l.AddEntry(hMassPi0[5],"50-60%","P");
466  l.SetBorderSize(0);
467  l.SetFillColor(0);
468  l.Draw();
469  }
470 
471  TLine l1(0.04,1,0.24,1);
472  l1.Draw("same");
473 
474  // Pi0 invariant mass per EMCal super module
475  cpi0->cd(3);
476 
477  TH1F* hSM [10];
478  TH1F* hMixSM[10];
479  binmin = hX->FindBin(4); // Project histo from 3 GeV pairs
480  binmax = hX->FindBin(20); // Project histo up to 20 GeV pairs
481  Float_t maxSM = 0;
482 
483  for(Int_t ism = 0; ism < 10; ism++)
484  {
485  TH2F* hTmpSM = (TH2F*) GetHisto(Form("AnaPi0_hReMod_%d",ism));
486  if(!hTmpSM) hTmpSM = (TH2F*) GetHisto(Form("QA_hIM_Mod%d",ism));
487 
488  hSM[ism] = (TH1F*) hTmpSM->ProjectionY(Form("hMassSM%d",ism),binmin,binmax);
489  hSM[ism]->Sumw2();
490  hSM[ism]->SetMarkerStyle(26);
491  hSM[ism]->Rebin(2);
492  //hSM[ism]->Scale(1./hSM[ism]->Integral(0,10000));
493  hSM[ism]->SetMarkerColor(color[ism]);
494  hSM[ism]->SetLineColor(color[ism]);
495  hSM[ism]->SetMarkerSize(0.5);
496 
497  TH2F* hTmpMixSM = (TH2F*) GetHisto(Form("AnaPi0_hMiMod_%d",ism));
498  if(hTmpMixSM)
499  {
500  hMixSM[ism] = (TH1F*) hTmpMixSM->ProjectionY(Form("hMassMixSM%d",ism),binmin,binmax);
501  hMixSM[ism]->Sumw2();
502  hMixSM[ism]->Rebin(2);
503  hSM[ism]->Divide(hMixSM[ism]);
504  hSM[ism]->Fit("pol0","Q","",0.25,0.35);
505  Float_t scale = 1;
506  if(hSM[ism]->GetFunction("pol0")) scale = hSM[ism]->GetFunction("pol0")->GetParameter(0);
507  //printf("Scale factor %f for cen %d\n",scale,icen);
508  hSM[ism]->Scale(1./scale);
509  hSM[ism]->SetYTitle("Real / Mixed");
510 
511  }
512 
513  if(maxSM < hSM[ism]->GetMaximum()) maxSM = hSM[ism]->GetMaximum();
514  }
515 
516  hSM[0]->SetTitle("#pi^{0} peak in Modules, 4 < E_{pair}< 10 GeV");
517  hSM[0]->SetTitleOffset(1.6,"Y");
518  hSM[0]->SetAxisRange(0.04,0.24);
519  hSM[0]->SetMaximum(maxSM*1.2);
520  hSM[0]->SetMinimum(0.8);
521 
522  hSM[0]->Draw("H");
523  TLegend lsm(0.12,0.5,0.35,0.85);
524  lsm.SetTextSize(0.04);
525  lsm.AddEntry(hSM[0],Form("Mod %d",0),"P");
526 
527  for(Int_t ism = 1; ism < 10; ism++)
528  {
529  hSM[ism]->Draw("Hsame");
530  lsm.AddEntry(hSM[ism],Form("Mod %d",ism),"P");
531  }
532 
533  lsm.SetBorderSize(0);
534  lsm.SetFillColor(0);
535  lsm.Draw();
536 
537  l1.Draw("same");
538 
539  // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
540  cpi0->cd(4);
541 
542  //gPad->SetLogy();
543  //gPad->SetGridy();
544  hMassEta[0]->SetMinimum(0.8);
545  hMassEta[0]->SetTitleOffset(1.6,"Y");
546  hMassEta[0]->SetYTitle("Real / Mixed");
547  hMassEta[0]->SetTitle("#eta peak, 2 < E_{pair}< 10 GeV");
548  hMassEta[0]->Draw("H");
549 
550  if(hMass[1]) // PbPb
551  {
552  hMassEta[0]->SetMaximum(maxEta*1.2);
553  hMassEta[5]->Draw("Hsame");
554  hMassEta[4]->Draw("Hsame");
555  hMassEta[3]->Draw("Hsame");
556  hMassEta[2]->Draw("Hsame");
557  hMassEta[1]->Draw("Hsame");
558  hMassEta[0]->Draw("Hsame");
559 
560 
561  TLegend l2(0.12,0.6,0.4,0.85);
562  l2.SetTextSize(0.04);
563  l2.AddEntry(hMassEta[0],"0-10%","P");
564  l2.AddEntry(hMassEta[1],"10-20%","P");
565  l2.AddEntry(hMassEta[2],"20-30%","P");
566  l2.AddEntry(hMassEta[3],"30-40%","P");
567  l2.AddEntry(hMassEta[4],"40-70%","P");
568  l2.AddEntry(hMassEta[5],"50-60%","P");
569  l2.SetBorderSize(0);
570  l2.SetFillColor(0);
571  l2.Draw();
572  }
573 
574  cpi0->Print(Form("%s_Pi0Histo.eps",histoTag.Data()));
575 }
576 
577 //__________________________________________________
579 //__________________________________________________
581 {
582  TCanvas * cCorrelation = new TCanvas(Form("CorrelationHisto_%s",histoTag.Data()),"",1000,500);
583  cCorrelation->Divide(2,1);
584 
585  Float_t minClusterE = 8;
586  Float_t assocBins[] = {0.5,2.,5.,10.,20.};
587  Int_t nAssocBins = 4;
588 
589  TH1F * hTrigger = (TH1F*) GetHisto("AnaPhotonHadronCorr_hPtTrigger");
590  Int_t minClusterEBin = hTrigger->FindBin(minClusterE);
591  Float_t nTrig = hTrigger->Integral(minClusterE,100000);
592 
593  //Azimuthal correlation
594  cCorrelation->cd(1);
595  gPad->SetLogy();
596  TH1F* hDeltaPhi[4];
597 
598  TLegend l(0.35,0.6,0.83,0.85);
599  l.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
600  l.SetTextSize(0.04);
601  l.SetBorderSize(0);
602  l.SetFillColor(0);
603 
604  for(Int_t ibin = 0; ibin < nAssocBins; ibin++ )
605  {
606  TH2F* hDeltaPhiE = (TH2F*) GetHisto(Form("AnaPhotonHadronCorr_hDeltaPhiPtAssocPt%2.1f_%2.1f",assocBins[ibin],assocBins[ibin+1]));
607  hDeltaPhi[ibin] = (TH1F*) hDeltaPhiE->ProjectionY(Form("DeltaPhi%2.1f",assocBins[ibin]),minClusterEBin,10000);
608  hDeltaPhi[ibin]->Sumw2();
609  hDeltaPhi[ibin]->Rebin(2);
610  hDeltaPhi[ibin]->Scale(1./nTrig);
611 
612  hDeltaPhi[ibin]->Fit("pol0","Q","",1,2);
613  Float_t scale = 1;
614  if(hDeltaPhi[ibin]->GetFunction("pol0"))
615  {
616  scale = hDeltaPhi[ibin]->GetFunction("pol0")->GetParameter(0);
617  hDeltaPhi[ibin]->GetFunction("pol0")->SetRange(6,7); // move from plot
618  }
619  hDeltaPhi[ibin]->Scale(1./scale);
620  //printf("ibin %d, scale %f\n",ibin,scale);
621 
622  hDeltaPhi[ibin]->SetAxisRange(-1.6,4.7);
623 
624  hDeltaPhi[ibin]->SetMarkerStyle(24);
625  hDeltaPhi[ibin]->SetMarkerColor(color[ibin]);
626  hDeltaPhi[ibin]->SetLineColor(color[ibin]);
627  hDeltaPhi[ibin]->SetTitleOffset(1.5,"Y");
628  hDeltaPhi[ibin]->SetYTitle("N_{pairs} / N_{trig} / ZYAM");
629  hDeltaPhi[ibin]->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
630 
631  l.AddEntry(hDeltaPhi[ibin],Form("%2.1f< p_{T,A}< %2.1f GeV/c",assocBins[ibin],assocBins[ibin+1]),"P");
632  }
633 
634  hDeltaPhi[2]->SetMaximum(hDeltaPhi[2]->GetMaximum()*10);
635  hDeltaPhi[2]->SetMinimum(0.8);
636 
637  hDeltaPhi[2]->Draw("H");
638  hDeltaPhi[1]->Draw("Hsame");
639  hDeltaPhi[3]->Draw("Hsame");
640  hDeltaPhi[0]->Draw("Hsame");
641 
642  l.Draw("same");
643 
644 
645  // xE correlation
646  cCorrelation->cd(2);
647  gPad->SetLogy();
648 
649  TLegend l2(0.35,0.6,0.83,0.85);
650  l2.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
651  l2.SetTextSize(0.04);
652  l2.SetBorderSize(0);
653  l2.SetFillColor(0);
654 
655  TH2F* hEXE = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXECharged");
656  TH2F* hEXEUE = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXEUeCharged");
657 
658  TH1F* hXE = (TH1F*) hEXE->ProjectionY(Form("XE%2.1fGeV",minClusterE),minClusterEBin,10000);
659  hXE->Sumw2();
660  hXE->Rebin(2);
661  hXE->Scale(1./nTrig);
662  hXE->SetAxisRange(0,1);
663  hXE->SetMarkerStyle(24);
664  hXE->SetMarkerColor(1);
665  hXE->SetLineColor(1);
666  hXE->SetTitleOffset(1.5,"Y");
667  hXE->SetYTitle("N_{pairs} / N_{trig}");
668  hXE->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
669  l2.AddEntry(hXE,"raw x_{E}","P");
670  hXE->Draw();
671 
672  TH1F* hXEUE = (TH1F*) hEXEUE->ProjectionY(Form("XEUE%2.1fGeV",minClusterE),minClusterEBin,10000);
673  hXEUE->Sumw2();
674  hXEUE->Rebin(2);
675  hXEUE->Scale(1./nTrig);
676  hXEUE->SetAxisRange(0,1);
677  hXEUE->SetMarkerStyle(25);
678  hXEUE->SetMarkerColor(2);
679  hXEUE->SetLineColor(2);
680  l2.AddEntry(hXEUE,"raw Und. Event x_{E}","P");
681  hXEUE->Draw("same");
682 
683 
684  l2.Draw("same");
685 
686 
687  cCorrelation->Print(Form("%s_CorrelationHisto.eps",histoTag.Data()));
688 }
689 
690 //________________________________________________________
692 //________________________________________________________
693 void MCQA()
694 {
695  TH2F* h2ClusterPho = (TH2F*) GetHisto("QA_hRecoMCE_Photon_Match0"); // not track-matched
696  TH2F* h2ClusterPi0 = (TH2F*) GetHisto("QA_hRecoMCE_Pi0_Match0"); // not track-matched
697  TH2F* h2ClusterEta = (TH2F*) GetHisto("QA_hRecoMCE_Eta_Match0"); // not track-matched
698  TH2F* h2ClusterEle = (TH2F*) GetHisto("QA_hRecoMCE_Electron_Match1"); // Track-matched
699 
700  if(!h2ClusterPho) return;
701 
702 
703 // TH1F* hPrimPho = (TH1F*) GetHisto("QA_hGenMCAccE_Photon");
704 // TH1F* hPrimPi0 = (TH1F*) GetHisto("QA_hGenMCAccE_Pi0");
705 // TH1F* hPrimEta = (TH1F*) GetHisto("QA_hGenMCAccE_Eta");
706 
707  TH1F* hPrimPho = (TH1F*) GetHisto("AnaPhoton_hPtPrim_MCPhoton");
708  TH1F* hPrimPi0 = (TH1F*) GetHisto("AnaPi0_hPrimPi0Pt");
709  TH1F* hPrimEta = (TH1F*) GetHisto("AnaPi0_hPrimEtaPt");
710 
711  TCanvas * cmc = new TCanvas(Form("MCHisto_%s",histoTag.Data()),"",1000,1000);
712  cmc->Divide(2,2);
713 
714  cmc->cd(1);
715  gPad->SetLogy();
716 
717  TH1F* hClusterPho = (TH1F*) h2ClusterPho->ProjectionX("ClusterPho",0,1000);
718  TH1F* hClusterPi0 = (TH1F*) h2ClusterPi0->ProjectionX("ClusterPi0",0,1000);
719  TH1F* hClusterEta = (TH1F*) h2ClusterEta->ProjectionX("ClusterEta",0,1000);
720 
721  hClusterPho->SetTitle("Cluster origin spectra, primary spectra in Calo acceptance");
722  hClusterPho->Sumw2();
723  hClusterPho->SetMarkerColor(1);
724  hClusterPho->SetMarkerStyle(20);
725  hClusterPho->SetAxisRange(0.,50.,"X");
726  //hClusterPho->SetXTitle("E_{rec,gen} (GeV)");
727  hClusterPho->SetXTitle("E_{rec}, p_{T,gen} (GeV)");
728  hClusterPho->Draw("");
729 
730  hClusterPi0->Sumw2();
731  hClusterPi0->SetMarkerColor(4);
732  hClusterPi0->SetMarkerStyle(21);
733  hClusterPi0->Draw("same");
734 
735  hClusterEta->Sumw2();
736  hClusterEta->SetMarkerColor(2);
737  hClusterEta->SetMarkerStyle(22);
738  hClusterEta->Draw("same");
739 
740  hPrimPho->Sumw2();
741  hPrimPho->SetMarkerColor(1);
742  hPrimPho->SetMarkerStyle(24);
743  hPrimPho->Draw("same");
744 
745  hPrimPi0->Sumw2();
746  hPrimPi0->SetMarkerColor(4);
747  hPrimPi0->SetMarkerStyle(25);
748  hPrimPi0->Draw("same");
749 
750  hPrimEta->Sumw2();
751  hPrimEta->SetMarkerColor(2);
752  hPrimEta->SetMarkerStyle(26);
753  hPrimEta->Draw("same");
754 
755  TLegend l(0.45,0.6,0.83,0.89);
756  l.SetTextSize(0.04);
757  l.AddEntry(hClusterPho,"#gamma cluster","P");
758  l.AddEntry(hClusterPi0,"#pi^{0} (merged) cluster","P");
759  l.AddEntry(hClusterEta,"#eta (merged) cluster","P");
760  l.AddEntry(hPrimPho,"#gamma generated","P");
761  l.AddEntry(hPrimPi0,"#pi^{0} generated","P");
762  l.AddEntry(hPrimEta,"#eta generated","P");
763  l.SetBorderSize(0);
764  l.SetFillColor(0);
765  l.Draw();
766 
767 
768  cmc->cd(2);
769  gPad->SetLogy();
770  TH1F* hRatPho = (TH1F*) hClusterPho->Clone("hGenRecoPho");
771  TH1F* hRatPi0 = (TH1F*) hClusterPi0->Clone("hGenRecoPi0");
772  TH1F* hRatEta = (TH1F*) hClusterEta->Clone("hGenRecoEta");
773 
774  hRatPho->Divide(hPrimPho);
775  hRatPi0->Divide(hPrimPi0);
776  hRatEta->Divide(hPrimEta);
777 
778  hRatPho->SetTitle("Reconstructed cluster / Generated particle in Calo acc.");
779  hRatPho->SetYTitle("Ratio");
780  hRatPho->SetXTitle("E(GeV)");
781  hRatPho->SetMinimum(1e-3);
782  hRatPho->SetMaximum(10);
783  hRatPho->Draw("");
784  hRatPi0->Draw("same");
785  hRatEta->Draw("same");
786 
787  TLegend l2(0.15,0.7,0.3,0.85);
788  l2.SetTextSize(0.04);
789  l2.AddEntry(hRatPho,"#gamma","P");
790  l2.AddEntry(hRatPi0,"#pi^{0}","P");
791  l2.AddEntry(hRatEta,"#eta","P");
792  l2.SetBorderSize(0);
793  l2.SetFillColor(0);
794  l2.Draw();
795 
796  cmc->cd(3);
797  //gPad->SetLogy();
798 
799  TH2F* h2PrimPhoPhi = (TH2F*) GetHisto("AnaPhoton_hPhiPrim_MCPhoton");
800  TH2F* h2PrimPi0Phi = (TH2F*) GetHisto("AnaPi0_hPrimPi0Phi");
801  TH2F* h2PrimEtaPhi = (TH2F*) GetHisto("AnaPi0_hPrimEtaPhi");
802 
803  Int_t binMin = hPrimPho->FindBin(3);
804 
805  TH1F* hPrimPhoPhi = (TH1F*) h2PrimPhoPhi->ProjectionY("PrimPhoPhi",binMin,1000);
806  TH1F* hPrimPi0Phi = (TH1F*) h2PrimPi0Phi->ProjectionY("PrimPi0Phi",binMin,1000);
807  TH1F* hPrimEtaPhi = (TH1F*) h2PrimEtaPhi->ProjectionY("PrimEtaPhi",binMin,1000);
808 
809  hPrimPhoPhi->Sumw2();
810  hPrimPi0Phi->Sumw2();
811  hPrimEtaPhi->Sumw2();
812 
813  hPrimPhoPhi->Scale(1./hPrimPhoPhi->Integral(0,1000));
814  hPrimPi0Phi->Scale(1./hPrimPi0Phi->Integral(0,1000));
815  hPrimEtaPhi->Scale(1./hPrimEtaPhi->Integral(0,1000));
816 
817  Float_t maxPhi = hPrimPhoPhi->GetMaximum();
818  if(maxPhi < hPrimPi0Phi->GetMaximum()) maxPhi = hPrimPi0Phi->GetMaximum();
819  if(maxPhi < hPrimEtaPhi->GetMaximum()) maxPhi = hPrimEtaPhi->GetMaximum();
820 
821  Float_t minPhi = hPrimPhoPhi->GetMinimum();
822  if(minPhi > hPrimPi0Phi->GetMinimum()) minPhi = hPrimPi0Phi->GetMinimum();
823  if(minPhi > hPrimEtaPhi->GetMinimum()) minPhi = hPrimEtaPhi->GetMinimum();
824 
825  hPrimPi0Phi->SetMaximum(maxPhi*1.1);
826  hPrimPi0Phi->SetMinimum(minPhi);
827  TGaxis::SetMaxDigits(3);
828 
829  hPrimPi0Phi->SetYTitle("1/total entries dN/d#phi");
830  hPrimPi0Phi->SetTitle("Generated particles #phi for E > 3 GeV");
831  hPrimPi0Phi->SetTitleOffset(1.6,"Y");
832  hPrimPi0Phi->SetMarkerColor(4);
833  hPrimPi0Phi->SetMarkerStyle(21);
834  hPrimPi0Phi->Draw("");
835 
836  hPrimPhoPhi->SetMarkerColor(1);
837  hPrimPhoPhi->SetMarkerStyle(20);
838  Float_t scale = TMath::RadToDeg();
839  ScaleXaxis(hPrimPhoPhi, TMath::RadToDeg());
840  hPrimPhoPhi->Draw("same");
841 
842  hPrimEtaPhi->SetMarkerColor(2);
843  hPrimEtaPhi->SetMarkerStyle(22);
844  hPrimEtaPhi->Draw("same");
845 
846  cmc->cd(4);
847  //gPad->SetLogy();
848 
849  TH2F* h2PrimPhoEta = (TH2F*) GetHisto("AnaPhoton_hYPrim_MCPhoton");
850  TH2F* h2PrimPi0Eta = (TH2F*) GetHisto("AnaPi0_hPrimPi0Rapidity");
851  TH2F* h2PrimEtaEta = (TH2F*) GetHisto("AnaPi0_hPrimEtaRapidity");
852 
853  h2PrimPhoEta->Sumw2();
854  h2PrimEtaEta->Sumw2();
855  h2PrimPi0Eta->Sumw2();
856 
857  Int_t binMin = hPrimPho->FindBin(3);
858 
859  TH1F* hPrimPhoEta = (TH1F*) h2PrimPhoEta->ProjectionY("PrimPhoEta",binMin,1000);
860  TH1F* hPrimPi0Eta = (TH1F*) h2PrimPi0Eta->ProjectionY("PrimPi0Eta",binMin,1000);
861  TH1F* hPrimEtaEta = (TH1F*) h2PrimEtaEta->ProjectionY("PrimEtaEta",binMin,1000);
862 
863  hPrimPhoEta->Scale(1./hPrimPhoEta->Integral(0,1000));
864  hPrimPi0Eta->Scale(1./hPrimPi0Eta->Integral(0,1000));
865  hPrimEtaEta->Scale(1./hPrimEtaEta->Integral(0,1000));
866 
867  Float_t maxEta = hPrimPhoEta->GetMaximum();
868  if(maxEta < hPrimPi0Eta->GetMaximum()) maxEta = hPrimPi0Eta->GetMaximum();
869  if(maxEta < hPrimEtaEta->GetMaximum()) maxEta = hPrimEtaEta->GetMaximum();
870 
871  Float_t minEta = hPrimPhoEta->GetMinimum();
872  if(minEta > hPrimPi0Eta->GetMinimum()) minEta = hPrimPi0Eta->GetMinimum();
873  if(minEta > hPrimEtaEta->GetMinimum()) minEta = hPrimEtaEta->GetMinimum();
874 
875  hPrimPi0Eta->SetMaximum(maxEta*1.1);
876  hPrimPi0Eta->SetMinimum(minEta);
877  TGaxis::SetMaxDigits(3);
878 
879  hPrimPi0Eta->SetYTitle("1/total entries dN/d#eta");
880  hPrimPi0Eta->SetTitle("Generated particles #eta for E > 3 GeV");
881  hPrimPi0Eta->SetTitleOffset(1.6,"Y");
882  hPrimPi0Eta->SetMarkerColor(4);
883  hPrimPi0Eta->SetMarkerStyle(21);
884  hPrimPi0Eta->Draw("");
885 
886  hPrimPhoEta->SetMarkerColor(1);
887  hPrimPhoEta->SetMarkerStyle(20);
888  Float_t scale = TMath::RadToDeg();
889  hPrimPhoEta->Draw("same");
890 
891  hPrimEtaEta->SetMarkerColor(2);
892  hPrimEtaEta->SetMarkerStyle(22);
893  hPrimEtaEta->Draw("same");
894 
895  cmc->Print(Form("%s_MCHisto.eps",histoTag.Data()));
896 }
897 
898 
899 //____________________________________________________________________
900 void GetFileAndList(TString fileName, TString listName, Bool_t export)
901 {
902  file = new TFile(fileName,"read");
903 
904  TDirectory * dir = (TDirectory*) file->Get(listName);
905  if(dir)
906  {
907  list = (TList*) dir->Get(listName);
908  if(export)
909  {
910  TFile * outputFile = new TFile("AnalysisResultsList.root","RECREATE");
911  list->Write();
912  outputFile->Close();
913  }
914  }
915 }
916 
917 //___________________________________
920 //___________________________________
921 TObject * GetHisto(TString histoName)
922 {
923  if(list) return list->FindObject(histoName);
924  else return file->Get (histoName);
925 }
926 
927 //______________________________________
928 void ScaleAxis(TAxis *a, Double_t scale)
929 {
930  if (!a) return; // just a precaution
931  if (a->GetXbins()->GetSize())
932  {
933  // an axis with variable bins
934  // note: bins must remain in increasing order, hence the "Scale"
935  // function must be strictly (monotonically) increasing
936  TArrayD X(*(a->GetXbins()));
937  for(Int_t i = 0; i < X.GetSize(); i++) X[i] = scale*X[i];
938  a->Set((X.GetSize() - 1), X.GetArray()); // new Xbins
939  }
940  else
941  {
942  // an axis with fix bins
943  // note: we modify Xmin and Xmax only, hence the "Scale" function
944  // must be linear (and Xmax must remain greater than Xmin)
945  a->Set(a->GetNbins(),
946  scale*a->GetXmin(), // new Xmin
947  scale*a->GetXmax()); // new Xmax
948  }
949  return;
950 }
951 
952 //_____________________________________
953 void ScaleXaxis(TH1 *h, Double_t scale)
954 {
955  if (!h) return; // just a precaution
956  ScaleAxis(h->GetXaxis(), scale);
957  return;
958 }
959 
960 
Int_t color[]
void DrawAnaCaloTrackQA(TString listName="Pi0IM_GammaTrackCorr_EMCAL_default", TString fileName="AnalysisResults.root", Bool_t export=kFALSE)
TString histoTag
TList * list
void CaloQA()
void ScaleAxis(TAxis *a, Double_t scale)
void GetFileAndList(TString fileName, TString listName, Bool_t export)
void MCQA()
Plot basic generated particle distribution histograms.
void Pi0QA()
void CorrelationQA()
Plot basic cluster-track correlation histograms.
TFile * file
void ScaleXaxis(TH1 *h, Double_t scale)
void TrackQA()
Plot basic hybrid tracks histograms.
TObject * GetHisto(TString histoName)