Example for fitting signal/background. 
This example can be executed with:
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
 
 
  
****************************************
Minimizer is Minuit2 / Migrad
Chi2                      =      58.9284
NDf                       =           54
Edm                       =  9.25609e-07
NCalls                    =          605
p0                        =    -0.864558   +/-   0.891619    
p1                        =      45.8427   +/-   2.65587     
p2                        =     -13.3213   +/-   0.980096    
p3                        =      13.8077   +/-   2.23262     
p4                        =     0.172312   +/-   0.0364912   
p5                        =     0.987278   +/-   0.0112098   
Minuit2Minimizer: Minimize with max-calls 1780 convergence for edm < 0.01 strategy 1
Minuit2Minimizer : Valid minimum - status = 0
FVAL  = 58.9283860619491762
Edm   = 4.48403149377138793e-13
Nfcn  = 163
p0   = -0.864713   +/-  0.891795
p1   = 45.8434  +/-  2.64223
p2   = -13.3214    +/-  0.976969
p3   = 13.8074  +/-  2.1776
p4   = 0.172309    +/-  0.0358281
p5   = 0.987281    +/-  0.0112683
 
Covariance Matrix:
 
                         p0          p1          p2          p3          p4          p5
p0                   0.7953     -1.2054     0.34842    -0.15945  -0.0037284  0.00042265
p1                  -1.2054      6.9814     -2.5255     -3.0272   -0.037043  -0.0018129
p2                  0.34842     -2.5255     0.95447      1.1587    0.014336  0.00058758
p3                 -0.15945     -3.0272      1.1587      4.7419     0.05537   0.0017371
p4               -0.0037284   -0.037043    0.014336     0.05537   0.0012837  2.8395e-05
p5               0.00042265  -0.0018129  0.00058758   0.0017371  2.8395e-05  0.00012697
 
Correlation Matrix:
 
                         p0          p1          p2          p3          p4          p5
p0                        1    -0.51155     0.39991    -0.08211    -0.11669    0.042058
p1                 -0.51155           1    -0.97834    -0.52614     -0.3913    -0.06089
p2                  0.39991    -0.97834           1     0.54464     0.40958    0.053373
p3                 -0.08211    -0.52614     0.54464           1      0.7097    0.070793
p4                 -0.11669     -0.3913     0.40958      0.7097           1    0.070334
p5                 0.042058    -0.06089    0.053373    0.070793    0.070334           1
****************************************
Minimizer is Minuit2 / Migrad
Chi2                      =      58.9284
NDf                       =           54
Edm                       =  4.48403e-13
NCalls                    =          163
p0                        =    -0.864713   +/-   0.891795    
p1                        =      45.8434   +/-   2.64223     
p2                        =     -13.3214   +/-   0.976969    
p3                        =      13.8074   +/-   2.1776      
p4                        =     0.172309   +/-   0.0358281   
p5                        =     0.987281   +/-   0.0112683   
   
 
   return par[0] + par[1]*
x[0] + par[2]*
x[0]*
x[0];
 
}
 
 
   + .25*par[1]*par[1]);
}
 
}
 
 
 
   const int nBins = 60;
 
   double data[nBins] = { 6, 1,10,12, 6,13,23,22,15,21,
 
                           23,26,36,25,27,35,40,44,66,81,
                           75,57,48,45,46,41,35,36,53,32,
                           40,37,38,31,36,44,42,37,32,32,
                           43,44,35,33,33,39,29,41,32,44,
                           26,39,29,35,32,21,21,15,25,15};
   c1->SetFrameFillColor(41);
 
 
      "Lorentzian Peak on Quadratic Background",60,0,3);
 
 
   
 
   
   
   
   
   
   fitFcn->SetParameters(1,1,1,1,1,1);
 
   histo->
Fit(
"fitFcn",
"0");
 
 
   
 
   histo->
Fit(
"fitFcn",
"V+",
"ep");
 
 
   
   double par[6];
 
   
 
 
 
   
   legend->AddEntry(histo,
"Data",
"lpe");
 
 
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
 
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
 
1-D histogram with a float per channel (see TH1 documentation)
 
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
 
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
 
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
 
This class displays a legend box (TPaveText) containing several legend entries.
 
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
 
- Author
 - Rene Brun 
 
Definition in file FittingDemo.C.