Logo ROOT   6.08/07
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 
14 
15 
16 #ifndef ROOSTATS_HypoTestCalculatorGeneric
18 #endif
19 
20 class RooArgSet;
21 class RooPoisson;
22 class RooProdPdf;
23 
24 
25 namespace RooStats {
26 
27 /**
28 
29  Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
30 
31  See G. Cowan, K. Cranmer, E. Gross and O. Vitells: Asymptotic formulae for likelihood- based tests of new physics. Eur. Phys. J., C71:1–19, 2011.
32  It provides method to perform an hypothesis tests using the likelihood function
33  and computes the p values for the null and the alternate using the asymptotic
34  formulae for the profile likelihood ratio described in the given paper.
35 
36  The calculator provides methods to produce the Asimov dataset, i.e a dataset generated where the observade values are equal to the expected ones.
37  The Asimov data set is then used to compute the observed asymptotic p-value for the alternate hypothesis and the asympotic expected p-values.
38 
39  The asymptotic formulae are valid only for one POI (parameter of interest). So the calculator works only for one-dimesional (one POI) model.
40  If more than one POI exists consider as POI only the first one is used.
41 
42  \ingroup Roostats
43 */
44 
45 
47 
48  public:
50  RooAbsData &data, // need to pass non-const since RooAbsPdf::fitTo takes a non-const data set
51  const ModelConfig &altModel,
52  const ModelConfig &nullModel,
53  bool nominalAsimov = false
54  );
55  // HypoTestCalculatorGeneric(data, altModel, nullModel, 0)
56  // {
57  // }
58 
60  }
61 
62  /// initialize the calculator by performin g a global fit and make the Asimov data set
63  bool Initialize() const;
64 
65  /// re-implement HypoTest computation using the asymptotic
66  virtual HypoTestResult *GetHypoTest() const;
67 
68  /// make the asimov data from the ModelConfig and list of poi - return data set annd snapshoot of global obs
69  /// poiValues is the snapshot of POI used for finding the best buisance parameter values (conditioned at these values)
70  /// genPoiValues is optionally a different set of POI values used for generating. By default the same POI are used for generating and for finding the nuisance parameters
71  static RooAbsData * MakeAsimovData( RooAbsData & data, const ModelConfig & model, const RooArgSet & poiValues, RooArgSet & globObs, const RooArgSet * genPoiValues = 0);
72 
73 
74  /// make a nominal asimov data from the ModelConfig and parameter values
75  /// The parameter values (including the nunisance) could be given from a fit to data or be at the nominal values
76  static RooAbsData * MakeAsimovData( const ModelConfig & model, const RooArgSet & allParamValues, RooArgSet & globObs);
77 
78 
79 
80  static RooAbsData * GenerateAsimovData(const RooAbsPdf & pdf, const RooArgSet & observables );
81 
82  /// function given the null and the alt p value - return the expected one given the N - sigma value
83  static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided = true );
84 
85  /// set test statistic for one sided (upper limits)
86  void SetOneSided(bool on) { fOneSided = on; }
87 
88  /// set the test statistics for two sided (in case of upper limits
89  /// for discovery does not make really sense)
90  void SetTwoSided() { fOneSided = false; fOneSidedDiscovery = false;}
91 
92  /// set the test statistics for one-sided discovery
93  void SetOneSidedDiscovery(bool on) { fOneSidedDiscovery = on; }
94 
95  /// re-implementation of setters since they are needed to re-initialize the calculator
96  virtual void SetNullModel(const ModelConfig &nullModel) {
98  fIsInitialized = false;
99  }
100  virtual void SetAlternateModel(const ModelConfig &altModel) {
102  fIsInitialized = false;
103  }
104  virtual void SetData(RooAbsData &data) {
106  fIsInitialized = false;
107  }
108 
109 
110  bool IsTwoSided() const { return (!fOneSided && !fOneSidedDiscovery); }
111  bool IsOneSidedDiscovery() const { return fOneSidedDiscovery; }
112 
113 
114  /// set using of qtilde, by default is controlled if RoORealVar is limited or not
115  void SetQTilde(bool on) { fUseQTilde = on; }
116 
117  /// return snapshot of the best fit parameter
118  const RooArgSet & GetBestFitPoi() const { return fBestFitPoi; }
119  /// return best fit parameter (firs of poi)
120  const RooRealVar * GetMuHat() const { return dynamic_cast<RooRealVar*>(fBestFitPoi.first()); }
121  /// return best fit value for all parameters
122  const RooArgSet & GetBestFitParams() const { return fBestFitPoi; }
123 
124  static void SetPrintLevel(int level);
125 
126  protected:
127  // // configure TestStatSampler for the Null run
128  // int PreNullHook(RooArgSet *parameterPoint, double obsTestStat) const;
129 
130  // // configure TestStatSampler for the Alt run
131  // int PreAltHook(RooArgSet *parameterPoint, double obsTestStat) const;
132 
133 
134  static RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
135  RooCategory * channelCat = 0);
136 
137  static RooAbsData * GenerateCountingAsimovData(RooAbsPdf & pdf, const RooArgSet & obs, const RooRealVar & weightVar,
138  RooCategory * channelCat = 0);
139 
140 
141  static void FillBins(const RooAbsPdf & pdf, const RooArgList &obs, RooAbsData & data, int &index, double
142  &binVolume, int &ibin);
143 
144  static double EvaluateNLL(RooAbsPdf & pdf, RooAbsData& data, const RooArgSet * condObs, const RooArgSet *poiSet = 0 );
145 
146  static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs);
147  static bool SetObsToExpected(RooProdPdf &prod, const RooArgSet &obs);
148 
149  protected:
151 
152  private:
153 
154  bool fOneSided; // for one sided PL test statistic (upper limits)
155  mutable bool fOneSidedDiscovery; // for one sided PL test statistic (for discovery)
156  bool fNominalAsimov; // make Asimov at nominal parameter values
157  mutable bool fIsInitialized; //! flag to check if calculator is initialized
158  mutable int fUseQTilde; // flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false, 1 (true)
159  static int fgPrintLevel; // control print level (0 minimal, 1 normal, 2 debug)
160  mutable double fNLLObs;
161  mutable double fNLLAsimov;
162 
163  mutable RooAbsData * fAsimovData; // asimov data set
164  mutable RooArgSet fAsimovGlobObs; // snapshot of Asimov global observables
165  mutable RooArgSet fBestFitPoi; // snapshot of best fitted POI values
166  mutable RooArgSet fBestFitParams; // snapshot of all best fitted Parameter values
167 
168 
169  };
170 }
171 
172 #endif
static RooAbsData * GenerateAsimovData(const RooAbsPdf &pdf, const RooArgSet &observables)
Poisson pdf.
Definition: RooPoisson.h:19
virtual void SetNullModel(const ModelConfig &nullModel)
re-implementation of setters since they are needed to re-initialize the calculator ...
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:52
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 ...
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
HypoTestResult is a base class for results from hypothesis tests.
const RooArgSet & GetBestFitParams() const
return best fit value for all parameters
AsymptoticCalculator(RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, bool nominalAsimov=false)
static void SetPrintLevel(int level)
static RooAbsData * GenerateCountingAsimovData(RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=0)
Common base class for the Hypothesis Test Calculators.
static RooAbsData * MakeAsimovData(RooAbsData &data, const ModelConfig &model, const RooArgSet &poiValues, RooArgSet &globObs, const RooArgSet *genPoiValues=0)
make the asimov data from the ModelConfig and list of poi - return data set annd snapshoot of global ...
static void FillBins(const RooAbsPdf &pdf, const RooArgList &obs, RooAbsData &data, int &index, double &binVolume, int &ibin)
#define ClassDef(name, id)
Definition: Rtypes.h:254
const RooArgSet & GetBestFitPoi() const
return snapshot of the best fit parameter
void SetQTilde(bool on)
set using of qtilde, by default is controlled if RoORealVar is limited or not
virtual HypoTestResult * GetHypoTest() const
re-implement HypoTest computation using the asymptotic
virtual void SetData(RooAbsData &data)
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
static double EvaluateNLL(RooAbsPdf &pdf, RooAbsData &data, const RooArgSet *condObs, const RooArgSet *poiSet=0)
bool Initialize() const
initialize the calculator by performin g a global fit and make the Asimov data set ...
void SetTwoSided()
set the test statistics for two sided (in case of upper limits for discovery does not make really sen...
RooAbsArg * first() const
static bool SetObsToExpected(RooAbsPdf &pdf, const RooArgSet &obs)
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:25
virtual void SetAlternateModel(const ModelConfig &altModel)
Namespace for the RooStats classes.
Definition: Asimov.h:20
int fUseQTilde
flag to check if calculator is initialized
void SetOneSidedDiscovery(bool on)
set the test statistics for one-sided discovery
void SetOneSided(bool on)
set test statistic for one sided (upper limits)
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
virtual void SetData(RooAbsData &data)
virtual void SetAlternateModel(const ModelConfig &altModel)
virtual void SetNullModel(const ModelConfig &nullModel)
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 RooAbsData * GenerateAsimovDataSinglePdf(const RooAbsPdf &pdf, const RooArgSet &obs, const RooRealVar &weightVar, RooCategory *channelCat=0)