ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitCommon/MathTools/src/MathUtils.cc
(Generate patch)

Comparing UserCode/MitCommon/MathTools/src/MathUtils.cc (file contents):
Revision 1.10 by sixie, Tue Nov 3 10:28:08 2009 UTC vs.
Revision 1.11 by loizides, Wed Nov 4 12:44:33 2009 UTC

# Line 23 | Line 23 | Double_t MathUtils::AddInQuadrature(Doub
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);
# Line 32 | Line 35 | void MathUtils::CalcRatio(Double_t n1, D
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);
# Line 47 | Line 48 | void MathUtils::CalcRatio(Double_t n1, D
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);
# Line 57 | Line 58 | void MathUtils::CalcRatio(Double_t n1, D
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        

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines