1 ///////////////////////////////////////////
3 // Macro to plot few selected histograms
4 // to QA data productions at 0th order
5 // Analysis performed with the wagon
6 // AddTaskPi0IMGammaCorrQA.C
7 // It generates 5 eps plots, each containing 2 to 4 canvases
9 // To execute: root -q -b -l DrawAnaCaloTrackQA.C'("Pi0IM_GammaTrackCorr_EMCAL_default","AnalysisResults.root")'
10 // The input list name might change depending on the wagon / data type
11 // In case output file is too large, possiblity to dump the list content in a sepate file: export = kTRUE
13 // Author: Gustavo.Conesa.Balbastre@cern.ch
17 // Some global variables
20 TString histoTag = "";
21 Int_t color[]={kBlack,kRed,kOrange+1,kYellow+1,kGreen+2,kBlue,kCyan+1,kViolet,kMagenta+2,kGray};
23 //_______________________________________________________________________
24 void DrawAnaCaloTrackQA(TString listName = "Pi0IM_GammaTrackCorr_EMCAL_default",
25 TString fileName = "AnalysisResultsQATrain.root",
26 Bool_t export = kFALSE)
29 printf("Open <%s>; Get List : <%s>; Export list? <%d>\n",fileName.Data(),listName.Data(),export);
33 //Access the file and list of histograms, global variables
34 GetFileAndList(fileName, listName, export);
36 gStyle->SetOptTitle(1);
37 gStyle->SetOptStat(0);
38 gStyle->SetOptFit(000000);
39 gStyle->SetPadRightMargin(0.15);
40 //gStyle->SetPadTopMargin(0.02);
41 //gStyle->SetPadLeftMargin(0.15);
42 gStyle->SetTitleFontSize(0.06);
44 //Plot basic Calorimeter QA
53 //Plot basic correlation QA
61 // Basic calorimeter QA histograms
63 TCanvas * ccalo = new TCanvas(Form("CaloHisto_%s",histoTag.Data()),"",1000,1000);
69 TH1F* hCellAmplitude = (TH1F*) GetHisto("QA_hAmplitude");
70 TH1F* hClusterEnergy = (TH1F*) GetHisto("QA_hE");
72 hClusterEnergy->SetTitle("Cluster-cell energy spectra");
73 hClusterEnergy->Sumw2();
74 hClusterEnergy->SetMarkerColor(1);
75 hClusterEnergy->SetMarkerStyle(20);
76 hClusterEnergy->SetAxisRange(0.,50.,"X");
77 hClusterEnergy->Draw();
79 hCellAmplitude->Sumw2();
80 hCellAmplitude->SetMarkerColor(4);
81 hCellAmplitude->SetMarkerStyle(25);
82 hCellAmplitude->Draw("same");
84 TLegend l(0.3,0.7,0.83,0.85);
86 l.AddEntry(hClusterEnergy,"Cluster (no exotic+non lin)","P");
87 l.AddEntry(hCellAmplitude,"Cell","P");
96 TH1F* hRaw = (TH1F*) GetHisto("AnaPhoton_hCut_0_Open");
97 TH1F* hCorr = (TH1F*) GetHisto("AnaPhoton_hCut_4_NCells");
98 TH1F* hTM = (TH1F*) GetHisto("AnaPhoton_hCut_7_Matching");
99 TH1F* hShSh = (TH1F*) GetHisto("AnaPhoton_hCut_9_PID");
103 hCorr->SetTitle("Ratio after cluster cuts application");
104 hCorr->SetYTitle("Selected clusters / Raw clusters");
105 hCorr->SetTitleOffset(1.5,"Y");
107 hCorr->SetMarkerColor(1);
108 hCorr->SetMarkerStyle(20);
110 hCorr->SetAxisRange(0.,30.,"X");
111 hCorr->SetMaximum(1);
112 hCorr->SetMinimum(0);
116 hTM ->SetMarkerColor(2);
117 hTM ->SetMarkerStyle(21);
122 hShSh->SetMarkerColor(4);
123 hShSh->SetMarkerStyle(22);
127 TLegend l2(0.3,0.7,0.83,0.85);
128 l2.SetTextSize(0.04);
129 l2.AddEntry(hCorr,"No Exotics + non linearity","P");
130 l2.AddEntry(hTM, "+ Track matching","P");
131 l2.AddEntry(hShSh,"+ #lambda^{2}_{0} < 0.4","P");
140 TH2F* hClusterTime = (TH2F*) GetHisto("QA_hClusterTimeEnergy");
141 hClusterTime->SetTitle("Cluster energy vs time");
142 hClusterTime->SetYTitle("time (ns)");
143 hClusterTime->SetAxisRange(300.,900.,"Y");
144 hClusterTime->SetAxisRange(0.,30.,"X");
145 hClusterTime->SetTitleOffset(1.5,"Y");
147 hClusterTime->Draw("colz");
152 TH2F* hClusterM02 = (TH2F*) GetHisto("AnaPhoton_hLam0E");
153 hClusterM02->SetTitle("Cluster energy vs #lambda^{2}_{0}");
154 //hClusterM02->SetAxisRange(300.,900.,"Y");
155 hClusterM02->SetAxisRange(0.,30.,"X");
156 hClusterM02->SetTitleOffset(1.5,"Y");
157 hClusterM02->Draw("colz");
159 ccalo->Print(Form("%s_CaloHisto.eps",histoTag.Data()));
162 TCanvas * ccalo2 = new TCanvas(Form("CaloHisto2_%s",histoTag.Data()),"",500,500);
167 TH2F* hCellAmpId = (TH2F*) GetHisto("QA_hAmpId");
168 hCellAmpId->SetTitle("Cell Id vs energy");
169 hCellAmpId->SetYTitle("Cell Id");
170 //hCellAmpId->SetAxisRange(300.,900.,"Y");
171 hCellAmpId->SetAxisRange(0.,30.,"X");
172 hCellAmpId->SetTitleOffset(1.5,"Y");
173 hCellAmpId->Draw("colz");
177 TH2F* hCellActivity = (TH2F*) GetHisto("QA_hGridCells");
178 hCellActivity->SetTitle("Hits per cell (E > 0.2 GeV)");
179 hCellActivity->SetTitleOffset(1.5,"Y");
180 hCellActivity->Draw("colz");
184 TH2F* hCellActivity = (TH2F*) GetHisto("QA_hGridCells");
185 TH2F* hCellActivityE = (TH2F*) GetHisto("QA_hGridCellsE");
186 hCellActivityE->SetTitle("Mean energy per cell (E > 0.2 GeV)");
187 hCellActivityE->Divide(hCellActivity);
188 hCellActivityE->SetTitleOffset(1.5,"Y");
189 hCellActivityE->Draw("colz");
193 TH2F* hClusterActivity = (TH2F*) GetHisto("AnaPhoton_hEtaPhi");
194 hClusterActivity->SetTitle("Clusters activity (E > 0.5 GeV)");
195 hClusterActivity->SetTitleOffset(1.5,"Y");
196 hClusterActivity->Draw("colz");
198 ccalo2->Print(Form("%s_CaloHisto2.eps",histoTag.Data()));
205 // Basic hybrid tracks histograms
207 TCanvas * ctrack = new TCanvas(Form("TrackHisto_%s",histoTag.Data()),"",1000,500);
212 TH2F * hTrackEtaPhi = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative");
213 hTrackEtaPhi ->Add((TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative"));
214 hTrackEtaPhi ->SetAxisRange(-0.9,0.9,"X");
215 hTrackEtaPhi ->SetTitle("Hybrid tracks #eta vs #phi (p_{T} > 0.2 GeV)");
216 hTrackEtaPhi ->Draw("colz");
220 TH2F * hTrackEtaPhiSPD = (TH2F*) GetHisto("AnaHadrons_hEtaPhiSPDRefitPt02");
221 TH2F * hTrackEtaPhiNoSPD = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNoSPDRefitPt02");
223 TH1F* hPhiSPD = (TH1F*)hTrackEtaPhiSPD ->ProjectionY("hTrackPhiSPD" ,0,1000);
224 TH1F* hPhiNoSPD = (TH1F*)hTrackEtaPhiNoSPD->ProjectionY("hTrackPhiNoSPD",0,1000);
225 //TH1F* hPhi = (TH1F*)hTrackEtaPhi ->ProjectionY("hTrackPhi" ,0,1000);
226 TH1F* hPhi = hPhiSPD->Clone("hTrackPhi");
227 hPhi->Add(hPhiNoSPD);
228 hPhi ->SetTitle("Hybrid track in #phi, composition, p_{T} > 0.2 GeV");
229 hPhi ->SetLineColor(1);
230 hPhiSPD ->SetLineColor(2);
231 hPhiNoSPD->SetLineColor(4);
233 hPhi ->SetMinimum(1);
236 hPhiSPD ->Draw("same");
237 hPhiNoSPD->Draw("same");
239 TLegend l(0.12,0.8,0.4,0.9);
241 l.AddEntry(hPhi,"Sum","L");
242 l.AddEntry(hPhiSPD ,"SPD+Refit","L");
243 l.AddEntry(hPhiNoSPD,"No SPD+Refit","L");
250 // TH2F* hPtDCAxy = (TH2F*) GetHisto("AnaHadrons_hPtDCAxy");
251 // hPtDCAxy->SetAxisRange(-1,1,"Y");
252 // hPtDCAxy->SetAxisRange(0,30,"X");
253 // hPtDCAxy->Draw("colz");
258 // TH2F* hPtDCAz = (TH2F*) GetHisto("AnaHadrons_hPtDCAz");
259 // hPtDCAz->SetAxisRange(-1,1,"Y");
260 // hPtDCAz->SetAxisRange(0,30,"X");
261 // hPtDCAz->Draw("colz");
263 ctrack->Print(Form("%s_TrackHisto.eps",histoTag.Data()));
270 // Basic invariant mass QA
272 TCanvas * cpi0 = new TCanvas(Form("Pi0Histo_%s",histoTag.Data()),"",500,500);
277 for(Int_t icen = 0; icen < 10; icen++)
279 hMassE [icen] = (TH2F*) GetHisto(Form("AnaPi0_hRe_cen%d_pidbit0_asy1_dist1",icen));
280 hMixMassE[icen] = (TH2F*) GetHisto(Form("AnaPi0_hMi_cen%d_pidbit0_asy1_dist1",icen));
283 // 2D Invariant mass vs E, in PbPb from 60 to 100 %, all in pp
288 if(hMassE[1]) // Plot centrality from 60 to 100%
290 h2DMass = (TH2F*) hMassE[6]->Clone("h2DMass");
291 for(Int_t icen = 7; icen < 10; icen++) h2DMass->Add(hMassE[icen]);
292 h2DMass->SetTitle("Invariant mass vs pair E, Cen: 60-100%");
296 h2DMass->SetTitle("Invariant mass vs cluster pair E");
300 h2DMass->SetTitleOffset(1.6,"Y");
301 h2DMass->SetAxisRange(0.0,0.7,"Y");
302 h2DMass->SetAxisRange(0,30,"X");
303 h2DMass->Draw("colz");
305 // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
312 TH1F * hX = (TH1F*) hMassE[0]->ProjectionX("hEPairCen0",0,10000);
313 Int_t binmin = hX->FindBin(2); // Project histo from 2 GeV pairs
314 Int_t binmax = hX->FindBin(10); // Project histo up to 10 GeV pairs
315 for(Int_t icen = 0; icen < 6; icen++)
317 if(!hMassE[icen]) continue;
319 hMass[icen] = (TH1F*) hMassE [icen]->ProjectionY(Form("hMassCen%d",icen),binmin,binmax);
320 hMix [icen] = (TH1F*) hMixMassE[icen]->ProjectionY(Form("hMixCen%d" ,icen),binmin,binmax);
321 hMass[icen]->Sumw2();
322 hMix [icen]->Sumw2();
324 hMassPi0[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassPi0Cen%d",icen));
325 hMassEta[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassEtaCen%d",icen));
327 hMassPi0[icen]->Divide(hMix[icen]);
328 hMassPi0[icen]->Fit("pol0","Q","",0.25,0.35);
330 if(hMassPi0[icen]->GetFunction("pol0")) scale = hMassPi0[icen]->GetFunction("pol0")->GetParameter(0);
331 //printf("Scale factor %f for cen %d\n",scale,icen);
332 hMassPi0[icen]->Scale(1./scale);
333 hMassPi0[icen]->SetMarkerStyle(24);
334 hMassPi0[icen]->SetMarkerColor(color[icen]);
335 hMassPi0[icen]->SetLineColor(color[icen]);
336 hMassPi0[icen]->SetAxisRange(0.04,0.24);
337 hMassPi0[icen]->SetMarkerSize(0.5);
339 hMassEta[icen]->Rebin(4);
340 hMix [icen]->Rebin(4);
341 hMassEta[icen]->Divide(hMix[icen]);
342 hMassEta[icen]->SetMarkerStyle(25);
343 hMassEta[icen]->SetMarkerColor(color[icen]);
344 hMassEta[icen]->SetLineColor(color[icen]);
345 hMassEta[icen]->SetAxisRange(0.4,0.9);
346 hMassEta[icen]->SetMarkerSize(0.5);
347 hMassEta[icen]->Scale(1./scale);
352 hMassPi0[0]->SetMinimum(0.9);
353 hMassPi0[0]->SetTitleOffset(1.6,"Y");
354 hMassPi0[0]->SetYTitle("Real / Mixed");
355 hMassPi0[0]->SetTitle("#pi^{0} peak, 2 < E_{pair}< 10 GeV");
360 hMassPi0[0]->SetMaximum(hMassPi0[5]->GetMaximum()*1.2);
361 hMassPi0[5]->Draw("Hsame");
362 hMassPi0[4]->Draw("Hsame");
363 hMassPi0[3]->Draw("Hsame");
364 hMassPi0[2]->Draw("Hsame");
365 hMassPi0[1]->Draw("Hsame");
366 hMassPi0[0]->Draw("Hsame");
367 //hMass[6]->Draw("Hsame");
368 //hMass[7]->Draw("same");
369 //hMass[8]->Draw("same");
370 //hMass[9]->Draw("same");
372 TLegend l(0.12,0.6,0.4,0.85);
374 l.AddEntry(hMassPi0[0],"0-10%","P");
375 l.AddEntry(hMassPi0[1],"10-20%","P");
376 l.AddEntry(hMassPi0[2],"20-30%","P");
377 l.AddEntry(hMassPi0[3],"30-40%","P");
378 l.AddEntry(hMassPi0[4],"40-70%","P");
379 l.AddEntry(hMassPi0[5],"50-60%","P");
385 TLine l1(0.04,1,0.24,1);
388 // Pi0 invariant mass per EMCal super module
392 binmin = hX->FindBin(4); // Project histo from 3 GeV pairs
393 binmax = hX->FindBin(20); // Project histo up to 20 GeV pairs
394 for(Int_t ism = 0; ism < 10; ism++)
396 TH2F* hTmpSM = (TH2F*) GetHisto(Form("QA_hIM_Mod%d",ism));
397 hSM[ism] = (TH1F*) hTmpSM->ProjectionY(Form("hMassSM%d",ism),binmin,binmax);
399 hSM[ism]->SetMarkerStyle(26);
401 //hSM[ism]->Scale(1./hSM[ism]->Integral(0,10000));
402 hSM[ism]->SetMarkerColor(color[ism]);
403 hSM[ism]->SetLineColor(color[ism]);
404 hSM[ism]->SetAxisRange(0.04,0.24);
405 hSM[ism]->SetMarkerSize(0.5);
408 hSM[0]->SetTitle("#pi^{0} peak in Modules, 4 < E_{pair}< 10 GeV");
409 hSM[0]->SetTitleOffset(1.6,"Y");
412 TLegend lsm(0.12,0.5,0.35,0.85);
413 lsm.SetTextSize(0.04);
414 lsm.AddEntry(hSM[0],Form("Mod %d",0),"P");
416 for(Int_t ism = 1; ism < 10; ism++)
418 hSM[ism]->Draw("Hsame");
419 lsm.AddEntry(hSM[ism],Form("Mod %d",ism),"P");
422 lsm.SetBorderSize(0);
426 // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
431 hMassEta[0]->SetMinimum(0.9);
432 hMassEta[0]->SetTitleOffset(1.6,"Y");
433 hMassEta[0]->SetYTitle("Real / Mixed");
434 hMassEta[0]->SetTitle("#eta peak, 2 < E_{pair}< 10 GeV");
435 hMassEta[0]->Draw("H");
439 hMassEta[0]->SetMaximum(hMassEta[5]->GetMaximum()*1.2);
440 hMassEta[5]->Draw("Hsame");
441 hMassEta[4]->Draw("Hsame");
442 hMassEta[3]->Draw("Hsame");
443 hMassEta[2]->Draw("Hsame");
444 hMassEta[1]->Draw("Hsame");
445 hMassEta[0]->Draw("Hsame");
448 TLegend l2(0.12,0.6,0.4,0.85);
449 l2.SetTextSize(0.04);
450 l2.AddEntry(hMassEta[0],"0-10%","P");
451 l2.AddEntry(hMassEta[1],"10-20%","P");
452 l2.AddEntry(hMassEta[2],"20-30%","P");
453 l2.AddEntry(hMassEta[3],"30-40%","P");
454 l2.AddEntry(hMassEta[4],"40-70%","P");
455 l2.AddEntry(hMassEta[5],"50-60%","P");
461 cpi0->Print(Form("%s_Pi0Histo.eps",histoTag.Data()));
469 TCanvas * cCorrelation = new TCanvas(Form("CorrelationHisto_%s",histoTag.Data()),"",1000,500);
470 cCorrelation->Divide(2,1);
472 Float_t minClusterE = 8;
473 Float_t assocBins[] = {0.5,2.,5.,10.,20.};
474 Int_t nAssocBins = 4;
476 TH1F * hLeading = (TH1F*) GetHisto("AnaPhotonHadronCorr_hPtLeading");
477 Int_t minClusterEBin = hLeading->FindBin(minClusterE);
478 Float_t nTrig = hLeading->Integral(minClusterE,100000);
480 //Azimuthal correlation
485 TLegend l(0.35,0.6,0.83,0.85);
486 l.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
491 for(Int_t ibin = 0; ibin < nAssocBins; ibin++ )
493 TH2F* hDeltaPhiE = (TH2F*) GetHisto(Form("AnaPhotonHadronCorr_hDeltaPhiPtAssocPt%2.1f_%2.1f",assocBins[ibin],assocBins[ibin+1]));
494 hDeltaPhi[ibin] = (TH1F*) hDeltaPhiE->ProjectionY(Form("DeltaPhi%2.1f",assocBins[ibin]),minClusterEBin,10000);
495 hDeltaPhi[ibin]->Sumw2();
496 hDeltaPhi[ibin]->Rebin(2);
497 hDeltaPhi[ibin]->Scale(1./nTrig);
499 hDeltaPhi[ibin]->Fit("pol0","Q","",1,2);
501 if(hDeltaPhi[ibin]->GetFunction("pol0"))
503 scale = hDeltaPhi[ibin]->GetFunction("pol0")->GetParameter(0);
504 hDeltaPhi[ibin]->GetFunction("pol0")->SetRange(6,7); // move from plot
506 hDeltaPhi[ibin]->Scale(1./scale);
507 //printf("ibin %d, scale %f\n",ibin,scale);
509 hDeltaPhi[ibin]->SetAxisRange(-1.8,4.1);
511 hDeltaPhi[ibin]->SetMarkerStyle(24);
512 hDeltaPhi[ibin]->SetMarkerColor(color[ibin]);
513 hDeltaPhi[ibin]->SetLineColor(color[ibin]);
514 hDeltaPhi[ibin]->SetTitleOffset(1.5,"Y");
515 hDeltaPhi[ibin]->SetYTitle("N_{pairs} / N_{trig} / ZYAM");
516 hDeltaPhi[ibin]->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
518 l.AddEntry(hDeltaPhi[ibin],Form("%2.1f< p_{T,A}< %2.1f GeV/c",assocBins[ibin],assocBins[ibin+1]),"P");
522 //hDeltaPhi[2]->SetMaximum(hDeltaPhi[2]->GetMaximum()*1.1);
523 //hDeltaPhi[2]->SetMinimum(0.0001);
525 hDeltaPhi[2]->Draw("H");
526 hDeltaPhi[1]->Draw("Hsame");
527 hDeltaPhi[3]->Draw("Hsame");
528 hDeltaPhi[0]->Draw("Hsame");
537 TLegend l2(0.35,0.6,0.83,0.85);
538 l2.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
539 l2.SetTextSize(0.04);
543 TH2F* hEXE = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXECharged");
544 TH2F* hEXEUE = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXEUeCharged");
546 TH1F* hXE = (TH1F*) hEXE->ProjectionY(Form("XE%2.1fGeV",minClusterE),minClusterEBin,10000);
549 hXE->Scale(1./nTrig);
550 hXE->SetAxisRange(0,1);
551 hXE->SetMarkerStyle(24);
552 hXE->SetMarkerColor(1);
553 hXE->SetLineColor(1);
554 hXE->SetTitleOffset(1.5,"Y");
555 hXE->SetYTitle("N_{pairs} / N_{trig}");
556 hXE->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
557 l2.AddEntry(hXE,"raw x_{E}","P");
560 TH1F* hXEUE = (TH1F*) hEXEUE->ProjectionY(Form("XEUE%2.1fGeV",minClusterE),minClusterEBin,10000);
563 hXEUE->Scale(1./nTrig);
564 hXEUE->SetAxisRange(0,1);
565 hXEUE->SetMarkerStyle(25);
566 hXEUE->SetMarkerColor(2);
567 hXEUE->SetLineColor(2);
568 l2.AddEntry(hXEUE,"raw Und. Event x_{E}","P");
575 cCorrelation->Print(Form("%s_CorrelationHisto.eps",histoTag.Data()));
580 //____________________________________________________________________
581 void GetFileAndList(TString fileName, TString listName, Bool_t export)
583 file = new TFile(fileName,"read");
585 TDirectory * dir = (TDirectory*) file->Get(listName);
588 list = (TList*) dir->Get(listName);
591 TFile * outputFile = new TFile("AnalysisResultsList.root","RECREATE");
598 //___________________________________
599 TObject * GetHisto(TString histoName)
601 // Check if the list is available, if not get the histo directly from file
603 if(list) return list->FindObject(histoName);
604 else return file->Get (histoName);