80enum BasisSign { Both = 0, Plus = +1, Minus = -1 };
102 std::string str =
name;
105 str.erase(remove(str.begin(),str.end(),
' '),str.end());
108 if (str ==
"exp(-@0/@1)")
return expBasisPlus ;
109 if (str ==
"exp(@0/@1)")
return expBasisMinus ;
110 if (str ==
"exp(-abs(@0)/@1)")
return expBasisSum ;
111 if (str ==
"exp(-@0/@1)*sin(@0*@2)")
return sinBasisPlus ;
112 if (str ==
"exp(@0/@1)*sin(@0*@2)")
return sinBasisMinus ;
113 if (str ==
"exp(-abs(@0)/@1)*sin(@0*@2)")
return sinBasisSum ;
114 if (str ==
"exp(-@0/@1)*cos(@0*@2)")
return cosBasisPlus ;
115 if (str ==
"exp(@0/@1)*cos(@0*@2)")
return cosBasisMinus ;
116 if (str ==
"exp(-abs(@0)/@1)*cos(@0*@2)")
return cosBasisSum ;
117 if (str ==
"(@0/@1)*exp(-@0/@1)")
return linBasisPlus ;
118 if (str ==
"(@0/@1)*(@0/@1)*exp(-@0/@1)")
return quadBasisPlus ;
119 if (str ==
"exp(-@0/@1)*cosh(@0*@2/2)")
return coshBasisPlus;
120 if (str ==
"exp(@0/@1)*cosh(@0*@2/2)")
return coshBasisMinus;
121 if (str ==
"exp(-abs(@0)/@1)*cosh(@0*@2/2)")
return coshBasisSum;
122 if (str ==
"exp(-@0/@1)*sinh(@0*@2/2)")
return sinhBasisPlus;
123 if (str ==
"exp(@0/@1)*sinh(@0*@2/2)")
return sinhBasisMinus;
124 if (str ==
"exp(-abs(@0)/@1)*sinh(@0*@2/2)")
return sinhBasisSum;
128 return genericBasis ;
194 BasisSign basisSign = (BasisSign)(
_basisCode - 10*(basisType-1) - 2 ) ;
197 if ((basisSign==Minus &&
x>0) ||
198 (basisSign==Plus &&
x<0))
return 0 ;
205 return std::exp(-std::abs((
double)
x)/tau) ;
209 return std::exp(-std::abs((
double)
x)/tau)*std::sin(
x*dm) ;
213 return std::exp(-std::abs((
double)
x)/tau)*std::cos(
x*dm) ;
216 double tscaled = std::abs((
double)
x)/tau;
217 return std::exp(-tscaled)*tscaled ;
220 double tscaled = std::abs((
double)
x)/tau;
221 return std::exp(-tscaled)*tscaled*tscaled;
225 return std::exp(-std::abs((
double)
x)/tau)*std::sinh(
x*dg/2) ;
229 return std::exp(-std::abs((
double)
x)/tau)*std::cosh(
x*dg/2) ;
241 auto config = ctx.
config(
this);
242 auto xVals = ctx.
at(
x);
257 const BasisType basisType =
static_cast<BasisType
>((
_basisCode == 0) ? 0 : (
_basisCode / 10) + 1);
261 const double basisSign =
static_cast<double>((BasisSign)(
_basisCode - 10 * (basisType - 1) - 2));
265 auto param1Vals = param1 ? ctx.
at(param1) : std::span<const double>{};
266 auto param2Vals = param2 ? ctx.
at(param2) : std::span<const double>{};
269 std::array<double, 1> extraArgs{basisSign};
278 {xVals, param1Vals, param2Vals}, extraArgs);
283 {xVals, param1Vals, param2Vals}, extraArgs);
298 {xVals, param1Vals, param2Vals}, extraArgs);
303 {xVals, param1Vals, param2Vals}, extraArgs);
353inline double indefiniteIntegralExpBasisPlus(
double x,
double tau,
double )
356 x = std::max(
x, 0.0);
357 return -tau * std::exp(-
x / tau);
361inline double indefiniteIntegralLinBasisPlus(
double x,
double tau,
double )
364 x = std::max(
x, 0.0);
365 return -(tau +
x) * std::exp(-
x / tau);
369inline double indefiniteIntegralQuadBasisPlus(
double x,
double tau,
double )
372 x = std::max(
x, 0.0);
373 return -(std::exp(-
x / tau) * (2 * tau * tau +
x *
x + 2 * tau *
x)) / tau;
378inline double commonFactorPlus(
double x,
double tau,
double dm)
380 const double num = tau * std::exp(-
x / tau);
381 const double den = dm * dm * tau * tau + 1.0;
387inline double commonFactorHyperbolicPlus(
double x,
double tau,
double dm)
389 const double num = 2 * tau * std::exp(-
x / tau);
390 const double den = dm * dm * tau * tau - 4.0;
395inline double indefiniteIntegralSinBasisPlus(
double x,
double tau,
double dm)
398 x = std::max(
x, 0.0);
399 const double fac = commonFactorPlus(
x, tau, dm);
403 return fac != 0.0 ? fac * (-tau * dm * std::cos(dm *
x) - std::sin(dm *
x)) : 0.0;
407inline double indefiniteIntegralCosBasisPlus(
double x,
double tau,
double dm)
410 x = std::max(
x, 0.0);
411 const double fac = commonFactorPlus(
x, tau, dm);
412 return fac != 0.0 ? fac * (tau * dm * std::sin(dm *
x) - std::cos(dm *
x)) : 0.0;
416inline double indefiniteIntegralSinhBasisPlus(
double x,
double tau,
double dm)
419 x = std::max(
x, 0.0);
420 const double fac = commonFactorHyperbolicPlus(
x, tau, dm);
421 const double arg = 0.5 * dm *
x;
422 return fac != 0.0 ? fac * (tau * dm * std::cosh(arg) - 2. * std::sinh(arg)) : 0.0;
426inline double indefiniteIntegralCoshBasisPlus(
double x,
double tau,
double dm)
429 x = std::max(
x, 0.0);
430 const double fac = commonFactorHyperbolicPlus(
x, tau, dm);
431 const double arg = 0.5 * dm *
x;
432 return fac != 0.0 ? fac * (tau * dm * std::sinh(arg) + 2. * std::cosh(arg)) : 0.0;
439template <
class Function>
440double definiteIntegral(
Function indefiniteIntegral,
double xmin,
double xmax,
double tau,
double dm,
441 BasisSign basisSign,
bool isSymmetric)
445 return isSymmetric ? 1.0 : 0.0;
447 if (basisSign != Minus) {
448 result += indefiniteIntegral(
xmax, tau, dm) - indefiniteIntegral(
xmin, tau, dm);
450 if (basisSign != Plus) {
451 const double resultMinus = indefiniteIntegral(-
xmax, tau, dm) - indefiniteIntegral(-
xmin, tau, dm);
452 result += isSymmetric ? -resultMinus : resultMinus;
474 BasisSign basisSign = (BasisSign)(
_basisCode - 10 * (basisType - 1) - 2);
477 basisType == sinBasis || basisType == cosBasis || basisType == sinhBasis || basisType == coshBasis;
483 const double xmin =
x.
min(rangeName);
484 const double xmax =
x.
max(rangeName);
486 auto integrate = [&](
auto indefiniteIntegral,
bool isSymmetric) {
487 return definiteIntegral(indefiniteIntegral,
xmin,
xmax, tau, dm, basisSign, isSymmetric);
491 case expBasis:
return integrate(indefiniteIntegralExpBasisPlus,
true);
492 case sinBasis:
return integrate(indefiniteIntegralSinBasisPlus,
false);
493 case cosBasis:
return integrate(indefiniteIntegralCosBasisPlus,
true);
494 case linBasis:
return integrate(indefiniteIntegralLinBasisPlus,
false);
495 case quadBasis:
return integrate(indefiniteIntegralQuadBasisPlus,
true);
496 case sinhBasis:
return integrate(indefiniteIntegralSinhBasisPlus,
false);
497 case coshBasis:
return integrate(indefiniteIntegralCoshBasisPlus,
true);
510 const RooArgSet* auxProto,
bool verbose)
const
513 return new RooGenContext(convPdf, vars, prototype, auxProto, verbose, &forceDirect);
523 if (
matchArgs(directVars,generateVars,
x))
return 1 ;
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
Double_t(* Function)(Double_t)
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.
TIterator Use servers() and begin()
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...
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 &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
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.
Implements a RooResolution model that corresponds to a delta function.
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={})