Simple fitting example (1-d histogram with an interpreted function)
Processing /builddir/build/BUILD/root-6.12.06/tutorials/fit/fit1.C...
TFile** fillrandom.root
TFile* fillrandom.root
KEY: TFormula form1;1 abs(sin(x)/x)
KEY: TF1 sqroot;1 x*gaus(0) + [3]*form1
KEY: TH1F h1f;1 Test random numbers
Formula based function: sqroot
sqroot : x*gaus(0) + [3]*form1 Ndim= 1, Npar= 4, Number= 0
Formula expression:
x*[p0]*exp(-0.5*((x-[p1])/[p2])*((x-[p1])/[p2]))+[p3]*(abs(sin(x)/x))
FCN=215.496 FROM MIGRAD STATUS=CONVERGED 148 CALLS 149 TOTAL
EDM=1.05209e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 3.37529e+01 5.49951e-01 3.17285e-03 -1.79492e-04
2 p1 4.01796e+00 1.65251e-02 9.63030e-05 -1.67548e-02
3 p2 9.65158e-01 1.24813e-02 6.02951e-05 1.41151e-02
4 p3 6.31092e+01 1.31523e+00 9.06523e-03 -6.04942e-05
fit1 : Real Time = 0.35 seconds Cpu Time = 0.34 seconds
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderMode(-1);
c1->GetFrame()->SetBorderSize(5);
gROOT->ProcessLine(
Form(
".x %s../hist/fillrandom.C",dir.
Data()));
}
file->GetObject(
"sqroot",sqroot);
if (!sqroot){
Error(
"fit1.C",
"Cannot find object sqroot of type TF1\n");
return;
}
file->GetObject(
"h1f",h1f);
if (!h1f){
Error(
"fit1.C",
"Cannot find object h1f of type TH1F\n");
return;
}
}
- Author
- Rene Brun
Definition in file fit1.C.