2 GetStack(const TList& forward, const char* sub, const char* name)
4 TList* lsub = &forward;
6 if (sub && sub[0] != '\0')
7 lsub = static_cast<TList*>(forward.FindObject(sub));
10 Warning("GetStack", "Sub list %s not found in %s", sub, forward.GetName());
13 THStack* ret = static_cast<THStack*>(lsub->FindObject(name));
15 Warning("GetStack" "Stack %s not found in %s", name, sub);
20 Rebin(TH1* h, Int_t rebin)
22 if (rebin <= 1) return h;
29 Ratio(const TH1* h1, const TH1* h2)
34 TH1* copy = static_cast<TH1*>(h2->Clone("tmp"));
35 copy->SetName(Form("%s_%s", h2->GetName(), h1->GetName()));
36 copy->SetTitle(Form("%s/%s", h2->GetTitle(), h1->GetTitle()));
37 copy->SetDirectory(0);
44 Ratio(THStack* r, const THStack* h1, const THStack* h2)
49 int n1 = h1->GetHists()->GetEntries();
50 int n2 = h2->GetHists()->GetEntries();
52 for (int i = 0; i < n1 && i < n2; i++) {
53 TH1* hh1 = static_cast<TH1*>(h1->GetHists()->At(i));
54 TH1* hh2 = static_cast<TH1*>(h2->GetHists()->At(i));
55 TH1* h = Ratio(hh1, hh2);
64 AddToAll(THStack* all, const TH1* h, Bool_t singleStep)
66 TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
67 copy->SetDirectory(0);
69 copy->SetMarkerColor(kGray);
70 copy->SetLineColor(kGray);
76 DimEntry(Int_t thisId, Int_t step, TLegendEntry* e)
79 Int_t col = (thisId == step || step <= 0) ? kBlack : kGray;
80 e->SetMarkerColor(col);
86 DrawStep(THStack* deltas, THStack* nchs, THStack* prims,
87 TH1* dndeta, Int_t step)
89 THStack* all = new THStack("all", "Analysis steps");
90 if (step > 0) all->SetTitle(Form("Step %d", step));
93 deltas->SetTitle("#sum_{} #Delta/#Delta_{mip}");
94 TIter next(deltas->GetHists());
96 while ((h = static_cast<TH1*>(next()))) {
97 h->SetMarkerStyle(25);
98 // Info("DrawStep", "Adding %s", h->GetName());
99 AddToAll(all, h, step>0);
103 nchs->SetTitle("#sum_{} N_{ch,incl}");
104 TIter next(nchs->GetHists());
106 while ((h = static_cast<TH1*>(next()))) {
107 h->SetMarkerStyle(21);
108 // Info("DrawStep", "Adding %s", h->GetName());
109 AddToAll(all, h, step>0);
113 prims->SetTitle("#sum_{} N_{ch,primary}");
114 TIter next(prims->GetHists());
116 while ((h = static_cast<TH1*>(next()))) {
117 h->SetMarkerStyle(22);
118 // Info("DrawStep", "Adding %s", h->GetName());
119 AddToAll(all, h, step>0);
123 dndeta->SetTitle("1/N dN_{ch}/d#eta");
124 dndeta->SetMarkerStyle(20);
125 dndeta->SetMarkerColor(kBlack);
126 // Info("DrawStep", "Adding %s", dndeta->GetName());
127 AddToAll(all, dndeta, step>0);
130 all->Draw("nostack");
131 all->GetHistogram()->SetXTitle("#eta");
132 all->GetHistogram()->SetYTitle("signal");
133 all->GetHistogram()->GetXaxis()->SetLabelFont(132);
134 all->GetHistogram()->GetXaxis()->SetTitleFont(132);
135 all->GetHistogram()->GetYaxis()->SetLabelFont(132);
136 all->GetHistogram()->GetYaxis()->SetTitleFont(132);
139 TLegend* l = new TLegend(.33, .2, .53, .9);
148 TIter next(deltas->GetHists());
150 while ((h = static_cast<TH1*>(next()))) {
151 e = l->AddEntry(Form("dummy%02d", i++),h->GetTitle(),"pl");
152 e->SetMarkerStyle(20);
153 e->SetMarkerColor(h->GetMarkerColor());
155 e = l->AddEntry(Form("dummy%02d", i++), deltas->GetTitle(),"pl");
156 TH1* h = static_cast<TH1*>(deltas->GetHists()->At(0));
157 e->SetMarkerStyle(h->GetMarkerStyle());
158 DimEntry(1, step, e);
161 e = l->AddEntry(Form("dummy%02d",i++),nchs->GetTitle(),"pl");
162 TH1* h = static_cast<TH1*>(nchs->GetHists()->At(0));
163 e->SetMarkerStyle(h->GetMarkerStyle());
164 DimEntry(2, step, e);
167 e = l->AddEntry(Form("dummy%02d", i++), prims->GetTitle(),"pl");
168 TH1* h = static_cast<TH1*>(prims->GetHists()->At(0));
169 e->SetMarkerStyle(h->GetMarkerStyle());
170 DimEntry(3, step, e);
173 e = l->AddEntry(Form("dummy%02d", i++), dndeta->GetTitle(),"pl");
174 e->SetMarkerStyle(dndeta->GetMarkerStyle());
175 DimEntry(4, step, e);
183 deltas->Draw("same nostack");
184 what = "After merging";
187 nchs->Draw("same nostack");
188 what = "After particle counting";
191 prims->Draw("same nostack");
192 what = "After corrections";
195 dndeta->Draw("same");
196 what = "After normalisation";
199 Error("DrawSteps", "Unknown step: %d (must be in 1-4)");
203 TLatex* ltx = new TLatex(.95, .85, what);
205 ltx->SetTextSize(.07);
206 ltx->SetTextAlign(33);
207 ltx->SetTextFont(132);
212 void DrawSteps(const char* filename="forward.root", Bool_t single=true)
214 gStyle->SetPalette(1);
215 gStyle->SetOptFit(0);
216 gStyle->SetOptStat(0);
218 TFile* file = TFile::Open(filename, "READ");
220 Error("DrawMCResult", "failed to open %s", filename);
223 const char* fname2 = "forward_dndeta.root";
224 TFile* file2 = TFile::Open(fname2, "READ");
226 Error("DrawSteps", "File %s not found", fname2);
229 TList* forward = static_cast<TList*>(file->Get("Forward"));
231 Error("DrawMCResult", "List Forward not found in %s", filename);
234 TList* forwardRes = (file2 ?
235 static_cast<TList*>(file2->Get("ForwardResults")) :
237 TList* forwardAll = (forwardRes ?
238 static_cast<TList*>(forwardRes->FindObject("all")) :
242 // THStack* res = GetStack(*forward, "ringResults", "all");
243 // THStack* mcRes = GetStack(*forward, "mcRingResults", "all");
244 THStack* deltas = GetStack(*forward, "fmdSharingFilter", "sums");
245 THStack* nchs = GetStack(*forward, "fmdDensityCalculator", "sums");
246 THStack* prims = GetStack(*forward, "fmdCorrector", "sums");
247 TH1* dndeta = (forwardAll ?
248 static_cast<TH1*>(forwardAll->FindObject("dndetaForward")):
251 Info("DrawSteps", "Got steps deltas=%p, nchs=%p, prims=%p, dndeta=%p",
252 deltas, nchs, prims, dndeta);
255 gStyle->SetTitleBorderSize(0);
256 gStyle->SetTitleFillColor(0);
257 gStyle->SetTitleStyle(0);
258 gStyle->SetTitleX(.7);
259 gStyle->SetTitleY(.95);
260 gStyle->SetTitleH(.1);
261 gStyle->SetTitleW(.25);
262 gStyle->SetOptTitle(1);
263 // gStyle->SetTitleColor(kBlack);
268 TCanvas* c = new TCanvas("c", "C", 900, 700);
271 c->SetTopMargin(0.05);
272 c->SetRightMargin(0.05);
274 DrawStep(deltas, nchs, prims, dndeta, 0);
275 c->SaveAs("steps_all.png");
279 if (deltas) nSteps++;
282 if (dndeta) nSteps++;
284 Int_t w = (nSteps >= 4 ? 1100 : 700);
285 Int_t h = (nSteps >= 4 ? 800 : 1100);
287 TCanvas* c = new TCanvas("c", "C", w, h);
290 c->SetTopMargin(0.05);
291 c->SetRightMargin(0.05);
294 c->Divide(2,(nSteps+1)/2,0,0);
296 c->Divide(1,nSteps,0,0);
298 for (Int_t i=1; i<=nSteps; i++) {
299 TVirtualPad* p = c->cd(i);
306 DrawStep(deltas, nchs, prims, dndeta, i);
308 c->SaveAs("steps_comic.png");