1#ifndef __JASTRONOMY__JASPERA__
2#define __JASTRONOMY__JASPERA__
44 void put(
const double s,
60 void put(
const size_t n,
64 for (
size_t i = 0; i != n; ++i) {
108#if defined(NEWTON_RAPHSON)
113 struct derivatives_type {
125 derivatives_type getDerivatives(
const double p)
const
133 const double z = 1.0 / (p + x);
159 }
else if (this->size() == 1 ) {
163 const double x = 1.0/
ws - (*this)[0];
181 }
else if (f1 > 0.0) {
184 x2 = (double) this->size() /
ws;
209#if defined(BISECTION)
215 const double x = 0.5 * (x1 + x2);
223 const double x = 0.5 * (x1 + x2);
227#elif defined(NEWTON_RAPHSON)
232 double x = 0.5 * (x1 + x2);
234 derivatives_type y = getDerivatives(x);
244 if ((y.fp + (x2 - x)*y.fpp)*(y.fp + (x1 - x)*y.fpp) > 0.0 || fabs(2.0*y.fp) > fabs(old.dx*y.fpp)) {
248 dx = 0.5 * (x2 - x1);
263 y = getDerivatives(x);
279 const double xm = 0.5 * (x1 + x2);
282 const double s = sqrt(fm*fm - f1*f2);
288 const double xn = xm + (xm - x1) * fm/s;
295 if (signbit(fn) != signbit(fm)) {
317 const double x = 0.5 * (x1 + x2);
333 const fit_type result = (*this)(
true);
335 if (result.signal <= 0.0)
337 else if (result.signal <= ps)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double signal
signal strength
double likelihood
likelihood
Auxiliary data structure to fit signal strength using likelihood ratio.
void addSignal(const double wS)
Add signal strength.
double getSignal() const
Get total signal strength.
double getLikelihood(const double p) const
Get likelihood for given signal strength.
void setSignal(const double wS)
Set signal strength.
void put(const double s, const double b)
Put signal and background to list of pre-computed N/S values.
double getTestStatisticForUpperLimit(const double ps) const
Get test statistic for given signal strength.
double ws
total signal strength
static constexpr double EPSILON
precision determination of signal strength
double getDerivative(const double p) const
Get derivative of likelihood for given signal strength.
fit_type operator()(const bool ns=false) const
Fit signal strength.
void put(const size_t n, const double s, const double b)
Put signal and background to list of pre-computed N/S values.