3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Thu Jul 7 10:57:01 2011
6 * @brief Script to draw steps (deprecated version - use DrawSteps.C)
9 * @ingroup pwg2_forward_scripts_qa
20 * @ingroup pwg2_forward_scripts_qa
23 GetStack(const TList& forward, const char* sub, const char* name)
25 TList* lsub = static_cast<TList*>(forward.FindObject(sub));
27 Warning("GetStack", "Sub list %s not found in %s", sub, forward.GetName());
30 THStack* ret = static_cast<THStack*>(lsub->FindObject(name));
32 Warning("GetStack" "Stack %s not found in %s", name, sub);
44 * @ingroup pwg2_forward_scripts_qa
47 Rebin(TH1* h, Int_t rebin)
49 if (rebin <= 1) return h;
63 * @ingroup pwg2_forward_scripts_qa
66 Ratio(const TH1* h1, const TH1* h2)
71 TH1* copy = static_cast<TH1*>(h2->Clone("tmp"));
72 copy->SetName(Form("%s_%s", h2->GetName(), h1->GetName()));
73 copy->SetTitle(Form("%s/%s", h2->GetTitle(), h1->GetTitle()));
74 copy->SetDirectory(0);
88 * @ingroup pwg2_forward_scripts_qa
91 Ratio(THStack* r, const THStack* h1, const THStack* h2)
96 int n1 = h1->GetHists()->GetEntries();
97 int n2 = h2->GetHists()->GetEntries();
99 for (int i = 0; i < n1 && i < n2; i++) {
100 TH1* hh1 = static_cast<TH1*>(h1->GetHists()->At(i));
101 TH1* hh2 = static_cast<TH1*>(h2->GetHists()->At(i));
102 TH1* h = Ratio(hh1, hh2);
116 * @ingroup pwg2_forward_scripts_qa
119 DrawMCResult(const char* filename="forward.root", Int_t rebin=1,
122 gStyle->SetPalette(1);
123 gStyle->SetOptFit(0);
124 gStyle->SetOptStat(0);
126 TFile* file = TFile::Open(filename, "READ");
128 Error("DrawMCResult", "failed to open %s", filename);
132 TList* forward = static_cast<TList*>(file->Get("Forward"));
134 Error("DrawMCResult", "List Forward not found in %s", filename);
137 THStack* res = GetStack(*forward, "ringResults", "all");
138 THStack* mcRes = GetStack(*forward, "mcRingResults", "all");
139 THStack* deltas = GetStack(*forward, "fmdSharingFilter", "sums");
140 THStack* nchs = GetStack(*forward, "fmdDensityCalculator", "sums");
141 THStack* prims = GetStack(*forward, "fmdCorrector", "sums");
143 TH1* sumEta = static_cast<TH1*>(forward->FindObject("mcSumEta"));
145 Warning("DrawMCResults", "mcSumEta not found in Forward");
149 gStyle->SetTitleBorderSize(0);
150 gStyle->SetTitleFillColor(0);
151 gStyle->SetTitleStyle(0);
152 // gStyle->SetTitleColor(kBlack);
155 TCanvas* c = new TCanvas("c", "C", 900, 700);
158 c->SetTopMargin(0.05);
159 c->SetRightMargin(0.05);
161 Double_t y1 = (ratios ? .3 : 0);
162 TPad* p1 = new TPad("p1", "p1", 0, y1, 1, 1, 0, 0, 0);
163 p1->SetBottomMargin(ratios ? 0.01 : .10);
165 p1->SetBorderSize(0);
166 p1->SetTopMargin(0.05);
167 p1->SetRightMargin(0.05);
171 THStack* all = new THStack("all", "Analysis steps");
173 res->SetTitle("dN_{ch}/d#eta");
174 TIter next(res->GetHists());
176 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
179 mcRes->SetTitle("Track-Refs");
180 TIter next(mcRes->GetHists());
182 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
185 deltas->SetTitle("#sum_{} #Delta/#Delta_{mip}");
186 TIter next(deltas->GetHists());
188 while ((h = static_cast<TH1*>(next()))) {
189 h->SetMarkerStyle(25);
190 all->Add(Rebin(h,rebin));
194 nchs->SetTitle("#sum_{} N_{ch,incl}");
195 TIter next(nchs->GetHists());
197 while ((h = static_cast<TH1*>(next()))) {
198 h->SetMarkerStyle(21);
199 all->Add(Rebin(h,rebin));
203 prims->SetTitle("#sum_{} N_{ch,primary}");
204 TIter next(prims->GetHists());
206 while ((h = static_cast<TH1*>(next()))) {
207 h->SetMarkerStyle(22);
208 all->Add(Rebin(h,rebin));
211 if (sumEta) all->Add(sumEta);
212 all->Draw("nostack");
213 all->GetHistogram()->SetXTitle("#eta");
214 all->GetHistogram()->SetYTitle("signal");
215 all->GetHistogram()->GetXaxis()->SetLabelFont(132);
216 all->GetHistogram()->GetXaxis()->SetTitleFont(132);
217 all->GetHistogram()->GetYaxis()->SetLabelFont(132);
218 all->GetHistogram()->GetYaxis()->SetTitleFont(132);
221 TLegend* l = new TLegend(.33, .2, .53, .9);
230 TIter next(res->GetHists());
232 while ((h = static_cast<TH1*>(next()))) {
233 e = l->AddEntry(Form("dummy%02d", i++),h->GetTitle(),"pl");
234 e->SetMarkerStyle(20);
235 e->SetMarkerColor(h->GetMarkerColor());
237 e = l->AddEntry(Form("dummy%02d", i++),res->GetTitle(),"pl");
238 e->SetMarkerStyle(20);
239 e->SetMarkerColor(kBlack);
242 e = l->AddEntry(Form("dummy%02d", i++), deltas->GetTitle(),"pl");
243 TH1* h = static_cast<TH1*>(deltas->GetHists()->At(0));
244 e->SetMarkerStyle(h->GetMarkerStyle());
245 e->SetMarkerColor(kBlack);
248 e = l->AddEntry(Form("dummy%02d",i++),nchs->GetTitle(),"pl");
249 TH1* h = static_cast<TH1*>(nchs->GetHists()->At(0));
250 e->SetMarkerStyle(h->GetMarkerStyle());
251 e->SetMarkerColor(kBlack);
254 e = l->AddEntry(Form("dummy%02d", i++), prims->GetTitle(),"pl");
255 TH1* h = static_cast<TH1*>(prims->GetHists()->At(0));
256 e->SetMarkerStyle(h->GetMarkerStyle());
257 e->SetMarkerColor(kBlack);
261 e = l->AddEntry(Form("dummy%02d", i++), mcRes->GetTitle(), "pl");
262 TH1* h = static_cast<TH1*>(mcRes->GetHists()->At(0));
263 e->SetMarkerStyle(h->GetMarkerStyle());
264 e->SetMarkerColor(kBlack);
267 if (sumEta) l->AddEntry(sumEta);
274 TPad* p2 = new TPad("p2", "p2", 0, 0, 1, y1, 0, 0, 0);
277 p2->SetBorderSize(0);
278 p2->SetRightMargin(0.05);
282 THStack* rs = new THStack("ratios", "Ratios");
283 Int_t nDN = Ratio(rs, deltas, nchs);
284 Int_t nNR = Ratio(rs, nchs, res);
285 Int_t nRP = Ratio(rs, res, prims);
288 TLegend* ll = new TLegend(.38, .2, .48, .9);
291 ll->SetBorderSize(0);
293 ll->SetTextFont(132);
295 e = ll->AddEntry("d1", Form("#frac{%s}{%s}",
297 deltas->GetTitle()), "lp");
298 e->SetMarkerStyle(21);
301 e = ll->AddEntry("d2", Form("#frac{%s}{%s}", res->GetTitle(),
302 nchs->GetTitle()), "lp");
303 e->SetMarkerStyle(20);
306 e = ll->AddEntry("d3", Form("#frac{%s}{%s}", prims->GetTitle(),
307 res->GetTitle()), "lp");
308 e->SetMarkerStyle(22);