205 fNumWarningsDeprecated1(0),
206 fNumWarningsDeprecated2(0)
208 SetModelParameters();
385 std::cerr <<
"TRolke - Error: Model id "<<
f_mid<<std::endl;
387 std::cerr <<
"TRolke - Please specify a model with e.g. 'SetGaussBkgGaussEff' (read the docs in Rolke.cxx )"<<std::endl;
392 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);
398 std::cerr <<
"TRolke - Warning: no limits found" <<std::endl;
438 std::cerr <<
"TRolke::GetBackground(): Model NR: " <<
439 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 < 1e-12))
break;
491 if (weightSum >= integral) {
499 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);
517 while (loop_x <= loop_max) {
524 if (loop_x >= loop_max) {
525 std::cout <<
"internal error finding maximum of distribution" << std::endl;
531 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);
547 int rolke_ncrit = -1;
550 maxj = 1000 + (
Int_t)background;
552 for (j = 0;j < maxj;j++) {
554 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);
562 if (rolke_ncrit == -1) {
563 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;
575 std::cerr <<
"*******************************************" <<std::endl;
576 std::cerr <<
"TRolke - Warning: 'SetSwitch' is depricated and may be removed from future releases:" <<std::endl;
577 std::cerr <<
" - Use 'SetBounding' instead "<<std::endl;
578 std::cerr <<
"*******************************************" <<std::endl;
586 std::cout <<
"*******************************************" <<std::endl;
587 std::cout <<
"* TRolke::Print() - dump of internals: " <<std::endl;
588 std::cout <<
"*"<<std::endl;
589 std::cout <<
"* model id, mid = "<<
f_mid <<std::endl;
590 std::cout <<
"*"<<std::endl;
591 std::cout <<
"* x = "<<
f_x <<std::endl;
592 std::cout <<
"* bm = "<<
f_bm <<std::endl;
593 std::cout <<
"* em = "<<
f_em <<std::endl;
594 std::cout <<
"* sde = "<<
f_sde <<std::endl;
595 std::cout <<
"* sdb = "<<
f_sdb <<std::endl;
596 std::cout <<
"* y = "<<
f_y <<std::endl;
597 std::cout <<
"* tau = "<<
f_tau <<std::endl;
598 std::cout <<
"* e = "<<
f_e <<std::endl;
599 std::cout <<
"* b = "<<
f_b <<std::endl;
600 std::cout <<
"* m = "<<
f_m <<std::endl;
601 std::cout <<
"* z = "<<
f_z <<std::endl;
602 std::cout <<
"*"<<std::endl;
603 std::cout <<
"* CL = "<<
fCL <<std::endl;
604 std::cout <<
"* Bounding = "<<
fBounding <<std::endl;
605 std::cout <<
"*"<<std::endl;
606 std::cout <<
"* calculated on demand only:"<<std::endl;
607 std::cout <<
"* fUpperLimit = "<<
fUpperLimit<<std::endl;
608 std::cout <<
"* fLowerLimit = "<<
fLowerLimit<<std::endl;
609 std::cout <<
"*******************************************" <<std::endl;
613 Double_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){
630 std::cerr <<
"*******************************************" <<std::endl;
631 std::cerr <<
"TRolke - Warning: 'CalculateInterval' is depricated and may be removed from future releases:" <<std::endl;
632 std::cerr <<
" - Use e.g. 'SetGaussBkgGaussEff' and 'GetLimits' instead (read the docs in Rolke.cxx )"<<std::endl;
633 std::cerr <<
"*******************************************" <<std::endl;
649 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);
654 void 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)
686 SetModelParameters(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
691 Double_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)
712 limit[1] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
724 limit[1] =
Interval(trial_x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
725 if (limit[1] > 0) done = 1;
732 Double_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)
751 Double_t tempxy[2], limits[2] = {0, 0};
752 Double_t slope, fmid, low, flow, high, fhigh,
test, ftest, mu0, maximum, target,
l, f0;
754 Double_t maxiter = 1000, acc = 0.00001;
758 if ((mid != 3) && (mid != 5)) bm =
y;
759 if ((mid == 3) || (mid == 5)) {
760 if (bm == 0) bm = 0.00001;
763 if ((mid == 6) || (mid == 7)) {
764 if (bm == 0) bm = 0.00001;
767 if ((mid <= 2) || (mid == 4)) bp = 1;
770 if (bp == 1 && x == 0 && bm > 0) {
771 for (i = 0; i < 2; i++) {
773 tempxy[i] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
776 slope = tempxy[1] - tempxy[0];
777 limits[1] = tempxy[0] - slope;
779 if (limits[1] < 0) limits[1] = 0.0;
783 if (bp != 1 && x == 0) {
785 for (i = 0; i < 2; i++) {
787 tempxy[i] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
789 slope = tempxy[1] - tempxy[0];
790 limits[1] = tempxy[0] - slope;
792 if (limits[1] < 0) limits[1] = 0.0;
796 if (bp != 1 && bm == 0) {
797 for (i = 0; i < 2; i++) {
799 limits[1] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
800 tempxy[i] = limits[1];
802 slope = tempxy[1] - tempxy[0];
803 limits[1] = tempxy[0] - slope;
804 if (limits[1] < 0) limits[1] = 0;
808 if (x == 0 && bm == 0) {
811 limits[1] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
812 tempxy[0] = limits[1];
815 limits[1] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
816 tempxy[1] = limits[1];
819 limits[1] =
Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
820 limits[1] = 3 * tempxy[0] - tempxy[1] - limits[1];
821 if (limits[1] < 0) limits[1] = 0;
825 mu0 =
Likelihood(0, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 1);
826 maximum =
Likelihood(0, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 2);
828 f0 =
Likelihood(test, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
830 if (mu0 < 0) maximum = f0;
833 target = maximum - dchi2;
846 for (i = 0; i < maxiter; i++) {
847 l = (target - fhigh) / (flow - fhigh);
848 if (l < 0.2) l = 0.2;
849 if (l > 0.8) l = 0.8;
850 med = l * low + (1 -
l) * high;
855 fmid =
Likelihood(med, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
863 if ((high - low) < acc*high)
break;
877 ftest =
Likelihood(test, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
878 if (ftest < target) {
882 slope = (ftest - flow) / (test - low);
883 high = test + (target - ftest) / slope;
884 fhigh =
Likelihood(high, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
887 for (i = 0; i < maxiter; i++) {
888 l = (target - fhigh) / (flow - fhigh);
889 if (l < 0.2) l = 0.2;
890 if (l > 0.8) l = 0.8;
891 med = l * low + (1. -
l) * high;
892 fmid =
Likelihood(med, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
902 if (high - low < acc*high)
break;
910 if ((mid == 4) || (mid == 5)) {
922 Double_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)
946 std::cerr <<
"TRolke::Likelihood(...): Model NR: " <<
947 f_mid <<
" unknown"<<std::endl;
968 f = (x - y / tau) / zm;
972 mu = (x - y / tau) / zm;
975 f =
LikeMod1(mu, b, e, x, y, z, tau, m);
982 f =
LikeMod1(mu, b, e, x, y, z, tau, m);
987 f =
LikeMod1(mu, b, e, x, y, z, tau, m);
1013 double f = 2*( lls + llb + lle);
1019 struct LikeFunction1 {
1029 Int_t maxiter = 1000;
1031 Double_t emin = ((m + mu * tau) -
TMath::Sqrt((m + mu * tau) * (m + mu * tau) - 4 * mu * tau * z)) / 2 / mu / tau;
1036 for (
Int_t i = 0; i < maxiter; i++) {
1037 med = (low + high) / 2.;
1041 if (high < 0.5) acc = 0.00001 * high;
1042 else acc = 0.00001 * (1 - high);
1044 if ((high - low) < acc*high)
break;
1046 if (fmid > 0) low = med;
1053 b =
Double_t(y) / (tau - eta / mu);
1062 eta =
static_cast<double>(z) / e - static_cast<double>(m - z) / (1.0 - e);
1063 etaprime = (-1) * (static_cast<double>(m - z) / ((1.0 - e) * (1.0 - e)) + static_cast<double>(z) / (e * e));
1065 bprime = (b * b * etaprime) / mu / y;
1066 f = (mu + bprime) * (x / (e * mu + b) - 1) + (y / b - tau) * bprime + eta;
1085 f = (x - y / tau) / em;
1089 mu = (x - y / tau) / em;
1092 f =
LikeMod2(mu, b, e, x, y, em, tau, v);
1099 f =
LikeMod2(mu, b, e, x, y, em, tau, v);
1102 coef[2] = mu * mu * v - 2 * em * mu - mu * mu * v * tau;
1103 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;
1104 coef[0] = x * mu * mu * v * v * tau + x * em * mu * v - y * mu * mu * v * v + y * em * mu *
v;
1110 if ( v > 0) b = y / (tau + (em - e) / mu / v);
1112 f =
LikeMod2(mu, b, e, x, y, em, tau, v);
1132 if ( v > 0) lle = - 0.9189385 -
TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1134 return 2*( lls + llb + lle);
1160 f =
LikeMod3(mu, b, e, x, bm, em, u, v);
1168 f =
LikeMod3(mu, b, e, x, bm, em, u, v);
1174 temp[0] = mu * mu * v + u;
1175 temp[1] = mu * mu * mu * v * v + mu * v * u - mu * mu * v * em + mu * v * bm - 2 * u * em;
1176 temp[2] = mu * mu * v * v * bm - mu * v * u * em - mu * v * bm * em + u * em * em - mu * mu * v * v *
x;
1177 e = (-temp[1] +
TMath::Sqrt(temp[1] * temp[1] - 4 * temp[0] * temp[2])) / 2 / temp[0];
1178 b = bm - (u * (em - e)) / v / mu;
1180 f =
LikeMod3(mu, b, e, x, bm, em, u, v);
1197 if ( u > 0) llb = - 0.9189385 -
TMath::Log(u) / 2 - (bm - b)*(bm - b) / u / 2;
1199 if ( v > 0) lle = - 0.9189385 -
TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1201 return 2*( lls + llb + lle);
1217 if (what == 1) f = x - y / tau;
1228 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);
1248 return 2*( lls + llb);
1274 Double_t b = ((bm - u - mu) +
TMath::Sqrt((bm - u - mu) * (bm - u - mu) - 4 * (mu * u - mu * bm - u * x))) / 2;
1290 if ( u > 0) llb = - 0.9189385 -
TMath::Log(u) / 2 - (bm - b)*(bm - b) / u / 2;
1292 return 2*( lls + llb);
1324 coef[2] = mu * b - mu * x - mu * mu - mu *
m;
1325 coef[1] = mu * x - mu * b + mu * z - m * b;
1350 return 2* (lls + lle);
1382 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;
1401 if ( v > 0) lle = - 0.9189385 -
TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1403 return 2*( lls + lle);
1417 ans = ans * x + *p++;
1436 ans = ans * x + *p++;
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)
XYZVector ans(TestRotation const &t, XYZVector const &v_in)
Double_t PoissonI(Double_t x, Double_t par)
compute the Poisson distribution function for (x,par) This is a non-smooth function.
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.
Double_t LogFactorial(Int_t n)
LogFactorial function (use the logGamma function via the relation Gamma(n+1) = n! ...
bool GetLimitsQuantile(Double_t &low, Double_t &high, Int_t &out_x, Double_t integral=0.5)
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)
Double_t background(Double_t *x, Double_t *par)
void SetModelParameters()
Int_t fNumWarningsDeprecated2
bool GetSensitivity(Double_t &low, Double_t &high, Double_t pPrecision=0.00001)
void SetPoissonBkgGaussEff(Int_t x, Int_t y, Double_t em, Double_t tau, Double_t sde)
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
void SetPoissonBkgBinomEff(Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
static Double_t EvalMonomial(Double_t x, const Int_t coef[], Int_t N)
evaluate mononomial
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 what = 1: Maximum...
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 what = 1: Maximum...
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)
void SetGaussBkgGaussEff(Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb)
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 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 what = 1: Maximum li...
Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m, Int_t what)
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.
bool GetLimitsML(Double_t &low, Double_t &high, Int_t &out_x)
ClassImp(TRolke) TRolke
constructor with optional Confidence Level argument.
void SetGaussBkgKnownEff(Int_t x, Double_t bm, Double_t sdb, Double_t e)
void SetKnownBkgBinomEff(Int_t x, Int_t z, Int_t m, Double_t b)
void SetPoissonBkgKnownEff(Int_t x, Int_t y, Double_t tau, Double_t e)
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)
void SetKnownBkgGaussEff(Int_t x, Double_t em, Double_t sde, Double_t b)
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 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
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 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 what = 1: Maximum li...
void SetBounding(const bool bnd)
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
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 what = 1: Maximum li...
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)
static Double_t EvalPolynomial(Double_t x, const Int_t coef[], Int_t N)
evaluate polynomial
Short_t Max(Short_t a, Short_t b)
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
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)
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.
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 a == coef[3], b == coef[2], c == coef[1], d == coef[0] coef[3] must be different from 0 If the boolean returned by the method is false: ==> there are 3 real roots a,b,c If the boolean returned by the method is true: ==> there is one real root a and 2 complex conjugates roots (b+i*c,b-i*c) Author: Francois-Xavier Gentit.
void Print(Option_t *) const
This method must be overridden when a class wants to print itself.
Double_t Sqrt(Double_t x)
bool GetCriticalNumber(Int_t &ncrit, Int_t maxtry=-1)
Int_t fNumWarningsDeprecated1
bool GetLimits(Double_t &low, Double_t &high)
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 what = 1: Maximum l...