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
14 * Draw the poisson @f$N_{ch}@f$ estimate against the @f$\Delta@f$
15 * @f$N_{ch}@f$ estimate and do a regression line between the two
23 * @return The regression coefficient
25 * @ingroup pwg2_forward_scripts_qa
28 DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
32 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
34 Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
38 TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
40 Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
44 TPad* pad = static_cast<TPad*>(gPad);
49 pad->SetRightMargin(0.01);
52 pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
53 pad->GetYlowNDC()+pad->GetHNDC());
54 pad->SetRightMargin(0.15);
60 TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
62 ltx->SetTextAlign(33);
63 ltx->SetTextSize(.08);
66 return corr->GetMean();
70 * Draw the correlation between the Poisson @f$N_{ch}@f$ estimate
71 * and the @f$\Delta@f$ @f$N_{ch}@f$ estimate and do a regression
72 * line between the two for each ring
74 * @param filename File to read
75 * @param xmax Minimum X
76 * @param xmin Maximum X
78 * @ingroup pwg2_forward_scripts_qa
81 DrawOccupancy(const char* filename="forward.root",
85 gStyle->SetPalette(1);
87 gStyle->SetOptStat(0);
88 gStyle->SetOptTitle(0);
89 gStyle->SetTitleW(.4);
90 gStyle->SetTitleH(.1);
91 gStyle->SetTitleX(.4);
92 // gStyle->SetTitleY(.1);
93 gStyle->SetTitleColor(0);
94 gStyle->SetTitleStyle(0);
95 gStyle->SetTitleBorderSize(0);
97 TFile* file = TFile::Open(filename, "READ");
99 Error("DrawOccupancy", "failed to open %s", filename);
103 TList* forward = static_cast<TList*>(file->Get("Forward"));
105 Error("DrawOccupancy", "List Forward not found in %s", filename);
109 TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
111 Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
115 TCanvas* c = new TCanvas("occupancy",
116 "Mean Occupancy", 900, 700);
120 c->SetHighLightColor(0);
121 c->SetBottomMargin(.15);
122 c->SetTopMargin(.02);
123 c->SetRightMargin(.02);
124 c->SetLeftMargin(.15);
125 c->Divide(3, 2, 0, 0);
129 c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I');
130 c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I');
131 c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O');
132 c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I');
133 c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O');
135 TVirtualPad* p = c->cd(4);
136 p->SetTopMargin(0.05);
137 p->SetRightMargin(0.10);
138 p->SetLeftMargin(0.15);
139 p->SetBottomMargin(0.15);
142 TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
143 hc->SetFillColor(kRed+1);
144 hc->SetFillStyle(3001);
146 hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]);
147 hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]);
148 hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]);
149 hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]);
150 hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]);
151 hc->GetXaxis()->SetLabelSize(0.08);
152 hc->GetYaxis()->SetTitle("#bar{occupancy}");
153 hc->SetMarkerSize(1.5);
154 hc->Draw("text hist");
155 hc->SetMaximum(hc->GetMaximum()*1.5);
157 // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
158 // if (highCuts) highCuts->Draw("colz");
160 c->SaveAs("occupancy.png");