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
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=184.789 FROM MIGRAD STATUS=CONVERGED 129 CALLS 130 TOTAL
EDM=4.01602e-09 STRATEGY= 1
ERROR MATRIX UNCERTAINTY 2.6 per cent
EXT PARAMETER STEP FIRST
NO. NAME VALUE
ERROR SIZE DERIVATIVE
1 p0 3.32226e+01 5.39594e-01 9.16743e-04 5.92056e-05
2 p1 4.00592e+00 1.69991e-02 -8.61428e-06 -2.04543e-03
3 p2 9.78603e-01 1.25863e-02 -1.48149e-05 -6.05028e-03
4
p3 6.43256e+01 1.33534e+00 1.60525e-03 5.27512e-05
fit1 : Real Time = 0.54 seconds Cpu Time = 0.53 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.