]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/qa/DrawNeighbors.C
Fixes for coverity checks.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / qa / DrawNeighbors.C
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
14 class TList;
15 #endif
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  *
23  * @ingroup pwg2_forward_scripts_qa
24  */
25 void
26 DrawRingNeighbors(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);
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
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);
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
72   gPad->cd();
73 }
74
75 /** 
76  * Draw the correlation of neighboring strips before/after merging 
77  * 
78  * @param filename 
79  *
80  * @ingroup pwg2_forward_scripts_qa
81  */
82 void
83 DrawNeighbors(const char* filename="forward.root", 
84               const char* folder="ForwardResults")
85 {
86   gStyle->SetPalette(1);
87   gStyle->SetOptFit(0);
88   gStyle->SetOptStat(0);
89   gStyle->SetTitleW(.4);
90   gStyle->SetTitleH(.1);
91   gStyle->SetTitleX(.1);
92   gStyle->SetTitleY(.1);
93   gStyle->SetTitleColor(0);
94   gStyle->SetTitleStyle(0);
95   gStyle->SetTitleBorderSize(0);
96   gStyle->SetOptTitle(0);
97
98   TFile* file = TFile::Open(filename, "READ");
99   if (!file) { 
100     Error("DrawNeighbors", "failed to open %s", filename);
101     return;
102   }
103
104   TList* forward = static_cast<TList*>(file->Get(folder));
105   if (!forward) { 
106     Error("DrawNeighbors", "List %s not found in %s", folder, filename);
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();
129   c->SaveAs("neighbors.png");
130 }
131
132   
133   
134  
135 //
136 // EOF
137 //