Fixes for coverity checks.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / qa / DrawNeighbors.C
CommitLineData
d015ecfe 1#ifndef __CINT__
2# include <TH1.h>
3# include <TH2.h>
4# include <TList.h>
5# include <TFile.h>
6# include <TString.h>
7# include <TError.h>
8# include <TPad.h>
9# include <TCanvas.h>
10# include <TLine.h>
11# include <TLatex.h>
12# include <TStyle.h>
13#else
14class TList;
15#endif
56199f2b 16/**
17 * Draw the correlation of neighboring strips before/after merging
18 *
19 * @param p List
20 * @param d Detector
21 * @param r Ring
22 *
f0ef1e71 23 * @ingroup pwg2_forward_scripts_qa
56199f2b 24 */
0919aa56 25void
26DrawRingNeighbors(TList* p, UShort_t d, Char_t r)
27{
28 if (!p) return;
29
30 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
31 if (!ring) {
32 Error("DrawNeighbors", "List FMD%d%c not found in %s",d,r,p->GetName());
33 return;
34 }
35
36 TH2* before = static_cast<TH2D*>(ring->FindObject("neighborsBefore"));
37 if (!before) {
38 Error("DrawRingNeighbors", "Histogram neighborsBefore not found in FMD%d%c",
39 d, r);
40 return;
41 }
42 TH2* after = static_cast<TH2D*>(ring->FindObject("neighborsAfter"));
43 if (!after) {
44 Error("DrawRingNeighbors", "Histogram neighborsAfter not found in FMD%d%c",
45 d, r);
46 return;
47 }
48 gPad->SetLogz();
49 gPad->SetFillColor(0);
b5c9a732 50 TPad* pad = (TPad*)gPad;
51 if (d == 3) {
52 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
53 pad->GetYlowNDC()+pad->GetHNDC());
54 pad->SetRightMargin(0.15);
55 }
56 // gStyle->SetTitleY(gPad->GetBottomMargin());
57
0919aa56 58 before->SetTitle(Form("FMD%d%c",d,r));
59 before->Draw("colz");
60 after->Draw("same box");
61
62 before->GetXaxis()->SetRangeUser(-.5, 2);
63 before->GetYaxis()->SetRangeUser(-.5, 2);
b5c9a732 64
65 TLatex* ltx = new TLatex(gPad->GetLeftMargin()+.01,
66 gPad->GetBottomMargin()+.01,
67 before->GetTitle());
68 ltx->SetNDC();
69 ltx->SetTextSize(.07);
70 ltx->Draw();
71
0919aa56 72 gPad->cd();
73}
74
56199f2b 75/**
76 * Draw the correlation of neighboring strips before/after merging
77 *
78 * @param filename
79 *
f0ef1e71 80 * @ingroup pwg2_forward_scripts_qa
56199f2b 81 */
0919aa56 82void
d015ecfe 83DrawNeighbors(const char* filename="forward.root",
84 const char* folder="ForwardResults")
0919aa56 85{
86 gStyle->SetPalette(1);
87 gStyle->SetOptFit(0);
88 gStyle->SetOptStat(0);
89 gStyle->SetTitleW(.4);
90 gStyle->SetTitleH(.1);
b5c9a732 91 gStyle->SetTitleX(.1);
92 gStyle->SetTitleY(.1);
0919aa56 93 gStyle->SetTitleColor(0);
94 gStyle->SetTitleStyle(0);
95 gStyle->SetTitleBorderSize(0);
b5c9a732 96 gStyle->SetOptTitle(0);
0919aa56 97
98 TFile* file = TFile::Open(filename, "READ");
99 if (!file) {
100 Error("DrawNeighbors", "failed to open %s", filename);
101 return;
102 }
103
d015ecfe 104 TList* forward = static_cast<TList*>(file->Get(folder));
0919aa56 105 if (!forward) {
d015ecfe 106 Error("DrawNeighbors", "List %s not found in %s", folder, filename);
0919aa56 107 return;
108 }
109
110 TList* sf = static_cast<TList*>(forward->FindObject("fmdSharingFilter"));
111 if (!sf) {
112 Error("DrawNeighbors", "List fmdSharingFilter not found in Forward");
113 return;
114 }
115
116 TCanvas* c = new TCanvas("neighbors", "Correlation of Neighbor strips",
117 900, 700);
118 c->SetFillColor(0);
119 c->SetBorderSize(0);
120 c->Divide(3, 2, 0, 0);
121
122 c->cd(1); DrawRingNeighbors(sf, 1, 'I');
123 c->cd(2); DrawRingNeighbors(sf, 2, 'I');
124 c->cd(5); DrawRingNeighbors(sf, 2, 'O');
125 c->cd(3); DrawRingNeighbors(sf, 3, 'I');
126 c->cd(6); DrawRingNeighbors(sf, 3, 'O');
127 c->cd(4)->SetFillColor(0);
128 c->cd();
d015ecfe 129 c->SaveAs("neighbors.png");
0919aa56 130}
131
132
133
134
56199f2b 135//
136// EOF
137//