2 * @file DrawRecAnaEloss.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Thu Jul 7 10:58:50 2011
6 * @brief Draw energ-loss before/after merging and used in the
9 * @ingroup pwg2_forward_scripts_qa
21 #include <TParameter.h>
36 * @ingroup pwg2_forward_scripts_qa
39 DrawText(TLatex* l, Double_t x, Double_t& y, const char* c1, const char* c2)
41 y -= 1.2*l->GetTextSize();
42 l->DrawLatex(x, y, c1);
43 l->DrawLatex(x+.4, y, c2);
46 * Draw the energy loss before/after mergin for a single ring
50 * @param lowCut Low cut
54 * @ingroup pwg2_forward_scripts_qa
57 DrawRingRecAnaEloss(TList* p, TList* p2, Double_t lowCut, UShort_t d, Char_t r)
61 TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
63 Error("DrawRecAnaEloss", "List FMD%d%c not found in %s",d,r,p->GetName());
66 TList* ring2 = static_cast<TList*>(p2->FindObject(Form("FMD%d%c",d,r)));
68 Error("DrawRecAnaEloss","List FMD%d%c not found in %s",d,r,p2->GetName());
72 TH1* before = static_cast<TH1D*>(ring->FindObject("esdEloss"));
74 Error("DrawRingRecAnaEloss", "Histogram esdEloss not found in FMD%d%c",
78 TH1* after = static_cast<TH1D*>(ring->FindObject("anaEloss"));
80 Error("DrawRingRecAnaEloss", "Histogram anaEloss not found in FMD%d%c",
84 TH1* presented = static_cast<TH1D*>(ring2->FindObject("eloss"));
86 Error("DrawRingRecAnaEloss", "Histogram eloss not found in FMD%d%c",
90 TH1* used = static_cast<TH1D*>(ring2->FindObject("elossUsed"));
92 Error("DrawRingRecAnaEloss", "Histogram elossUsed not found in FMD%d%c",
98 Int_t low = before->GetXaxis()->FindBin(lowCut);
99 Int_t ib = Int_t(before->Integral(low,before->GetNbinsX()));
100 Int_t ia = Int_t(after->Integral(low,after->GetNbinsX()));
101 Int_t ip = Int_t(presented->Integral(low,presented->GetNbinsX()));
102 Int_t iu = Int_t(used->Integral(low,used->GetNbinsX()));
103 // before->Scale(1. / ib);
104 // after->Scale(1. / ib);
105 // presented->Scale(1. / ib);
106 // used->Scale(1. / ib);
109 gPad->SetFillColor(0);
110 before->SetTitle(Form("FMD%d%c",d,r));
113 presented->Draw("same");
116 // ib = before->Integral(low,before->GetNbinsX());
117 // ia = after->Integral(low,after->GetNbinsX());
118 // ip = presented->Integral(low,presented->GetNbinsX());
119 // iu = used->Integral(low,used->GetNbinsX());
121 Double_t x = gPad->GetLeftMargin() + .25;
122 Double_t y = 1-gPad->GetTopMargin()-gStyle->GetTitleH()+ts;
123 TLatex* ltx = new TLatex(x, y, Form("FMD%d%c", d, r));
125 ltx->SetTextAlign(13);
126 ltx->SetTextSize(ts);
128 // ltx->SetTextSize(.05);
129 TString inte(Form("Integral [%4.2f,#infty]", lowCut));
130 DrawText(ltx, x, y, Form("%s before:", inte.Data()), Form("%9d", ib));
131 DrawText(ltx, x, y, Form("%s after:", inte.Data()), Form("%9d", ia));
132 DrawText(ltx, x, y, Form("%s input:", inte.Data()), Form("%9d", ip));
133 DrawText(ltx, x, y, Form("%s user:", inte.Data()), Form("%9d", iu));
134 TLine* l = new TLine;
136 l->DrawLineNDC(x, y-0.9*ts, 1-gPad->GetRightMargin()-0.01, y-0.9*ts);
137 if (ib != 0 && ia != 0) {
138 DrawText(ltx, x, y, "Change (merging)", Form("%5.1f%%", (100.*(ia-ib))/ib));
139 DrawText(ltx, x, y, "Change (input)", Form("%5.1f%% (%5.1f%%)",
142 DrawText(ltx, x, y, "Change (use)", Form("%5.1f%% (%5.1f%%)",
146 before->GetXaxis()->SetRangeUser(0, 4);
151 * Draw energy loss before/after merging
155 * @ingroup pwg2_forward_scripts_qa
158 DrawRecAnaEloss(const char* filename="forward.root",
159 const char* folder="ForwardResults")
161 gStyle->SetPalette(1);
162 gStyle->SetOptFit(0);
163 gStyle->SetOptStat(0);
164 gStyle->SetOptTitle(1);
165 gStyle->SetTitleW(.4);
166 gStyle->SetTitleH(.1);
167 gStyle->SetTitleColor(0);
168 gStyle->SetTitleStyle(0);
169 gStyle->SetTitleBorderSize(0);
170 gStyle->SetTitleX(.6);
172 TFile* file = TFile::Open(filename, "READ");
174 Error("DrawRecAnaEloss", "failed to open %s", filename);
178 TList* forward = static_cast<TList*>(file->Get(folder));
180 Error("DrawRecAnaEloss", "List %s not found in %s", folder, filename);
184 TList* sf = static_cast<TList*>(forward->FindObject("fmdSharingFilter"));
186 Error("DrawRecAnaEloss", "List fmdSharingFilter not found in Forward");
189 TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
191 Error("DrawRecAnaEloss","List fmdDensityCalculator not found in Forward");
195 TParameter<double>* lowCut =
196 static_cast<TParameter<double>*>(sf->FindObject("lowCut"));
197 Double_t low = (lowCut ? lowCut->GetVal() : 0.15);
199 Warning("DrawRecAnaEloss", "Low cut not found in %s, assuming %f",
201 TCanvas* c = new TCanvas("recAnaELoss",
202 "Reconstructed and Analysed energy loss", 900, 700);
205 c->SetLeftMargin(0.15);
206 c->SetRightMargin(0.02);
207 c->SetTopMargin(0.02);
208 c->Divide(3, 2, 0, 0);
210 c->cd(1); DrawRingRecAnaEloss(sf, dc, low, 1, 'I');
211 c->cd(2); DrawRingRecAnaEloss(sf, dc, low, 2, 'I');
212 c->cd(5); DrawRingRecAnaEloss(sf, dc, low, 2, 'O');
213 c->cd(3); DrawRingRecAnaEloss(sf, dc, low, 3, 'I');
214 c->cd(6); DrawRingRecAnaEloss(sf, dc, low, 3, 'O');
215 TVirtualPad* p = c->cd(4);
216 // p->SetTopMargin(0.05);
217 p->SetRightMargin(0.15);
219 TH2D* highCuts = static_cast<TH2D*>(sf->FindObject("highCuts"));
220 if (highCuts) highCuts->Draw("colz");
222 c->SaveAs("recAnaELoss.png");