Logo ROOT   6.08/07
Reference Guide
CombinedCalculator.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
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_CombinedCalculator
12 #define ROOSTATS_CombinedCalculator
13 
14 
15 #ifndef ROOSTATS_IntervalCalculator
17 #endif
18 
19 #ifndef ROOSTATS_HypoTestCalculator
21 #endif
22 
23 #ifndef ROOSTATS_ModelConfig
24 #include "RooStats/ModelConfig.h"
25 #endif
26 
27 #ifndef ROO_ABS_PDF
28 #include "RooAbsPdf.h"
29 #endif
30 
31 #ifndef ROO_ABS_DATA
32 #include "RooAbsData.h"
33 #endif
34 
35 #ifndef ROO_ARG_SET
36 #include "RooArgSet.h"
37 #endif
38 
39 // #ifndef ROO_WORKSPACE
40 // #include "RooWorkspace.h"
41 // #endif
42 
43 namespace RooStats {
44 
45 /**
46 
47  \class CombinedCalculator
48 
49  \ingroup Roostats
50 
51 CombinedCalculator is an interface class for a tools which can produce both RooStats HypoTestResults and ConfIntervals. The interface currently assumes that any such calculator can be configured by specifying:
52 
53 * a model common model (eg. a family of specific models which includes both the null and alternate),
54 * a data set,
55 * a set of parameters of which specify the null (including values and const/non-const status),
56 * a set of parameters of which specify the alternate (including values and const/non-const status),
57 * a set of parameters of nuisance parameters (including values and const/non-const status).
58 
59 The interface allows one to pass the model, data, and parameters via a workspace and then specify them with names. The interface also allows one to pass the model, data, and parameters without a workspace (which is created internally).
60 
61 After configuring the calculator, one only needs to ask GetHypoTest() (which will return a HypoTestResult pointer) or GetInterval() (which will return an ConfInterval pointer).
62 
63 The concrete implementations of this interface should deal with the details of how the nuisance parameters are dealt with (eg. integration vs. profiling) and which test-statistic is used (perhaps this should be added to the interface).
64 
65 The motivation for this interface is that we hope to be able to specify the problem in a common way for several concrete calculators.
66 
67 
68 */
69 
70 
72 
73  public:
74 
76  fSize(0.),
77  fPdf(0),
78  fData(0)
79  {}
80 
81  CombinedCalculator(RooAbsData& data, RooAbsPdf& pdf, const RooArgSet& paramsOfInterest,
82  Double_t size = 0.05, const RooArgSet* nullParams = 0, const RooArgSet* altParams = 0, const RooArgSet* nuisParams = 0) :
83 
84  fPdf(&pdf),
85  fData(&data),
86  fPOI(paramsOfInterest)
87  {
88  if (nullParams) fNullParams.add(*nullParams);
89  if (altParams) fAlternateParams.add(*altParams);
90  if (nuisParams) fNuisParams.add(*nuisParams);
91  SetTestSize(size);
92  }
93 
94  /// constructor from data and model configuration
96  Double_t size = 0.05) :
97  fPdf(0),
98  fData(&data)
99  {
100  SetModel(model);
101  SetTestSize(size);
102  }
103 
104 
105  /// destructor.
106  virtual ~CombinedCalculator() { }
107 
108 
109 
110  /// Main interface to get a ConfInterval, pure virtual
111  virtual ConfInterval* GetInterval() const = 0;
112  /// main interface to get a HypoTestResult, pure virtual
113  virtual HypoTestResult* GetHypoTest() const = 0;
114 
115  /// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
116  virtual void SetTestSize(Double_t size) {fSize = size;}
117  /// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
118  virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}
119  /// Get the size of the test (eg. rate of Type I error)
120  virtual Double_t Size() const {return fSize;}
121  /// Get the Confidence level for the test
122  virtual Double_t ConfidenceLevel() const {return 1.-fSize;}
123 
124  /// Set the DataSet, add to the the workspace if not already there
125  virtual void SetData(RooAbsData & data) {
126  fData = &data;
127  }
128 
129  /// set the model (in this case can set only the parameters for the null hypothesis)
130  virtual void SetModel(const ModelConfig & model) {
131  fPdf = model.GetPdf();
133  if (model.GetSnapshot()) SetNullParameters(*model.GetSnapshot());
136  }
137 
138  virtual void SetNullModel( const ModelConfig &) { // to be understood what to do
139  }
140  virtual void SetAlternateModel(const ModelConfig &) { // to be understood what to do
141  }
142 
143  /* specific setting - keep for convenience- some of them could be removed */
144 
145  /// Set the Pdf
146  virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
147 
148  /// specify the parameters of interest in the interval
149  virtual void SetParameters(const RooArgSet& set) { fPOI.removeAll(); fPOI.add(set); }
150 
151  /// specify the nuisance parameters (eg. the rest of the parameters)
153 
154  /// set parameter values for the null if using a common PDF
155  virtual void SetNullParameters(const RooArgSet& set) {fNullParams.removeAll(); fNullParams.add(set);}
156 
157  /// set parameter values for the alternate if using a common PDF
159 
160  /// set conditional observables needed for computing the NLL
162 
163 
164  protected:
165 
166  RooAbsPdf * GetPdf() const { return fPdf; }
167  RooAbsData * GetData() const { return fData; }
168 
169  Double_t fSize; // size of the test (eg. specified rate of Type I error)
170 
173  RooArgSet fPOI; // RooArgSet specifying parameters of interest for interval
174  RooArgSet fNullParams; // RooArgSet specifying null parameters for hypothesis test
175  RooArgSet fAlternateParams; // RooArgSet specifying alternate parameters for hypothesis test // Is it used ????
176  RooArgSet fNuisParams;// RooArgSet specifying nuisance parameters for interval
177  RooArgSet fConditionalObs; // RooArgSet specifying the conditional observables
178 
179 
180  ClassDef(CombinedCalculator,1) // A base class that is for tools that can be both HypoTestCalculators and IntervalCalculators
181 
182  };
183 }
184 
185 
186 #endif
virtual ~CombinedCalculator()
destructor.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition: ModelConfig.h:52
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:86
IntervalCalculator is an interface class for a tools which produce RooStats ConfIntervals.
virtual void SetTestSize(Double_t size)
set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval) ...
HypoTestResult is a base class for results from hypothesis tests.
virtual void SetNullModel(const ModelConfig &)
virtual void SetAlternateModel(const ModelConfig &)
virtual void SetModel(const ModelConfig &model)
set the model (in this case can set only the parameters for the null hypothesis)
virtual HypoTestResult * GetHypoTest() const =0
main interface to get a HypoTestResult, pure virtual
virtual ConfInterval * GetInterval() const =0
Main interface to get a ConfInterval, pure virtual.
virtual void SetAlternateParameters(const RooArgSet &set)
set parameter values for the alternate if using a common PDF
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual void SetPdf(RooAbsPdf &pdf)
Set the Pdf.
virtual void SetData(RooAbsData &data)
Set the DataSet, add to the the workspace if not already there.
virtual void SetNuisanceParameters(const RooArgSet &set)
specify the nuisance parameters (eg. the rest of the parameters)
HypoTestCalculator is an interface class for a tools which produce RooStats HypoTestResults.
virtual void SetConditionalObservables(const RooArgSet &set)
set conditional observables needed for computing the NLL
const RooArgSet * GetConditionalObservables() const
get RooArgSet for conditional observables (return NULL if not existing)
Definition: ModelConfig.h:262
virtual void SetParameters(const RooArgSet &set)
specify the parameters of interest in the interval
virtual Double_t Size() const
Get the size of the test (eg. rate of Type I error)
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
CombinedCalculator is an interface class for a tools which can produce both RooStats HypoTestResults ...
CombinedCalculator(RooAbsData &data, RooAbsPdf &pdf, const RooArgSet &paramsOfInterest, Double_t size=0.05, const RooArgSet *nullParams=0, const RooArgSet *altParams=0, const RooArgSet *nuisParams=0)
ConfInterval is an interface class for a generic interval in the RooStats framework.
Definition: ConfInterval.h:44
Namespace for the RooStats classes.
Definition: Asimov.h:20
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
Definition: ModelConfig.h:244
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
Definition: ModelConfig.h:247
double Double_t
Definition: RtypesCore.h:55
virtual void SetNullParameters(const RooArgSet &set)
set parameter values for the null if using a common PDF
CombinedCalculator(RooAbsData &data, const ModelConfig &model, Double_t size=0.05)
constructor from data and model configuration
virtual void SetConfidenceLevel(Double_t cl)
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval) ...
virtual Double_t ConfidenceLevel() const
Get the Confidence level for the test.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
Definition: ModelConfig.h:250
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return NULL if not existing) ...