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 * @deprecated Use DrawSteps.C instead
10 * @ingroup pwglf_forward_scripts_qa
15 * @param forward Forward folder
16 * @param sub Sub-folder to get
17 * @param name Name of stack
19 * @return Stack, or null
21 * @deprecated Use DrawSteps.C instead
22 * @ingroup pwglf_forward_scripts_qa
25 GetStack(const TList& forward, const char* sub, const char* name)
27 TList* lsub = static_cast<TList*>(forward.FindObject(sub));
29 Warning("GetStack", "Sub list %s not found in %s", sub, forward.GetName());
32 THStack* ret = static_cast<THStack*>(lsub->FindObject(name));
34 Warning("GetStack" "Stack %s not found in %s", name, sub);
42 * @param rebin Rebinning factor
44 * @return Pointer to histogram
46 * @deprecated Use DrawSteps.C instead
47 * @ingroup pwglf_forward_scripts_qa
50 Rebin(TH1* h, Int_t rebin)
52 if (rebin <= 1) return h;
59 * Take ratio of two histograms
62 * @param h2 Denominator
64 * @return Newly allocated histogram containg ratio
66 * @deprecated Use DrawSteps.C instead
67 * @ingroup pwglf_forward_scripts_qa
70 Ratio(const TH1* h1, const TH1* h2)
75 TH1* copy = static_cast<TH1*>(h2->Clone("tmp"));
76 copy->SetName(Form("%s_%s", h2->GetName(), h1->GetName()));
77 copy->SetTitle(Form("%s/%s", h2->GetTitle(), h1->GetTitle()));
78 copy->SetDirectory(0);
84 * Take ratio of histograms in stacks
86 * @param r Return stack of ratios
87 * @param h1 Numerators
88 * @param h2 Denominators
90 * @return How many histograms in the return stack
92 * @deprecated Use DrawSteps.C instead
93 * @ingroup pwglf_forward_scripts_qa
96 Ratio(THStack* r, const THStack* h1, const THStack* h2)
101 int n1 = h1->GetHists()->GetEntries();
102 int n2 = h2->GetHists()->GetEntries();
104 for (int i = 0; i < n1 && i < n2; i++) {
105 TH1* hh1 = static_cast<TH1*>(h1->GetHists()->At(i));
106 TH1* hh2 = static_cast<TH1*>(h2->GetHists()->At(i));
107 TH1* h = Ratio(hh1, hh2);
117 * @param filename Input file name
118 * @param rebin Rebinning factor
119 * @param ratios Whether to show ratios
121 * @deprecated Use DrawSteps.C instead
122 * @ingroup pwglf_forward_scripts_qa
125 DrawMCResult(const char* filename="forward.root", Int_t rebin=1,
128 gStyle->SetPalette(1);
129 gStyle->SetOptFit(0);
130 gStyle->SetOptStat(0);
132 TFile* file = TFile::Open(filename, "READ");
134 Error("DrawMCResult", "failed to open %s", filename);
138 TList* forward = static_cast<TList*>(file->Get("Forward"));
140 Error("DrawMCResult", "List Forward not found in %s", filename);
143 THStack* res = GetStack(*forward, "ringResults", "all");
144 THStack* mcRes = GetStack(*forward, "mcRingResults", "all");
145 THStack* deltas = GetStack(*forward, "fmdSharingFilter", "sums");
146 THStack* nchs = GetStack(*forward, "fmdDensityCalculator", "sums");
147 THStack* prims = GetStack(*forward, "fmdCorrector", "sums");
149 TH1* sumEta = static_cast<TH1*>(forward->FindObject("mcSumEta"));
151 Warning("DrawMCResults", "mcSumEta not found in Forward");
155 gStyle->SetTitleBorderSize(0);
156 gStyle->SetTitleFillColor(0);
157 gStyle->SetTitleStyle(0);
158 // gStyle->SetTitleColor(kBlack);
161 TCanvas* c = new TCanvas("c", "C", 900, 700);
164 c->SetTopMargin(0.05);
165 c->SetRightMargin(0.05);
167 Double_t y1 = (ratios ? .3 : 0);
168 TPad* p1 = new TPad("p1", "p1", 0, y1, 1, 1, 0, 0, 0);
169 p1->SetBottomMargin(ratios ? 0.01 : .10);
171 p1->SetBorderSize(0);
172 p1->SetTopMargin(0.05);
173 p1->SetRightMargin(0.05);
177 THStack* all = new THStack("all", "Analysis steps");
179 res->SetTitle("dN_{ch}/d#eta");
180 TIter next(res->GetHists());
182 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
185 mcRes->SetTitle("Track-Refs");
186 TIter next(mcRes->GetHists());
188 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
191 deltas->SetTitle("#sum_{} #Delta/#Delta_{mip}");
192 TIter next(deltas->GetHists());
194 while ((h = static_cast<TH1*>(next()))) {
195 h->SetMarkerStyle(25);
196 all->Add(Rebin(h,rebin));
200 nchs->SetTitle("#sum_{} N_{ch,incl}");
201 TIter next(nchs->GetHists());
203 while ((h = static_cast<TH1*>(next()))) {
204 h->SetMarkerStyle(21);
205 all->Add(Rebin(h,rebin));
209 prims->SetTitle("#sum_{} N_{ch,primary}");
210 TIter next(prims->GetHists());
212 while ((h = static_cast<TH1*>(next()))) {
213 h->SetMarkerStyle(22);
214 all->Add(Rebin(h,rebin));
217 if (sumEta) all->Add(sumEta);
218 all->Draw("nostack");
219 all->GetHistogram()->SetXTitle("#eta");
220 all->GetHistogram()->SetYTitle("signal");
221 all->GetHistogram()->GetXaxis()->SetLabelFont(132);
222 all->GetHistogram()->GetXaxis()->SetTitleFont(132);
223 all->GetHistogram()->GetYaxis()->SetLabelFont(132);
224 all->GetHistogram()->GetYaxis()->SetTitleFont(132);
227 TLegend* l = new TLegend(.33, .2, .53, .9);
236 TIter next(res->GetHists());
238 while ((h = static_cast<TH1*>(next()))) {
239 e = l->AddEntry(Form("dummy%02d", i++),h->GetTitle(),"pl");
240 e->SetMarkerStyle(20);
241 e->SetMarkerColor(h->GetMarkerColor());
243 e = l->AddEntry(Form("dummy%02d", i++),res->GetTitle(),"pl");
244 e->SetMarkerStyle(20);
245 e->SetMarkerColor(kBlack);
248 e = l->AddEntry(Form("dummy%02d", i++), deltas->GetTitle(),"pl");
249 TH1* h = static_cast<TH1*>(deltas->GetHists()->At(0));
250 e->SetMarkerStyle(h->GetMarkerStyle());
251 e->SetMarkerColor(kBlack);
254 e = l->AddEntry(Form("dummy%02d",i++),nchs->GetTitle(),"pl");
255 TH1* h = static_cast<TH1*>(nchs->GetHists()->At(0));
256 e->SetMarkerStyle(h->GetMarkerStyle());
257 e->SetMarkerColor(kBlack);
260 e = l->AddEntry(Form("dummy%02d", i++), prims->GetTitle(),"pl");
261 TH1* h = static_cast<TH1*>(prims->GetHists()->At(0));
262 e->SetMarkerStyle(h->GetMarkerStyle());
263 e->SetMarkerColor(kBlack);
267 e = l->AddEntry(Form("dummy%02d", i++), mcRes->GetTitle(), "pl");
268 TH1* h = static_cast<TH1*>(mcRes->GetHists()->At(0));
269 e->SetMarkerStyle(h->GetMarkerStyle());
270 e->SetMarkerColor(kBlack);
273 if (sumEta) l->AddEntry(sumEta);
280 TPad* p2 = new TPad("p2", "p2", 0, 0, 1, y1, 0, 0, 0);
283 p2->SetBorderSize(0);
284 p2->SetRightMargin(0.05);
288 THStack* rs = new THStack("ratios", "Ratios");
289 Int_t nDN = Ratio(rs, deltas, nchs);
290 Int_t nNR = Ratio(rs, nchs, res);
291 Int_t nRP = Ratio(rs, res, prims);
294 TLegend* ll = new TLegend(.38, .2, .48, .9);
297 ll->SetBorderSize(0);
299 ll->SetTextFont(132);
301 e = ll->AddEntry("d1", Form("#frac{%s}{%s}",
303 deltas->GetTitle()), "lp");
304 e->SetMarkerStyle(21);
307 e = ll->AddEntry("d2", Form("#frac{%s}{%s}", res->GetTitle(),
308 nchs->GetTitle()), "lp");
309 e->SetMarkerStyle(20);
312 e = ll->AddEntry("d3", Form("#frac{%s}{%s}", prims->GetTitle(),
313 res->GetTitle()), "lp");
314 e->SetMarkerStyle(22);