181 fNumWarningsDeprecated1(0),
182 fNumWarningsDeprecated2(0)
377 std::cerr <<
"TRolke - Error: Model id "<<
f_mid<<std::endl;
379 std::cerr <<
"TRolke - Please specify a model with e.g. 'SetGaussBkgGaussEff' (read the docs in Rolke.cxx )"<<std::endl;
384 ComputeInterval(
f_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
390 std::cerr <<
"TRolke - Warning: no limits found" <<std::endl;
436 std::cerr <<
"TRolke::GetBackground(): Model NR: " <<
437 f_mid <<
" unknown"<<std::endl;
457 ComputeInterval(loop_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
462 if (loop_x > (background + 1)) {
463 if ((weightSum > (1 - pPrecision)) || (weight < 1
e-12))
break;
492 if (weightSum >= integral) {
500 ComputeInterval(loop_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
520 while (loop_x <= loop_max) {
527 if (loop_x >= loop_max) {
528 std::cout <<
"internal error finding maximum of distribution" << std::endl;
534 ComputeInterval(loop_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
552 int rolke_ncrit = -1;
555 maxj = 1000 + (
Int_t)background;
557 for (j = 0;j < maxj;j++) {
559 ComputeInterval(rolke_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
567 if (rolke_ncrit == -1) {
568 std::cerr <<
"TRolke GetCriticalNumber : Error: problem finding rolke inverse. Specify a larger maxtry value. maxtry was: " << maxj <<
". highest x considered was j "<< j<< std::endl;
582 std::cerr <<
"*******************************************" <<std::endl;
583 std::cerr <<
"TRolke - Warning: 'SetSwitch' is deprecated and may be removed from future releases:" <<std::endl;
584 std::cerr <<
" - Use 'SetBounding' instead "<<std::endl;
585 std::cerr <<
"*******************************************" <<std::endl;
595 std::cout <<
"*******************************************" <<std::endl;
596 std::cout <<
"* TRolke::Print() - dump of internals: " <<std::endl;
597 std::cout <<
"*"<<std::endl;
598 std::cout <<
"* model id, mid = "<<
f_mid <<std::endl;
599 std::cout <<
"*"<<std::endl;
600 std::cout <<
"* x = "<<
f_x <<std::endl;
601 std::cout <<
"* bm = "<<
f_bm <<std::endl;
602 std::cout <<
"* em = "<<
f_em <<std::endl;
603 std::cout <<
"* sde = "<<
f_sde <<std::endl;
604 std::cout <<
"* sdb = "<<
f_sdb <<std::endl;
605 std::cout <<
"* y = "<<
f_y <<std::endl;
606 std::cout <<
"* tau = "<<
f_tau <<std::endl;
607 std::cout <<
"* e = "<<
f_e <<std::endl;
608 std::cout <<
"* b = "<<
f_b <<std::endl;
609 std::cout <<
"* m = "<<
f_m <<std::endl;
610 std::cout <<
"* z = "<<
f_z <<std::endl;
611 std::cout <<
"*"<<std::endl;
612 std::cout <<
"* CL = "<<
fCL <<std::endl;
613 std::cout <<
"* Bounding = "<<
fBounding <<std::endl;
614 std::cout <<
"*"<<std::endl;
615 std::cout <<
"* calculated on demand only:"<<std::endl;
616 std::cout <<
"* fUpperLimit = "<<
fUpperLimit<<std::endl;
617 std::cout <<
"* fLowerLimit = "<<
fLowerLimit<<std::endl;
618 std::cout <<
"*******************************************" <<std::endl;
638Double_t TRolke::CalculateInterval(
Int_t x,
Int_t y,
Int_t z,
Double_t bm,
Double_t em,
Double_t e,
Int_t mid,
Double_t sde,
Double_t sdb,
Double_t tau,
Double_t b,
Int_t m){
640 std::cerr <<
"*******************************************" <<std::endl;
641 std::cerr <<
"TRolke - Warning: 'CalculateInterval' is deprecated and may be removed from future releases:" <<std::endl;
642 std::cerr <<
" - Use e.g. 'SetGaussBkgGaussEff' and 'GetLimits' instead (read the docs in Rolke.cxx )"<<std::endl;
643 std::cerr <<
"*******************************************" <<std::endl;
659 return ComputeInterval(
f_x,
f_y,
f_z,
f_bm,
f_em,
f_e,
f_mid,
f_sde,
f_sdb,
f_tau,
f_b,
f_m);
676void TRolke::SetModelParameters(
Int_t x,
Int_t y,
Int_t z,
Double_t bm,
Double_t em,
Double_t e,
Int_t mid,
Double_t sde,
Double_t sdb,
Double_t tau,
Double_t b,
Int_t m)
695 SetModelParameters(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
714Double_t TRolke::ComputeInterval(
Int_t x,
Int_t y,
Int_t z,
Double_t bm,
Double_t em,
Double_t e,
Int_t mid,
Double_t sde,
Double_t sdb,
Double_t tau,
Double_t b,
Int_t m)
720 limit[1] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
732 limit[1] =
Interval(trial_x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
733 if (limit[1] > 0) done = 1;
755Double_t TRolke::Interval(
Int_t x,
Int_t y,
Int_t z,
Double_t bm,
Double_t em,
Double_t e,
Int_t mid,
Double_t sde,
Double_t sdb,
Double_t tau,
Double_t b,
Int_t m)
758 Double_t tempxy[2], limits[2] = {0, 0};
759 Double_t slope, fmid, low, flow, high, fhigh, test, ftest, mu0, maximum,
target,
l, f0;
761 Double_t maxiter = 1000, acc = 0.00001;
765 if ((mid != 3) && (mid != 5)) bm =
y;
766 if ((mid == 3) || (mid == 5)) {
767 if (bm == 0) bm = 0.00001;
770 if ((mid == 6) || (mid == 7)) {
771 if (bm == 0) bm = 0.00001;
774 if ((mid <= 2) || (mid == 4)) bp = 1;
777 if (bp == 1 &&
x == 0 && bm > 0) {
778 for (i = 0; i < 2; i++) {
780 tempxy[i] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
783 slope = tempxy[1] - tempxy[0];
784 limits[1] = tempxy[0] - slope;
786 if (limits[1] < 0) limits[1] = 0.0;
790 if (bp != 1 &&
x == 0) {
792 for (i = 0; i < 2; i++) {
794 tempxy[i] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
796 slope = tempxy[1] - tempxy[0];
797 limits[1] = tempxy[0] - slope;
799 if (limits[1] < 0) limits[1] = 0.0;
803 if (bp != 1 && bm == 0) {
804 for (i = 0; i < 2; i++) {
806 limits[1] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
807 tempxy[i] = limits[1];
809 slope = tempxy[1] - tempxy[0];
810 limits[1] = tempxy[0] - slope;
811 if (limits[1] < 0) limits[1] = 0;
815 if (
x == 0 && bm == 0) {
818 limits[1] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
819 tempxy[0] = limits[1];
822 limits[1] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
823 tempxy[1] = limits[1];
826 limits[1] =
Interval(
x,
y, z, bm, em,
e, mid, sde, sdb, tau,
b,
m);
827 limits[1] = 3 * tempxy[0] - tempxy[1] - limits[1];
828 if (limits[1] < 0) limits[1] = 0;
832 mu0 =
Likelihood(0,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 1);
833 maximum =
Likelihood(0,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 2);
835 f0 =
Likelihood(test,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 3);
837 if (mu0 < 0) maximum = f0;
853 for (i = 0; i < maxiter; i++) {
854 l = (
target - fhigh) / (flow - fhigh);
855 if (
l < 0.2)
l = 0.2;
856 if (
l > 0.8)
l = 0.8;
857 med =
l * low + (1 -
l) * high;
862 fmid =
Likelihood(med,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 3);
870 if ((high - low) < acc*high)
break;
884 ftest =
Likelihood(test,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 3);
889 slope = (ftest - flow) / (test - low);
890 high = test + (
target - ftest) / slope;
891 fhigh =
Likelihood(high,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 3);
894 for (i = 0; i < maxiter; i++) {
895 l = (
target - fhigh) / (flow - fhigh);
896 if (
l < 0.2)
l = 0.2;
897 if (
l > 0.8)
l = 0.8;
898 med =
l * low + (1. -
l) * high;
899 fmid =
Likelihood(med,
x,
y, z, bm, em, mid, sde, sdb, tau,
b,
m, 3);
909 if (high - low < acc*high)
break;
917 if ((mid == 4) || (mid == 5)) {
934Double_t TRolke::Likelihood(
Double_t mu,
Int_t x,
Int_t y,
Int_t z,
Double_t bm,
Double_t em,
Int_t mid,
Double_t sde,
Double_t sdb,
Double_t tau,
Double_t b,
Int_t m,
Int_t what)
952 std::cerr <<
"TRolke::Likelihood(...): Model NR: " <<
953 f_mid <<
" unknown"<<std::endl;
974 f = (
x -
y / tau) / zm;
978 mu = (
x -
y / tau) / zm;
1018 double f = 2*( lls + llb + lle);
1033 Int_t maxiter = 1000;
1035 Double_t emin = ((
m + mu * tau) -
TMath::Sqrt((
m + mu * tau) * (
m + mu * tau) - 4 * mu * tau * z)) / 2 / mu / tau;
1040 for (
Int_t i = 0; i < maxiter; i++) {
1041 med = (low + high) / 2.;
1045 if (high < 0.5) acc = 0.00001 * high;
1046 else acc = 0.00001 * (1 - high);
1048 if ((high - low) < acc*high)
break;
1050 if (fmid > 0) low = med;
1066 eta =
static_cast<double>(z) /
e -
static_cast<double>(
m - z) / (1.0 -
e);
1067 etaprime = (-1) * (
static_cast<double>(
m - z) / ((1.0 -
e) * (1.0 -
e)) +
static_cast<double>(z) / (
e *
e));
1069 bprime = (
b *
b * etaprime) / mu /
y;
1070 f = (mu + bprime) * (
x / (
e * mu +
b) - 1) + (
y /
b - tau) * bprime + eta;
1089 f = (
x -
y / tau) / em;
1093 mu = (
x -
y / tau) / em;
1106 coef[2] = mu * mu *
v - 2 * em * mu - mu * mu *
v * tau;
1107 coef[1] = (-
x) * mu *
v - mu * mu * mu *
v *
v * tau - mu * mu *
v * em + em * mu * mu *
v * tau + em * em * mu -
y * mu *
v;
1108 coef[0] =
x * mu * mu *
v *
v * tau +
x * em * mu *
v -
y * mu * mu *
v *
v +
y * em * mu *
v;
1114 if (
v > 0)
b =
y / (tau + (em -
e) / mu /
v);
1136 if (
v > 0) lle = - 0.9189385 -
TMath::Log(
v) / 2 - (em -
e)*(em -
e) /
v / 2;
1138 return 2*( lls + llb + lle);
1178 temp[0] = mu * mu *
v + u;
1179 temp[1] = mu * mu * mu *
v *
v + mu *
v * u - mu * mu *
v * em + mu *
v * bm - 2 * u * em;
1180 temp[2] = mu * mu *
v *
v * bm - mu *
v * u * em - mu *
v * bm * em + u * em * em - mu * mu *
v *
v *
x;
1181 e = (-temp[1] +
TMath::Sqrt(temp[1] * temp[1] - 4 * temp[0] * temp[2])) / 2 / temp[0];
1182 b = bm - (u * (em -
e)) /
v / mu;
1201 if ( u > 0) llb = - 0.9189385 -
TMath::Log(u) / 2 - (bm -
b)*(bm -
b) / u / 2;
1203 if (
v > 0) lle = - 0.9189385 -
TMath::Log(
v) / 2 - (em -
e)*(em -
e) /
v / 2;
1205 return 2*( lls + llb + lle);
1221 if (
what == 1)
f =
x -
y / tau;
1232 Double_t b = (
x +
y - (1 + tau) * mu + sqrt((
x +
y - (1 + tau) * mu) * (
x +
y - (1 + tau) * mu) + 4 * (1 + tau) *
y * mu)) / 2 / (1 + tau);
1252 return 2*( lls + llb);
1278 Double_t b = ((bm - u - mu) +
TMath::Sqrt((bm - u - mu) * (bm - u - mu) - 4 * (mu * u - mu * bm - u *
x))) / 2;
1294 if ( u > 0) llb = - 0.9189385 -
TMath::Log(u) / 2 - (bm -
b)*(bm -
b) / u / 2;
1296 return 2*( lls + llb);
1328 coef[2] = mu *
b - mu *
x - mu * mu - mu *
m;
1329 coef[1] = mu *
x - mu *
b + mu * z -
m *
b;
1354 return 2* (lls + lle);
1386 e = (-(mu * em -
b - mu * mu *
v) -
TMath::Sqrt((mu * em -
b - mu * mu *
v) * (mu * em -
b - mu * mu *
v) + 4 * mu * (
x * mu *
v - mu *
b *
v +
b * em))) / (- mu) / 2;
1405 if (
v > 0) lle = - 0.9189385 -
TMath::Log(
v) / 2 - (em -
e)*(em -
e) /
v / 2;
1407 return 2*( lls + lle);
1421 ans = ans *
x + *
p++;
1440 ans = ans *
x + *
p++;
winID h TVirtualViewer3D TVirtualGLPainter p
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 Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
<div class="legacybox"><h2>Legacy Code</h2> TRolke is a legacy interface: there will be no bug fixes ...
Double_t EvalLikeMod3(Double_t mu, Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb, Int_t what)
Calculates the Profile Likelihood for MODEL 3: Gauss background/ Gauss Efficiency.
void SetGaussBkgKnownEff(Int_t x, Double_t bm, Double_t sdb, Double_t e)
Model 5: Background - Gaussian, Efficiency - known (x,bm,sdb,e.
Double_t Interval(Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m)
Internal helper function 'Interval'.
bool GetLimitsML(Double_t &low, Double_t &high, Int_t &out_x)
get the upper and lower limits for the most likely outcome.
Double_t LikeMod7(Double_t mu, Double_t b, Double_t e, Int_t x, Double_t em, Double_t v)
Profile Likelihood function for MODEL 6: background known/ Efficiency gaussian.
Double_t EvalLikeMod6(Double_t mu, Int_t x, Int_t z, Double_t b, Int_t m, Int_t what)
Calculates the Profile Likelihood for MODEL 6: Background known/Efficiency binomial.
bool GetCriticalNumber(Int_t &ncrit, Int_t maxtry=-1)
get the value of x corresponding to rejection of the null hypothesis.
static Double_t EvalPolynomial(Double_t x, const Int_t coef[], Int_t N)
Evaluate polynomial.
void Print(Option_t *) const override
Dump internals. Print members.
void SetKnownBkgBinomEff(Int_t x, Int_t z, Int_t m, Double_t b)
Model 6: Background - known, Efficiency - Binomial (x,z,m,b)
Double_t Likelihood(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m, Int_t what)
Internal helper function Chooses between the different profile likelihood functions to use for the di...
Int_t fNumWarningsDeprecated1
Double_t LikeMod1(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Profile Likelihood function for MODEL 1: Poisson background/ Binomial Efficiency.
Double_t EvalLikeMod4(Double_t mu, Int_t x, Int_t y, Double_t tau, Int_t what)
Calculates the Profile Likelihood for MODEL 4: Poiss background/Efficiency known.
void SetPoissonBkgKnownEff(Int_t x, Int_t y, Double_t tau, Double_t e)
Model 4: Background - Poisson, Efficiency - known (x,y,tau,e)
Double_t LikeMod5(Double_t mu, Double_t b, Int_t x, Double_t bm, Double_t u)
Profile Likelihood function for MODEL 5: Gauss background/Efficiency known.
Double_t GetUpperLimit()
Calculate and get upper limit for the pre-specified model.
void SetBounding(const bool bnd)
void SetKnownBkgGaussEff(Int_t x, Double_t em, Double_t sde, Double_t b)
Model 7: Background - known, Efficiency - Gaussian (x,em,sde,b)
void SetGaussBkgGaussEff(Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb)
Model 3: Background - Gaussian, Efficiency - Gaussian (x,bm,em,sde,sdb)
void SetPoissonBkgGaussEff(Int_t x, Int_t y, Double_t em, Double_t tau, Double_t sde)
Model 2: Background - Poisson, Efficiency - Gaussian.
static Double_t EvalMonomial(Double_t x, const Int_t coef[], Int_t N)
Evaluate mononomial.
Double_t EvalLikeMod5(Double_t mu, Int_t x, Double_t bm, Double_t sdb, Int_t what)
Calculates the Profile Likelihood for MODEL 5: Gauss background/Efficiency known.
bool GetSensitivity(Double_t &low, Double_t &high, Double_t pPrecision=0.00001)
get the upper and lower average limits based on the specified model.
Double_t LikeGradMod1(Double_t e, Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Gradient model likelihood.
TRolke(Double_t CL=0.9, Option_t *option="")
Constructor with optional Confidence Level argument.
void ProfLikeMod1(Double_t mu, Double_t &b, Double_t &e, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Helper for calculation of estimates of efficiency and background for model 1.
Double_t LikeMod3(Double_t mu, Double_t b, Double_t e, Int_t x, Double_t bm, Double_t em, Double_t u, Double_t v)
Profile Likelihood function for MODEL 3: Gauss background/Gauss Efficiency.
Double_t EvalLikeMod7(Double_t mu, Int_t x, Double_t em, Double_t sde, Double_t b, Int_t what)
Calculates the Profile Likelihood for MODEL 7: background known/Efficiency Gauss.
void SetSwitch(bool bnd)
Deprecated name for SetBounding.
void SetModelParameters()
bool GetLimitsQuantile(Double_t &low, Double_t &high, Int_t &out_x, Double_t integral=0.5)
get the upper and lower limits for the outcome corresponding to a given quantile.
Double_t CalculateInterval(Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m)
Deprecated and error prone model selection interface.
bool GetLimits(Double_t &low, Double_t &high)
Calculate and get the upper and lower limits for the pre-specified model.
void SetPoissonBkgBinomEff(Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Model 1: Background - Poisson, Efficiency - Binomial.
Double_t LogFactorial(Int_t n)
LogFactorial function (use the logGamma function via the relation Gamma(n+1) = n!
Double_t ComputeInterval(Int_t x, Int_t y, Int_t z, Double_t bm, Double_t em, Double_t e, Int_t mid, Double_t sde, Double_t sdb, Double_t tau, Double_t b, Int_t m)
ComputeInterval, the internals.
Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m, Int_t what)
Calculates the Profile Likelihood for MODEL 1: Poisson background/ Binomial Efficiency.
Double_t GetLowerLimit()
Calculate and get lower limit for the pre-specified model.
Int_t fNumWarningsDeprecated2
Double_t LikeMod2(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t y, Double_t em, Double_t tau, Double_t v)
Profile Likelihood function for MODEL 2: Poisson background/Gauss Efficiency.
Double_t GetBackground()
Return a simple background value (estimate/truth) given the pre-specified model.
~TRolke() override
Destructor.
Double_t LikeMod6(Double_t mu, Double_t b, Double_t e, Int_t x, Int_t z, Int_t m)
Profile Likelihood function for MODEL 6: background known/ Efficiency binomial.
Double_t EvalLikeMod2(Double_t mu, Int_t x, Int_t y, Double_t em, Double_t sde, Double_t tau, Int_t what)
Calculates the Profile Likelihood for MODEL 2: Poisson background/ Gauss Efficiency.
Double_t LikeMod4(Double_t mu, Double_t b, Int_t x, Int_t y, Double_t tau)
Profile Likelihood function for MODEL 4: Poiss background/Efficiency known.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t PoissonI(Double_t x, Double_t par)
Computes the Discrete Poisson distribution function for (x,par).
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Bool_t RootsCubic(const Double_t coef[4], Double_t &a, Double_t &b, Double_t &c)
Calculates roots of polynomial of 3rd order a*x^3 + b*x^2 + c*x + d, where.
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.