23 |
|
//-------------------------------------------------------------------------------------------------- |
24 |
|
void MathUtils::CalcRatio(Double_t n1, Double_t n2, Double_t &r, Double_t &rlow, Double_t &rup, Int_t type = 0) |
25 |
|
{ |
26 |
< |
// Calculate ratio and lower/upper errors from given values using Bayes. |
26 |
> |
// Calculate ratio and lower/upper errors from given values using various methods, dependent on type: |
27 |
> |
// 0: Bayes |
28 |
> |
// 1: Feldman-Cousins |
29 |
> |
// 2: Clopper-Pearson |
30 |
|
|
31 |
|
if (n1>n2) { |
32 |
|
Error("CalcRatio", "First value should be smaller than second: %f > %f", n1, n2); |
35 |
|
rup = 0; |
36 |
|
return; |
37 |
|
} |
35 |
– |
|
38 |
|
|
39 |
|
if (n2 >= 1) { |
40 |
|
if (type == 1) { |
39 |
– |
r = double(n1) / double(n2); |
40 |
– |
|
41 |
|
//compute errors using Feldman-Cousins |
42 |
+ |
r = double(n1) / double(n2); |
43 |
|
FeldmanCousinsBinomialInterval fc; |
44 |
|
const double alpha = (1-0.682); |
45 |
|
fc.init(alpha); |
48 |
|
rup = fc.upper() - r; |
49 |
|
|
50 |
|
} else if (type == 2) { |
51 |
+ |
//compute errors using Clopper-Pearson |
52 |
|
r = double(n1) / double(n2); |
51 |
– |
|
53 |
|
ClopperPearsonBinomialInterval cp; |
54 |
|
const double alpha = (1-0.682); |
55 |
|
cp.init(alpha); |
58 |
|
rup = cp.upper() - r; |
59 |
|
|
60 |
|
} else { |
61 |
+ |
//compute using Bayes |
62 |
|
TH1D h1("dummy1","",1,1,2); |
63 |
|
h1.SetBinContent(1,n1); |
64 |
|
|