75 :
RooAbsPdf(
name, title),
x_(
"x",
"Dependent", this,
x),
x0_(
"x0",
"X0", this,
x0),
103 :
RooAbsPdf(
name, title),
x_(
"x",
"Dependent", this,
x),
x0_(
"x0",
"X0", this,
x0),
104 sigmaL_(
"sigmaL",
"Left Sigma", this, sigmaLR),
sigmaR_(
"sigmaR",
"Right Sigma", this, sigmaLR),
130 :
RooAbsPdf(
name, title),
x_(
"x",
"Dependent", this,
x),
x0_(
"x0",
"X0", this,
x0),
131 sigmaL_{
"sigmaL",
"Left Sigma", this, sigmaLR},
sigmaR_{
"sigmaR",
"Right Sigma", this, sigmaLR},
132 alphaL_{
"alphaL",
"Left Alpha", this, alpha},
133 nL_{
"nL",
"Left Order", this,
n}
136 alphaR_ = std::make_unique<RooRealProxy>(
"alphaR",
"Right Alpha",
this, alpha);
137 nR_ = std::make_unique<RooRealProxy>(
"nR",
"Right Order",
this,
n);
153 nL_{
"nL", this, other.
nL_},
163inline double evaluateCrystalBallTail(
double t,
double alpha,
double n)
165 double r =
n / alpha;
166 double b =
r - alpha;
168 return std::exp(-0.5 * alpha * alpha) * std::pow(
r / (
b - t),
n);
171inline double integrateGaussian(
double sigmaL,
double sigmaR,
double tmin,
double tmax)
173 constexpr double sqrtPiOver2 = 1.2533141373;
174 constexpr double sqrt2 = 1.4142135624;
176 const double sigmaMin = tmin < 0 ? sigmaL : sigmaR;
177 const double sigmaMax = tmax < 0 ? sigmaL : sigmaR;
179 return sqrtPiOver2 * (sigmaMax * std::erf(tmax / sqrt2) - sigmaMin * std::erf(tmin / sqrt2));
182inline double integrateTailLogVersion(
double sigma,
double alpha,
double n,
double tmin,
double tmax)
184 double r =
n / alpha;
185 double a = std::pow(
r,
n) *
exp(-0.5 * alpha * alpha);
186 double b =
r - alpha;
188 double log_b_tmin =
log(
b - tmin);
189 double log_b_tmax =
log(
b - tmax);
191 return a *
sigma * (log_b_tmin - log_b_tmax + 0.5 * (1.0 -
n) * (log_b_tmin * log_b_tmin - log_b_tmax * log_b_tmax));
194inline double integrateTailRegular(
double sigma,
double alpha,
double n,
double tmin,
double tmax)
196 double r =
n / alpha;
197 double b =
r - alpha;
199 return r *
exp(-0.5 * alpha * alpha) *
sigma / (1.0 -
n) * (std::pow(
r / (
b - tmin),
n - 1.0) - std::pow(
r / (
b - tmax),
n - 1.0));
209 const double x0 =
x0_;
227 return evaluateCrystalBallTail(t,
alphaL,
nL);
229 return std::exp(-0.5 * t * t);
231 return evaluateCrystalBallTail(-t,
alphaR,
nR);
248 const double x0 =
x0_;
263 constexpr double switchToLogThreshold = 1.0e-05;
265 const double xmin =
x_.min(rangeName);
266 const double xmax =
x_.max(rangeName);
273 auto integrateTailL = std::abs(
nL - 1.0) < switchToLogThreshold ? integrateTailLogVersion : integrateTailRegular;
277 auto integrateTailR = std::abs(
nR - 1.0) < switchToLogThreshold ? integrateTailLogVersion : integrateTailRegular;
280 if (tmin < alphaR && tmax > -
alphaL) {
RooTemplateProxy< RooAbsReal > RooRealProxy
Compatibility typedef replacing the old RooRealProxy class.
int Int_t
Signed integer 4 bytes (int).
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
RooAbsPdf()
Default constructor.
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.
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.
RooAbsReal const * nR() const
RooAbsReal const * alphaR() const
RooAbsReal const & sigmaR() const
std::unique_ptr< RooRealProxy > alphaR_
RooAbsReal const & nL() const
RooAbsReal const & x0() const
RooAbsReal const & x() const
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.
RooAbsReal const & sigmaL() const
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.
RooAbsReal const & alphaL() const
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.