Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 /// clone method, required since some data members cannot rely on the streamers to copy them
36 TObject* Clone(const char* newname = nullptr) const override {
37 auto out = new HypoTestResult(*this);
38 if(newname && strlen(newname)) out->SetName(newname);
39 return out;
40 }
41
42 /// destructor
43 ~HypoTestResult() override;
44
45 /// assignment operator
47
48 /// add values from another HypoTestResult
49 virtual void Append(const HypoTestResult *other);
50
51 /// Return p-value for null hypothesis
52 virtual double NullPValue() const { return fNullPValue; }
53
54 /// Return p-value for alternate hypothesis
55 virtual double AlternatePValue() const { return fAlternatePValue; }
56
57 /// Convert NullPValue into a "confidence level"
58 virtual double CLb() const { return !fBackgroundIsAlt ? NullPValue() : AlternatePValue(); }
59
60 /// Convert AlternatePValue into a "confidence level"
61 virtual double CLsplusb() const { return !fBackgroundIsAlt ? AlternatePValue() : NullPValue(); }
62
63 /// \f$CL_{s}\f$ is simply \f$CL_{s+b}/CL_{b}\f$ (not a method, but a quantity)
64 virtual double CLs() const {
65 double thisCLb = CLb();
66 if (thisCLb == 0) {
67 std::cout << "Error: Cannot compute CLs because CLb = 0. Returning CLs = -1\n";
68 return -1;
69 }
70 double thisCLsb = CLsplusb();
71 return thisCLsb / thisCLb;
72 }
73
74 /// familiar name for the Null p-value in terms of 1-sided Gaussian significance
75 virtual double Significance() const {return RooStats::PValueToSignificance( NullPValue() ); }
76
78 SamplingDistribution* GetAltDistribution(void) const { return fAltDistr.get(); }
81 RooDataSet* GetFitInfo() const { return fFitInfo.get(); }
82 double GetTestStatisticData(void) const { return fTestStatisticData; }
84 bool HasTestStatisticData(void) const;
85
86 void SetNullPValue(double pvalue) { fNullPValue = pvalue; }
87 void SetNullPValueError(double err) { fNullPValueError = err; }
88 void SetAltPValue(double pvalue) { fAlternatePValue = pvalue; }
89 void SetAltPValueError(double err) { fAlternatePValueError = err; }
94 void SetFitInfo(RooDataSet* d) { fFitInfo.reset(d); }
95 void SetTestStatisticData(const double tsd);
96 void SetAllTestStatisticsData(const RooArgList* tsd);
97
98 void SetPValueIsRightTail(bool pr);
99 bool GetPValueIsRightTail(void) const { return fPValueIsRightTail; }
100
101 void SetBackgroundAsAlt(bool l = true) { fBackgroundIsAlt = l; }
102 bool GetBackGroundIsAlt(void) const { return fBackgroundIsAlt; }
103
104 /// The error on the "confidence level" of the null hypothesis
105 double CLbError() const;
106
107 /// The error on the "confidence level" of the alternative hypothesis
108 double CLsplusbError() const;
109
110 /// The error on the ratio \f$CL_{s+b}/CL_{b}\f$
111 double CLsError() const;
112
113 /// The error on the Null p-value
114 double NullPValueError() const;
115
116 /// The error on the significance, computed from NullPValueError via error propagation
117 double SignificanceError() const;
118
119
120 void Print(const Option_t* = "") const override;
121
122 private:
123 void UpdatePValue(const SamplingDistribution* distr, double &pvalue, double &perror, bool pIsRightTail);
124
125
126 protected:
127
128 mutable double fNullPValue; ///< p-value for the null hypothesis (small number means disfavoured)
129 mutable double fAlternatePValue; ///< p-value for the alternate hypothesis (small number means disfavoured)
130 mutable double fNullPValueError; ///< error of p-value for the null hypothesis (small number means disfavoured)
131 mutable double fAlternatePValueError; ///< error of p-value for the alternate hypothesis (small number means disfavoured)
132 double fTestStatisticData; ///< result of the test statistic evaluated on data
133 std::unique_ptr<const RooArgList> fAllTestStatisticsData; ///< for the case of multiple test statistics, holds all the results
134 std::unique_ptr<SamplingDistribution> fNullDistr;
135 std::unique_ptr<SamplingDistribution> fAltDistr;
136 std::unique_ptr<RooDataSet> fNullDetailedOutput;
137 std::unique_ptr<RooDataSet> fAltDetailedOutput;
138 std::unique_ptr<RooDataSet> fFitInfo;
141
142 ClassDefOverride(HypoTestResult,5) // Base class to represent results of a hypothesis test
143
144 };
145}
146
147
148#endif
#define d(i)
Definition RSha256.hxx:102
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
char name[80]
Definition TGX11.cxx:110
Storage_t const & get() const
Const access to the underlying stl container.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
Container class to hold unbinned data.
Definition RooDataSet.h:33
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
HypoTestResult is a base class for results from hypothesis tests.
RooDataSet * GetFitInfo() const
std::unique_ptr< RooDataSet > fNullDetailedOutput
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".
std::unique_ptr< RooDataSet > fAltDetailedOutput
void SetAllTestStatisticsData(const RooArgList *tsd)
TObject * Clone(const char *newname=nullptr) const override
clone method, required since some data members cannot rely on the streamers to copy them
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)
void SetAltPValue(double pvalue)
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
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 SetAltPValueError(double err)
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)
RooDataSet * GetAltDetailedOutput(void) const
std::unique_ptr< const RooArgList > fAllTestStatisticsData
for the case of multiple test statistics, holds all the results
SamplingDistribution * GetNullDistribution(void) const
std::unique_ptr< RooDataSet > fFitInfo
std::unique_ptr< SamplingDistribution > fAltDistr
virtual double CLs() const
is simply (not a method, but a quantity)
double fAlternatePValue
p-value for the alternate hypothesis (small number means disfavoured)
std::unique_ptr< SamplingDistribution > fNullDistr
virtual double CLb() const
Convert NullPValue into a "confidence level".
void SetNullPValue(double pvalue)
void SetNullPValueError(double err)
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
Mother of all ROOT objects.
Definition TObject.h:41
Namespace for the RooStats classes.
Definition Asimov.h:19
double PValueToSignificance(double pvalue)
returns one-sided significance corresponding to a p-value
TLine l
Definition textangle.C:4