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