Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:19:05

0001 void fitter()
0002 {
0003     // gStyle->SetOptStat(1111);
0004     // gStyle->SetOptFit(1111);
0005     TFile *f = new TFile("../../qa_results.root");
0006 
0007     TGraphErrors *g_locpolbf = (TGraphErrors*)f->Get("locpolphasebf");
0008 
0009     TF1 *fline = new TF1("fline","pol0",45000,52000);
0010 
0011     g_locpolbf->GetYaxis()->SetRangeUser(-5,5);
0012     g_locpolbf->GetYaxis()->SetTitle("Blue asymmetry phase (rad)");
0013     g_locpolbf->GetXaxis()->SetTitle("Run number");
0014     g_locpolbf->Draw("ape");
0015 
0016     g_locpolbf->Fit(fline,"rob=0.8");
0017 
0018     float constant = fline->GetParameter(0);
0019 
0020     float RMSE = 0.;
0021     for (int i = 0; i < g_locpolbf->GetN(); ++i)
0022     {
0023         RMSE += pow(g_locpolbf->GetY()[i]-constant,2);
0024     }
0025 
0026     RMSE /= g_locpolbf->GetN();
0027     RMSE = sqrt(RMSE);
0028     std::cout << constant << " " << RMSE << std::endl;
0029 
0030     TLine *uband = new TLine(42000,constant+RMSE,54000,constant+RMSE);
0031     uband->SetLineStyle(2);
0032     uband->SetLineColor(kRed);
0033     uband->Draw();
0034 
0035     TLine *lband = new TLine(42000,constant-RMSE,54000,constant-RMSE);
0036     lband->SetLineStyle(2);
0037     lband->SetLineColor(kRed);
0038     lband->Draw();
0039 
0040 
0041 }