78enum BasisSign { Both = 0, Plus = +1, Minus = -1 };
99 std::string str =
name;
102 str.erase(remove(str.begin(),str.end(),
' '),str.end());
105 if (str ==
"exp(-@0/@1)")
return expBasisPlus ;
106 if (str ==
"exp(@0/@1)")
return expBasisMinus ;
107 if (str ==
"exp(-abs(@0)/@1)")
return expBasisSum ;
108 if (str ==
"exp(-@0/@1)*sin(@0*@2)")
return sinBasisPlus ;
109 if (str ==
"exp(@0/@1)*sin(@0*@2)")
return sinBasisMinus ;
110 if (str ==
"exp(-abs(@0)/@1)*sin(@0*@2)")
return sinBasisSum ;
111 if (str ==
"exp(-@0/@1)*cos(@0*@2)")
return cosBasisPlus ;
112 if (str ==
"exp(@0/@1)*cos(@0*@2)")
return cosBasisMinus ;
113 if (str ==
"exp(-abs(@0)/@1)*cos(@0*@2)")
return cosBasisSum ;
114 if (str ==
"(@0/@1)*exp(-@0/@1)")
return linBasisPlus ;
115 if (str ==
"(@0/@1)*(@0/@1)*exp(-@0/@1)")
return quadBasisPlus ;
116 if (str ==
"exp(-@0/@1)*cosh(@0*@2/2)")
return coshBasisPlus;
117 if (str ==
"exp(@0/@1)*cosh(@0*@2/2)")
return coshBasisMinus;
118 if (str ==
"exp(-abs(@0)/@1)*cosh(@0*@2/2)")
return coshBasisSum;
119 if (str ==
"exp(-@0/@1)*sinh(@0*@2/2)")
return sinhBasisPlus;
120 if (str ==
"exp(@0/@1)*sinh(@0*@2/2)")
return sinhBasisMinus;
121 if (str ==
"exp(-abs(@0)/@1)*sinh(@0*@2/2)")
return sinhBasisSum;
125 return genericBasis ;
191 BasisSign basisSign = (BasisSign)(
_basisCode - 10*(basisType-1) - 2 ) ;
194 if ((basisSign==Minus &&
x>0) ||
195 (basisSign==Plus &&
x<0))
return 0 ;
202 return std::exp(-std::abs((
double)
x)/tau) ;
206 return std::exp(-std::abs((
double)
x)/tau)*std::sin(
x*dm) ;
210 return std::exp(-std::abs((
double)
x)/tau)*std::cos(
x*dm) ;
213 double tscaled = std::abs((
double)
x)/tau;
214 return std::exp(-tscaled)*tscaled ;
217 double tscaled = std::abs((
double)
x)/tau;
218 return std::exp(-tscaled)*tscaled*tscaled;
222 return std::exp(-std::abs((
double)
x)/tau)*std::sinh(
x*dg/2) ;
226 return std::exp(-std::abs((
double)
x)/tau)*std::cosh(
x*dg/2) ;
238 auto config = ctx.
config(
this);
239 auto xVals = ctx.
at(
x);
254 const BasisType basisType =
static_cast<BasisType
>((
_basisCode == 0) ? 0 : (
_basisCode / 10) + 1);
258 const double basisSign =
static_cast<double>((BasisSign)(
_basisCode - 10 * (basisType - 1) - 2));
262 auto param1Vals = param1 ? ctx.
at(param1) : std::span<const double>{};
263 auto param2Vals = param2 ? ctx.
at(param2) : std::span<const double>{};
266 std::array<double, 1> extraArgs{basisSign};
275 {xVals, param1Vals, param2Vals}, extraArgs);
280 {xVals, param1Vals, param2Vals}, extraArgs);
295 {xVals, param1Vals, param2Vals}, extraArgs);
300 {xVals, param1Vals, param2Vals}, extraArgs);
350inline double indefiniteIntegralExpBasisPlus(
double x,
double tau,
double )
353 x = std::max(
x, 0.0);
354 return -tau * std::exp(-
x / tau);
358inline double indefiniteIntegralLinBasisPlus(
double x,
double tau,
double )
361 x = std::max(
x, 0.0);
362 return -(tau +
x) * std::exp(-
x / tau);
366inline double indefiniteIntegralQuadBasisPlus(
double x,
double tau,
double )
369 x = std::max(
x, 0.0);
370 return -(std::exp(-
x / tau) * (2 * tau * tau +
x *
x + 2 * tau *
x)) / tau;
375inline double commonFactorPlus(
double x,
double tau,
double dm)
377 const double num = tau * std::exp(-
x / tau);
378 const double den = dm * dm * tau * tau + 1.0;
384inline double commonFactorHyperbolicPlus(
double x,
double tau,
double dm)
386 const double num = 2 * tau * std::exp(-
x / tau);
387 const double den = dm * dm * tau * tau - 4.0;
392inline double indefiniteIntegralSinBasisPlus(
double x,
double tau,
double dm)
395 x = std::max(
x, 0.0);
396 const double fac = commonFactorPlus(
x, tau, dm);
400 return fac != 0.0 ? fac * (-tau * dm * std::cos(dm *
x) - std::sin(dm *
x)) : 0.0;
404inline double indefiniteIntegralCosBasisPlus(
double x,
double tau,
double dm)
407 x = std::max(
x, 0.0);
408 const double fac = commonFactorPlus(
x, tau, dm);
409 return fac != 0.0 ? fac * (tau * dm * std::sin(dm *
x) - std::cos(dm *
x)) : 0.0;
413inline double indefiniteIntegralSinhBasisPlus(
double x,
double tau,
double dm)
416 x = std::max(
x, 0.0);
417 const double fac = commonFactorHyperbolicPlus(
x, tau, dm);
418 const double arg = 0.5 * dm *
x;
419 return fac != 0.0 ? fac * (tau * dm * std::cosh(arg) - 2. * std::sinh(arg)) : 0.0;
423inline double indefiniteIntegralCoshBasisPlus(
double x,
double tau,
double dm)
426 x = std::max(
x, 0.0);
427 const double fac = commonFactorHyperbolicPlus(
x, tau, dm);
428 const double arg = 0.5 * dm *
x;
429 return fac != 0.0 ? fac * (tau * dm * std::sinh(arg) + 2. * std::cosh(arg)) : 0.0;
436template <
class Function>
437double definiteIntegral(Function indefiniteIntegral,
double xmin,
double xmax,
double tau,
double dm,
438 BasisSign basisSign,
bool isSymmetric)
442 return isSymmetric ? 1.0 : 0.0;
444 if (basisSign != Minus) {
445 result += indefiniteIntegral(
xmax, tau, dm) - indefiniteIntegral(
xmin, tau, dm);
447 if (basisSign != Plus) {
448 const double resultMinus = indefiniteIntegral(-
xmax, tau, dm) - indefiniteIntegral(-
xmin, tau, dm);
449 result += isSymmetric ? -resultMinus : resultMinus;
471 BasisSign basisSign = (BasisSign)(
_basisCode - 10 * (basisType - 1) - 2);
474 basisType == sinBasis || basisType == cosBasis || basisType == sinhBasis || basisType == coshBasis;
480 const double xmin =
x.
min(rangeName);
481 const double xmax =
x.
max(rangeName);
483 auto integrate = [&](
auto indefiniteIntegral,
bool isSymmetric) {
484 return definiteIntegral(indefiniteIntegral,
xmin,
xmax, tau, dm, basisSign, isSymmetric);
488 case expBasis:
return integrate(indefiniteIntegralExpBasisPlus,
true);
489 case sinBasis:
return integrate(indefiniteIntegralSinBasisPlus,
false);
490 case cosBasis:
return integrate(indefiniteIntegralCosBasisPlus,
true);
491 case linBasis:
return integrate(indefiniteIntegralLinBasisPlus,
false);
492 case quadBasis:
return integrate(indefiniteIntegralQuadBasisPlus,
true);
493 case sinhBasis:
return integrate(indefiniteIntegralSinhBasisPlus,
false);
494 case coshBasis:
return integrate(indefiniteIntegralCoshBasisPlus,
true);
507 const RooArgSet* auxProto,
bool verbose)
const
510 return new RooGenContext(convPdf, vars, prototype, auxProto, verbose, &forceDirect);
520 if (
matchArgs(directVars,generateVars,
x))
return 1 ;
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Base class for PDFs that represent a physics model that can be analytically convolved with a resoluti...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void removeServer(RooAbsArg &server, bool force=false)
Unregister another RooAbsArg as a server to us, ie, declare that we no longer depend on its value and...
const RefCountList_t & servers() const
List of all servers of this object.
void addServer(RooAbsArg &server, bool valueProp=true, bool shapeProp=false, std::size_t refCount=1)
Register another RooAbsArg as a server to us, ie, declare that we depend on it.
Abstract base class for generator contexts of RooAbsPdf objects.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Container class to hold unbinned data.
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
Implements a universal generator context for all RooAbsPdf classes that do not have or need a special...
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
bool _ownBasis
Flag indicating ownership of _basis.
Int_t _basisCode
Identifier code for selected basis function.
RooAbsRealLValue & convVar() const
Return the convolution variable of the resolution model.
RooFormulaVar * _basis
Basis function convolved with this resolution model.
const RooFormulaVar & basis() const
RooTemplateProxy< RooAbsRealLValue > x
Dependent/convolution variable.
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.
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
void generateEvent(Int_t code) override
Implement internal generator for observable x, x=0 for all events following definition of delta funct...
double evaluate() const override
Evaluate the truth model: a delta function when used as PDF, the basis function itself,...
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Advertise analytical integrals for compiled basis functions and when used as p.d.f without basis func...
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Advertise internal generator for observable x.
RooAbsGenContext * modelGenContext(const RooAbsAnaConvPdf &convPdf, const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implement analytical integrals when used as p.d.f and for compiled basis functions.
Int_t basisCode(const char *name) const override
Return basis code for given basis definition string.
void changeBasis(RooFormulaVar *basis) override
Changes associated bases function to 'inBasis'.
const char * GetTitle() const override
Returns title of object.
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})