AliPhysics  2c6b7ad (2c6b7ad)
DrawRubensCorr.C
Go to the documentation of this file.
1 
9 void
10 DrawRubensCorr(const char* fname="rubensRatio.root",
11  const char* hname = "dNdEtaCor1D_cls")
12 {
13  TFile* f = TFile::Open(fname, "READ");
14  if (!f) {
15  Error("DrawRubensCorr", "%s not found", fname);
16  return;
17  }
18  TH1D* h = static_cast<TH1D*>(f->Get(hname));
19  if (!h) {
20  Error("DrawRubensCorr", "%s not found in %s", hname, fname);
21  return;
22  }
23 
24  gStyle->SetOptTitle(0);
25  gStyle->SetOptStat(0);
26 
27  TCanvas* c = new TCanvas("c", "c", 800, 800);
28  c->SetFillColor(0);
29  c->SetFillStyle(0);
30  c->SetBorderSize(0);
31  c->SetBorderMode(0);
32  c->SetRightMargin(0.03);
33  c->SetLeftMargin(0.15);
34  c->SetTopMargin(0.03);
35 
36  h->GetXaxis()->SetTitleFont(132);
37  h->GetXaxis()->SetLabelFont(132);
38  h->GetXaxis()->SetDecimals();
39  h->GetYaxis()->SetTitleFont(132);
40  h->GetYaxis()->SetLabelFont(132);
41  h->GetYaxis()->SetDecimals();
42  h->GetYaxis()->SetTitleOffset(1.8);
43  h->SetYTitle("Clusters/Tracklets");
44  h->Draw();
45 
46  TF1* g = new TF1("g", "pol2", -2.2, 2.2);
47  g->SetLineWidth(2);
48  h->Fit(g, "NQ");
49  g->Draw("same");
50  Info("DrawRubensCorr", "Result of Fit:\n"
51  " chi^2/NDF = %7.4f / %2d = %7.4f\n"
52  " A = %+4.2f +/- %5.3f\n"
53  " B = %+5.3f +/- %6.4f\n"
54  " C = %+6.4f +/- %7.5f\n"
55  " f(x)=%4.2f%+5.3f*x%+6.4f*x*x",
56  g->GetChisquare(), g->GetNDF(), g->GetChisquare()/g->GetNDF(),
57  g->GetParameter(0), g->GetParError(0),
58  g->GetParameter(1), g->GetParError(1),
59  g->GetParameter(2), g->GetParError(2),
60  g->GetParameter(0), g->GetParameter(1), g->GetParameter(2));
61 
62  TLatex* ltx = new TLatex(.2, .9, Form("f(x)=%4.2f%+5.3fx%+6.4fx^{2}",
63  g->GetParameter(0),
64  g->GetParameter(1),
65  g->GetParameter(2)));
66  ltx->SetNDC();
67  ltx->SetTextFont(132);
68  ltx->Draw();
69 
70  c->SaveAs("rubens_corr.png");
71 }
72 
73 //
74 // EOF
75 //
TCanvas * c
Definition: TestFitELoss.C:172
Definition: External.C:212
void DrawRubensCorr(const char *fname="rubensRatio.root", const char *hname="dNdEtaCor1D_cls")