67 _x(
"x",
"Dependent", this,
x),
68 _coefList(
"coefList",
"List of coefficients", this),
69 _lowestOrder(lowestOrder)
73 coutE(InputArguments) <<
"RooExpPoly::ctor(" <<
GetName()
74 <<
") WARNING: lowestOrder must be >=0, setting value to 0" << std::endl;
80 coutE(InputArguments) <<
"RooExpPoly::ctor(" <<
GetName() <<
") ERROR: coefficient " << coef->GetName()
81 <<
" is not of type RooAbsReal" << std::endl;
93 _x(
"x", this, other._x),
94 _coefList(
"coefList", this, other._coefList),
95 _lowestOrder(other._lowestOrder)
109 std::vector<double> coefs;
119 for (
size_t i = 0; i < sz; ++i) {
120 retval += coefs[i] * xpow;
124 if (std::numeric_limits<double>::max_exponent < retval) {
125 coutE(InputArguments) <<
"RooExpPoly::evaluateLog(" <<
GetName() <<
") ERROR: exponent at " <<
x
126 <<
" larger than allowed maximum, result will be infinite! " << retval <<
" > "
140 vars.push_back(dataMap.
at(
_x));
142 std::vector<double> coefVals;
144 vars.push_back(dataMap.
at(coef));
161 double max = std::numeric_limits<double>::max_exponent / sz;
163 std::vector<double> coefs;
168 const double xmax =
x->getMax();
170 for (
size_t i = 0; i < sz; ++i) {
171 double thismax = max / xmaxpow;
189 const double val = std::exp(logval);
190 if (std::isinf(val)) {
191 coutE(InputArguments) <<
"RooExpPoly::evaluate(" <<
GetName()
192 <<
") ERROR: result of exponentiation is infinite! exponent was " << logval << std::endl;
221#define PI TMath::Pi()
224double deltaerf(
long double x1,
long double x2)
230 double y2 =
x1 > 0 ? erfc(
x1) : -erfc(-
x1);
231 double y1 =
x2 > 0 ? erfc(
x2) : -erfc(-
x2);
233 std::cout <<
"WARNING in calculation of analytical integral limited by numerical precision" << std::endl;
234 std::cout <<
"x: " <<
x1 <<
" , " <<
x2 << std::endl;
235 std::cout <<
"y: " <<
y1 <<
" , " <<
y2 << std::endl;
240double deltaerfi(
double x1,
double x2)
242 std::complex<double> u1 = {
x1, 0.};
243 std::complex<double> u2 = {
x2, 0.};
248 std::cout <<
"WARNING in calculation of analytical integral limited by numerical precision" << std::endl;
249 std::cout <<
"x: " <<
x1 <<
" , " <<
x2 << std::endl;
250 std::cout <<
"y: " <<
y1 <<
" , " <<
y2 << std::endl;
252 return y1.imag() -
y2.imag();
263 std::vector<double> coefs;
284 const double absa = std::abs(
a);
285 const double sqrta = std::sqrt(absa);
287 double d = ::deltaerf((-
b + 2 * absa *
xmax) / (2 * sqrta), (-
b + 2 * absa *
xmin) / (2 * sqrta));
288 double retval = exp(
b *
b / (4 * absa) +
c) * std::sqrt(
PI) *
d / (2 * sqrta);
291 double d = ::deltaerfi((
b + 2 * absa *
xmax) / (2 * sqrta), (
b + 2 * absa *
xmin) / (2 * sqrta));
292 double retval = exp(-
b *
b / (4 * absa) +
c) * std::sqrt(
PI) *
d / (2 * sqrta);
295 return 1. /
b * (std::exp(
b *
xmax) - exp(
b *
xmin)) * exp(
c);
308 std::stringstream ss;
317 ss << coef->GetName();
318 ss <<
"*pow(" <<
_x.
GetName() <<
"," << order <<
")";
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 is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Storage_t::size_type size() const
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...
const RooArgSet * nset() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooExpPoly implements a polynomial PDF of the form.
double evaluate() const override
Evaluation.
double evaluateLog() const
std::string getFormulaExpression(bool expand) const
int lowestOrder() const
Return the order for the first coefficient in the list.
void computeBatch(double *output, size_t size, RooFit::Detail::DataMap const &) 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 getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
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...
RooAbsReal const & x() const
Get the x variable.
RooArgList const & coefList() const
Get the coefficient list.
RooBatchCompute::Config config(RooAbsArg const *arg) const
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
static std::complex< double > faddeeva(std::complex< double > z)
evaluate Faddeeva function for complex argument
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setMax(const char *name, double value)
Set maximum of name range to given value.
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
const char * GetName() const override
Returns name of object.
std::vector< std::span< const double > > VarVector
std::vector< double > ArgVector
void compute(Config cfg, Computer comp, RestrictArr output, size_t size, const VarVector &vars, ArgVector &extraArgs)