 
  Example of fitting with a linear function, using TLinearFitter This example is for a TGraphErrors, but it can also be used when fitting a histogram, a TGraph2D or a TMultiGraph
  Example of fitting with a linear function, using TLinearFitter This example is for a TGraphErrors, but it can also be used when fitting a histogram, a TGraph2D or a TMultiGraph 
  
 
****************************************
Minimizer is Linear / Migrad
Chi2                      =      36.5406
NDf                       =           36
p0                        =     -7.07142   +/-   0.0233493   
p1                        =   -0.0194368   +/-   0.0354128   
p2                        =      2.03968   +/-   0.0136149   
p3                        =      1.00594   +/-   0.0139068   
 
****************************************
Minimizer is Linear / Migrad
Chi2                      =      46.7362
NDf                       =           38
p0                        =       1.0005   +/-   0.0242765   
p1                        =     0.985942   +/-   0.0279149   
 
****************************************
Minimizer is Linear / Migrad
Chi2                      =      43.6161
NDf                       =           38
p0                        =     -2.04095   +/-   0.0220454   
p1                        =      1.01171   +/-   0.00904363  
 
 
 
 
void fitLinear()
{
      "Fitting 3 TGraphErrors with linear functions");
 
   
   makePoints(
n, 
x, 
y, 
e, 3);
   
   
 
   
   makePoints(
n, 
x, 
y, 
e, 2);
   
   
   
   
   
   
   
   TF1 *f2 = 
new TF1(
"f2", 
"sin(x) ++ sin(2*x)", -2, 2);
 
 
   
   makePoints(
n, 
x, 
y, 
e, 4);
   
   
   gre4->
Fit(
"1 ++ exp(-x)");
   
 
   leg->AddEntry(gre3, 
" -7 + 2*x*x + x*x*x", 
"p");
 
   leg->AddEntry(gre2, 
"sin(x) + sin(2*x)", 
"p");
 
   leg->AddEntry(gre4, 
"-2 + exp(-x)", 
"p");
 
 
}
 
{
 
  if (p==2) {
    }
  }
  if (p==3) {
      y[i] = -7 + 2*
x[i]*
x[i] + 
x[i]*
x[i]*
x[i]+ 
r.Gaus()*0.1;
 
    }
  }
  if (p==4) {
    }
  }
}
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
A TGraphErrors is a TGraph with error bars.
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
This is the base class for the ROOT Random number generators.
- Author
- Anna Kreshuk 
Definition in file fitLinear.C.