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;
117 double powUp = std::pow(high / nominal, x0);
118 double powDown = std::pow(low / nominal, x0);
119 double logHi = std::log(high);
120 double logLo = std::log(low);
121 double powUpLog = high <= 0.0 ? 0.0 : powUp * logHi;
122 double powDownLog = low <= 0.0 ? 0.0 : -powDown * logLo;
123 double powUpLog2 = high <= 0.0 ? 0.0 : powUpLog * logHi;
124 double powDownLog2 = low <= 0.0 ? 0.0 : -powDownLog * logLo;
126 double S0 = 0.5 * (powUp + powDown);
127 double A0 = 0.5 * (powUp - powDown);
128 double S1 = 0.5 * (powUpLog + powDownLog);
129 double A1 = 0.5 * (powUpLog - powDownLog);
130 double S2 = 0.5 * (powUpLog2 + powDownLog2);
131 double A2 = 0.5 * (powUpLog2 - powDownLog2);
135 double a = 1. / (8 * x0) * (15 * A0 - 7 * x0 *
S1 + x0 * x0 * A2);
136 double b = 1. / (8 * x0 * x0) * (-24 + 24 *
S0 - 9 * x0 * A1 + x0 * x0 * S2);
137 double c = 1. / (4 * std::pow(x0, 3)) * (-5 * A0 + 5 * x0 *
S1 - x0 * x0 * A2);
138 double d = 1. / (4 * std::pow(x0, 4)) * (12 - 12 *
S0 + 7 * x0 * A1 - x0 * x0 * S2);
139 double e = 1. / (8 * std::pow(x0, 5)) * (+3 * A0 - 3 * x0 *
S1 + x0 * x0 * A2);
140 double f = 1. / (8 * std::pow(x0, 6)) * (-8 + 8 *
S0 - 5 * x0 * A1 + x0 * x0 * S2);
148flexibleInterp(
unsigned int code,
double low,
double high,
double boundary,
double nominal,
double paramVal,
double res)
153 return paramVal * (high - nominal);
155 return paramVal * (nominal - low);
156 }
else if (code == 1) {
159 return res * (std::pow(high / nominal, +paramVal) - 1);
161 return res * (std::pow(low / nominal, -paramVal) - 1);
162 }
else if (code == 2) {
164 double a = 0.5 * (high + low) - nominal;
165 double b = 0.5 * (high - low);
168 return (2 *
a +
b) * (paramVal - 1) + high - nominal;
169 }
else if (paramVal < -1) {
170 return -1 * (2 *
a -
b) * (paramVal + 1) + low - nominal;
172 return a * std::pow(paramVal, 2) +
b * paramVal +
c;
174 }
else if (code == 3) {
176 double a = 0.5 * (high + low) - nominal;
177 double b = 0.5 * (high - low);
180 return (2 *
a +
b) * (paramVal - 1) + high - nominal;
181 }
else if (paramVal < -1) {
182 return -1 * (2 *
a -
b) * (paramVal + 1) + low - nominal;
184 return a * std::pow(paramVal, 2) +
b * paramVal +
c;
186 }
else if (code == 4) {
189 return x * (high - nominal);
190 }
else if (
x <= -boundary) {
191 return x * (nominal - low);
195 }
else if (code == 5) {
199 mod = std::pow(high / nominal, +paramVal);
200 }
else if (
x <= -boundary) {
201 mod = std::pow(low / nominal, -paramVal);
205 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)