]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/qa/DrawOccupancy.C
Fixes for pA indenfication of events
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / qa / DrawOccupancy.C
CommitLineData
2970d087 1/**
2 * @file DrawOccupancy.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Thu Jul 7 10:24:58 2011
5 *
2dbde04b 6 * @brief A script to draw the occupancy as given by Poisson method
2970d087 7 *
2dbde04b 8 * @deprecated Use QATrender instead
bd6f5206 9 * @ingroup pwglf_forward_scripts_qa
2970d087 10 *
11 */
d015ecfe 12#ifndef __CINT__
13# include <TH1.h>
14# include <TH2.h>
15# include <TList.h>
16# include <TFile.h>
17# include <TString.h>
18# include <TError.h>
19# include <TPad.h>
20# include <TCanvas.h>
21# include <TLine.h>
22# include <TLatex.h>
23# include <TStyle.h>
24#else
25class TList;
26#endif
2970d087 27
28/**
2dbde04b 29 * Draw the Poisson estimate of the occupancy in a given ring.
2970d087 30 *
31 * @param p List
32 * @param d Detector
33 * @param r Ring
2970d087 34 *
2dbde04b 35 * @return The occupancy (in percent)
2970d087 36 *
2dbde04b 37 * @deprecated Use QATrender instead
bd6f5206 38 * @ingroup pwglf_forward_scripts_qa
2970d087 39 */
40Double_t
41DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
42{
d015ecfe 43 if (!p) return 0;
2970d087 44
45 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
46 if (!ring) {
47 Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
d015ecfe 48 return 0;
2970d087 49 }
50
51 TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
52 if (!corr) {
53 Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
54 d, r);
d015ecfe 55 return 0;
2970d087 56 }
d015ecfe 57 corr->Rebin(4);
58
2970d087 59 TPad* pad = static_cast<TPad*>(gPad);
60 pad->SetGridy();
61 pad->SetGridx();
62 pad->SetLogy();
63 pad->SetFillColor(0);
64 pad->SetRightMargin(0.01);
65#if 0
66 if (d == 3) {
67 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
68 pad->GetYlowNDC()+pad->GetHNDC());
69 pad->SetRightMargin(0.15);
70 }
71#endif
72
73 corr->Draw("hist");
74
75 TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
76 ltx->SetNDC();
77 ltx->SetTextAlign(33);
78 ltx->SetTextSize(.08);
79 ltx->Draw();
80
81 return corr->GetMean();
82}
83
84/**
2dbde04b 85 * Draw the Poisson estimate of the occupancy
2970d087 86 *
2dbde04b 87 * @param filename Input file name
88 * @param folder Input folder name in file
89 *
90 * @deprecated Use QATrender instead
bd6f5206 91 * @ingroup pwglf_forward_scripts_qa
2970d087 92 */
93void
94DrawOccupancy(const char* filename="forward.root",
d015ecfe 95 const char* folder="ForwardResults")
2970d087 96{
97 gStyle->SetPalette(1);
98 gStyle->SetOptFit(0);
99 gStyle->SetOptStat(0);
100 gStyle->SetOptTitle(0);
101 gStyle->SetTitleW(.4);
102 gStyle->SetTitleH(.1);
103 gStyle->SetTitleX(.4);
104 // gStyle->SetTitleY(.1);
105 gStyle->SetTitleColor(0);
106 gStyle->SetTitleStyle(0);
107 gStyle->SetTitleBorderSize(0);
108
109 TFile* file = TFile::Open(filename, "READ");
110 if (!file) {
111 Error("DrawOccupancy", "failed to open %s", filename);
112 return;
113 }
114
d015ecfe 115 TList* forward = static_cast<TList*>(file->Get(folder));
2970d087 116 if (!forward) {
d015ecfe 117 Error("DrawOccupancy", "List %s not found in %s", folder, filename);
2970d087 118 return;
119 }
120
121 TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
122 if (!dc) {
123 Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
124 return;
125 }
126
127 TCanvas* c = new TCanvas("occupancy",
128 "Mean Occupancy", 900, 700);
129 c->SetFillColor(0);
130 c->SetBorderSize(0);
131 c->SetBorderMode(0);
132 c->SetHighLightColor(0);
133 c->SetBottomMargin(.15);
134 c->SetTopMargin(.02);
135 c->SetRightMargin(.02);
136 c->SetLeftMargin(.15);
137 c->Divide(3, 2, 0, 0);
138
139
140 Double_t corrs[5];
141 c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I');
142 c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I');
143 c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O');
144 c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I');
145 c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O');
146
147 TVirtualPad* p = c->cd(4);
148 p->SetTopMargin(0.05);
149 p->SetRightMargin(0.10);
150 p->SetLeftMargin(0.15);
151 p->SetBottomMargin(0.15);
152 p->SetFillColor(0);
153
154 TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
155 hc->SetFillColor(kRed+1);
156 hc->SetFillStyle(3001);
157 hc->SetMinimum(0.0);
158 hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]);
159 hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]);
160 hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]);
161 hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]);
162 hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]);
163 hc->GetXaxis()->SetLabelSize(0.08);
164 hc->GetYaxis()->SetTitle("#bar{occupancy}");
165 hc->SetMarkerSize(1.5);
166 hc->Draw("text hist");
167 hc->SetMaximum(hc->GetMaximum()*1.5);
168
169 // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
170 // if (highCuts) highCuts->Draw("colz");
171 c->cd();
172 c->SaveAs("occupancy.png");
173}
174//
175// EOF
176//