Logo ROOT  
Reference Guide
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#ifndef ROOSTATS_HypoTestResult
11#define ROOSTATS_HypoTestResult
12
15
16#include "TNamed.h"
17
18#include <memory>
19
20namespace RooStats {
21
22 class HypoTestResult : public TNamed {
23
24 public:
25
26 /// default constructor
27 explicit HypoTestResult(const char *name = nullptr);
28
29 /// copy constructor
30 HypoTestResult(const HypoTestResult& other);
31
32 /// constructor from name, null and alternate p values
33 HypoTestResult(const char* name, double nullp, double altp);
34
35 /// destructor
36 ~HypoTestResult() override;
37
38 /// assignment operator
40
41 /// add values from another HypoTestResult
42 virtual void Append(const HypoTestResult *other);
43
44 /// Return p-value for null hypothesis
45 virtual double NullPValue() const { return fNullPValue; }
46
47 /// Return p-value for alternate hypothesis
48 virtual double AlternatePValue() const { return fAlternatePValue; }
49
50 /// Convert NullPValue into a "confidence level"
51 virtual double CLb() const { return !fBackgroundIsAlt ? NullPValue() : AlternatePValue(); }
52
53 /// Convert AlternatePValue into a "confidence level"
54 virtual double CLsplusb() const { return !fBackgroundIsAlt ? AlternatePValue() : NullPValue(); }
55
56 /// \f$CL_{s}\f$ is simply \f$CL_{s+b}/CL_{b}\f$ (not a method, but a quantity)
57 virtual double CLs() const {
58 double thisCLb = CLb();
59 if (thisCLb == 0) {
60 std::cout << "Error: Cannot compute CLs because CLb = 0. Returning CLs = -1\n";
61 return -1;
62 }
63 double thisCLsb = CLsplusb();
64 return thisCLsb / thisCLb;
65 }
66
67 /// familiar name for the Null p-value in terms of 1-sided Gaussian significance
68 virtual double Significance() const {return RooStats::PValueToSignificance( NullPValue() ); }
69
74 RooDataSet* GetFitInfo() const { return fFitInfo.get(); }
75 double GetTestStatisticData(void) const { return fTestStatisticData; }
77 bool HasTestStatisticData(void) const;
78
83 void SetFitInfo(RooDataSet* d) { fFitInfo.reset(d); }
84 void SetTestStatisticData(const double tsd);
85 void SetAllTestStatisticsData(const RooArgList* tsd);
86
87 void SetPValueIsRightTail(bool pr);
88 bool GetPValueIsRightTail(void) const { return fPValueIsRightTail; }
89
90 void SetBackgroundAsAlt(bool l = true) { fBackgroundIsAlt = l; }
91 bool GetBackGroundIsAlt(void) const { return fBackgroundIsAlt; }
92
93 /// The error on the "confidence level" of the null hypothesis
94 double CLbError() const;
95
96 /// The error on the "confidence level" of the alternative hypothesis
97 double CLsplusbError() const;
98
99 /// The error on the ratio \f$CL_{s+b}/CL_{b}\f$
100 double CLsError() const;
101
102 /// The error on the Null p-value
103 double NullPValueError() const;
104
105 /// The error on the significance, computed from NullPValueError via error propagation
106 double SignificanceError() const;
107
108
109 void Print(const Option_t* = "") const override;
110
111 private:
112 void UpdatePValue(const SamplingDistribution* distr, double &pvalue, double &perror, bool pIsRightTail);
113
114
115 protected:
116
117 mutable double fNullPValue; ///< p-value for the null hypothesis (small number means disfavoured)
118 mutable double fAlternatePValue; ///< p-value for the alternate hypothesis (small number means disfavoured)
119 mutable double fNullPValueError; ///< error of p-value for the null hypothesis (small number means disfavoured)
120 mutable double fAlternatePValueError; ///< error of p-value for the alternate hypothesis (small number means disfavoured)
121 double fTestStatisticData; ///< result of the test statistic evaluated on data
122 const RooArgList* fAllTestStatisticsData; ///< for the case of multiple test statistics, holds all the results
127 std::unique_ptr<RooDataSet> fFitInfo;
130
131 ClassDefOverride(HypoTestResult,4) // Base class to represent results of a hypothesis test
132
133 };
134}
135
136
137#endif
#define d(i)
Definition: RSha256.hxx:102
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
char name[80]
Definition: TGX11.cxx:110
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
HypoTestResult is a base class for results from hypothesis tests.
RooDataSet * GetFitInfo() const
RooDataSet * fAltDetailedOutput
void UpdatePValue(const SamplingDistribution *distr, double &pvalue, double &perror, bool pIsRightTail)
updates the pvalue if sufficient data is available
void Print(const Option_t *="") const override
Print out some information about the results Note: use Alt/Null labels for the hypotheses here as the...
void SetAltDetailedOutput(RooDataSet *d)
double fNullPValue
p-value for the null hypothesis (small number means disfavoured)
bool HasTestStatisticData(void) const
double fAlternatePValueError
error of p-value for the alternate hypothesis (small number means disfavoured)
HypoTestResult & operator=(const HypoTestResult &other)
assignment operator
void SetNullDetailedOutput(RooDataSet *d)
virtual double CLsplusb() const
Convert AlternatePValue into a "confidence level".
void SetAllTestStatisticsData(const RooArgList *tsd)
double GetTestStatisticData(void) const
virtual void Append(const HypoTestResult *other)
add values from another HypoTestResult
double NullPValueError() const
The error on the Null p-value.
double CLsError() const
The error on the ratio .
RooDataSet * GetNullDetailedOutput(void) const
virtual double Significance() const
familiar name for the Null p-value in terms of 1-sided Gaussian significance
void SetBackgroundAsAlt(bool l=true)
RooDataSet * fNullDetailedOutput
SamplingDistribution * fAltDistr
bool GetPValueIsRightTail(void) const
const RooArgList * GetAllTestStatisticsData(void) const
virtual double AlternatePValue() const
Return p-value for alternate hypothesis.
void SetNullDistribution(SamplingDistribution *null)
~HypoTestResult() override
destructor
bool GetBackGroundIsAlt(void) const
HypoTestResult(const char *name=nullptr)
default constructor
double SignificanceError() const
The error on the significance, computed from NullPValueError via error propagation.
virtual double NullPValue() const
Return p-value for null hypothesis.
double CLbError() const
The error on the "confidence level" of the null hypothesis.
void SetTestStatisticData(const double tsd)
double CLsplusbError() const
The error on the "confidence level" of the alternative hypothesis.
void SetFitInfo(RooDataSet *d)
double fNullPValueError
error of p-value for the null hypothesis (small number means disfavoured)
double fTestStatisticData
result of the test statistic evaluated on data
void SetAltDistribution(SamplingDistribution *alt)
void SetPValueIsRightTail(bool pr)
RooDataSet * GetAltDetailedOutput(void) const
const RooArgList * fAllTestStatisticsData
for the case of multiple test statistics, holds all the results
SamplingDistribution * GetNullDistribution(void) const
std::unique_ptr< RooDataSet > fFitInfo
virtual double CLs() const
is simply (not a method, but a quantity)
double fAlternatePValue
p-value for the alternate hypothesis (small number means disfavoured)
virtual double CLb() const
Convert NullPValue into a "confidence level".
SamplingDistribution * fNullDistr
SamplingDistribution * GetAltDistribution(void) const
This class simply holds a sampling distribution of some test statistic.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Namespace for the RooStats classes.
Definition: Asimov.h:19
double PValueToSignificance(double pvalue)
returns one-sided significance corresponding to a p-value
Definition: RooStatsUtils.h:49
null_t< F > null()
TLine l
Definition: textangle.C:4