I’m running this code with a ROOT::Math::Minimizer implemented. The problem is that my parameters are not optimized at all after minimization, the minimizer just returns input parameters.
Can someone help me see if the problem is in the code?
Thanks a lot,
main3.cpp (6.24 KB)
I briefly tried your code using:
min->SetPrintLevel(1); and it seems to me that it works fine (note that your “Chi Squared” function returns also negative values -> maybe you wanted to “return chi * chi;”).
Thanks for your reply.
I tried the setting you suggested, but it still gives the same result after fitting, the fit doesn’t improve anything, the two histograms, lab_frame and fitted look exactly the same.
My chi square is not really chi square, it’s a kinematic fit. If I understand, that constraint is what makes it to be negative sometimes.
And why do you expect that your fit will “improve” anything if your initial parameters are already at “minimum” (“E1fit = E1m”, “E2fit = E2m”, “theta = thetam” and I think that “lambda” is ill-defined as it jumps between its min and max allowed values so maybe you should “fix” it)?
Ok, that is a bad idea?
Yes, if I had the chi squared, that would be at minimum, but with the constraint 2lambda(2E1fitE2fit*(1-cos(theta)) - m0*m0) wouldn’t necessarily be satisfied for those starting values.
Thanks, I’ll try choosing different initial parameters.