Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooGaussExpTails.cxx
Go to the documentation of this file.
1/** \class RooGaussExpTails
2 \ingroup Roofit
3
4PDF implementing a Gaussian core + double-sided exponential tail distribution
5\author Souvik Das (8/1/2013) Initial implementation and
6Giovanni Marchiori (30/3/2016) Implemented analytic integral
7\see http://arxiv.org/pdf/1603.08591v1.pdf, https://github.com/mpuccio/RooCustomPdfs/blob/master/RooGausDExp.cxx, https://doi.org/10.1142/S0217751X14300440
8\note To use the one-sided version, just set the opposite parameter k to a very large value
9*/
10
11
12#include "RooGaussExpTails.h"
13#include "RooAbsReal.h"
14#include <cmath>
16
17//_____________________________________________________________________________
20 : RooAbsPdf(name, title),
21 _x("x", "x", this, x),
22 _x0("x0", "x0", this, x0),
23 _sigma("sigma", "sigma", this, sigma),
24 _kL("kL", "kL", this, kL),
25 _kH("kH", "kH", this, kH)
26{
27}
28
29//_____________________________________________________________________________
32 _x("x", this, other._x),
33 _x0("x0", this, other._x0),
34 _sigma("sigma", this, other._sigma),
35 _kL("kL", this, other._kL),
36 _kH("kH", this, other._kH)
37{
38}
39
40////////////////////////////////////////////////////////////////////////////////
41
42namespace {
43
44inline double gaussianIntegral(double tmin, double tmax)
45{
46 constexpr double m_sqrt_2_pi = 2.50662827463; // std::sqrt(TMath::TwoPi())
48}
49
50inline double tailIntegral(double tmin, double tmax, double k)
51{
52 double a = std::exp(0.5 * k * k) / k;
53 return a * (std::exp(k * tmax) - std::exp(k * tmin));
54}
55
56} // namespace
57
58//_____________________________________________________________________________
60{
61 Double_t t = (_x - _x0) / _sigma;
62
63 if (t <= -_kL)
64 return std::exp(0.5 * _kL * _kL + _kL * t);
65 else if (t > _kH)
66 return std::exp(0.5 * _kH * _kH - _kH * t);
67 else
68 return std::exp(-0.5 * t * t);
69}
70
71//_____________________________________________________________________________
72Int_t RooGaussExpTails::getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char * /*rangeName*/) const
73{
74 if (matchArgs(allVars, analVars, _x))
75 return 1;
76
77 return 0;
78}
79
80//_____________________________________________________________________________
82{
83 R__ASSERT(code == 1);
84 double result = 0;
85
86 double sig = std::abs((Double_t)_sigma);
87 double tmin = (_x.min(rangeName) - _x0) / sig;
88 double tmax = (_x.max(rangeName) - _x0) / sig;
89
90 if (tmin <= -_kL)
91 result += tailIntegral(tmin, std::min(tmax, -_kL), _kL);
93 result += gaussianIntegral(std::max(tmin, -_kL), std::min(tmax, +_kH));
94 if (tmax > _kH)
95 result += tailIntegral(std::max(tmin, +_kH), tmax, -_kH);
96
97 return sig * result;
98}
#define a(i)
Definition RSha256.hxx:99
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
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
char name[80]
Definition TGX11.cxx:110
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
A RooAbsReal::Ref can be constructed from a RooAbsReal& or a double that will be implicitly converted...
Definition RooAbsReal.h:72
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
Definition RooAbsReal.h:428
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
PDF implementing a Gaussian core + double-sided exponential tail distribution.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooRealProxy _sigma
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 Double_t sigma
Double_t x[n]
Definition legend1.C:17
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.