67 _x(
"x",
"Dependent", this,
x),
68 _coefList(
"coefList",
"List of coefficients", this),
73 coutE(InputArguments) <<
"RooLegacyExpPoly::ctor(" <<
GetName()
74 <<
") WARNING: lowestOrder must be >=0, setting value to 0" << std::endl;
86 _x(
"x", this, other.
_x),
102 std::vector<double> coefs;
112 for (
double coef : coefs) {
113 retval += coef * xpow;
117 if (std::numeric_limits<double>::max_exponent < retval) {
118 coutE(InputArguments) <<
"RooLegacyExpPoly::evaluateLog(" <<
GetName() <<
") ERROR: exponent at " <<
x
119 <<
" larger than allowed maximum, result will be infinite! " << retval <<
" > "
131 std::vector<std::span<const double>> vars;
133 vars.push_back(ctx.
at(
_x));
135 std::vector<double> coefVals;
137 vars.push_back(ctx.
at(coef));
140 std::array<double, 2> args{
static_cast<double>(
_lowestOrder),
static_cast<double>(
_coefList.size())};
152 double max = std::numeric_limits<double>::max_exponent / sz;
154 std::vector<double> coefs;
159 const double xmax =
x->getMax();
162 double thismax = max / xmaxpow;
164 coef->setVal(thismax);
165 coef->setMax(thismax);
179 const double val = std::exp(logval);
180 if (std::isinf(val)) {
181 coutE(InputArguments) <<
"RooLegacyExpPoly::evaluate(" <<
GetName()
182 <<
") ERROR: result of exponentiation is infinite! exponent was " << logval << std::endl;
211#define PI TMath::Pi()
214double deltaerf(
long double x1,
long double x2)
220 double y2 =
x1 > 0 ? erfc(
x1) : -erfc(-
x1);
221 double y1 =
x2 > 0 ? erfc(
x2) : -erfc(-
x2);
223 std::cout <<
"WARNING in calculation of analytical integral limited by numerical precision" << std::endl;
224 std::cout <<
"x: " <<
x1 <<
" , " <<
x2 << std::endl;
225 std::cout <<
"y: " <<
y1 <<
" , " <<
y2 << std::endl;
230double deltaerfi(
double x1,
double x2)
232 std::complex<double> u1 = {
x1, 0.};
233 std::complex<double> u2 = {
x2, 0.};
238 std::cout <<
"WARNING in calculation of analytical integral limited by numerical precision" << std::endl;
239 std::cout <<
"x: " <<
x1 <<
" , " <<
x2 << std::endl;
240 std::cout <<
"y: " <<
y1 <<
" , " <<
y2 << std::endl;
242 return y1.imag() -
y2.imag();
248 const double xmin =
_x.min(rangeName);
249 const double xmax =
_x.max(rangeName);
254 std::vector<double> coefs;
275 const double absa = std::abs(
a);
276 const double sqrta = std::sqrt(absa);
278 double d = ::deltaerf((-
b + 2 * absa *
xmax) / (2 * sqrta), (-
b + 2 * absa *
xmin) / (2 * sqrta));
279 double retval = exp(
b *
b / (4 * absa) +
c) * std::sqrt(
PI) *
d / (2 * sqrta);
282 double d = ::deltaerfi((
b + 2 * absa *
xmax) / (2 * sqrta), (
b + 2 * absa *
xmin) / (2 * sqrta));
283 double retval = exp(-
b *
b / (4 * absa) +
c) * std::sqrt(
PI) *
d / (2 * sqrta);
286 return 1. /
b * (std::exp(
b *
xmax) - exp(
b *
xmin)) * exp(
c);
299 std::stringstream ss;
306 ss << (static_cast<RooAbsReal *>(coef))->
getVal();
308 ss << coef->GetName();
310 ss <<
"*pow(" <<
_x.GetName() <<
"," << order <<
")";
ROOT::RRangeCast< T, true, Range_t > dynamic_range_cast(Range_t &&coll)
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
RooAbsArg()
Default constructor.
RooAbsPdf()
Default constructor.
virtual double getLogVal(const RooArgSet *set=nullptr) const
Return the log of the current value with given normalization An error message is printed if the argum...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
int getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
double evaluateLog() const
RooArgList const & coefList() const
Get the coefficient list.
RooAbsReal const & x() const
Get the x variable.
double getLogVal(const RooArgSet *nset) const override
Return the log of the current value with given normalization An error message is printed if the argum...
std::string getFormulaExpression(bool expand) const
double evaluate() const override
Evaluation.
void doEval(RooFit::EvalContext &) const override
Compute multiple values of ExpPoly distribution.
double analyticalIntegral(int code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
int lowestOrder() const
Return the order for the first coefficient in the list.
static std::complex< double > faddeeva(std::complex< double > z)
evaluate Faddeeva function for complex argument
Variable that can be changed from the outside.
const char * GetName() const override
Returns name of object.
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})