27 GetStack(
const TList& forward,
const char* sub,
const char* name)
29 TList* lsub = &forward;
31 if (sub && sub[0] !=
'\0')
32 lsub =
static_cast<TList*
>(forward.FindObject(sub));
35 Warning(
"GetStack",
"Sub list %s not found in %s", sub, forward.GetName());
38 THStack* ret =
static_cast<THStack*
>(lsub->FindObject(name));
40 Warning(
"GetStack" "Stack %s not found in %s", name, sub);
57 if (rebin <= 1)
return h;
79 TH1* copy =
static_cast<TH1*
>(h2->Clone(
"tmp"));
80 copy->SetName(Form(
"%s_%s", h2->GetName(), h1->GetName()));
81 copy->SetTitle(Form(
"%s/%s", h2->GetTitle(), h1->GetTitle()));
82 copy->SetDirectory(0);
100 Ratio(THStack* r,
const THStack* h1,
const THStack* h2)
105 int n1 = h1->GetHists()->GetEntries();
106 int n2 = h2->GetHists()->GetEntries();
108 for (
int i = 0; i < n1 && i < n2; i++) {
109 TH1* hh1 =
static_cast<TH1*
>(h1->GetHists()->At(i));
110 TH1* hh2 =
static_cast<TH1*
>(h2->GetHists()->At(i));
131 TH1* copy =
static_cast<TH1*
>(h->Clone(Form(
"%s_copy", h->GetName())));
132 copy->SetDirectory(0);
134 copy->SetMarkerColor(kGray);
135 copy->SetLineColor(kGray);
153 Int_t col = (thisId == step || step <= 0) ? kBlack : kGray;
154 e->SetMarkerColor(col);
155 e->SetLineColor(col);
156 e->SetTextColor(col);
171 DrawStep(THStack* deltas, THStack* nchs, THStack* prims,
174 THStack* all =
new THStack(
"all",
"Analysis steps");
175 if (step > 0) all->SetTitle(Form(
"Step %d", step));
178 deltas->SetTitle(
"#sum_{} #Delta/#Delta_{mip}");
179 TIter next(deltas->GetHists());
181 while ((h = static_cast<TH1*>(next()))) {
182 h->SetMarkerStyle(25);
188 nchs->SetTitle(
"#sum_{} N_{ch,incl}");
189 TIter next(nchs->GetHists());
191 while ((h = static_cast<TH1*>(next()))) {
192 h->SetMarkerStyle(21);
198 prims->SetTitle(
"#sum_{} N_{ch,primary}");
199 TIter next(prims->GetHists());
201 while ((h = static_cast<TH1*>(next()))) {
202 h->SetMarkerStyle(22);
208 dndeta->SetTitle(
"1/N dN_{ch}/d#eta");
209 dndeta->SetMarkerStyle(20);
210 dndeta->SetMarkerColor(kBlack);
215 all->Draw(
"nostack");
216 all->GetHistogram()->SetXTitle(
"#eta");
217 all->GetHistogram()->SetYTitle(
"signal");
218 all->GetHistogram()->GetXaxis()->SetLabelFont(132);
219 all->GetHistogram()->GetXaxis()->SetTitleFont(132);
220 all->GetHistogram()->GetYaxis()->SetLabelFont(132);
221 all->GetHistogram()->GetYaxis()->SetTitleFont(132);
224 TLegend* l =
new TLegend(.33, .2, .53, .9);
233 TIter next(deltas->GetHists());
235 while ((h = static_cast<TH1*>(next()))) {
236 e = l->AddEntry(Form(
"dummy%02d", i++),h->GetTitle(),
"pl");
237 e->SetMarkerStyle(20);
238 e->SetMarkerColor(h->GetMarkerColor());
240 e = l->AddEntry(Form(
"dummy%02d", i++), deltas->GetTitle(),
"pl");
241 TH1* h =
static_cast<TH1*
>(deltas->GetHists()->At(0));
242 e->SetMarkerStyle(h->GetMarkerStyle());
246 e = l->AddEntry(Form(
"dummy%02d",i++),nchs->GetTitle(),
"pl");
247 TH1* h =
static_cast<TH1*
>(nchs->GetHists()->At(0));
248 e->SetMarkerStyle(h->GetMarkerStyle());
252 e = l->AddEntry(Form(
"dummy%02d", i++), prims->GetTitle(),
"pl");
253 TH1* h =
static_cast<TH1*
>(prims->GetHists()->At(0));
254 e->SetMarkerStyle(h->GetMarkerStyle());
258 e = l->AddEntry(Form(
"dummy%02d", i++), dndeta->GetTitle(),
"pl");
259 e->SetMarkerStyle(dndeta->GetMarkerStyle());
268 deltas->Draw(
"same nostack");
269 what =
"After merging";
272 nchs->Draw(
"same nostack");
273 what =
"After particle counting";
276 prims->Draw(
"same nostack");
277 what =
"After corrections";
280 dndeta->Draw(
"same");
281 what =
"After normalisation";
284 Error(
"DrawSteps",
"Unknown step: %d (must be in 1-4)");
288 TLatex* ltx =
new TLatex(.95, .85, what);
290 ltx->SetTextSize(.07);
291 ltx->SetTextAlign(33);
292 ltx->SetTextFont(132);
306 gStyle->SetPalette(1);
307 gStyle->SetOptFit(0);
308 gStyle->SetOptStat(0);
312 Error(
"DrawMCResult",
"failed to open %s",
filename);
315 const char* fname2 =
"forward_dndeta.root";
316 TFile* file2 = TFile::Open(fname2,
"READ");
318 Error(
"DrawSteps",
"File %s not found", fname2);
321 TList* forward =
static_cast<TList*
>(file->Get(
"Forward"));
323 Error(
"DrawMCResult",
"List Forward not found in %s",
filename);
326 TList* forwardRes = (file2 ?
327 static_cast<TList*
>(file2->Get(
"ForwardResults")) :
329 TList* forwardAll = (forwardRes ?
330 static_cast<TList*
>(forwardRes->FindObject(
"all")) :
336 THStack* deltas =
GetStack(*forward,
"fmdSharingFilter",
"sums");
337 THStack* nchs =
GetStack(*forward,
"fmdDensityCalculator",
"sums");
338 THStack* prims =
GetStack(*forward,
"fmdCorrector",
"sums");
339 TH1* dndeta = (forwardAll ?
340 static_cast<TH1*
>(forwardAll->FindObject(
"dndetaForward")):
343 Info(
"DrawSteps",
"Got steps deltas=%p, nchs=%p, prims=%p, dndeta=%p",
344 deltas, nchs, prims, dndeta);
347 gStyle->SetTitleBorderSize(0);
348 gStyle->SetTitleFillColor(0);
349 gStyle->SetTitleStyle(0);
350 gStyle->SetTitleX(.7);
351 gStyle->SetTitleY(.95);
352 gStyle->SetTitleH(.1);
353 gStyle->SetTitleW(.25);
354 gStyle->SetOptTitle(1);
360 TCanvas*
c =
new TCanvas(
"c",
"C", 900, 700);
363 c->SetTopMargin(0.05);
364 c->SetRightMargin(0.05);
366 DrawStep(deltas, nchs, prims, dndeta, 0);
367 c->SaveAs(
"steps_all.png");
371 if (deltas) nSteps++;
374 if (dndeta) nSteps++;
376 Int_t w = (nSteps >= 4 ? 1100 : 700);
377 Int_t h = (nSteps >= 4 ? 800 : 1100);
379 TCanvas*
c =
new TCanvas(
"c",
"C", w, h);
382 c->SetTopMargin(0.05);
383 c->SetRightMargin(0.05);
386 c->Divide(2,(nSteps+1)/2,0,0);
388 c->Divide(1,nSteps,0,0);
390 for (
Int_t i=1; i<=nSteps; i++) {
391 TVirtualPad* p = c->cd(i);
398 DrawStep(deltas, nchs, prims, dndeta, i);
400 c->SaveAs(
"steps_comic.png");
void AddToAll(THStack *all, const TH1 *h, Bool_t singleStep)
void DimEntry(Int_t thisId, Int_t step, TLegendEntry *e)
void DrawStep(THStack *deltas, THStack *nchs, THStack *prims, TH1 *dndeta, Int_t step)
TH1 * Ratio(const TH1 *h1, const TH1 *h2)
TFile * file
TList with histograms for a given trigger.
THStack * GetStack(TCollection *c, const char *name, Bool_t verb=true)
void DrawSteps(const char *filename="forward.root", Bool_t single=true)