Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
AsymptoticCalculator.h
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Sven Kreiss, Kyle Cranmer Nov 2010
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#ifndef ROOSTATS_AsymptoticCalculator
12#define ROOSTATS_AsymptoticCalculator
13
15#include "RooArgSet.h"
16#include "Rtypes.h"
17
18class RooArgList;
19class RooCategory;
20class RooRealVar;
21class RooPoisson;
22class RooProdPdf;
23
24
25namespace RooStats {
26
28
29 public:
31 RooAbsData &data, // need to pass non-const since RooAbsPdf::fitTo takes a non-const data set
32 const ModelConfig &altModel,
33 const ModelConfig &nullModel,
34 bool nominalAsimov = false
35 );
36
37 /// initialize the calculator by performing a global fit and make the Asimov data set
38 bool Initialize() const;
39
40 /// re-implement HypoTest computation using the asymptotic
41 HypoTestResult *GetHypoTest() const override;
42
43 /// Make Asimov data.
44 static RooAbsData * MakeAsimovData( RooAbsData & data, const ModelConfig & model, const RooArgSet & poiValues, RooArgSet & globObs, const RooArgSet * genPoiValues = nullptr);
45
46
47 /// Make a nominal Asimov data set from a model.
48 static RooAbsData * MakeAsimovData( const ModelConfig & model, const RooArgSet & allParamValues, RooArgSet & globObs);
49
50
51
52 static RooAbsData * GenerateAsimovData(const RooAbsPdf & pdf, const RooArgSet & observables );
53
54 /// function given the null and the alt p value - return the expected one given the N - sigma value
55 static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided = true );
56
57 /// set test statistic for one sided (upper limits)
58 void SetOneSided(bool on) { fOneSided = on; }
59
60 /// set the test statistics for two sided (in case of upper limits
61 /// for discovery does not make really sense)
62 void SetTwoSided() { fOneSided = false; fOneSidedDiscovery = false;}
63
64 /// set the test statistics for one-sided discovery
66
67 /// re-implementation of setters since they are needed to re-initialize the calculator
68 void SetNullModel(const ModelConfig &nullModel) override {
70 fIsInitialized = false;
71 }
72 void SetAlternateModel(const ModelConfig &altModel) override {
74 fIsInitialized = false;
75 }
76 void SetData(RooAbsData &data) override {
78 fIsInitialized = false;
79 }
80
81
82 bool IsTwoSided() const { return (!fOneSided && !fOneSidedDiscovery); }
83 bool IsOneSidedDiscovery() const { return fOneSidedDiscovery; }
84
85
86 /// set using of qtilde, by default is controlled if RoORealVar is limited or not
87 void SetQTilde(bool on) { fUseQTilde = on; }
88
89 /// return snapshot of the best fit parameter
90 const RooArgSet & GetBestFitPoi() const { return fBestFitPoi; }
91 /// return best fit parameter (firs of poi)
92 const RooRealVar * GetMuHat() const { return dynamic_cast<RooRealVar*>(fBestFitPoi.first()); }
93 /// return best fit value for all parameters
94 const RooArgSet & GetBestFitParams() const { return fBestFitPoi; }
95
96 static void SetPrintLevel(int level);
97
98 protected:
99 // // configure TestStatSampler for the Null run
100 // int PreNullHook(RooArgSet *parameterPoint, double obsTestStat) const;
101
102 // // configure TestStatSampler for the Alt run
103 // int PreAltHook(RooArgSet *parameterPoint, double obsTestStat) const;
104
105
106 static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
107 RooCategory * channelCat = nullptr);
108
109 static RooAbsData * GenerateCountingAsimovData(RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
110 RooCategory * channelCat = nullptr);
111
112
113 static void FillBins(const RooAbsPdf & pdf, const RooArgList &obs, RooAbsData & data, int &index, double
114 &binVolume, int &ibin);
115
116 static double EvaluateNLL(RooStats::ModelConfig const& modelConfig, RooAbsData& data, const RooArgSet *poiSet = nullptr );
117
118 static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs);
119 static bool SetObsToExpected(RooProdPdf &prod, const RooArgSet &obs);
120
121 protected:
123
124 private:
125
126 bool fOneSided; ///< for one sided PL test statistic (upper limits)
127 mutable bool fOneSidedDiscovery; ///< for one sided PL test statistic (for discovery)
128 bool fNominalAsimov; ///< make Asimov at nominal parameter values
129 mutable bool fIsInitialized; ///<! flag to check if calculator is initialized
130 mutable int fUseQTilde; ///< flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false, 1 (true)
131 static int fgPrintLevel; ///< control print level (0 minimal, 1 normal, 2 debug)
132 mutable double fNLLObs;
133 mutable double fNLLAsimov;
134
135 mutable RooAbsData * fAsimovData; ///< asimov data set
136 mutable RooArgSet fAsimovGlobObs; ///< snapshot of Asimov global observables
137 mutable RooArgSet fBestFitPoi; ///< snapshot of best fitted POI values
138 mutable RooArgSet fBestFitParams; ///< snapshot of all best fitted Parameter values
139
140
141 };
142}
143
144#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
RooAbsArg * first() const
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Object to represent discrete states.
Definition RooCategory.h:28
Poisson pdf.
Definition RooPoisson.h:19
Efficient implementation of a product of PDFs of the form.
Definition RooProdPdf.h:33
Variable that can be changed from the outside.
Definition RooRealVar.h:37
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
const RooRealVar * GetMuHat() const
return best fit parameter (firs of poi)
static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided=true)
function given the null and the alt p value - return the expected one given the N - sigma value
void SetAlternateModel(const ModelConfig &altModel) override
Set the model for the alternate hypothesis.
static double EvaluateNLL(RooStats::ModelConfig const &modelConfig, RooAbsData &data, const RooArgSet *poiSet=nullptr)
static int fgPrintLevel
control print level (0 minimal, 1 normal, 2 debug)
void SetOneSidedDiscovery(bool on)
set the test statistics for one-sided discovery
static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs)
set observed value to the expected one works for Gaussian, Poisson or LogNormal assumes mean paramete...
void SetData(RooAbsData &data) override
Set the DataSet.
static void SetPrintLevel(int level)
set print level (static function)
RooArgSet fAsimovGlobObs
snapshot of Asimov global observables
static RooAbsData * GenerateAsimovData(const RooAbsPdf &pdf, const RooArgSet &observables)
generate the asimov data for the observables (not the global ones) need to deal with the case of a si...
int fUseQTilde
flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false,...
static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=nullptr)
Compute the asimov data set for an observable of a pdf.
bool fIsInitialized
! flag to check if calculator is initialized
const RooArgSet & GetBestFitParams() const
return best fit value for all parameters
HypoTestResult * GetHypoTest() const override
re-implement HypoTest computation using the asymptotic
bool fOneSided
for one sided PL test statistic (upper limits)
RooArgSet fBestFitParams
snapshot of all best fitted Parameter values
static RooAbsData * GenerateCountingAsimovData(RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=nullptr)
Generate counting Asimov data for the case when the pdf cannot be extended.
void SetTwoSided()
set the test statistics for two sided (in case of upper limits for discovery does not make really sen...
bool fOneSidedDiscovery
for one sided PL test statistic (for discovery)
RooAbsData * fAsimovData
asimov data set
RooArgSet fBestFitPoi
snapshot of best fitted POI values
void SetQTilde(bool on)
set using of qtilde, by default is controlled if RoORealVar is limited or not
static RooAbsData * MakeAsimovData(RooAbsData &data, const ModelConfig &model, const RooArgSet &poiValues, RooArgSet &globObs, const RooArgSet *genPoiValues=nullptr)
Make Asimov data.
const RooArgSet & GetBestFitPoi() const
return snapshot of the best fit parameter
static void FillBins(const RooAbsPdf &pdf, const RooArgList &obs, RooAbsData &data, int &index, double &binVolume, int &ibin)
fill bins by looping recursively on observables
void SetNullModel(const ModelConfig &nullModel) override
re-implementation of setters since they are needed to re-initialize the calculator
bool fNominalAsimov
make Asimov at nominal parameter values
void SetOneSided(bool on)
set test statistic for one sided (upper limits)
bool Initialize() const
initialize the calculator by performing a global fit and make the Asimov data set
Common base class for the Hypothesis Test Calculators.
void SetNullModel(const ModelConfig &nullModel) override
set the model for the null hypothesis (only B)
void SetData(RooAbsData &data) override
Set the DataSet.
void SetAlternateModel(const ModelConfig &altModel) override
Set the model for the alternate hypothesis (S+B)
HypoTestResult is a base class for results from hypothesis tests.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition ModelConfig.h:35
Namespace for the RooStats classes.
Definition Asimov.h:19