Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
HypoTestResult.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke, Sven Kreiss
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 
12 
13 
14 #ifndef ROOSTATS_HypoTestResult
15 #define ROOSTATS_HypoTestResult
16 
17 #include "TNamed.h"
18 
19 #include "RooStats/RooStatsUtils.h"
20 
22 
23 namespace RooStats {
24 
25  class HypoTestResult : public TNamed {
26 
27  public:
28 
29  /// default constructor
30  explicit HypoTestResult(const char* name = 0);
31 
32  /// copy constructor
33  HypoTestResult(const HypoTestResult& other);
34 
35  /// constructor from name, null and alternate p values
36  HypoTestResult(const char* name, Double_t nullp, Double_t altp);
37 
38  /// destructor
39  virtual ~HypoTestResult();
40 
41  /// assignment operator
42  HypoTestResult & operator=(const HypoTestResult& other);
43 
44  /// add values from another HypoTestResult
45  virtual void Append(const HypoTestResult *other);
46 
47  /// Return p-value for null hypothesis
48  virtual Double_t NullPValue() const { return fNullPValue; }
49 
50  /// Return p-value for alternate hypothesis
51  virtual Double_t AlternatePValue() const { return fAlternatePValue; }
52 
53  /// Convert NullPValue into a "confidence level"
54  virtual Double_t CLb() const { return !fBackgroundIsAlt ? NullPValue() : AlternatePValue(); }
55 
56  /// Convert AlternatePValue into a "confidence level"
57  virtual Double_t CLsplusb() const { return !fBackgroundIsAlt ? AlternatePValue() : NullPValue(); }
58 
59  /// \f$CL_{s}\f$ is simply \f$CL_{s+b}/CL_{b}\f$ (not a method, but a quantity)
60  virtual Double_t CLs() const {
61  double thisCLb = CLb();
62  if (thisCLb == 0) {
63  std::cout << "Error: Cannot compute CLs because CLb = 0. Returning CLs = -1\n";
64  return -1;
65  }
66  double thisCLsb = CLsplusb();
67  return thisCLsb / thisCLb;
68  }
69 
70  /// familiar name for the Null p-value in terms of 1-sided Gaussian significance
71  virtual Double_t Significance() const {return RooStats::PValueToSignificance( NullPValue() ); }
72 
73  SamplingDistribution* GetNullDistribution(void) const { return fNullDistr; }
74  SamplingDistribution* GetAltDistribution(void) const { return fAltDistr; }
75  RooDataSet* GetNullDetailedOutput(void) const { return fNullDetailedOutput; }
76  RooDataSet* GetAltDetailedOutput(void) const { return fAltDetailedOutput; }
77  RooDataSet* GetFitInfo(void) const { return fFitInfo; }
78  Double_t GetTestStatisticData(void) const { return fTestStatisticData; }
79  const RooArgList* GetAllTestStatisticsData(void) const { return fAllTestStatisticsData; }
80  Bool_t HasTestStatisticData(void) const;
81 
82  void SetAltDistribution(SamplingDistribution *alt);
83  void SetNullDistribution(SamplingDistribution *null);
84  void SetAltDetailedOutput(RooDataSet* d) { fAltDetailedOutput = d; }
85  void SetNullDetailedOutput(RooDataSet* d) { fNullDetailedOutput = d; }
86  void SetFitInfo(RooDataSet* d) { fFitInfo = d; }
87  void SetTestStatisticData(const Double_t tsd);
88  void SetAllTestStatisticsData(const RooArgList* tsd);
89 
90  void SetPValueIsRightTail(Bool_t pr);
91  Bool_t GetPValueIsRightTail(void) const { return fPValueIsRightTail; }
92 
93  void SetBackgroundAsAlt(Bool_t l = kTRUE) { fBackgroundIsAlt = l; }
94  Bool_t GetBackGroundIsAlt(void) const { return fBackgroundIsAlt; }
95 
96  /// The error on the "confidence level" of the null hypothesis
97  Double_t CLbError() const;
98 
99  /// The error on the "confidence level" of the alternative hypothesis
100  Double_t CLsplusbError() const;
101 
102  /// The error on the ratio \f$CL_{s+b}/CL_{b}\f$
103  Double_t CLsError() const;
104 
105  /// The error on the Null p-value
106  Double_t NullPValueError() const;
107 
108  /// The error on the significance, computed from NullPValueError via error propagation
109  Double_t SignificanceError() const;
110 
111 
112  void Print(const Option_t* = "") const;
113 
114  private:
115  void UpdatePValue(const SamplingDistribution* distr, Double_t &pvalue, Double_t &perror, Bool_t pIsRightTail);
116 
117 
118  protected:
119 
120  mutable Double_t fNullPValue; // p-value for the null hypothesis (small number means disfavoured)
121  mutable Double_t fAlternatePValue; // p-value for the alternate hypothesis (small number means disfavoured)
122  mutable Double_t fNullPValueError; // error of p-value for the null hypothesis (small number means disfavoured)
123  mutable Double_t fAlternatePValueError; // error of p-value for the alternate hypothesis (small number means disfavoured)
124  Double_t fTestStatisticData; // result of the test statistic evaluated on data
125  const RooArgList* fAllTestStatisticsData; // for the case of multiple test statistics, holds all the results
126  SamplingDistribution *fNullDistr;
127  SamplingDistribution *fAltDistr;
128  RooDataSet* fNullDetailedOutput;
129  RooDataSet* fAltDetailedOutput;
130  RooDataSet* fFitInfo;
131  Bool_t fPValueIsRightTail;
132  Bool_t fBackgroundIsAlt;
133 
134  ClassDef(HypoTestResult,3) // Base class to represent results of a hypothesis test
135 
136  };
137 }
138 
139 
140 #endif