8 # include <TLegendEntry.h>
40 Warning(
"GetStack",
"List is null");
45 if (rebin > 1) n.Append(Form(
"_rebin%02d", rebin));
46 TObject* o = list->FindObject(n);
48 Warning(
"GetStack",
"No %s object found in %s", n.Data(), list->GetName());
51 return static_cast<THStack*
>(o);
69 Warning(
"GetStack",
"List is null");
72 TList* all =
static_cast<TList*
>(list->FindObject(
"all"));
74 Warning(
"GetHist",
"List all not found in %s", list->GetName());
79 if (rebin > 1) n.Append(Form(
"_rebin%02d", rebin));
80 TObject* o = all->FindObject(n);
82 Warning(
"GetStack",
"No %s object found in %s", n.Data(), all->GetName());
85 return static_cast<TH1*
>(o);
103 THStack* s =
GetStack(list, name, rebin);
106 TIter next(s->GetHists());
108 while ((hist = static_cast<TH1*>(next())))
124 TLegend* l =
new TLegend(1.2*gPad->GetLeftMargin(),
125 .55, .35, 1-gPad->GetTopMargin());
130 l->SetHeader(
"Centralities");
133 Int_t nCol = gStyle->GetNumberOfColors();
134 for (
Int_t i = 0; i < c->GetNbins(); i++) {
135 UShort_t low = c->GetBinLowEdge(i+1);
136 UShort_t high = c->GetBinUpEdge(i+1);
137 Float_t fc = (low+double(high-low)/2) / 100;
138 Int_t icol = TMath::Min(nCol-1,
int(fc * nCol + .5));
139 Int_t col = gStyle->GetColorPalette(icol);
140 TLegendEntry* e = l->AddEntry(Form(
"dummy%02d", i),
141 Form(
"%3d%% - %3d%%", low, high),
"p");
142 e->SetMarkerColor(col);
159 Double_t x1 = .75, x2 = 1-gPad->GetRightMargin();
160 Double_t y1 = .8, y2 = 1-gPad->GetTopMargin();
168 TLegend* l =
new TLegend(x1, y1, x2, y2,
"");
176 TIter next(stack->GetHists());
178 while ((hist = static_cast<TH1*>(next()))) {
180 if (n.Contains(
"mirrored"))
continue;
181 if (seen.FindObject(n.Data()))
continue;
182 TObjString* ns =
new TObjString(n);
183 ns->SetUniqueID(((hist->GetMarkerStyle() & 0xFFFF) << 16) |
184 ((hist->GetMarkerColor() & 0xFFFF) << 0));
191 while ((s = nextu())) {
192 TLegendEntry* dd = l->AddEntry(Form(
"data%2d", i++),
194 Int_t style = (s->GetUniqueID() >> 16) & 0xFFFF;
195 Int_t color = (s->GetUniqueID() >> 0) & 0xFFFF;
196 dd->SetLineColor(kBlack);
197 if (c) dd->SetMarkerColor(kBlack);
198 else dd->SetMarkerColor(color);
199 dd->SetMarkerStyle(style);
200 Int_t st = dd->GetMarkerStyle();
201 if (st == 27 || st == 28 || st == 29 || st == 30 || st == 33 || st == 34)
202 dd->SetMarkerSize(1.4*dd->GetMarkerSize());
206 TLine* sep =
new TLine(0,0,1,1);
207 sep->SetLineWidth(1);
208 sep->DrawLineNDC(x1+.02, y1-.005, x2-.03, y1-.005);
211 TLegend* l2 =
new TLegend(x1, y1-.005, x2, y1-.15,
"");
214 l2->SetBorderSize(0);
215 l2->SetTextFont(132);
217 TLegendEntry* d1 = l2->AddEntry(
"d1",
"Data",
"p");
218 d1->SetLineColor(kBlack);
219 d1->SetMarkerColor(kBlack);
220 d1->SetMarkerStyle(20);
221 TLegendEntry* d2 = l2->AddEntry(
"d2",
"Mirrored data",
"p");
222 d2->SetLineColor(kBlack);
223 d2->SetMarkerColor(kBlack);
224 d2->SetMarkerStyle(24);
243 TLatex* wip =
new TLatex(x, y,
"Work in progress");
245 wip->SetTextColor(TColor::GetColor(234,26,46));
246 wip->SetTextAlign(13);
247 wip->SetTextFont(132);
248 wip->SetTextSize(ts);
253 TObject* sNN = forward->FindObject(
"sNN");
254 TObject* sys = forward->FindObject(
"sys");
255 TObject* trg = forward->FindObject(
"trigger");
256 TObject* vtx = forward->FindObject(
"vtxAxis");
257 TObject* sch = forward->FindObject(
"scheme");
263 TString s = Form(
"%s @ #sqrt{s%s}=",
265 (isPP ?
"" :
"_{NN}"));
266 Int_t cms = sNN->GetUniqueID();
267 if (cms > 1000) s.Append(Form(
"%5.2fTeV",
float(cms)/1000));
268 else s.Append(Form(
"%3dGeV", cms));
269 s.Append(Form(
", %s", trg->GetTitle()));
273 x = 1-gPad->GetRightMargin()-.01;
274 y = 1-gPad->GetTopMargin()-.01;
277 TLatex* ltx =
new TLatex(x, y, s.Data());
279 ltx->SetTextColor(TColor::GetColor(41,73,156));
280 ltx->SetTextAlign((isPP ? 33 : 13));
281 ltx->SetTextFont(132);
282 ltx->SetTextSize(ts);
285 ltx->DrawLatex(x, y, vtx->GetTitle());
287 ltx->DrawLatex(x, y, sch->GetTitle());
307 return a1*(TMath::Gaus(x, 0, s1) - a2 * TMath::Gaus(x, 0, s2));
324 TH1* tmp =
static_cast<TH1*
>(fwd->Clone(
"dndetaFitted"));
325 tmp->SetMarkerStyle(0);
326 tmp->SetFillColor(kGray);
327 tmp->SetFillStyle(3001);
328 tmp->SetDirectory(0);
331 for (
Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
333 Double_t cf = fwd->GetBinContent(i);
338 if (cc < 0.001 && cf < 0.01)
continue;
339 xlow = TMath::Min(tmp->GetXaxis()->GetBinLowEdge(i),xlow);
340 xhigh = TMath::Max(tmp->GetXaxis()->GetBinUpEdge(i),xhigh);
346 ne = TMath::Sqrt(ec*ec + ef*ef);
349 tmp->SetBinContent(i, nc);
350 tmp->SetBinError(i, ne);
352 TF1* tmpf =
new TF1(
"tmpf",
"gaus", xlow, xhigh);
353 tmp->Fit(tmpf,
"NQ",
"");
355 TF1* fit =
new TF1(
"f",
myFunc, xlow, xhigh, 4);
356 fit->SetParNames(
"a_{1}",
"a_{2}",
"#sigma_{1}",
"#sigma_{2}");
357 fit->SetParameters(tmpf->GetParameter(0),
359 tmpf->GetParameter(2),
360 tmpf->GetParameter(2)/4);
361 tmp->Fit(fit,
"0WQ",
"");
362 for (
Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
363 Double_t tc = tmp->GetBinContent(i);
364 if (tc < 0.01)
continue;
365 Double_t x = tmp->GetXaxis()->GetBinCenter(i);
367 tmp->SetBinContent(i, y);
368 tmp->SetBinError(i,sysErr*y);
388 Error(
"SimpledNdeta",
"File %s not found",
filename);
392 TList* forward =
static_cast<TList*
>(file->Get(
"ForwardResults"));
393 TList* central =
static_cast<TList*
>(file->Get(
"CentralResults"));
394 TList* mctruth =
static_cast<TList*
>(file->Get(
"MCTruthResults"));
396 THStack* all =
new THStack(
"all",
"All");
412 TAxis* centAxis =
static_cast<TAxis*
>(forward->FindObject(
"centAxis"));
413 Bool_t isPP = centAxis == 0;
415 gStyle->SetPalette(1);
416 gStyle->SetOptTitle(0);
417 TCanvas*
c =
new TCanvas(
"dndeta",
"dN/deta results", 900, 600);
422 c->SetTopMargin(0.03);
423 c->SetRightMargin(0.03);
425 all->Draw(
"nostack");
426 TAxis* xa = all->GetHistogram()->GetXaxis();
427 xa->SetTitleFont(132);
428 xa->SetLabelFont(132);
429 xa->SetTitle(
"#eta");
430 TAxis* ya = all->GetHistogram()->GetYaxis();
431 ya->SetTitleFont(132);
432 ya->SetLabelFont(132);
433 ya->SetTitle(
"dN_{ch}/d#eta");
436 tmp->Draw(
"e5 same");
437 all->Draw(
"same nostack");
449 c->SaveAs(
"dndeta_simple.C");
450 c->SaveAs(
"dndeta_simple.png");
451 c->SaveAs(
"dndeta_simple.root");
THStack * GetStack(const TList *list, const char *name, Int_t rebin)
TH1 * GetHist(const TList *list, const char *name, Int_t rebin)
Double_t myFunc(Double_t *xp, Double_t *pp)
void BuildLegend(const THStack *stack, const TAxis *c)
TH1 * MakeSysError(const TH1 *cen, const TH1 *fwd, Double_t sysErr=0.7)
void BuildCentLegend(const TAxis *c)
void SimpledNdeta(Int_t what=0x5, Int_t rebin=5, const char *filename="forward_dndeta.root")
THStack * AddStack(THStack *p, const TList *list, const char *name, Int_t rebin)
void AddInformation(TList *forward, bool prelim=true)