Fitting problem!

Your fit has the “STATUS=FAILED” (you could see it if you removed the “Q” fitting option).

You need to set “reasonable” initial values of fit parameters so, try something like this:

TF1 *gr_fit = ((TF1 *)(gROOT->GetFunction("pol1")));
gr_fit->SetParameters(-20, 2);
gr->Fit(gr_fit, "Q");

Or you can try to “help” to make your fit more “foolproof”:

TF1 *gr_fit = ((TF1 *)(gROOT->GetFunction("pol1")));
gr->Fit(gr_fit, "WQ"); // "initial pre-fit"
gr->Fit(gr_fit, "Q"); // "final fit"