Logo ROOT  
Reference Guide
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
38 }
39
40 /// initialize the calculator by performing a global fit and make the Asimov data set
41 bool Initialize() const;
42
43 /// re-implement HypoTest computation using the asymptotic
44 HypoTestResult *GetHypoTest() const override;
45
46 /// Make Asimov data.
47 static RooAbsData * MakeAsimovData( RooAbsData & data, const ModelConfig & model, const RooArgSet & poiValues, RooArgSet & globObs, const RooArgSet * genPoiValues = nullptr);
48
49
50 /// Make a nominal Asimov data set from a model.
51 static RooAbsData * MakeAsimovData( const ModelConfig & model, const RooArgSet & allParamValues, RooArgSet & globObs);
52
53
54
55 static RooAbsData * GenerateAsimovData(const RooAbsPdf & pdf, const RooArgSet & observables );
56
57 /// function given the null and the alt p value - return the expected one given the N - sigma value
58 static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided = true );
59
60 /// set test statistic for one sided (upper limits)
61 void SetOneSided(bool on) { fOneSided = on; }
62
63 /// set the test statistics for two sided (in case of upper limits
64 /// for discovery does not make really sense)
65 void SetTwoSided() { fOneSided = false; fOneSidedDiscovery = false;}
66
67 /// set the test statistics for one-sided discovery
69
70 /// re-implementation of setters since they are needed to re-initialize the calculator
71 void SetNullModel(const ModelConfig &nullModel) override {
73 fIsInitialized = false;
74 }
75 void SetAlternateModel(const ModelConfig &altModel) override {
77 fIsInitialized = false;
78 }
79 void SetData(RooAbsData &data) override {
81 fIsInitialized = false;
82 }
83
84
85 bool IsTwoSided() const { return (!fOneSided && !fOneSidedDiscovery); }
86 bool IsOneSidedDiscovery() const { return fOneSidedDiscovery; }
87
88
89 /// set using of qtilde, by default is controlled if RoORealVar is limited or not
90 void SetQTilde(bool on) { fUseQTilde = on; }
91
92 /// return snapshot of the best fit parameter
93 const RooArgSet & GetBestFitPoi() const { return fBestFitPoi; }
94 /// return best fit parameter (firs of poi)
95 const RooRealVar * GetMuHat() const { return dynamic_cast<RooRealVar*>(fBestFitPoi.first()); }
96 /// return best fit value for all parameters
97 const RooArgSet & GetBestFitParams() const { return fBestFitPoi; }
98
99 static void SetPrintLevel(int level);
100
101 protected:
102 // // configure TestStatSampler for the Null run
103 // int PreNullHook(RooArgSet *parameterPoint, double obsTestStat) const;
104
105 // // configure TestStatSampler for the Alt run
106 // int PreAltHook(RooArgSet *parameterPoint, double obsTestStat) const;
107
108
109 static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
110 RooCategory * channelCat = nullptr);
111
112 static RooAbsData * GenerateCountingAsimovData(RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
113 RooCategory * channelCat = nullptr);
114
115
116 static void FillBins(const RooAbsPdf & pdf, const RooArgList &obs, RooAbsData & data, int &index, double
117 &binVolume, int &ibin);
118
119 static double EvaluateNLL(RooAbsPdf & pdf, RooAbsData& data, const RooArgSet * condObs, const RooArgSet * globObs, const RooArgSet *poiSet = nullptr );
120
121 static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs);
122 static bool SetObsToExpected(RooProdPdf &prod, const RooArgSet &obs);
123
124 protected:
126
127 private:
128
129 bool fOneSided; ///< for one sided PL test statistic (upper limits)
130 mutable bool fOneSidedDiscovery; ///< for one sided PL test statistic (for discovery)
131 bool fNominalAsimov; ///< make Asimov at nominal parameter values
132 mutable bool fIsInitialized; ///<! flag to check if calculator is initialized
133 mutable int fUseQTilde; ///< flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false, 1 (true)
134 static int fgPrintLevel; ///< control print level (0 minimal, 1 normal, 2 debug)
135 mutable double fNLLObs;
136 mutable double fNLLAsimov;
137
138 mutable RooAbsData * fAsimovData; ///< asimov data set
139 mutable RooArgSet fAsimovGlobObs; ///< snapshot of Asimov global observables
140 mutable RooArgSet fBestFitPoi; ///< snapshot of best fitted POI values
141 mutable RooArgSet fBestFitParams; ///< snapshot of all best fitted Parameter values
142
143
144 };
145}
146
147#endif
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
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
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
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:56
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:28
Poisson pdf.
Definition: RooPoisson.h:19
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:33
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
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 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
static double EvaluateNLL(RooAbsPdf &pdf, RooAbsData &data, const RooArgSet *condObs, const RooArgSet *globObs, const RooArgSet *poiSet=nullptr)
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
AsymptoticCalculator(RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, bool nominalAsimov=false)
constructor for asymptotic calculator from Data set and ModelConfig
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:30
Namespace for the RooStats classes.
Definition: Asimov.h:19