]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/scripts/DrawRubensCorr.C
27de9dc661b8a0b2a9f1f304427e0bfd409d8888
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / DrawRubensCorr.C
1 void
2 DrawRubensCorr(const char* fname="rubensRatio.root",
3                const char* hname = "dNdEtaCor1D_cls")
4 {
5   TFile* f = TFile::Open(fname, "READ");
6   if (!f) { 
7     Error("DrawRubensCorr", "%s not found", fname);
8     return;
9   }
10   TH1D* h = static_cast<TH1D*>(f->Get(hname));
11   if (!h) {
12     Error("DrawRubensCorr", "%s not found in %s", hname, fname);
13     return;
14   }
15
16   gStyle->SetOptTitle(0);
17   gStyle->SetOptStat(0);
18   
19   TCanvas* c = new TCanvas("c", "c", 800, 800);
20   c->SetFillColor(0);
21   c->SetFillStyle(0);
22   c->SetBorderSize(0);
23   c->SetBorderMode(0);
24   c->SetRightMargin(0.03);
25   c->SetLeftMargin(0.15);
26   c->SetTopMargin(0.03);
27   
28   h->GetXaxis()->SetTitleFont(132);
29   h->GetXaxis()->SetLabelFont(132);
30   h->GetXaxis()->SetDecimals();
31   h->GetYaxis()->SetTitleFont(132);
32   h->GetYaxis()->SetLabelFont(132);
33   h->GetYaxis()->SetDecimals();
34   h->GetYaxis()->SetTitleOffset(1.8);
35   h->SetYTitle("Clusters/Tracklets");
36   h->Draw();
37   
38   TF1* g = new TF1("g", "pol2", -2.2, 2.2);
39   g->SetLineWidth(2);
40   h->Fit(g, "NQ");
41   g->Draw("same");
42   Info("DrawRubensCorr", "Result of Fit:\n"
43        "  chi^2/NDF = %7.4f / %2d = %7.4f\n"
44        "  A =   %+4.2f +/-   %5.3f\n"
45        "  B =  %+5.3f +/-  %6.4f\n"
46        "  C = %+6.4f +/- %7.5f\n"
47        "  f(x)=%4.2f%+5.3f*x%+6.4f*x*x",
48        g->GetChisquare(), g->GetNDF(), g->GetChisquare()/g->GetNDF(), 
49        g->GetParameter(0), g->GetParError(0), 
50        g->GetParameter(1), g->GetParError(1), 
51        g->GetParameter(2), g->GetParError(2), 
52        g->GetParameter(0), g->GetParameter(1), g->GetParameter(2));
53
54   TLatex* ltx = new TLatex(.2, .9, Form("f(x)=%4.2f%+5.3fx%+6.4fx^{2}",
55                                         g->GetParameter(0), 
56                                         g->GetParameter(1), 
57                                         g->GetParameter(2)));
58   ltx->SetNDC();
59   ltx->SetTextFont(132);
60   ltx->Draw();
61
62   c->SaveAs("rubens_corr.png");
63 }
64