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 Poisson vs Energy Loss correlation
9 * @ingroup pwg2_forward_scripts_qa
29 * Draw the poisson @f$N_{ch}@f$ estimate against the @f$\Delta@f$
30 * @f$N_{ch}@f$ estimate and do a regression line between the two
38 * @return The regression coefficient
40 * @ingroup pwg2_forward_scripts_qa
43 DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
47 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
49 Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
53 TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
55 Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
61 TPad* pad = static_cast<TPad*>(gPad);
66 pad->SetRightMargin(0.01);
69 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
70 pad->GetYlowNDC()+pad->GetHNDC());
71 pad->SetRightMargin(0.15);
77 TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
79 ltx->SetTextAlign(33);
80 ltx->SetTextSize(.08);
83 return corr->GetMean();
87 * Draw the correlation between the Poisson @f$N_{ch}@f$ estimate
88 * and the @f$\Delta@f$ @f$N_{ch}@f$ estimate and do a regression
89 * line between the two for each ring
91 * @param filename File to read
92 * @param xmax Minimum X
93 * @param xmin Maximum X
95 * @ingroup pwg2_forward_scripts_qa
98 DrawOccupancy(const char* filename="forward.root",
99 const char* folder="ForwardResults")
101 gStyle->SetPalette(1);
102 gStyle->SetOptFit(0);
103 gStyle->SetOptStat(0);
104 gStyle->SetOptTitle(0);
105 gStyle->SetTitleW(.4);
106 gStyle->SetTitleH(.1);
107 gStyle->SetTitleX(.4);
108 // gStyle->SetTitleY(.1);
109 gStyle->SetTitleColor(0);
110 gStyle->SetTitleStyle(0);
111 gStyle->SetTitleBorderSize(0);
113 TFile* file = TFile::Open(filename, "READ");
115 Error("DrawOccupancy", "failed to open %s", filename);
119 TList* forward = static_cast<TList*>(file->Get(folder));
121 Error("DrawOccupancy", "List %s not found in %s", folder, filename);
125 TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
127 Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
131 TCanvas* c = new TCanvas("occupancy",
132 "Mean Occupancy", 900, 700);
136 c->SetHighLightColor(0);
137 c->SetBottomMargin(.15);
138 c->SetTopMargin(.02);
139 c->SetRightMargin(.02);
140 c->SetLeftMargin(.15);
141 c->Divide(3, 2, 0, 0);
145 c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I');
146 c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I');
147 c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O');
148 c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I');
149 c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O');
151 TVirtualPad* p = c->cd(4);
152 p->SetTopMargin(0.05);
153 p->SetRightMargin(0.10);
154 p->SetLeftMargin(0.15);
155 p->SetBottomMargin(0.15);
158 TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
159 hc->SetFillColor(kRed+1);
160 hc->SetFillStyle(3001);
162 hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]);
163 hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]);
164 hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]);
165 hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]);
166 hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]);
167 hc->GetXaxis()->SetLabelSize(0.08);
168 hc->GetYaxis()->SetTitle("#bar{occupancy}");
169 hc->SetMarkerSize(1.5);
170 hc->Draw("text hist");
171 hc->SetMaximum(hc->GetMaximum()*1.5);
173 // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
174 // if (highCuts) highCuts->Draw("colz");
176 c->SaveAs("occupancy.png");