File indexing completed on 2024-11-16 09:54:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ROOSTATS_HypoTestResult
0011 #define ROOSTATS_HypoTestResult
0012
0013 #include "RooStats/RooStatsUtils.h"
0014 #include "RooStats/SamplingDistribution.h"
0015
0016 #include "TNamed.h"
0017
0018 #include <memory>
0019
0020 namespace RooStats {
0021
0022 class HypoTestResult : public TNamed {
0023
0024 public:
0025
0026
0027 explicit HypoTestResult(const char *name = nullptr);
0028
0029
0030 HypoTestResult(const HypoTestResult& other);
0031
0032
0033 HypoTestResult(const char* name, double nullp, double altp);
0034
0035
0036 ~HypoTestResult() override;
0037
0038
0039 HypoTestResult & operator=(const HypoTestResult& other);
0040
0041
0042 virtual void Append(const HypoTestResult *other);
0043
0044
0045 virtual double NullPValue() const { return fNullPValue; }
0046
0047
0048 virtual double AlternatePValue() const { return fAlternatePValue; }
0049
0050
0051 virtual double CLb() const { return !fBackgroundIsAlt ? NullPValue() : AlternatePValue(); }
0052
0053
0054 virtual double CLsplusb() const { return !fBackgroundIsAlt ? AlternatePValue() : NullPValue(); }
0055
0056
0057 virtual double CLs() const {
0058 double thisCLb = CLb();
0059 if (thisCLb == 0) {
0060 std::cout << "Error: Cannot compute CLs because CLb = 0. Returning CLs = -1\n";
0061 return -1;
0062 }
0063 double thisCLsb = CLsplusb();
0064 return thisCLsb / thisCLb;
0065 }
0066
0067
0068 virtual double Significance() const {return RooStats::PValueToSignificance( NullPValue() ); }
0069
0070 SamplingDistribution* GetNullDistribution(void) const { return fNullDistr; }
0071 SamplingDistribution* GetAltDistribution(void) const { return fAltDistr; }
0072 RooDataSet* GetNullDetailedOutput(void) const { return fNullDetailedOutput; }
0073 RooDataSet* GetAltDetailedOutput(void) const { return fAltDetailedOutput; }
0074 RooDataSet* GetFitInfo() const { return fFitInfo.get(); }
0075 double GetTestStatisticData(void) const { return fTestStatisticData; }
0076 const RooArgList* GetAllTestStatisticsData(void) const { return fAllTestStatisticsData; }
0077 bool HasTestStatisticData(void) const;
0078
0079 void SetNullPValue(double pvalue) { fNullPValue = pvalue; }
0080 void SetNullPValueError(double err) { fNullPValueError = err; }
0081 void SetAltPValue(double pvalue) { fAlternatePValue = pvalue; }
0082 void SetAltPValueError(double err) { fAlternatePValueError = err; }
0083 void SetAltDistribution(SamplingDistribution *alt);
0084 void SetNullDistribution(SamplingDistribution *null);
0085 void SetAltDetailedOutput(RooDataSet* d) { fAltDetailedOutput = d; }
0086 void SetNullDetailedOutput(RooDataSet* d) { fNullDetailedOutput = d; }
0087 void SetFitInfo(RooDataSet* d) { fFitInfo.reset(d); }
0088 void SetTestStatisticData(const double tsd);
0089 void SetAllTestStatisticsData(const RooArgList* tsd);
0090
0091 void SetPValueIsRightTail(bool pr);
0092 bool GetPValueIsRightTail(void) const { return fPValueIsRightTail; }
0093
0094 void SetBackgroundAsAlt(bool l = true) { fBackgroundIsAlt = l; }
0095 bool GetBackGroundIsAlt(void) const { return fBackgroundIsAlt; }
0096
0097
0098 double CLbError() const;
0099
0100
0101 double CLsplusbError() const;
0102
0103
0104 double CLsError() const;
0105
0106
0107 double NullPValueError() const;
0108
0109
0110 double SignificanceError() const;
0111
0112
0113 void Print(const Option_t* = "") const override;
0114
0115 private:
0116 void UpdatePValue(const SamplingDistribution* distr, double &pvalue, double &perror, bool pIsRightTail);
0117
0118
0119 protected:
0120
0121 mutable double fNullPValue;
0122 mutable double fAlternatePValue;
0123 mutable double fNullPValueError;
0124 mutable double fAlternatePValueError;
0125 double fTestStatisticData;
0126 const RooArgList* fAllTestStatisticsData;
0127 SamplingDistribution *fNullDistr;
0128 SamplingDistribution *fAltDistr;
0129 RooDataSet* fNullDetailedOutput;
0130 RooDataSet* fAltDetailedOutput;
0131 std::unique_ptr<RooDataSet> fFitInfo;
0132 bool fPValueIsRightTail;
0133 bool fBackgroundIsAlt;
0134
0135 ClassDefOverride(HypoTestResult,4)
0136
0137 };
0138 }
0139
0140
0141 #endif