Plot best fit with errors

Hello,
How can i plot and fit the data with first degree polynomial, reading in the data from an ascii file (see attached) Run_13-19.txt (1.7 KB)
i’m tryin to use this script basic.C (2.7 KB)
instead of plotting histogram : i’m not if its wise to use TGraph *h1 = new TGraph(nlines,time,Vi_brick1) ; gStyle->SetOptFit(0001);

i’m more interested in displaying the best fit line, with its parameters and excluding the points

Thank you in advance

{
  gStyle->SetStatStyle(0); // hollow
  gStyle->SetOptFit(10011);
  TTree *t = new TTree("ntuple", "data from txt file");
  t->ReadFile("Run_13-19.txt",
              "Time/I:Vi_Brick1/F:Io_Brick1:Vo_Brick1:Vi_Brick2:Io_Brick2:Vo_Brick2:Vi_Brick3:Io_Brick3:Vo_Brick3:Vi_Brick4:Io_Brick4:Vo_Brick4");
  t->SetEstimate(-1);
  // t->Print();
  t->SetMarkerStyle(kFullStar); t->SetMarkerColor(kMagenta);
  t->Draw("Vi_Brick1:Time");
  if (gPad) {
    TGraph *g = (TGraph*)gPad->GetPrimitive("Graph");
    if (g) {
      g->Fit("pol1", "Q");
#if 0 /* 0 or 1 */
      TF1 *f = (TF1*)g->GetListOfFunctions()->FindObject("pol1");
      if (f) {
        f = new TF1(*f); // make a copy
        f->Draw();
        TLatex *l = new TLatex(); l->SetTextFont(42); l->SetTextSize(0.03);
        l->DrawLatexNDC(0.35, 0.85, Form("p0 = %g #pm %g", f->GetParameter(0), f->GetParError(0)));
        l->DrawLatexNDC(0.35, 0.80, Form("p1 = %g #pm %g", f->GetParameter(1), f->GetParError(1)));
        // f->Print();
      }
#endif /* 0 or 1 */
    }
  }
}

I should incorporate this macro into the basic.C script?

If you want to display just the best fit line and exclude points on the graph, how would you go about doing that?

#if 1 /* 0 or 1 */

doing so it doesnt display the parameters of the best fit on the plot

In a case where by the each parameter (Vi_brick1,Io_brick1,Vo_brick1,…) have errors that accompanies them , how can i include them in the plots?