//! Get the coefficients of a given spline segment in the form a + bx + cx^2 + dx^3
/*!
\param [in] segIndex refers to the index of the knot at the left end of the segment (segIndex = 0 gets the coefficients of the the segment between x_0 and x_1)
\param [in] normalise if true, the coefficients returned will be normalised by the integral of the complete spline (defaults to false)
std::cerr << "WARNING in LauSplineDecayTimeEfficiency::fitToTH1 : fit failed with status " << fitResult->Status() << " and covariance matrix status " << fitResult->CovMatrixStatus() << "\n";
std::cerr << " : will not update spline parameters based on this fit result" << std::endl;
return;
}
if ( fitResult->CovMatrixStatus() == 2 )
{
std::cerr << "WARNING in LauSplineDecayTimeEfficiency::fitToTH1 : final covariance matrix not PosDef!" << std::endl;
std::cerr << " : continuing, but double check your fit!" << std::endl;
}
const std::size_t nKnots { ownedParams_.size() };
for ( std::size_t knot{0}; knot < nKnots; ++knot ) {
/* case Lau1DCubicSpline::AkimaSpline: // Double check the Akima description of splines (in evaluate) right now they're the same except for the first derivatives
{
//using fomulae from https://asmquantmacro.com/2015/09/01/akima-spline-interpolation-in-excel/
std::function<Double_t(Int_t)> m = [&](Int_t j) //formula to get the straight line gradient
{
if(j < 0){return 2*m(j+1)-m(j+2);}
if(j >= nKnots_){return 2*m(j-1)-m(j-2);}
return (y_[j+1]-y_[j]) / (x_[j+1]-x_[j]);
};
auto t = [&](Int_t j)
{
Double_t res = 0.; //originally res was called 't' but that produced a shadow warning