Hello all,
I am fairly new to root, so I’m sorry if this is posted or something in the documentation. I got this 2D histogram that I shared here and tried to use it to fit for the first-order term of a pol5. I could fit without profileX but the Chi2/NDf is not ideal. I then tried to fit the profilX but a error message popped up saying the matrix is not positive definite. Weirdly enough, when I changed the fitting function from pol5 to pol3, it worked alright. The example code and outputs are pasted below. Does anyone have any insights of what might be happening here? All comments are appreciated.
Thanks!
TFile* rootfile = new TFile("example_hist.root");
h1=(TH2F*)rootfile->Get("hist3");
Prof1=(TProfile*)h1->ProfileX("prof_1",1,-1,"i");
pffit=(TFitResultPtr)Prof1->Fit("pol3","S");
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
****************************************
Minimizer is Linear / Migrad
Chi2 = 809.476
NDf = 476
p0 = -0.000387502 +/- 5.95421e-06
p1 = -0.00863839 +/- 0.000666944
p2 = 0.171426 +/- 0.0115273
p3 = 1.67383 +/- 0.45491
(TFitResultPtr &)
****************************************
Minimizer is Linear / Migrad
Chi2 = 809.476
NDf = 476
p0 = -0.000387502 +/- 5.95421e-06
p1 = -0.00863839 +/- 0.000666944
p2 = 0.171426 +/- 0.0115273
p3 = 1.67383 +/- 0.45491
pffit=(TFitResultPtr)Prof1->Fit("pol5","S");
Error in <TDecompChol::Decompose()>: matrix not positive definite
Error in <TDecompChol::Solve()>: Decomposition failed
Error in <TLinearFitter::Eval>: Matrix inversion failed
Warning in <Minimize>: TLinearFitter failed in finding the solution
/usr/include/c++/8/bits/stl_vector.h:1021: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::front() const [with _Tp = double; _Alloc = std::allocator<double>; std::vector<_Tp, _Alloc>::const_reference = const double&]: Assertion '__builtin_expect(!this->empty(), true)' failed.
ROOT Version: v6-28-04
Platform: Linux
Compiler: Not Provided