2 * @file DrawOccupancy.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Thu Jul 7 10:24:58 2011
6 * @brief A script to draw the occupancy as given by Poisson method
8 * @deprecated Use QATrender instead
9 * @ingroup pwglf_forward_scripts_qa
29 * Draw the Poisson estimate of the occupancy in a given ring.
35 * @return The occupancy (in percent)
37 * @deprecated Use QATrender instead
38 * @ingroup pwglf_forward_scripts_qa
41 DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
45 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
47 Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
51 TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
53 Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
59 TPad* pad = static_cast<TPad*>(gPad);
64 pad->SetRightMargin(0.01);
67 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
68 pad->GetYlowNDC()+pad->GetHNDC());
69 pad->SetRightMargin(0.15);
75 TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
77 ltx->SetTextAlign(33);
78 ltx->SetTextSize(.08);
81 return corr->GetMean();
85 * Draw the Poisson estimate of the occupancy
87 * @param filename Input file name
88 * @param folder Input folder name in file
90 * @deprecated Use QATrender instead
91 * @ingroup pwglf_forward_scripts_qa
94 DrawOccupancy(const char* filename="forward.root",
95 const char* folder="ForwardResults")
97 gStyle->SetPalette(1);
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);
109 TFile* file = TFile::Open(filename, "READ");
111 Error("DrawOccupancy", "failed to open %s", filename);
115 TList* forward = static_cast<TList*>(file->Get(folder));
117 Error("DrawOccupancy", "List %s not found in %s", folder, filename);
121 TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
123 Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
127 TCanvas* c = new TCanvas("occupancy",
128 "Mean Occupancy", 900, 700);
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);
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');
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);
154 TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
155 hc->SetFillColor(kRed+1);
156 hc->SetFillStyle(3001);
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);
169 // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
170 // if (highCuts) highCuts->Draw("colz");
172 c->SaveAs("occupancy.png");