15 if (!l->IsA()->InheritsFrom(TCollection::Class())) {
16 Error(
"GetObject",
"passed parent %s not a TCollection, but %s",
17 l->GetName(), l->IsA()->GetName());
22 Error(
"GetObject",
"No object '%s' found in '%s'", name, l->GetName());
48 TList* parent =
static_cast<TList*
>(dir->Get(which));
50 Error(
"GetHist",
"List '%s' not found in '%s'", which, dir->GetName());
53 TList* child =
static_cast<TList*
>(parent->FindObject(sub));
55 Error(
"GetHist",
"List '%s' not found in '%s'", sub, parent->GetName());
60 return static_cast<TH1D*
>(o);
82 const char* sub=
"all")
84 TString name(Form(
"dndeta%s", which));
85 if (rebin > 1) name.Append(Form(
"_rebin%02d", rebin));
86 return GetHist(dir, Form(
"%sResults", which), sub, name);
105 TH1* tmp =
static_cast<TH1*
>(fwd->Clone(
"dndetaMerged"));
108 tmp->SetDirectory(0);
111 for (
Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
113 Double_t cf = fwd->GetBinContent(i);
118 if (cc < 0.001 && cf < 0.01)
continue;
119 xlow = TMath::Min(tmp->GetXaxis()->GetBinLowEdge(i),xlow);
120 xhigh = TMath::Max(tmp->GetXaxis()->GetBinUpEdge(i),xhigh);
126 ne = TMath::Sqrt(ec*ec + ef*ef);
129 tmp->SetBinContent(i, nc);
130 tmp->SetBinError(i, ne);
158 return a1*(TMath::Gaus(x, 0, s1) - a2 * TMath::Gaus(x, 0, s2));
178 if (TMath::Abs(denom) < 1.e-6)
return 0;
179 return myFunc(xp, pp) / denom;
197 TF1* tmpf =
new TF1(
"tmpf",
"gaus", xlow, xhigh);
198 tmp->Fit(tmpf,
"N",
"");
199 tmp->SetDirectory(0);
201 TF1* fit =
new TF1(
"f",
myFunc, xlow, xhigh, 4);
202 fit->SetParNames(
"a_{1}",
"a_{2}",
"#sigma_{1}",
"#sigma_{2}");
203 fit->SetParameters(tmpf->GetParameter(0),
205 tmpf->GetParameter(2),
206 tmpf->GetParameter(2)/4);
207 fit->SetParLimits(3, 0, 100);
208 fit->SetParLimits(4, 0, 100);
209 tmp->Fit(fit,
"0W",
"");
225 for (
Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
226 Double_t tc = tmp->GetBinContent(i);
227 if (tc < 0.01)
continue;
228 Double_t x = tmp->GetXaxis()->GetBinCenter(i);
230 tmp->SetBinContent(i, y);
231 tmp->SetBinError(i,sysErr*y);
249 Int_t nBins = g->GetN();
250 TArrayF bins(nBins+1);
256 for (
Int_t i = 0; i < nBins; i++) {
260 xmin = TMath::Min(x-exl, xmin);
261 xmax = TMath::Max(x+exh, xmax);
262 bins.fArray[i] = x-exl;
263 bins.fArray[i+1] = x+exh;
265 if (dxi == 0 && i != 0) dxi = bins.fArray[i]-bins.fArray[i-1];
266 if (dx == 0) dx = dxi;
267 else if (dxi != dx) dx = 0;
269 y.fArray[i] = g->GetY()[i];
270 ey.fArray[i] = TMath::Max(g->GetEYlow()[i],g->GetEYhigh()[i]);
277 h =
new TH1D(name.Data(),
title.Data(), nBins,
278 bins[0]-dx/2, bins[nBins]+dx/2);
281 h =
new TH1D(name.Data(),
title.Data(), nBins, bins.fArray);
283 for (
Int_t i = 1; i <= nBins; i++) {
284 h->SetBinContent(i, y.fArray[i-1]);
285 h->SetBinError(i, ey.fArray[i-1]);
287 h->SetMarkerStyle(g->GetMarkerStyle());
288 h->SetMarkerColor(g->GetMarkerColor());
289 h->SetMarkerSize(g->GetMarkerSize());
310 TH1* ret =
static_cast<TH1*
>(h->Clone(Form(
"%s_%s",
313 ret->SetDirectory(0);
314 if (title) ret->SetTitle(title);
315 else ret->SetTitle(Form(
"%s (data) / %s",
316 h->GetTitle(),f->GetTitle()));
318 for (
Int_t i = 1; i <= ret->GetNbinsX(); i++) {
321 ret->SetBinContent(i,0);
322 ret->SetBinError(i,0);
330 ret->SetBinContent(i, yy);
331 ret->SetBinError(i, ey);
355 gROOT->SetMacroPath(Form(
".:$ALICE_PHYSICS.trunk/PWGLF/FORWARD/analysis2/:%s",
356 gROOT->GetMacroPath()));
357 gROOT->LoadMacro(
"OtherData.C");
363 if (!gp || !gn)
return 0;
368 Int_t nn = p->GetNbinsX();
369 xlow = n->GetXaxis()->GetXmin();
370 xhigh = p->GetXaxis()->GetXmax();
371 TH1D* ret =
new TH1D(
"ua5",
"UA5", 2*nn, xlow, xhigh);
372 ret->SetDirectory(0);
373 ret->SetMarkerColor(p->GetMarkerColor());
374 ret->SetMarkerStyle(p->GetMarkerStyle());
376 for (
Int_t i = 1; i <= nn; i++) {
377 ret->SetBinContent(nn+i, p->GetBinContent(i));
378 ret->SetBinContent( i, n->GetBinContent(i));
379 ret->SetBinError(nn+i, p->GetBinError(i));
380 ret->SetBinError( i, n->GetBinError(i));
399 TFile* forward_dndeta = TFile::Open(fname,
"READ");
400 if (!forward_dndeta) {
401 Error(
"DrawUA5Ratios",
"%s not found", fname);
412 if (!sys || !sNN || !trg)
return;
413 if (sys->GetUniqueID() != 1) {
414 Error(
"DrawUA5Ratios",
"Comparison only valid for pp, not %s",
418 if (sNN->GetUniqueID() != 900) {
419 Error(
"DrawUA5Ratios",
"Comparison only valid for 900GeV, not %dGeV",
423 if (trg->GetUniqueID() != 1 &&
424 trg->GetUniqueID() != 4) {
425 Error(
"DrawUA5Ratios",
426 "Comparison only valid for INEL or NSD, not %s (%d)",
427 trg->GetTitle(), trg->GetUniqueID());
433 TH1D* ali =
Merge(central, forward, alilow, alihigh);
434 TF1* alifit =
FitMerged(ali, alilow, alihigh);
435 ali->SetTitle(
"Forward+Central");
436 alifit->SetLineColor(kRed+1);
437 alifit->SetLineStyle(2);
438 alifit->SetName(
"alifit");
439 alifit->SetTitle(
"Fit to Forward+Central");
443 TH1D* ua5 =
GetUA5Data(trg->GetUniqueID(), ua5p, ua5n, ua5low, ua5high);
444 TF1* ua5fit =
FitMerged(ua5, ua5low, ua5high);
445 ua5fit->SetLineColor(kBlue+1);
446 ua5fit->SetLineStyle(3);
447 ua5fit->SetName(
"ua5fit");
448 ua5fit->SetTitle(
"Fit to UA5");
450 gStyle->SetOptTitle(0);
451 TCanvas*
c =
new TCanvas(
"c",
"C", 900, 900);
459 TPad* p1 =
new TPad(
"p1",
"p1", 0, yd, 1, 1, 0, 0, 0);
460 p1->SetBorderSize(0);
461 p1->SetBorderMode(0);
464 p1->SetRightMargin(0.02);
465 p1->SetTopMargin(0.02);
466 p1->SetBottomMargin(0.00);
471 THStack* all =
new THStack(
"all",
"All");
478 all->Draw(
"nostack");
479 all->SetMinimum(-.07);
480 all->GetXaxis()->SetTitleFont(132);
481 all->GetYaxis()->SetTitleFont(132);
482 all->GetXaxis()->SetLabelFont(132);
483 all->GetYaxis()->SetLabelFont(132);
484 all->GetYaxis()->SetDecimals();
486 all->Draw(
"nostack");
489 alifit->Draw(
"same");
490 ua5fit->Draw(
"same");
492 TLegend* l =
new TLegend(.2, .1, .8, .5,
493 Form(
"pp @ #sqrt{s}=900GeV, %s",trg->GetTitle()));
494 l->AddEntry(ua5, Form(
"U: %s", ua5->GetTitle()),
"lp");
495 l->AddEntry(forward,
"F: Forward",
"lp");
496 l->AddEntry(central,
"C: Central",
"lp");
498 Form(
"f: %s: %4.2f#left[e^{(x/%4.2f)^{2}}-"
499 "%4.2fe^{(x/%4.2f)^{2}}#right]",
501 alifit->GetParameter(0),
502 alifit->GetParameter(2),
503 alifit->GetParameter(1),
504 alifit->GetParameter(3)),
"l");
506 Form(
"u: %s: %4.2f#left[e^{(x/%4.2f)^{2}}-"
507 "%4.2fe^{(x/%4.2f)^{2}}#right]",
509 ua5fit->GetParameter(0),
510 ua5fit->GetParameter(2),
511 ua5fit->GetParameter(1),
512 ua5fit->GetParameter(3)),
"l");
520 TPad* p2 =
new TPad(
"p2",
"p2", 0, 0, 1, yd, 0, 0, 0);
521 p2->SetBorderSize(0);
522 p2->SetBorderMode(0);
525 p2->SetRightMargin(0.02);
526 p2->SetTopMargin(0.00);
527 p2->SetBottomMargin(0.15);
532 THStack* ratios =
new THStack(
"Ratios",
"Ratios");
533 TH1* ua5ali =
Ratio(ua5, alifit, 0);
534 TH1* aliua5 =
Ratio(ali, ua5fit, 0);
537 ratios->Draw(
"nostack");
538 ratios->SetMinimum(0.4);
539 ratios->GetYaxis()->SetTitleSize(2*ratios->GetYaxis()->GetTitleSize());
540 ratios->GetYaxis()->SetLabelSize(2*ratios->GetYaxis()->GetLabelSize());
541 ratios->GetYaxis()->SetNdivisions(508);
542 ratios->GetXaxis()->SetTitleSize(2*ratios->GetXaxis()->GetTitleSize());
543 ratios->GetXaxis()->SetLabelSize(2*ratios->GetXaxis()->GetLabelSize());
544 ratios->GetXaxis()->SetNdivisions(510);
545 ratios->GetXaxis()->SetTitle(
"#eta");
546 ratios->GetXaxis()->SetTitleFont(132);
547 ratios->GetYaxis()->SetTitleFont(132);
548 ratios->GetXaxis()->SetLabelFont(132);
549 ratios->GetYaxis()->SetLabelFont(132);
550 ratios->GetYaxis()->SetDecimals();
554 sysErr->SetPoint(0, all->GetHistogram()->GetXaxis()->GetXmin(),1);
555 sysErr->SetPoint(1, all->GetHistogram()->GetXaxis()->GetXmax(),1);
556 sysErr->SetPointError(0,0,.07);
557 sysErr->SetPointError(1,0,.07);
558 sysErr->SetTitle(
"Systematic error on Forward+Central");
559 sysErr->SetFillColor(kYellow+1);
560 sysErr->SetFillStyle(3001);
561 sysErr->SetHistogram(ratios->GetHistogram());
562 sysErr->DrawClone(
"ael3");
563 ratios->DrawClone(
"nostack same");
565 TF1* fitfit =
new TF1(
"fitfit",
myRatio, alilow, alihigh, 8);
566 fitfit->SetParameters(ua5fit->GetParameter(0),
567 ua5fit->GetParameter(1),
568 ua5fit->GetParameter(2),
569 ua5fit->GetParameter(3),
570 alifit->GetParameter(0),
571 alifit->GetParameter(1),
572 alifit->GetParameter(2),
573 alifit->GetParameter(3));
574 fitfit->Draw(
"same");
576 TLegend* ll =
new TLegend(.3,.15, .7, .6);
577 ll->AddEntry(sysErr, sysErr->GetTitle(),
"f");
578 ll->AddEntry(ua5ali, ua5ali->GetTitle(),
"lp");
579 ll->AddEntry(aliua5, aliua5->GetTitle(),
"lp");
580 ll->AddEntry(fitfit,
"UA5 (fit) / Forward+Central (fit)",
"lp");
581 ll->SetTextFont(132);
582 ll->SetBorderSize(0);
588 c->SaveAs(Form(
"ua5_ratios_%s_r%02d.png", trg->GetTitle(),
rebin));
589 gROOT->GetInterpreter()->UnloadFile(
"OtherData.C");
Double_t myRatio(Double_t *xp, Double_t *pp)
TH1D * GetUA5Data(UShort_t type, TH1 *&p, TH1 *&n, Double_t &xlow, Double_t &xhigh)
TH1 * Graph2Hist(const TGraphAsymmErrors *g)
TObject * GetObject(const TObject *l, const char *name)
TH1 * Ratio(TH1 *h, TF1 *f, const char *title)
void MakeSysError(TH1 *tmp, TF1 *fit)
TH1 * Merge(const TH1 *cen, const TH1 *fwd, Double_t &xlow, Double_t &xhigh)
TObject * FindObject(int bin, const char *nameH, const TList *lst, Bool_t normPerEvent=kTRUE)
Double_t myFunc(Double_t *xp, Double_t *pp)
TF1 * FitMerged(TH1 *tmp, Double_t xlow, Double_t xhigh)
TH1D * GetHist(TDirectory *dir, const char *which, const char *sub, const char *hname)
void DrawUA5Ratios(const char *fname="forward_dndeta.root", UShort_t rebin=5)