ROOT logo
/** 
 * Draw Rubens corrections 
 * 
 * @param fname 
 * @param hname 
 *
 * @ingroup pwglf_forward_scripts
 */
void
DrawRubensCorr(const char* fname="rubensRatio.root",
	       const char* hname = "dNdEtaCor1D_cls")
{
  TFile* f = TFile::Open(fname, "READ");
  if (!f) { 
    Error("DrawRubensCorr", "%s not found", fname);
    return;
  }
  TH1D* h = static_cast<TH1D*>(f->Get(hname));
  if (!h) {
    Error("DrawRubensCorr", "%s not found in %s", hname, fname);
    return;
  }

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  
  TCanvas* c = new TCanvas("c", "c", 800, 800);
  c->SetFillColor(0);
  c->SetFillStyle(0);
  c->SetBorderSize(0);
  c->SetBorderMode(0);
  c->SetRightMargin(0.03);
  c->SetLeftMargin(0.15);
  c->SetTopMargin(0.03);
  
  h->GetXaxis()->SetTitleFont(132);
  h->GetXaxis()->SetLabelFont(132);
  h->GetXaxis()->SetDecimals();
  h->GetYaxis()->SetTitleFont(132);
  h->GetYaxis()->SetLabelFont(132);
  h->GetYaxis()->SetDecimals();
  h->GetYaxis()->SetTitleOffset(1.8);
  h->SetYTitle("Clusters/Tracklets");
  h->Draw();
  
  TF1* g = new TF1("g", "pol2", -2.2, 2.2);
  g->SetLineWidth(2);
  h->Fit(g, "NQ");
  g->Draw("same");
  Info("DrawRubensCorr", "Result of Fit:\n"
       "  chi^2/NDF = %7.4f / %2d = %7.4f\n"
       "  A =   %+4.2f +/-   %5.3f\n"
       "  B =  %+5.3f +/-  %6.4f\n"
       "  C = %+6.4f +/- %7.5f\n"
       "  f(x)=%4.2f%+5.3f*x%+6.4f*x*x",
       g->GetChisquare(), g->GetNDF(), g->GetChisquare()/g->GetNDF(), 
       g->GetParameter(0), g->GetParError(0), 
       g->GetParameter(1), g->GetParError(1), 
       g->GetParameter(2), g->GetParError(2), 
       g->GetParameter(0), g->GetParameter(1), g->GetParameter(2));

  TLatex* ltx = new TLatex(.2, .9, Form("f(x)=%4.2f%+5.3fx%+6.4fx^{2}",
					g->GetParameter(0), 
					g->GetParameter(1), 
					g->GetParameter(2)));
  ltx->SetNDC();
  ltx->SetTextFont(132);
  ltx->Draw();

  c->SaveAs("rubens_corr.png");
}

//
// EOF
//
 DrawRubensCorr.C:1
 DrawRubensCorr.C:2
 DrawRubensCorr.C:3
 DrawRubensCorr.C:4
 DrawRubensCorr.C:5
 DrawRubensCorr.C:6
 DrawRubensCorr.C:7
 DrawRubensCorr.C:8
 DrawRubensCorr.C:9
 DrawRubensCorr.C:10
 DrawRubensCorr.C:11
 DrawRubensCorr.C:12
 DrawRubensCorr.C:13
 DrawRubensCorr.C:14
 DrawRubensCorr.C:15
 DrawRubensCorr.C:16
 DrawRubensCorr.C:17
 DrawRubensCorr.C:18
 DrawRubensCorr.C:19
 DrawRubensCorr.C:20
 DrawRubensCorr.C:21
 DrawRubensCorr.C:22
 DrawRubensCorr.C:23
 DrawRubensCorr.C:24
 DrawRubensCorr.C:25
 DrawRubensCorr.C:26
 DrawRubensCorr.C:27
 DrawRubensCorr.C:28
 DrawRubensCorr.C:29
 DrawRubensCorr.C:30
 DrawRubensCorr.C:31
 DrawRubensCorr.C:32
 DrawRubensCorr.C:33
 DrawRubensCorr.C:34
 DrawRubensCorr.C:35
 DrawRubensCorr.C:36
 DrawRubensCorr.C:37
 DrawRubensCorr.C:38
 DrawRubensCorr.C:39
 DrawRubensCorr.C:40
 DrawRubensCorr.C:41
 DrawRubensCorr.C:42
 DrawRubensCorr.C:43
 DrawRubensCorr.C:44
 DrawRubensCorr.C:45
 DrawRubensCorr.C:46
 DrawRubensCorr.C:47
 DrawRubensCorr.C:48
 DrawRubensCorr.C:49
 DrawRubensCorr.C:50
 DrawRubensCorr.C:51
 DrawRubensCorr.C:52
 DrawRubensCorr.C:53
 DrawRubensCorr.C:54
 DrawRubensCorr.C:55
 DrawRubensCorr.C:56
 DrawRubensCorr.C:57
 DrawRubensCorr.C:58
 DrawRubensCorr.C:59
 DrawRubensCorr.C:60
 DrawRubensCorr.C:61
 DrawRubensCorr.C:62
 DrawRubensCorr.C:63
 DrawRubensCorr.C:64
 DrawRubensCorr.C:65
 DrawRubensCorr.C:66
 DrawRubensCorr.C:67
 DrawRubensCorr.C:68
 DrawRubensCorr.C:69
 DrawRubensCorr.C:70
 DrawRubensCorr.C:71
 DrawRubensCorr.C:72
 DrawRubensCorr.C:73
 DrawRubensCorr.C:74
 DrawRubensCorr.C:75
 DrawRubensCorr.C:76