I am trying to fit a histogram with an exponential function and constant background.
I have attached the ROOT file that contains the histogram I am trying to fit.
My simple script to fit the histogram is:
#include "TFile.h"
#include "TH1F.h"
#include "TF1.h"
#include "TCanvas.h"
#include <iostream>
void fit(){
TFile* fIn = new TFile("output.root","READ");
TH1F* hist = (TH1F*) fIn->Get("hist");
TCanvas* c1 = new TCanvas("c1","c1");
TF1* fitting_function = new TF1("fitting_function","expo(0)+pol0(2)");
hist->Fit("fitting_function","","",0,6);
}
With ROOT 5 (/mnt/misc/sw/x86_64/Debian/8/root/gnu/5.34.32/bin/root), this script produces a reasonable fit (attached as ROOT_5.PNG), and the output is
root [0] .X fit.C
FCN=104.494 FROM MIGRAD STATUS=CONVERGED 193 CALLS 194 TOTAL
EDM=3.06699e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 5.56220e+00 2.40323e-02 8.08691e-05 3.16005e-02
2 p1 -6.58121e-01 3.44066e-02 6.18487e-05 2.30452e-04
3 p2 1.10443e+02 2.83615e+00 5.73207e-03 5.52584e-05
With ROOT 6 (/mnt/misc/sw/x86_64/Debian/8/root/gnu/6.04.02/bin/root), this no longer produces a reasonable fit (attached as ROOT_6.PNG), and the output is
root [0] .X fit.C
****************************************
Minimizer is Linear
Chi2 = 1.58239e+282
NDf = 117
p0 = 330.075 +/- 4.44962
p1 = -87.9062 +/- 3.01891
p2 = 9.02567 +/- 0.454093
Can someone please tell me what has happened between ROOT 5 and ROOT 6 such that I no longer obtain the same result?
output.root (3.8 KB)