14#ifndef RooFit_Detail_EvaluateFuncs_h
15#define RooFit_Detail_EvaluateFuncs_h
26namespace EvaluateFuncs {
31 const double arg =
x - mean;
32 const double sig =
sigma;
33 return std::exp(-0.5 * arg * arg / (sig * sig));
37template <
bool pdfMode = false>
40 double retVal = coeffs[nCoeffs - 1];
41 for (
int i = nCoeffs - 2; i >= 0; i--)
42 retVal = coeffs[i] +
x * retVal;
43 retVal = retVal * std::pow(
x, lowestOrder);
44 return retVal + (pdfMode && lowestOrder > 0 ? 1.0 : 0.0);
47inline double chebychevEvaluate(
double *coeffs,
unsigned int nCoeffs,
double x_in,
double xMin,
double xMax)
50 const double xPrime = (x_in - 0.5 * (xMax + xMin)) / (0.5 * (xMax - xMin));
56 double twox = 2 * xPrime;
58 double newval = twox * curr - last;
61 for (
unsigned int i = 0; nCoeffs != i; ++i) {
62 sum += last * coeffs[i];
63 newval = twox * curr - last;
74 for (
unsigned int i = 0; i < compSize; i++) {
75 sum -= std::log(comp[i]);
80inline unsigned int getUniformBinning(
double low,
double high,
double val,
unsigned int numBins)
82 double binWidth = (high - low) / numBins;
83 return val >= high ? numBins - 1 : std::abs((val - low) / binWidth);
94 return std::exp(-par);
103 double t =
x / boundary;
104 double eps_plus = high - nominal;
105 double eps_minus = nominal - low;
106 double S = 0.5 * (eps_plus + eps_minus);
107 double A = 0.0625 * (eps_plus - eps_minus);
109 return x * (S + t * A * (15 + t * t * (-10 + t * t * 3)));
114 double x0 = boundary;
120 double powUp = std::pow(high, x0);
121 double powDown = std::pow(low, x0);
122 double logHi = std::log(high);
123 double logLo = std::log(low);
124 double powUpLog = high <= 0.0 ? 0.0 : powUp * logHi;
125 double powDownLog = low <= 0.0 ? 0.0 : -powDown * logLo;
126 double powUpLog2 = high <= 0.0 ? 0.0 : powUpLog * logHi;
127 double powDownLog2 = low <= 0.0 ? 0.0 : -powDownLog * logLo;
129 double S0 = 0.5 * (powUp + powDown);
130 double A0 = 0.5 * (powUp - powDown);
131 double S1 = 0.5 * (powUpLog + powDownLog);
132 double A1 = 0.5 * (powUpLog - powDownLog);
133 double S2 = 0.5 * (powUpLog2 + powDownLog2);
134 double A2 = 0.5 * (powUpLog2 - powDownLog2);
138 double a = 1. / (8 * x0) * (15 * A0 - 7 * x0 *
S1 + x0 * x0 * A2);
139 double b = 1. / (8 * x0 * x0) * (-24 + 24 *
S0 - 9 * x0 * A1 + x0 * x0 * S2);
140 double c = 1. / (4 * std::pow(x0, 3)) * (-5 * A0 + 5 * x0 *
S1 - x0 * x0 * A2);
141 double d = 1. / (4 * std::pow(x0, 4)) * (12 - 12 *
S0 + 7 * x0 * A1 - x0 * x0 * S2);
142 double e = 1. / (8 * std::pow(x0, 5)) * (+3 * A0 - 3 * x0 *
S1 + x0 * x0 * A2);
143 double f = 1. / (8 * std::pow(x0, 6)) * (-8 + 8 *
S0 - 5 * x0 * A1 + x0 * x0 * S2);
151flexibleInterp(
unsigned int code,
double low,
double high,
double boundary,
double nominal,
double paramVal,
double res)
156 return paramVal * (high - nominal);
158 return paramVal * (nominal - low);
159 }
else if (code == 1) {
162 return res * (std::pow(high / nominal, +paramVal) - 1);
164 return res * (std::pow(low / nominal, -paramVal) - 1);
165 }
else if (code == 2) {
167 double a = 0.5 * (high + low) - nominal;
168 double b = 0.5 * (high - low);
171 return (2 *
a +
b) * (paramVal - 1) + high - nominal;
172 }
else if (paramVal < -1) {
173 return -1 * (2 *
a -
b) * (paramVal + 1) + low - nominal;
175 return a * std::pow(paramVal, 2) +
b * paramVal +
c;
177 }
else if (code == 3) {
179 double a = 0.5 * (high + low) - nominal;
180 double b = 0.5 * (high - low);
183 return (2 *
a +
b) * (paramVal - 1) + high - nominal;
184 }
else if (paramVal < -1) {
185 return -1 * (2 *
a -
b) * (paramVal + 1) + low - nominal;
187 return a * std::pow(paramVal, 2) +
b * paramVal +
c;
189 }
else if (code == 4) {
192 return x * (high - nominal);
193 }
else if (
x <= -boundary) {
194 return x * (nominal - low);
198 }
else if (code == 5) {
202 mod = std::pow(high / nominal, +paramVal);
203 }
else if (
x <= -boundary) {
204 mod = std::pow(low / nominal, -paramVal);
208 return res * (mod - 1.0);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
double lognormal_pdf(double x, double m, double s, double x0=0)
Probability density function of the lognormal distribution.
double poissonEvaluate(double x, double par)
double constraintSumEvaluate(double const *comp, unsigned int compSize)
double gaussianEvaluate(double x, double mean, double sigma)
Function to evaluate an un-normalized RooGaussian.
double flexibleInterp(unsigned int code, double low, double high, double boundary, double nominal, double paramVal, double res)
double polynomialEvaluate(double const *coeffs, int nCoeffs, int lowestOrder, double x)
In pdfMode, a coefficient for the constant term of 1.0 is implied if lowestOrder > 0.
double logNormalEvaluate(double x, double k, double m0)
double logNormalEvaluateStandard(double x, double sigma, double mu)
double interpolate6thDegreeExp(double x, double low, double high, double nominal, double boundary)
unsigned int getUniformBinning(double low, double high, double val, unsigned int numBins)
double interpolate6thDegree(double x, double low, double high, double nominal, double boundary)
double chebychevEvaluate(double *coeffs, unsigned int nCoeffs, double x_in, double xMin, double xMax)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
static uint64_t sum(uint64_t i)