Skip to content

Commit

Permalink
[RF] Small fixup for using RooFit with new Clad 1.5
Browse files Browse the repository at this point in the history
Using template functions in the generated code can cause linker errors,
which is avoided with this suggested commit.

To be backported to the 6.32 branch.
  • Loading branch information
guitargeek committed May 21, 2024
1 parent baf0923 commit a2d3663
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion roofit/histfactory/src/FlexibleInterpVar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void FlexibleInterpVar::translate(RooFit::Detail::CodeSquashContext &ctx) const
}

std::string const &resName = ctx.buildCall("RooFit::Detail::MathFuncs::flexibleInterp", interpCode,
_paramList, n, _low, _high, _interpBoundary, _nominal);
_paramList, n, _low, _high, _interpBoundary, _nominal, 1.0);
ctx.addResult(this, resName);
}

Expand Down
4 changes: 2 additions & 2 deletions roofit/histfactory/src/PiecewiseInterpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ void PiecewiseInterpolation::translate(RooFit::Detail::CodeSquashContext &ctx) c
code += "double * " + highName + " = " + valsHighStr + " + " + nStr + " * " + idxName + ";\n";
code += "double " + nominalName + " = *(" + valsNominalStr + " + " + idxName + ");\n";

std::string funcCall = ctx.buildCall("RooFit::Detail::MathFuncs::flexibleInterp<false>", _interpCode[0], _paramSet,
n, lowName, highName, 1.0, nominalName);
std::string funcCall = ctx.buildCall("RooFit::Detail::MathFuncs::flexibleInterp", _interpCode[0], _paramSet, n,
lowName, highName, 1.0, nominalName, 0.0);
code += "double " + resName + " = " + funcCall + ";\n";

if (_positiveDefinite)
Expand Down
5 changes: 2 additions & 3 deletions roofit/roofitcore/inc/RooFit/Detail/MathFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,15 @@ inline double flexibleInterpSingle(unsigned int code, double low, double high, d
return 0.0;
}

template <bool cutoff = true>
inline double flexibleInterp(unsigned int code, double *params, unsigned int n, double *low, double *high,
double boundary, double nominal)
double boundary, double nominal, int doCutoff)
{
double total = nominal;
for (std::size_t i = 0; i < n; ++i) {
total += flexibleInterpSingle(code, low[i], high[i], boundary, nominal, params[i], total);
}

return cutoff && total <= 0 ? TMath::Limits<double>::Min() : total;
return doCutoff && total <= 0 ? TMath::Limits<double>::Min() : total;
}

inline double landau(double x, double mu, double sigma)
Expand Down

0 comments on commit a2d3663

Please sign in to comment.