Simple fitting example (1-d histogram with an interpreted function)
Processing /builddir/build/BUILD/root-6.08.02/tutorials/fit/fit1.C...
TFile** fillrandom.root
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=221.728 FROM MIGRAD STATUS=CONVERGED 127 CALLS 128 TOTAL
EDM=2.78521e-09 STRATEGY= 1
ERROR MATRIX UNCERTAINTY 2.5 per cent
EXT PARAMETER STEP FIRST
1 p0 3.28007e+01 5.25704e-01 1.35072e-03 9.84426e-05
2 p1 3.97845e+00 1.78399e-02 1.77460e-05 6.60948e-04
3 p2 1.01167e+00 1.29497e-02 -2.41832e-05 1.87405e-03
4
p3 6.17770e+01 1.32090e+00 6.25672e-03 7.19377e-05
fit1 : Real
Time = 0.41 seconds Cpu
Time = 0.41 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.