2 GetStack(const TList& forward, const char* sub, const char* name)
4 TList* lsub = static_cast<TList*>(forward.FindObject(sub));
6 Warning("GetStack", "Sub list %s not found in %s", sub, forward.GetName());
9 THStack* ret = static_cast<THStack*>(lsub->FindObject(name));
11 Warning("GetStack" "Stack %s not found in %s", name, sub);
16 Rebin(TH1* h, Int_t rebin)
18 if (rebin <= 1) return h;
25 Ratio(const TH1* h1, const TH1* h2)
30 TH1* copy = static_cast<TH1*>(h2->Clone("tmp"));
31 copy->SetName(Form("%s_%s", h2->GetName(), h1->GetName()));
32 copy->SetTitle(Form("%s/%s", h2->GetTitle(), h1->GetTitle()));
33 copy->SetDirectory(0);
40 Ratio(THStack* r, const THStack* h1, const THStack* h2)
45 int n1 = h1->GetHists()->GetEntries();
46 int n2 = h2->GetHists()->GetEntries();
48 for (int i = 0; i < n1 && i < n2; i++) {
49 TH1* hh1 = static_cast<TH1*>(h1->GetHists()->At(i));
50 TH1* hh2 = static_cast<TH1*>(h2->GetHists()->At(i));
51 TH1* h = Ratio(hh1, hh2);
60 DrawMCResult(const char* filename="forward.root", Int_t rebin=1,
63 gStyle->SetPalette(1);
65 gStyle->SetOptStat(0);
67 TFile* file = TFile::Open(filename, "READ");
69 Error("DrawMCResult", "failed to open %s", filename);
73 TList* forward = static_cast<TList*>(file->Get("Forward"));
75 Error("DrawMCResult", "List Forward not found in %s", filename);
78 THStack* res = GetStack(*forward, "ringResults", "all");
79 THStack* mcRes = GetStack(*forward, "mcRingResults", "all");
80 THStack* deltas = GetStack(*forward, "fmdSharingFilter", "sums");
81 THStack* nchs = GetStack(*forward, "fmdDensityCalculator", "sums");
82 THStack* prims = GetStack(*forward, "fmdCorrector", "sums");
84 TH1* sumEta = static_cast<TH1*>(forward->FindObject("mcSumEta"));
86 Warning("DrawMCResults", "mcSumEta not found in Forward");
90 gStyle->SetTitleBorderSize(0);
91 gStyle->SetTitleFillColor(0);
92 gStyle->SetTitleStyle(0);
93 // gStyle->SetTitleColor(kBlack);
96 TCanvas* c = new TCanvas("c", "C", 900, 700);
99 c->SetTopMargin(0.05);
100 c->SetRightMargin(0.05);
102 Double_t y1 = (ratios ? .3 : 0);
103 TPad* p1 = new TPad("p1", "p1", 0, y1, 1, 1, 0, 0, 0);
104 p1->SetBottomMargin(ratios ? 0.01 : .10);
106 p1->SetBorderSize(0);
107 p1->SetTopMargin(0.05);
108 p1->SetRightMargin(0.05);
112 THStack* all = new THStack("all", "Analysis steps");
114 res->SetTitle("dN_{ch}/d#eta");
115 TIter next(res->GetHists());
117 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
120 mcRes->SetTitle("Track-Refs");
121 TIter next(mcRes->GetHists());
123 while ((h = static_cast<TH1*>(next()))) all->Add(Rebin(h,rebin));
126 deltas->SetTitle("#sum_{} #Delta/#Delta_{mip}");
127 TIter next(deltas->GetHists());
129 while ((h = static_cast<TH1*>(next()))) {
130 h->SetMarkerStyle(25);
131 all->Add(Rebin(h,rebin));
135 nchs->SetTitle("#sum_{} N_{ch,incl}");
136 TIter next(nchs->GetHists());
138 while ((h = static_cast<TH1*>(next()))) {
139 h->SetMarkerStyle(21);
140 all->Add(Rebin(h,rebin));
144 prims->SetTitle("#sum_{} N_{ch,primary}");
145 TIter next(prims->GetHists());
147 while ((h = static_cast<TH1*>(next()))) {
148 h->SetMarkerStyle(22);
149 all->Add(Rebin(h,rebin));
152 if (sumEta) all->Add(sumEta);
153 all->Draw("nostack");
154 all->GetHistogram()->SetXTitle("#eta");
155 all->GetHistogram()->SetYTitle("signal");
156 all->GetHistogram()->GetXaxis()->SetLabelFont(132);
157 all->GetHistogram()->GetXaxis()->SetTitleFont(132);
158 all->GetHistogram()->GetYaxis()->SetLabelFont(132);
159 all->GetHistogram()->GetYaxis()->SetTitleFont(132);
162 TLegend* l = new TLegend(.33, .2, .53, .9);
171 TIter next(res->GetHists());
173 while ((h = static_cast<TH1*>(next()))) {
174 e = l->AddEntry(Form("dummy%02d", i++),h->GetTitle(),"pl");
175 e->SetMarkerStyle(20);
176 e->SetMarkerColor(h->GetMarkerColor());
178 e = l->AddEntry(Form("dummy%02d", i++),res->GetTitle(),"pl");
179 e->SetMarkerStyle(20);
180 e->SetMarkerColor(kBlack);
183 e = l->AddEntry(Form("dummy%02d", i++), deltas->GetTitle(),"pl");
184 TH1* h = static_cast<TH1*>(deltas->GetHists()->At(0));
185 e->SetMarkerStyle(h->GetMarkerStyle());
186 e->SetMarkerColor(kBlack);
189 e = l->AddEntry(Form("dummy%02d",i++),nchs->GetTitle(),"pl");
190 TH1* h = static_cast<TH1*>(nchs->GetHists()->At(0));
191 e->SetMarkerStyle(h->GetMarkerStyle());
192 e->SetMarkerColor(kBlack);
195 e = l->AddEntry(Form("dummy%02d", i++), prims->GetTitle(),"pl");
196 TH1* h = static_cast<TH1*>(prims->GetHists()->At(0));
197 e->SetMarkerStyle(h->GetMarkerStyle());
198 e->SetMarkerColor(kBlack);
202 e = l->AddEntry(Form("dummy%02d", i++), mcRes->GetTitle(), "pl");
203 TH1* h = static_cast<TH1*>(mcRes->GetHists()->At(0));
204 e->SetMarkerStyle(h->GetMarkerStyle());
205 e->SetMarkerColor(kBlack);
208 if (sumEta) l->AddEntry(sumEta);
215 TPad* p2 = new TPad("p2", "p2", 0, 0, 1, y1, 0, 0, 0);
218 p2->SetBorderSize(0);
219 p2->SetRightMargin(0.05);
223 THStack* rs = new THStack("ratios", "Ratios");
224 Int_t nDN = Ratio(rs, deltas, nchs);
225 Int_t nNR = Ratio(rs, nchs, res);
226 Int_t nRP = Ratio(rs, res, prims);
229 TLegend* ll = new TLegend(.38, .2, .48, .9);
232 ll->SetBorderSize(0);
234 ll->SetTextFont(132);
236 e = ll->AddEntry("d1", Form("#frac{%s}{%s}",
238 deltas->GetTitle()), "lp");
239 e->SetMarkerStyle(21);
242 e = ll->AddEntry("d2", Form("#frac{%s}{%s}", res->GetTitle(),
243 nchs->GetTitle()), "lp");
244 e->SetMarkerStyle(20);
247 e = ll->AddEntry("d3", Form("#frac{%s}{%s}", prims->GetTitle(),
248 res->GetTitle()), "lp");
249 e->SetMarkerStyle(22);