ROOT  6.06/09
Reference Guide
TRolke.cxx
Go to the documentation of this file.
1 
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // TRolke
5 //
6 // This class computes confidence intervals for the rate of a Poisson
7 // process in the presence of uncertain background and/or efficiency.
8 //
9 // The treatment and the resulting limits are fully frequentist. The
10 // limit calculations make use of the profile likelihood method.
11 //
12 // Author: Jan Conrad (CERN) 2004
13 // Updated: Johan Lundberg (CERN) 2009
14 //
15 // Copyright CERN 2004,2009 Jan.Conrad@cern.ch,
16 // Johan.Lundberg@cern.ch
17 //
18 // For a full list of methods and their syntax, and build instructions,
19 // consult the header file TRolke.h.
20 // --------------------------------
21 //
22 // Examples/tutorials are found in the separate file Rolke.C
23 // ---------------------------------------------------------
24 //
25 //////////////////////////////////////////////////////////////////////////////
26 //
27 //
28 // TRolke implements the following Models
29 // =======================================
30 //
31 // The signal is always assumed to be Poisson, with the following
32 // combinations of models of background and detection efficiency:
33 //
34 // If unsure, first consider model 3, 4 or 5.
35 //
36 // 1: SetPoissonBkgBinomEff(x,y,z,tau,m)
37 //
38 // Background: Poisson
39 // Efficiency: Binomial
40 //
41 // when the background is simultaneously measured
42 // from sidebands (or MC), and
43 // the signal efficiency was determined from Monte Carlo
44 //
45 // 2: SetPoissonBkgGaussEff(x,y,em,sde,tau)
46 //
47 // Background: Poisson
48 // Efficiency: Gaussian
49 //
50 // when the background is simultaneously measured
51 // from sidebands (or MC), and
52 // the efficiency is modeled as Gaussian
53 //
54 // 3: SetGaussBkgGaussEff(x,bm,em,sde,sdb)
55 //
56 // Background: Gaussian
57 // Efficiency: Gaussian
58 //
59 // when background and efficiency can both be
60 // modeled as Gaussian.
61 //
62 // 4: SetPoissonBkgKnownEff(x,y,tau,e)
63 //
64 // Background: Poisson
65 // Efficiency: Known
66 //
67 // when the background is simultaneously measured
68 // from sidebands (or MC).
69 //
70 // 5: SetGaussBkgKnownEff(x,bm,sdb,e)
71 //
72 // Background: Gaussian
73 // Efficiency: Known
74 //
75 // when background is Gaussian
76 //
77 // 6: SetKnownBkgBinomEff(x,z,b,m)
78 //
79 // Background: Known
80 // Efficiency: Binomial
81 //
82 // when signal efficiency was determined from Monte Carlo
83 //
84 // 7: SetKnownBkgGaussEff(x,em,sde,b)
85 //
86 // Background: Known
87 // Efficiency: Gaussian
88 //
89 // when background is known and efficiency Gaussian
90 //
91 // Parameters and further explanation
92 // ==================================
93 //
94 // For all models:
95 // ---------------
96 //
97 // x = number of observed events in the experiment
98 //
99 // Efficiency (e or em) is the detection probability for signal.
100 // A low efficiency hence generally means weaker limits.
101 // If the efficiency of an experiment (with analysis cuts) is
102 // dealt with elsewhere, em or e can be set to one.
103 //
104 // For Poisson background measurements (sideband or MC):
105 // -----------------------------------------------------
106 //
107 // y = number of observed events in background region
108 // tau =
109 // Either: the ratio between signal and background region
110 // in case background is observed.
111 // Or: the ratio between observed and simulated live-time
112 // in case background is determined from MC.
113 //
114 // For Gaussian efficiency or background:
115 // --------------------------------------
116 //
117 // bm = estimate of the background
118 // sdb = corresponding standard deviation
119 //
120 // em = estimate of the efficiency
121 // sde = corresponding standard deviation
122 //
123 // If the efficiency scale of dealt with elsewhere,
124 // set em to 1 and sde to the relative uncertainty.
125 //
126 // For Binomial signal efficiency:
127 // -------------------------------
128 //
129 // m = number of MC events generated
130 // z = number of MC events observed
131 //
132 // For the case of known background expectation or known efficiency:
133 // -----------------------------------------------------------------
134 //
135 // e = true efficiency (considered known)
136 // b = background expectation value (considered known)
137 //
138 //
139 ////////////////////////////////////////////////////////////////////
140 //
141 //
142 // The confidence level (CL) is set either at construction
143 // time or with either of SetCL or SetCLSigmas
144 //
145 // The TRolke method is very similar to the one used in MINUIT (MINOS).
146 //
147 // Two options are offered to deal with cases where the maximum likelihood
148 // estimate (MLE) is not in the physical region. Version "bounded likelihood"
149 // is the one used by MINOS if bounds for the physical region are chosen.
150 // Unbounded likelihood (the default) allows the MLE to be in the
151 // unphysical region. It has however better coverage.
152 // For more details consult the reference (see below).
153 //
154 // For a description of the method and its properties:
155 //
156 // W.Rolke, A. Lopez, J. Conrad and Fred James
157 // "Limits and Confidence Intervals in presence of nuisance parameters"
158 // http://lanl.arxiv.org/abs/physics/0403059
159 // Nucl.Instrum.Meth.A551:493-503,2005
160 //
161 // Should I use TRolke, TFeldmanCousins, TLimit?
162 // ----------------------------------------------
163 //
164 // 1. Does TRolke make TFeldmanCousins obsolete?
165 //
166 // Certainly not. TFeldmanCousins is the fully frequentist construction and
167 // should be used in case of no (or negligible) uncertainties. It is however
168 // not capable of treating uncertainties in nuisance parameters. In other
169 // words, it does not handle background expectations or signal efficiencies
170 // which are known only with some limited accuracy.
171 //
172 // TRolke is designed for this case and it is shown in the reference above
173 // that it has good coverage properties for most cases, and can be used
174 // where FeldmannCousins can't.
175 //
176 // 2. What are the advantages of TRolke over TLimit?
177 //
178 // TRolke is fully frequentist. TLimit treats nuisance parameters Bayesian.
179 //
180 // For a coverage study of a Bayesian method refer to
181 // physics/0408039 (Tegenfeldt & J.C). However, this note studies
182 // the coverage of Feldman&Cousins with Bayesian treatment of nuisance
183 // parameters. To make a long story short: using the Bayesian method you
184 // might introduce a small amount of over-coverage (though I haven't shown it
185 // for TLimit). On the other hand, coverage of course is a not so interesting
186 // when you consider yourself a Bayesian.
187 //
188 ///////////////////////////////////////////////////////////////////////////
189 
190 #include "TRolke.h"
191 #include "TMath.h"
192 #include "Riostream.h"
193 
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 ///constructor with optional Confidence Level argument.
198 ///'option' is not used.
199 
200 TRolke::TRolke(Double_t CL, Option_t * /*option*/)
201 : fCL(CL),
202  fUpperLimit(0.0),
203  fLowerLimit(0.0),
204  fBounding(false), // true gives bounded likelihood
205  fNumWarningsDeprecated1(0),
206  fNumWarningsDeprecated2(0)
207 {
208  SetModelParameters();
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 
214 {
215 }
216 
217 /* ______________________ new interface _____________________ */
219 {
220 // Model 1: Background - Poisson, Efficiency - Binomial
221 // x : number of observed events in the experiment
222 // y : number of observed events in background region
223 // z : number of MC events observed
224 // tau : ratio parameter (read TRolke.cxx for details)
225 // m : number of MC events generated
227  x , // Int_t x,
228  y , // Int_t y,
229  z , // Int_t z,
230  0 , // Double_t bm,
231  0 , // Double_t em,
232  0 , // Double_t e,
233  1 , // Int_t mid,
234  0 , // Double_t sde,
235  0 , // Double_t sdb,
236  tau, // Double_t tau,
237  0 , // Double_t b,
238  m); // Int_t m
239 }
240 
242 {
243 // Model 2: Background - Poisson, Efficiency - Gaussian
244 // x : number of observed events in the experiment
245 // y : number of observed events in background region
246 // em : estimate of the efficiency
247 // tau : ratio parameter (read TRolke.cxx for details)
248 // sde : efficiency estimate's standard deviation
250  x , // Int_t x,
251  y , // Int_t y,
252  0 , // Int_t z,
253  0 , // Double_t bm,
254  em , // Double_t em,
255  0 , // Double_t e,
256  2 , // Int_t mid,
257  sde, // Double_t sde,
258  0 , // Double_t sdb,
259  tau, // Double_t tau,
260  0 , // Double_t b,
261  0); // Int_t m
262 
263 }
264 
266 {
267 // Model 3: Background - Gaussian, Efficiency - Gaussian (x,bm,em,sde,sdb)
268 // x : number of observed events in the experiment
269 // bm : estimate of the background
270 // em : estimate of the efficiency
271 // sde : efficiency estimate's standard deviation
272 // sdb : background estimate's standard deviation
274  x , // Int_t x,
275  0 , // Int_t y,
276  0 , // Int_t z,
277  bm , // Double_t bm,
278  em , // Double_t em,
279  0 , // Double_t e,
280  3 , // Int_t mid,
281  sde, // Double_t sde,
282  sdb, // Double_t sdb,
283  0 , // Double_t tau,
284  0 , // Double_t b,
285  0); // Int_t m
286 
287 }
288 
290 {
291 // Model 4: Background - Poisson, Efficiency - known (x,y,tau,e)
292 // x : number of observed events in the experiment
293 // y : number of observed events in background region
294 // tau : ratio parameter (read TRolke.cxx for details)
295 // e : true efficiency (considered known)
297  x , // Int_t x,
298  y , // Int_t y,
299  0 , // Int_t z,
300  0 , // Double_t bm,
301  0 , // Double_t em,
302  e , // Double_t e,
303  4 , // Int_t mid,
304  0 , // Double_t sde,
305  0 , // Double_t sdb,
306  tau, // Double_t tau,
307  0 , // Double_t b,
308  0); // Int_t m
309 
310 }
311 
313 {
314 // Model 5: Background - Gaussian, Efficiency - known (x,bm,sdb,e
315 // x : number of observed events in the experiment
316 // bm : estimate of the background
317 // sdb : background estimate's standard deviation
318 // e : true efficiency (considered known)
320  x , // Int_t x,
321  0 , // Int_t y,
322  0 , // Int_t z,
323  bm , // Double_t bm,
324  0 , // Double_t em,
325  e , // Double_t e,
326  5 , // Int_t mid,
327  0 , // Double_t sde,
328  sdb, // Double_t sdb,
329  0 , // Double_t tau,
330  0 , // Double_t b,
331  0); // Int_t m
332 
333 }
334 
336 {
337 // Model 6: Background - known, Efficiency - Binomial (x,z,m,b)
338 // x : number of observed events in the experiment
339 // z : number of MC events observed
340 // m : number of MC events generated
341 // b : background expectation value (considered known)
343  x , // Int_t x,
344  0 , // Int_t y
345  z , // Int_t z,
346  0 , // Double_t bm,
347  0 , // Double_t em,
348  0 , // Double_t e,
349  6 , // Int_t mid,
350  0 , // Double_t sde,
351  0 , // Double_t sdb,
352  0 , // Double_t tau,
353  b , // Double_t b,
354  m); // Int_t m
355 
356 }
357 
359 {
360 // Model 7: Background - known, Efficiency - Gaussian (x,em,sde,b)
361 // x : number of observed events in the experiment
362 // em : estimate of the efficiency
363 // sde : efficiency estimate's standard deviation
364 // b : background expectation value (considered known)
366  x , // Int_t x,
367  0 , // Int_t y
368  0 , // Int_t z,
369  0 , // Double_t bm,
370  em , // Double_t em,
371  0 , // Double_t e,
372  7 , // Int_t mid,
373  sde, // Double_t sde,
374  0 , // Double_t sdb,
375  0 , // Double_t tau,
376  b , // Double_t b,
377  0); // Int_t m
378 
379 }
380 
382 {
383 /* Calculate and get the upper and lower limits for the pre-specified model */
384  if ((f_mid<1)||(f_mid>7)) {
385  std::cerr << "TRolke - Error: Model id "<< f_mid<<std::endl;
386  if (f_mid<1) {
387  std::cerr << "TRolke - Please specify a model with e.g. 'SetGaussBkgGaussEff' (read the docs in Rolke.cxx )"<<std::endl;
388  }
389  return false;
390  }
391 
393  low = fLowerLimit;
394  high = fUpperLimit;
395  if (low < high) {
396  return true;
397  }else{
398  std::cerr << "TRolke - Warning: no limits found" <<std::endl;
399  return false;
400  }
401 }
402 
404 {
405 /* Calculate and get upper limit for the pre-specified model */
406  Double_t low(0), high(0);
407  GetLimits(low,high);
408  return fUpperLimit;
409 }
410 
412 {
413 /* Calculate and get lower limit for the pre-specified model */
414  Double_t low(0), high(0);
415  GetLimits(low,high);
416  return fLowerLimit;
417 }
418 
420 {
421 /* Return a simple background value (estimate/truth) given the pre-specified model */
422  Double_t background = 0;
423  switch (f_mid) {
424  case 1:
425  case 2:
426  case 4:
427  background = f_y / f_tau;
428  break;
429  case 3:
430  case 5:
431  background = f_bm;
432  break;
433  case 6:
434  case 7:
435  background = f_b;
436  break;
437  default:
438  std::cerr << "TRolke::GetBackground(): Model NR: " <<
439  f_mid << " unknown"<<std::endl;
440  return 0;
441  }
442  return background;
443 }
444 
445 bool TRolke::GetSensitivity(Double_t& low, Double_t& high, Double_t pPrecision)
446 {
447 // get the upper and lower average limits based on the specified model.
448 // No uncertainties are considered for the Poisson weights in the averaging sum
450 
451  Double_t weight = 0;
452  Double_t weightSum = 0;
453 
454  int loop_x = 0;
455 
456  while (1) {
458  weight = TMath::PoissonI(loop_x, background);
459  low += fLowerLimit * weight;
460  high += fUpperLimit * weight;
461  weightSum += weight;
462  if (loop_x > (background + 1)) { // don't stop too early
463  if ((weightSum > (1 - pPrecision)) || (weight < 1e-12)) break;
464  }
465  loop_x++;
466  }
467  low /= weightSum;
468  high /= weightSum;
469 
470  return (low < high); // could also add more detailed test
471 }
472 
473 
474 bool TRolke::GetLimitsQuantile(Double_t& low, Double_t& high, Int_t& out_x, Double_t integral)
475 {
476 /* get the upper and lower limits for the outcome corresponding to
477  a given quantile.
478  For integral=0.5 this gives the median limits
479  in repeated experiments. The returned out_x is the corresponding
480  (e.g. median) value of x.
481  No uncertainties are considered for the Poisson weights when calculating
482  the Poisson integral */
484  Double_t weight = 0;
485  Double_t weightSum = 0;
486  Int_t loop_x = 0;
487 
488  while (1) {
489  weight = TMath::PoissonI(loop_x, background);
490  weightSum += weight;
491  if (weightSum >= integral) {
492  break;
493  }
494  loop_x++;
495  }
496 
497  out_x = loop_x;
498 
500  low = fLowerLimit;
501  high = fUpperLimit;
502  return (low < high); // could also add more detailed test
503 
504 }
505 
506 bool TRolke::GetLimitsML(Double_t& low, Double_t& high, Int_t& out_x)
507 {
508 /* get the upper and lower limits for the most likely outcome.
509  The returned out_x is the corresponding value of x
510  No uncertainties are considered for the Poisson weights when finding ML */
512 
513  Int_t loop_x = 0; // this can be optimized if needed.
514  Int_t loop_max = 1000 + (Int_t)background; // --||--
515 
516  Double_t max = TMath::PoissonI(loop_x, background);
517  while (loop_x <= loop_max) {
518  if (TMath::PoissonI(loop_x + 1, background) < max) {
519  break;
520  }
521  loop_x++;
522  max = TMath::PoissonI(loop_x, background);
523  }
524  if (loop_x >= loop_max) {
525  std::cout << "internal error finding maximum of distribution" << std::endl;
526  return false;
527  }
528 
529  out_x = loop_x;
530 
532  low = fLowerLimit;
533  high = fUpperLimit;
534  return (low < high); // could also add more detailed test
535 
536 }
537 
539 {
540 // get the value of x corresponding to rejection of the null hypothesis.
541 // This means a lower limit >0 with the pre-specified Confidence Level.
542 // Optionally give maxtry; the maximum value of x to try. Of not, or if
543 // maxtry<0 an automatic mode is used.
545 
546  int j = 0;
547  int rolke_ncrit = -1;
548  int maxj =maxtry ;
549  if(maxtry<1){
550  maxj = 1000 + (Int_t)background; // max value to try
551  }
552  for (j = 0;j < maxj;j++) {
553  Int_t rolke_x = 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);
555  double rolke_ll = fLowerLimit;
556  if (rolke_ll > 0) {
557  rolke_ncrit = j;
558  break;
559  }
560  }
561 
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;
564  ncrit = -1;
565  return false;
566  } else {
567  ncrit = rolke_ncrit;
568  return true;
569  }
570 }
571 
572 void TRolke::SetSwitch(bool bnd) {
573 /* Deprecated name for SetBounding. */
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;
580  }
581  SetBounding(bnd);
582 }
583 
584 void TRolke::Print(Option_t*) const {
585 /* Dump internals. Print members. */
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;
610 }
611 
612 
614 /* Deprecated and error prone model selection interface.
615  It's use is trongly discouraged. 'mid' is the model ID (1 to 7).
616  This method is provided for backwards compatibility/developer use only. */
617 // x : number of observed events in the experiment
618 // y : number of observed events in background region
619 // z : number of MC events observed
620 // bm : estimate of the background
621 // em : estimate of the efficiency
622 // e : true efficiency (considered known)
623 // mid : internal model id (really, you should not use this method at all)
624 // sde : efficiency estimate's standard deviation
625 // sdb : background estimate's standard deviation
626 // tau : ratio parameter (read TRolke.cxx for details)
627 // b : background expectation value (considered known)
628 // m : number of MC events generated
629  if (fNumWarningsDeprecated2<2 ) {
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;
635  }
637  x,
638  y,
639  z,
640  bm,
641  em,
642  e,
643  mid,
644  sde,
645  sdb,
646  tau,
647  b,
648  m);
650 }
651 
652 
653 // --------------- Private methods ----------------
655 {
656 //___________________________________________________________________________
657 // x : number of observed events in the experiment
658 // y : number of observed events in background region
659 // z : number of MC events observed
660 // bm : estimate of the background
661 // em : estimate of the efficiency
662 // e : true efficiency (considered known)
663 // mid : internal model id
664 // sde : efficiency estimate's standard deviation
665 // sdb : background estimate's standard deviation
666 // tau : ratio parameter (read TRolke.cxx for details)
667 // b : background expectation value (considered known)
668 // m : number of MC events generated
669  f_x = x ;
670  f_y = y ;
671  f_z = z ;
672  f_bm = bm ;
673  f_em = em ;
674  f_e = e ;
675  f_mid = mid ;
676  f_sde = sde ;
677  f_sdb = sdb ;
678  f_tau = tau ;
679  f_b = b ;
680  f_m = m ;
681 }
682 
684 {
685 /* Clear internal model */
686  SetModelParameters(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
687  f_mid=0;
688 }
689 
690 
692 {
693 //___________________________________________________________________________
694 // ComputeInterval, the internals.
695 // x : number of observed events in the experiment
696 // y : number of observed events in background region
697 // z : number of MC events observed
698 // bm : estimate of the background
699 // em : estimate of the efficiency
700 // e : true efficiency (considered known)
701 // mid : internal model id (really, you should not use this method at all)
702 // sde : efficiency estimate's standard deviation
703 // sdb : background estimate's standard deviation
704 // tau : ratio parameter (read TRolke.cxx for details)
705 // b : background expectation value (considered known)
706 // m : number of MC events generated
707 
708  //calculate interval
709  Int_t done = 0;
710  Double_t limit[2];
711 
712  limit[1] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
713 
714  if (limit[1] > 0) {
715  done = 1;
716  }
717 
718  if (! fBounding) {
719 
720  Int_t trial_x = x;
721 
722  while (done == 0) {
723  trial_x++;
724  limit[1] = Interval(trial_x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
725  if (limit[1] > 0) done = 1;
726  }
727  }
728 
729  return limit[1];
730 }
731 
733 {
734 //_____________________________________________________________________
735 // Internal helper function 'Interval'
736 //
737 // x : number of observed events in the experiment
738 // y : number of observed events in background region
739 // z : number of MC events observed
740 // bm : estimate of the background
741 // em : estimate of the efficiency
742 // e : true efficiency (considered known)
743 // mid : internal model id (really, you should not use this method at all)
744 // sde : efficiency estimate's standard deviation
745 // sdb : background estimate's standard deviation
746 // tau : ratio parameter (read TRolke.cxx for details)
747 // b : background expectation value (considered known)
748 // m : number of MC events generated
749 
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;
753  Double_t med = 0;
754  Double_t maxiter = 1000, acc = 0.00001;
755  Int_t i;
756  Int_t bp = 0;
757 
758  if ((mid != 3) && (mid != 5)) bm = y;
759  if ((mid == 3) || (mid == 5)) {
760  if (bm == 0) bm = 0.00001;
761  }
762 
763  if ((mid == 6) || (mid == 7)) {
764  if (bm == 0) bm = 0.00001;
765  }
766 
767  if ((mid <= 2) || (mid == 4)) bp = 1;
768 
769 
770  if (bp == 1 && x == 0 && bm > 0) {
771  for (i = 0; i < 2; i++) {
772  x++;
773  tempxy[i] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
774  }
775 
776  slope = tempxy[1] - tempxy[0];
777  limits[1] = tempxy[0] - slope;
778  limits[0] = 0.0;
779  if (limits[1] < 0) limits[1] = 0.0;
780  goto done;
781  }
782 
783  if (bp != 1 && x == 0) {
784 
785  for (i = 0; i < 2; i++) {
786  x++;
787  tempxy[i] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
788  }
789  slope = tempxy[1] - tempxy[0];
790  limits[1] = tempxy[0] - slope;
791  limits[0] = 0.0;
792  if (limits[1] < 0) limits[1] = 0.0;
793  goto done;
794  }
795 
796  if (bp != 1 && bm == 0) {
797  for (i = 0; i < 2; i++) {
798  bm++;
799  limits[1] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
800  tempxy[i] = limits[1];
801  }
802  slope = tempxy[1] - tempxy[0];
803  limits[1] = tempxy[0] - slope;
804  if (limits[1] < 0) limits[1] = 0;
805  goto done;
806  }
807 
808  if (x == 0 && bm == 0) {
809  x++;
810  bm++;
811  limits[1] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
812  tempxy[0] = limits[1];
813  x = 1;
814  bm = 2;
815  limits[1] = Interval(x, y, z, bm, em, e, mid, sde, sdb, tau, b, m);
816  tempxy[1] = limits[1];
817  x = 2;
818  bm = 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;
822  goto done;
823  }
824 
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);
827  test = 0;
828  f0 = Likelihood(test, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
829  if (fBounding) {
830  if (mu0 < 0) maximum = f0;
831  }
832 
833  target = maximum - dchi2;
834  if (f0 > target) {
835  limits[0] = 0;
836  } else {
837  if (mu0 < 0) {
838  limits[0] = 0;
839  limits[1] = 0;
840  }
841 
842  low = 0;
843  flow = f0;
844  high = mu0;
845  fhigh = maximum;
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;
851  if (med < 0.01) {
852  limits[1] = 0.0;
853  goto done;
854  }
855  fmid = Likelihood(med, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
856  if (fmid > target) {
857  high = med;
858  fhigh = fmid;
859  } else {
860  low = med;
861  flow = fmid;
862  }
863  if ((high - low) < acc*high) break;
864  }
865  limits[0] = med;
866  }
867 
868  if (mu0 > 0) {
869  low = mu0;
870  flow = maximum;
871  } else {
872  low = 0;
873  flow = f0;
874  }
875 
876  test = low + 1 ;
877  ftest = Likelihood(test, x, y, z, bm, em, mid, sde, sdb, tau, b, m, 3);
878  if (ftest < target) {
879  high = test;
880  fhigh = ftest;
881  } else {
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);
885  }
886 
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);
893 
894  if (fmid < target) {
895  high = med;
896  fhigh = fmid;
897  } else {
898  low = med;
899  flow = fmid;
900  }
901 
902  if (high - low < acc*high) break;
903  }
904 
905  limits[1] = med;
906 
907 done:
908 
909  // apply known efficiency
910  if ((mid == 4) || (mid == 5)) {
911  limits[0] /= e;
912  limits[1] /= e;
913  }
914 
915  fUpperLimit = limits[1];
916  fLowerLimit = TMath::Max(limits[0], 0.0);
917 
918  return limits[1];
919 }
920 
921 
923 {
924 //___________________________________________________________________________
925 //Internal helper function
926 // Chooses between the different profile likelihood functions to use for the
927 // different models.
928 // Returns evaluation of the profile likelihood functions.
929 
930  switch (mid) {
931  case 1:
932  return EvalLikeMod1(mu, x, y, z, tau, m, what);
933  case 2:
934  return EvalLikeMod2(mu, x, y, em, sde, tau, what);
935  case 3:
936  return EvalLikeMod3(mu, x, bm, em, sde, sdb, what);
937  case 4:
938  return EvalLikeMod4(mu, x, y, tau, what);
939  case 5:
940  return EvalLikeMod5(mu, x, bm, sdb, what);
941  case 6:
942  return EvalLikeMod6(mu, x, z, b, m, what);
943  case 7:
944  return EvalLikeMod7(mu, x, em, sde, b, what);
945  default:
946  std::cerr << "TRolke::Likelihood(...): Model NR: " <<
947  f_mid << " unknown"<<std::endl;
948  return 0;
949  }
950 
951  return 0;
952 }
953 
955 {
956 //_________________________________________________________________________
957 //
958 // Calculates the Profile Likelihood for MODEL 1:
959 // Poisson background/ Binomial Efficiency
960 // what = 1: Maximum likelihood estimate is returned
961 // what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
962 // what = 3: Profile Likelihood of Test hypothesis is returned
963 // otherwise parameters as described in the beginning of the class)
964  Double_t f = 0;
965  Double_t zm = Double_t(z) / m;
966 
967  if (what == 1) {
968  f = (x - y / tau) / zm;
969  }
970 
971  if (what == 2) {
972  mu = (x - y / tau) / zm;
973  Double_t b = y / tau;
974  Double_t e = zm;
975  f = LikeMod1(mu, b, e, x, y, z, tau, m);
976  }
977 
978  if (what == 3) {
979  if (mu == 0) {
980  Double_t b = (x + y) / (1.0 + tau);
981  Double_t e = zm;
982  f = LikeMod1(mu, b, e, x, y, z, tau, m);
983  } else {
984  Double_t e = 0;
985  Double_t b = 0;
986  ProfLikeMod1(mu, b, e, x, y, z, tau, m);
987  f = LikeMod1(mu, b, e, x, y, z, tau, m);
988  }
989  }
990 
991  return f;
992 }
993 
994 
996 {
997 //________________________________________________________________________
998 // Profile Likelihood function for MODEL 1:
999 // Poisson background/ Binomial Efficiency
1000 
1001  double s = e*mu+b;
1002  double lls = - s;
1003  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1004  double bg = tau*b;
1005  double llb = -bg;
1006  if ( y > 0) llb = y*TMath::Log( bg) - bg - LogFactorial(y);
1007 
1008  double lle = 0; // binomial log-like
1009  if (z == 0) lle = m * TMath::Log(1-e);
1010  else if ( z == m) lle = m * TMath::Log(e);
1011  else lle = z * TMath::Log(e) + (m - z)*TMath::Log(1 - e) + LogFactorial(m) - LogFactorial(m-z) - LogFactorial(z);
1012 
1013  double f = 2*( lls + llb + lle);
1014  return f;
1015 }
1016 
1017 
1018 // this code is non-sense - // need to solve using Minuit
1019 struct LikeFunction1 {
1020 };
1021 
1023 {
1024 //________________________________________________________________________
1025 // Helper for calculation of estimates of efficiency and background for model 1
1026 //
1027 
1028  Double_t med = 0.0, fmid;
1029  Int_t maxiter = 1000;
1030  Double_t acc = 0.00001;
1031  Double_t emin = ((m + mu * tau) - TMath::Sqrt((m + mu * tau) * (m + mu * tau) - 4 * mu * tau * z)) / 2 / mu / tau;
1032 
1033  Double_t low = TMath::Max(1e-10, emin + 1e-10);
1034  Double_t high = 1 - 1e-10;
1035 
1036  for (Int_t i = 0; i < maxiter; i++) {
1037  med = (low + high) / 2.;
1038 
1039  fmid = LikeGradMod1(med, mu, x, y, z, tau, m);
1040 
1041  if (high < 0.5) acc = 0.00001 * high;
1042  else acc = 0.00001 * (1 - high);
1043 
1044  if ((high - low) < acc*high) break;
1045 
1046  if (fmid > 0) low = med;
1047  else high = med;
1048  }
1049 
1050  e = med;
1051  Double_t eta = Double_t(z) / e - Double_t(m - z) / (1 - e);
1052 
1053  b = Double_t(y) / (tau - eta / mu);
1054 }
1055 
1056 ////////////////////////////////////////////////////////////////////////////////
1057 ///gradient model likelihood
1058 
1060 {
1061  Double_t eta, etaprime, bprime, f;
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));
1064  Double_t b = y / (tau - eta / mu);
1065  bprime = (b * b * etaprime) / mu / y;
1066  f = (mu + bprime) * (x / (e * mu + b) - 1) + (y / b - tau) * bprime + eta;
1067  return f;
1068 }
1069 
1070 ////////////////////////////////////////////////////////////////////////////////
1071 /// Calculates the Profile Likelihood for MODEL 2:
1072 /// Poisson background/ Gauss Efficiency
1073 /// what = 1: Maximum likelihood estimate is returned
1074 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1075 /// what = 3: Profile Likelihood of Test hypothesis is returned
1076 /// otherwise parameters as described in the beginning of the class)
1077 
1079 {
1080  Double_t v = sde * sde;
1081  Double_t coef[4], roots[3];
1082  Double_t f = 0;
1083 
1084  if (what == 1) {
1085  f = (x - y / tau) / em;
1086  }
1087 
1088  if (what == 2) {
1089  mu = (x - y / tau) / em;
1090  Double_t b = y / tau;
1091  Double_t e = em;
1092  f = LikeMod2(mu, b, e, x, y, em, tau, v);
1093  }
1094 
1095  if (what == 3) {
1096  if (mu == 0) {
1097  Double_t b = (x + y) / (1 + tau);
1098  Double_t e = em ;
1099  f = LikeMod2(mu, b, e, x, y, em, tau, v);
1100  } else {
1101  coef[3] = mu;
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;
1105 
1106  TMath::RootsCubic(coef, roots[0], roots[1], roots[2]);
1107 
1108  Double_t e = roots[1];
1109  Double_t b;
1110  if ( v > 0) b = y / (tau + (em - e) / mu / v);
1111  else b = y/tau;
1112  f = LikeMod2(mu, b, e, x, y, em, tau, v);
1113  }
1114  }
1115 
1116  return f;
1117 }
1118 
1119 ////////////////////////////////////////////////////////////////////////////////
1120 /// Profile Likelihood function for MODEL 2:
1121 /// Poisson background/Gauss Efficiency
1122 
1124 {
1125  double s = e*mu+b;
1126  double lls = - s;
1127  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1128  double bg = tau*b;
1129  double llb = -bg;
1130  if ( y > 0) llb = y*TMath::Log( bg) - bg - LogFactorial(y);
1131  double lle = 0;
1132  if ( v > 0) lle = - 0.9189385 - TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1133 
1134  return 2*( lls + llb + lle);
1135 }
1136 
1137 ////////////////////////////////////////////////////////////////////////////////
1138 /// Calculates the Profile Likelihood for MODEL 3:
1139 /// Gauss background/ Gauss Efficiency
1140 /// what = 1: Maximum likelihood estimate is returned
1141 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1142 /// what = 3: Profile Likelihood of Test hypothesis is returned
1143 /// otherwise parameters as described in the beginning of the class)
1144 
1146 {
1147  Double_t f = 0.;
1148  Double_t v = sde * sde;
1149  Double_t u = sdb * sdb;
1150 
1151  if (what == 1) {
1152  f = (x - bm) / em;
1153  }
1154 
1155 
1156  if (what == 2) {
1157  mu = (x - bm) / em;
1158  Double_t b = bm;
1159  Double_t e = em;
1160  f = LikeMod3(mu, b, e, x, bm, em, u, v);
1161  }
1162 
1163 
1164  if (what == 3) {
1165  if (mu == 0.0) {
1166  Double_t b = ((bm - u) + TMath::Sqrt((bm - u) * (bm - u) + 4 * x * u)) / 2.;
1167  Double_t e = em;
1168  f = LikeMod3(mu, b, e, x, bm, em, u, v);
1169  } else {
1170  Double_t e = em;
1171  Double_t b = bm;
1172  if ( v > 0) {
1173  Double_t temp[3];
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;
1179  }
1180  f = LikeMod3(mu, b, e, x, bm, em, u, v);
1181  }
1182  }
1183 
1184  return f;
1185 }
1186 
1187 ////////////////////////////////////////////////////////////////////////////////
1188 /// Profile Likelihood function for MODEL 3:
1189 /// Gauss background/Gauss Efficiency
1190 
1192 {
1193  double s = e*mu+b;
1194  double lls = - s;
1195  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1196  double llb = 0;
1197  if ( u > 0) llb = - 0.9189385 - TMath::Log(u) / 2 - (bm - b)*(bm - b) / u / 2;
1198  double lle = 0;
1199  if ( v > 0) lle = - 0.9189385 - TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1200 
1201  return 2*( lls + llb + lle);
1202 
1203 }
1204 
1205 ////////////////////////////////////////////////////////////////////////////////
1206 /// Calculates the Profile Likelihood for MODEL 4:
1207 /// Poiss background/Efficiency known
1208 /// what = 1: Maximum likelihood estimate is returned
1209 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1210 /// what = 3: Profile Likelihood of Test hypothesis is returned
1211 /// otherwise parameters as described in the beginning of the class)
1212 
1214 {
1215  Double_t f = 0.0;
1216 
1217  if (what == 1) f = x - y / tau;
1218  if (what == 2) {
1219  mu = x - y / tau;
1220  Double_t b = y / tau;
1221  f = LikeMod4(mu, b, x, y, tau);
1222  }
1223  if (what == 3) {
1224  if (mu == 0.0) {
1225  Double_t b = Double_t(x + y) / (1 + tau);
1226  f = LikeMod4(mu, b, x, y, tau);
1227  } else {
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);
1229  f = LikeMod4(mu, b, x, y, tau);
1230  }
1231  }
1232  return f;
1233 }
1234 
1235 ////////////////////////////////////////////////////////////////////////////////
1236 /// Profile Likelihood function for MODEL 4:
1237 /// Poiss background/Efficiency known
1238 
1240 {
1241  double s = mu+b;
1242  double lls = - s;
1243  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1244  double bg = tau*b;
1245  double llb = -bg;
1246  if ( y > 0) llb = y*TMath::Log( bg) - bg - LogFactorial(y);
1247 
1248  return 2*( lls + llb);
1249 }
1250 
1251 ////////////////////////////////////////////////////////////////////////////////
1252 /// Calculates the Profile Likelihood for MODEL 5:
1253 /// Gauss background/Efficiency known
1254 /// what = 1: Maximum likelihood estimate is returned
1255 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1256 /// what = 3: Profile Likelihood of Test hypothesis is returned
1257 /// otherwise parameters as described in the beginning of the class)
1258 
1260 {
1261  Double_t u = sdb * sdb;
1262  Double_t f = 0;
1263 
1264  if (what == 1) {
1265  f = x - bm;
1266  }
1267  if (what == 2) {
1268  mu = x - bm;
1269  Double_t b = bm;
1270  f = LikeMod5(mu, b, x, bm, u);
1271  }
1272 
1273  if (what == 3) {
1274  Double_t b = ((bm - u - mu) + TMath::Sqrt((bm - u - mu) * (bm - u - mu) - 4 * (mu * u - mu * bm - u * x))) / 2;
1275  f = LikeMod5(mu, b, x, bm, u);
1276  }
1277  return f;
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Profile Likelihood function for MODEL 5:
1282 /// Gauss background/Efficiency known
1283 
1285 {
1286  double s = mu+b;
1287  double lls = - s;
1288  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1289  double llb = 0;
1290  if ( u > 0) llb = - 0.9189385 - TMath::Log(u) / 2 - (bm - b)*(bm - b) / u / 2;
1291 
1292  return 2*( lls + llb);
1293 }
1294 
1295 ////////////////////////////////////////////////////////////////////////////////
1296 /// Calculates the Profile Likelihood for MODEL 6:
1297 /// Background known/Efficiency binomial
1298 /// what = 1: Maximum likelihood estimate is returned
1299 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1300 /// what = 3: Profile Likelihood of Test hypothesis is returned
1301 /// otherwise parameters as described in the beginning of the class)
1302 
1304 {
1305  Double_t coef[4], roots[3];
1306  Double_t f = 0.;
1307  Double_t zm = Double_t(z) / m;
1308 
1309  if (what == 1) {
1310  f = (x - b) / zm;
1311  }
1312 
1313  if (what == 2) {
1314  mu = (x - b) / zm;
1315  Double_t e = zm;
1316  f = LikeMod6(mu, b, e, x, z, m);
1317  }
1318  if (what == 3) {
1319  Double_t e;
1320  if (mu == 0) {
1321  e = zm;
1322  } else {
1323  coef[3] = mu * mu;
1324  coef[2] = mu * b - mu * x - mu * mu - mu * m;
1325  coef[1] = mu * x - mu * b + mu * z - m * b;
1326  coef[0] = b * z;
1327  TMath::RootsCubic(coef, roots[0], roots[1], roots[2]);
1328  e = roots[1];
1329  }
1330  f = LikeMod6(mu, b, e, x, z, m);
1331  }
1332  return f;
1333 }
1334 
1335 ////////////////////////////////////////////////////////////////////////////////
1336 /// Profile Likelihood function for MODEL 6:
1337 /// background known/ Efficiency binomial
1338 
1340 {
1341  double s = e*mu+b;
1342  double lls = - s;
1343  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1344 
1345  double lle = 0;
1346  if (z == 0) lle = m * TMath::Log(1-e);
1347  else if ( z == m) lle = m * TMath::Log(e);
1348  else lle = z * TMath::Log(e) + (m - z)*TMath::Log(1 - e) + LogFactorial(m) - LogFactorial(m-z) - LogFactorial(z);
1349 
1350  return 2* (lls + lle);
1351 }
1352 
1353 
1354 ////////////////////////////////////////////////////////////////////////////////
1355 /// Calculates the Profile Likelihood for MODEL 7:
1356 /// background known/Efficiency Gauss
1357 /// what = 1: Maximum likelihood estimate is returned
1358 /// what = 2: Profile Likelihood of Maximum Likelihood estimate is returned.
1359 /// what = 3: Profile Likelihood of Test hypothesis is returned
1360 /// otherwise parameters as described in the beginning of the class)
1361 
1363 {
1364  Double_t v = sde * sde;
1365  Double_t f = 0.;
1366 
1367  if (what == 1) {
1368  f = (x - b) / em;
1369  }
1370 
1371  if (what == 2) {
1372  mu = (x - b) / em;
1373  Double_t e = em;
1374  f = LikeMod7(mu, b, e, x, em, v);
1375  }
1376 
1377  if (what == 3) {
1378  Double_t e;
1379  if (mu == 0) {
1380  e = em;
1381  } else {
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;
1383  }
1384  f = LikeMod7(mu, b, e, x, em, v);
1385  }
1386 
1387  return f;
1388 }
1389 
1390 ////////////////////////////////////////////////////////////////////////////////
1391 /// Profile Likelihood function for MODEL 6:
1392 /// background known/ Efficiency gaussian
1393 
1395 {
1396  double s = e*mu+b;
1397  double lls = - s;
1398  if (x > 0) lls = x*TMath::Log(s) - s - LogFactorial(x);
1399 
1400  double lle = 0;
1401  if ( v > 0) lle = - 0.9189385 - TMath::Log(v) / 2 - (em - e)*(em - e) / v / 2;
1402 
1403  return 2*( lls + lle);
1404 }
1405 
1406 ////////////////////////////////////////////////////////////////////////////////
1407 /// evaluate polynomial
1408 
1410 {
1411  const Int_t *p;
1412  p = coef;
1413  Double_t ans = *p++;
1414  Int_t i = N;
1415 
1416  do
1417  ans = ans * x + *p++;
1418  while (--i);
1419 
1420  return ans;
1421 }
1422 
1423 ////////////////////////////////////////////////////////////////////////////////
1424 /// evaluate mononomial
1425 
1427 {
1428  Double_t ans;
1429  const Int_t *p;
1430 
1431  p = coef;
1432  ans = x + *p++;
1433  Int_t i = N - 1;
1434 
1435  do
1436  ans = ans * x + *p++;
1437  while (--i);
1438 
1439  return ans;
1440 }
1441 
1442 ////////////////////////////////////////////////////////////////////////////////
1443 /// LogFactorial function (use the logGamma function via the relation Gamma(n+1) = n!
1444 
1446 {
1447  return TMath::LnGamma(n+1);
1448 }
1449 
1450 
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)
Definition: TRolke.cxx:732
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.
Definition: TMath.cxx:592
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.
Definition: TRolke.cxx:1239
Double_t Log(Double_t x)
Definition: TMath.h:526
Double_t LogFactorial(Int_t n)
LogFactorial function (use the logGamma function via the relation Gamma(n+1) = n! ...
Definition: TRolke.cxx:1445
Double_t f_em
Definition: TRolke.h:51
const char Option_t
Definition: RtypesCore.h:62
bool GetLimitsQuantile(Double_t &low, Double_t &high, Int_t &out_x, Double_t integral=0.5)
Definition: TRolke.cxx:474
Int_t f_y
Definition: TRolke.h:48
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)
Definition: TRolke.cxx:613
Double_t f_sdb
Definition: TRolke.h:55
Double_t background(Double_t *x, Double_t *par)
#define N
void SetModelParameters()
Definition: TRolke.cxx:683
Int_t f_x
Definition: TRolke.h:47
Int_t fNumWarningsDeprecated2
Definition: TRolke.h:43
bool GetSensitivity(Double_t &low, Double_t &high, Double_t pPrecision=0.00001)
Definition: TRolke.cxx:445
int Int_t
Definition: RtypesCore.h:41
void SetPoissonBkgGaussEff(Int_t x, Int_t y, Double_t em, Double_t tau, Double_t sde)
Definition: TRolke.cxx:241
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
Definition: TIterator.cxx:20
void SetPoissonBkgBinomEff(Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m)
Definition: TRolke.cxx:218
Int_t f_z
Definition: TRolke.h:49
double sqrt(double)
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
Definition: TMath.cxx:2141
Double_t x[n]
Definition: legend1.C:17
static Double_t EvalMonomial(Double_t x, const Int_t coef[], Int_t N)
evaluate mononomial
Definition: TRolke.cxx:1426
Double_t f_bm
Definition: TRolke.h:50
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...
Definition: TRolke.cxx:1078
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...
Definition: TRolke.cxx:1303
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)
Definition: TRolke.cxx:922
void SetGaussBkgGaussEff(Int_t x, Double_t bm, Double_t em, Double_t sde, Double_t sdb)
Definition: TRolke.cxx:265
Double_t f_b
Definition: TRolke.h:57
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.
Definition: TRolke.cxx:1339
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...
Definition: TRolke.cxx:1213
Double_t EvalLikeMod1(Double_t mu, Int_t x, Int_t y, Int_t z, Double_t tau, Int_t m, Int_t what)
Definition: TRolke.cxx:954
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.
Definition: TRolke.cxx:1394
bool GetLimitsML(Double_t &low, Double_t &high, Int_t &out_x)
Definition: TRolke.cxx:506
TCanvas * roots()
Definition: roots.C:1
ClassImp(TRolke) TRolke
constructor with optional Confidence Level argument.
Definition: TRolke.cxx:194
Double_t f_sde
Definition: TRolke.h:54
static const char * what
Definition: stlLoader.cc:6
void SetGaussBkgKnownEff(Int_t x, Double_t bm, Double_t sdb, Double_t e)
Definition: TRolke.cxx:312
void SetKnownBkgBinomEff(Int_t x, Int_t z, Int_t m, Double_t b)
Definition: TRolke.cxx:335
bool fBounding
Definition: TRolke.h:40
SVector< double, 2 > v
Definition: Dict.h:5
void SetSwitch(bool bnd)
Definition: TRolke.cxx:572
Double_t fUpperLimit
Definition: TRolke.h:38
TMarker * m
Definition: textangle.C:8
void SetPoissonBkgKnownEff(Int_t x, Int_t y, Double_t tau, Double_t e)
Definition: TRolke.cxx:289
TLine * l
Definition: textangle.C:4
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)
Definition: TRolke.cxx:995
Double_t f_tau
Definition: TRolke.h:56
virtual ~TRolke()
Definition: TRolke.cxx:213
Int_t f_m
Definition: TRolke.h:58
void SetKnownBkgGaussEff(Int_t x, Double_t em, Double_t sde, Double_t b)
Definition: TRolke.cxx:358
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.
Definition: TRolke.cxx:1191
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
Definition: TRolke.cxx:1059
Double_t GetLowerLimit()
Definition: TRolke.cxx:411
double f(double x)
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.
Definition: TRolke.cxx:1123
double Double_t
Definition: RtypesCore.h:55
Double_t GetUpperLimit()
Definition: TRolke.cxx:403
Double_t f_e
Definition: TRolke.h:52
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...
Definition: TRolke.cxx:1362
Double_t y[n]
Definition: legend1.C:17
void SetBounding(const bool bnd)
Definition: TRolke.h:184
Int_t f_mid
Definition: TRolke.h:53
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
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...
Definition: TRolke.cxx:1259
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)
Definition: TRolke.cxx:1022
static Double_t EvalPolynomial(Double_t x, const Int_t coef[], Int_t N)
evaluate polynomial
Definition: TRolke.cxx:1409
Double_t GetBackground()
Definition: TRolke.cxx:419
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
Double_t fCL
Definition: TRolke.h:37
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Definition: TMath.cxx:490
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)
Definition: TRolke.cxx:691
Definition: TRolke.h:33
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.
Definition: TRolke.cxx:1284
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.
Definition: TMath.cxx:1077
void Print(Option_t *) const
This method must be overridden when a class wants to print itself.
Definition: TRolke.cxx:584
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
bool GetCriticalNumber(Int_t &ncrit, Int_t maxtry=-1)
Definition: TRolke.cxx:538
Int_t fNumWarningsDeprecated1
Definition: TRolke.h:42
Double_t fLowerLimit
Definition: TRolke.h:39
const Int_t n
Definition: legend1.C:16
bool GetLimits(Double_t &low, Double_t &high)
Definition: TRolke.cxx:381
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...
Definition: TRolke.cxx:1145