Example of fit where the model is histogram + function
****************************************
Minimizer is Minuit2 / Migrad
Chi2 = 7.84157
NDf = 96
Edm = 3.7399e-06
NCalls = 174
p0 = 156.638 +/- 5.91061 (limited)
p1 = 5.98183 +/- 0.0189043
p2 = -0.506659 +/- 0.0180481
p3 = 1.0003 +/- 0.0112955
void histgen() {
TF1 f1(
"f1",
"pol1",0,10);
f1.SetParameters(5,-0.5);
TH1F h(
"background",
"linear background",100,0,10);
h.FillRandom(
"f1",10000);
TFile f(
"background.root",
"recreate");
TF1 f2(
"f2",
"gaus",0,10);
f2.SetParameters(1,6,0.5);
}
double ftotal(
double *
x,
double *par) {
double arg = (xx-par[1])/par[2];
return sr + br;
}
void fithist() {
histgen();
background = (
TH1F*)
f->Get(
"background");
TF1 *ftot =
new TF1(
"ftot",ftotal,0,10,4);
}
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
virtual void SetParameters(const Double_t *params)
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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 Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
- Author
- Rene Brun
Definition in file fithist.C.