76 :
RooAbsPdf(
name, title), x_(
"x",
"Dependent", this,
x), x0_(
"x0",
"X0", this, x0),
77 sigmaL_(
"sigmaL",
"Left Sigma", this, sigmaL), sigmaR_(
"sigmaR",
"Right Sigma", this, sigmaR),
78 alphaL_{
"alphaL",
"Left Alpha", this, alphaL}, nL_{
"nL",
"Left Order", this, nL},
79 alphaR_{std::make_unique<
RooRealProxy>(
"alphaR",
"Right Alpha", this, alphaR)},
80 nR_{std::make_unique<
RooRealProxy>(
"nR",
"Right Order", this, nR)}
104 :
RooAbsPdf(
name, title), x_(
"x",
"Dependent", this,
x), x0_(
"x0",
"X0", this, x0),
105 sigmaL_(
"sigmaL",
"Left Sigma", this, sigmaLR), sigmaR_(
"sigmaR",
"Right Sigma", this, sigmaLR),
106 alphaL_{
"alphaL",
"Left Alpha", this, alphaL}, nL_{
"nL",
"Left Order", this, nL},
107 alphaR_{std::make_unique<
RooRealProxy>(
"alphaR",
"Right Alpha", this, alphaR)},
108 nR_{std::make_unique<
RooRealProxy>(
"nR",
"Right Order", this, nR)}
131 :
RooAbsPdf(
name, title), x_(
"x",
"Dependent", this,
x), x0_(
"x0",
"X0", this, x0),
132 sigmaL_{
"sigmaL",
"Left Sigma", this, sigmaLR}, sigmaR_{
"sigmaR",
"Right Sigma", this, sigmaLR},
133 alphaL_{
"alphaL",
"Left Alpha", this, alpha},
134 nL_{
"nL",
"Left Order", this,
n}
137 alphaR_ = std::make_unique<RooRealProxy>(
"alphaR",
"Right Alpha",
this, alpha);
138 nR_ = std::make_unique<RooRealProxy>(
"nR",
"Right Order",
this,
n);
151 :
RooAbsPdf(other,
name), x_(
"x", this, other.x_), x0_(
"x0", this, other.x0_),
152 sigmaL_(
"sigmaL", this, other.sigmaL_),
153 sigmaR_(
"sigmaR", this, other.sigmaR_), alphaL_{
"alphaL", this, other.alphaL_},
154 nL_{
"nL", this, other.nL_},
155 alphaR_{other.alphaR_ ? std::make_unique<
RooRealProxy>(
"alphaR", this, *other.alphaR_) : nullptr},
156 nR_{other.nR_ ? std::make_unique<
RooRealProxy>(
"nR", this, *other.nR_) : nullptr}
164inline double evaluateCrystalBallTail(
double t,
double alpha,
double n)
166 double a = std::pow(
n / alpha,
n) * std::exp(-0.5 * alpha * alpha);
167 double b =
n / alpha - alpha;
169 return a / std::pow(
b - t,
n);
172inline double integrateGaussian(
double sigmaL,
double sigmaR,
double tmin,
double tmax)
174 constexpr double sqrtPiOver2 = 1.2533141373;
175 constexpr double sqrt2 = 1.4142135624;
177 const double sigmaMin = tmin < 0 ? sigmaL : sigmaR;
178 const double sigmaMax = tmax < 0 ? sigmaL : sigmaR;
180 return sqrtPiOver2 * (sigmaMax * std::erf(tmax / sqrt2) - sigmaMin * std::erf(tmin / sqrt2));
183inline double integrateTailLogVersion(
double sigma,
double alpha,
double n,
double tmin,
double tmax)
185 double a = std::pow(
n / alpha,
n) *
exp(-0.5 * alpha * alpha);
186 double b =
n / alpha - alpha;
191inline double integrateTailRegular(
double sigma,
double alpha,
double n,
double tmin,
double tmax)
193 double a = std::pow(
n / alpha,
n) *
exp(-0.5 * alpha * alpha);
194 double b =
n / alpha - alpha;
196 return a *
sigma / (1.0 -
n) * (1.0 / (std::pow(
b - tmin,
n - 1.0)) - 1.0 / (std::pow(
b - tmax,
n - 1.0)));
206 const double x0 =
x0_;
207 const double sigmaL = std::abs(
sigmaL_);
208 const double sigmaR = std::abs(
sigmaR_);
209 double alphaL = std::abs(
alphaL_);
211 double alphaR =
alphaR_ ? std::abs(*
alphaR_) : std::numeric_limits<double>::infinity();
212 double nR =
nR_ ? *
nR_ : 0.0;
217 std::swap(alphaL, alphaR);
221 const double t = (
x - x0) / (
x < x0 ? sigmaL : sigmaR);
224 return evaluateCrystalBallTail(t, alphaL, nL);
225 }
else if (t <= alphaR) {
226 return std::exp(-0.5 * t * t);
228 return evaluateCrystalBallTail(-t, alphaR, nR);
245 const double x0 =
x0_;
246 const double sigmaL = std::abs(
sigmaL_);
247 const double sigmaR = std::abs(
sigmaR_);
248 double alphaL = std::abs(
alphaL_);
250 double alphaR =
alphaR_ ? std::abs(*
alphaR_) : std::numeric_limits<double>::infinity();
251 double nR =
nR_ ? *
nR_ : 0.0;
256 std::swap(alphaL, alphaR);
260 constexpr double switchToLogThreshold = 1.0e-05;
264 const double tmin = (
xmin - x0) / (
xmin < x0 ? sigmaL : sigmaR);
265 const double tmax = (
xmax - x0) / (
xmax < x0 ? sigmaL : sigmaR);
269 if (tmin < -alphaL) {
270 auto integrateTailL = std::abs(nL - 1.0) < switchToLogThreshold ? integrateTailLogVersion : integrateTailRegular;
271 result += integrateTailL(sigmaL, alphaL, nL, tmin, std::min(tmax, -alphaL));
274 auto integrateTailR = std::abs(nR - 1.0) < switchToLogThreshold ? integrateTailLogVersion : integrateTailRegular;
275 result += integrateTailR(sigmaR, alphaR, nR, -tmax, std::min(-tmin, -alphaR));
277 if (tmin < alphaR && tmax > -alphaL) {
278 result += integrateGaussian(sigmaL, sigmaR, std::max(tmin, -alphaL), std::min(tmax, alphaR));
#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
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
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.
PDF implementing the generalized Asymmetrical Double-Sided Crystall Ball line shape.
std::unique_ptr< RooRealProxy > nR_
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
std::unique_ptr< RooRealProxy > alphaR_
double maxVal(Int_t code) const override
Return maximum value for set of observables identified by code assigned in getMaxVal.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Int_t getMaxVal(const RooArgSet &vars) const override
Advertise that we know the maximum of self for given (m0,alpha,n,sigma).
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
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.
RVec< PromoteType< T > > log(const RVec< T > &v)
RVec< PromoteType< T > > exp(const RVec< T > &v)
void checkRangeOfParameters(const RooAbsReal *callingClass, std::initializer_list< const RooAbsReal * > pars, double min=-std::numeric_limits< double >::max(), double max=std::numeric_limits< double >::max(), bool limitsInAllowedRange=false, std::string const &extraMessage="")
Check if the parameters have a range, and warn if the range extends below / above the set limits.