Simple fitting example (1-d histogram with an interpreted function)
Processing /builddir/build/BUILD/root-6.10.00/tutorials/fit/fit1.C...
TFile** fillrandom.root
KEY:
TF1 sqroot;1 x*gaus(0) + [3]*form1
KEY:
TH1F h1f;1 Test random numbers
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.632 FROM MIGRAD STATUS=CONVERGED 125 CALLS 126 TOTAL
EDM=1.63207e-07 STRATEGY= 1
ERROR MATRIX UNCERTAINTY 8.1 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE
ERROR SIZE DERIVATIVE
1 p0 3.33513e+01 5.36413e-01 -2.78521e-03 -7.94128e-04
2 p1 3.99703e+00 1.71655e-02 -3.10949e-05 -3.54793e-02
3 p2 9.90940e-01 1.26286e-02 1.36450e-05 -3.87116e-02
4
p3 6.20311e+01 1.32826e+00 6.63847e-03 -4.19990e-04
fit1 : Real
Time = 0.75 seconds Cpu
Time = 0.75 seconds
void fit1() {
if (!file) {
gROOT->ProcessLine(
Form(
".x %s../hist/fillrandom.C",dir.
Data()));
if (!file) return;
}
if (!sqroot){
Error(
"fit1.C",
"Cannot find object sqroot of type TF1\n");
return;
}
if (!h1f){
Error(
"fit1.C",
"Cannot find object h1f of type TH1F\n");
return;
}
}
- Author
- Rene Brun
Definition in file fit1.C.