%%cpp -d #include "TCanvas.h" #include "TRandom3.h" #include "TGraph.h" #include "TMath.h" #include "TArc.h" #include "Fit/Fitter.h" #include int n=10000; TCanvas *c1 = new TCanvas("c1","c1",600,600); c1->SetGrid(); TGraph* gr = new TGraph(n); if (n> 999) gr->SetMarkerStyle(1); else gr->SetMarkerStyle(3); TRandom3 r; double x,y; for (int i=0;iSetPoint(i,x,y); } c1->DrawFrame(-5,-5,5,5); gr->Draw("p"); auto chi2Function = [&](const double *par) { //minimisation function computing the sum of squares of residuals // looping at the graph points int np = gr->GetN(); double f = 0; double *x = gr->GetX(); double *y = gr->GetY(); for (int i=0;iSetLineColor(kRed); arc->SetLineWidth(4); arc->SetFillStyle(0); arc->Draw(); gROOT->GetListOfCanvases()->Draw()