Logo ROOT  
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 
16 
18 
19 #include "RooStats/ModelConfig.h"
20 
21 #include "RooAbsPdf.h"
22 
23 #include "RooAbsData.h"
24 
25 #include "RooArgSet.h"
26 
27 // #ifndef ROO_WORKSPACE
28 // #include "RooWorkspace.h"
29 // #endif
30 
31 namespace RooStats {
32 
33 /** \class CombinedCalculator
34  \ingroup Roostats
35 
36 CombinedCalculator is an interface class for a tools which can produce both RooStats
37 HypoTestResults and ConfIntervals. The interface currently assumes that any such
38 calculator can be configured by specifying:
39 
40  - a model common model (eg. a family of specific models which includes both the null and alternate),
41  - a data set,
42  - a set of parameters of which specify the null (including values and const/non-const status),
43  - a set of parameters of which specify the alternate (including values and const/non-const status),
44  - a set of parameters of nuisance parameters (including values and const/non-const status).
45 
46 The interface allows one to pass the model, data, and parameters via a workspace
47 and then specify them with names. The interface also allows one to pass the model,
48 data, and parameters without a workspace (which is created internally).
49 
50 After configuring the calculator, one only needs to ask GetHypoTest() (which will
51 return a HypoTestResult pointer) or GetInterval() (which will return an ConfInterval pointer).
52 
53 The concrete implementations of this interface should deal with the details of how
54 the nuisance parameters are dealt with (eg. integration vs. profiling) and which test-statistic is used (perhaps this should be added to the interface).
55 
56 The motivation for this interface is that we hope to be able to specify the problem
57 in a common way for several concrete calculators.
58 
59 */
60 
61 
62  class CombinedCalculator : public IntervalCalculator, public HypoTestCalculator {
63 
64  public:
65 
67  fSize(0.),
68  fPdf(0),
69  fData(0)
70  {}
71 
72  CombinedCalculator(RooAbsData& data, RooAbsPdf& pdf, const RooArgSet& paramsOfInterest,
73  Double_t size = 0.05, const RooArgSet* nullParams = 0, const RooArgSet* altParams = 0, const RooArgSet* nuisParams = 0) :
74 
75  fPdf(&pdf),
76  fData(&data),
77  fPOI(paramsOfInterest)
78  {
79  if (nullParams) fNullParams.add(*nullParams);
80  if (altParams) fAlternateParams.add(*altParams);
81  if (nuisParams) fNuisParams.add(*nuisParams);
82  SetTestSize(size);
83  }
84 
85  /// constructor from data and model configuration
87  Double_t size = 0.05) :
88  fPdf(0),
89  fData(&data)
90  {
91  SetModel(model);
92  SetTestSize(size);
93  }
94 
95 
96  /// destructor.
97  virtual ~CombinedCalculator() { }
98 
99 
100 
101  /// Main interface to get a ConfInterval, pure virtual
102  virtual ConfInterval* GetInterval() const = 0;
103  /// main interface to get a HypoTestResult, pure virtual
104  virtual HypoTestResult* GetHypoTest() const = 0;
105 
106  /// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
107  virtual void SetTestSize(Double_t size) {fSize = size;}
108  /// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
109  virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}
110  /// Get the size of the test (eg. rate of Type I error)
111  virtual Double_t Size() const {return fSize;}
112  /// Get the Confidence level for the test
113  virtual Double_t ConfidenceLevel() const {return 1.-fSize;}
114 
115  /// Set the DataSet, add to the the workspace if not already there
116  virtual void SetData(RooAbsData & data) {
117  fData = &data;
118  }
119 
120  /// set the model (in this case can set only the parameters for the null hypothesis)
121  virtual void SetModel(const ModelConfig & model) {
122  fPdf = model.GetPdf();
123  if (model.GetParametersOfInterest()) SetParameters(*model.GetParametersOfInterest());
124  if (model.GetSnapshot()) SetNullParameters(*model.GetSnapshot());
125  if (model.GetNuisanceParameters()) SetNuisanceParameters(*model.GetNuisanceParameters());
126  if (model.GetConditionalObservables()) SetConditionalObservables(*model.GetConditionalObservables());
127  if (model.GetGlobalObservables()) SetGlobalObservables(*model.GetGlobalObservables());
128  }
129 
130  virtual void SetNullModel( const ModelConfig &) { // to be understood what to do
131  }
132  virtual void SetAlternateModel(const ModelConfig &) { // to be understood what to do
133  }
134 
135  /* specific setting - keep for convenience- some of them could be removed */
136 
137  /// Set the Pdf
138  virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
139 
140  /// specify the parameters of interest in the interval
141  virtual void SetParameters(const RooArgSet& set) { fPOI.removeAll(); fPOI.add(set); }
142 
143  /// specify the nuisance parameters (eg. the rest of the parameters)
145 
146  /// set parameter values for the null if using a common PDF
147  virtual void SetNullParameters(const RooArgSet& set) {fNullParams.removeAll(); fNullParams.add(set);}
148 
149  /// set parameter values for the alternate if using a common PDF
151 
152  /// set conditional observables needed for computing the NLL
154 
155  /// set global observables needed for computing the NLL
156  virtual void SetGlobalObservables(const RooArgSet& set) {fGlobalObs.removeAll(); fGlobalObs.add(set);}
157 
158 
159  protected:
160 
161  RooAbsPdf * GetPdf() const { return fPdf; }
162  RooAbsData * GetData() const { return fData; }
163 
164  Double_t fSize; // size of the test (eg. specified rate of Type I error)
165 
166  RooAbsPdf * fPdf;
168  RooArgSet fPOI; // RooArgSet specifying parameters of interest for interval
169  RooArgSet fNullParams; // RooArgSet specifying null parameters for hypothesis test
170  RooArgSet fAlternateParams; // RooArgSet specifying alternate parameters for hypothesis test // Is it used ????
171  RooArgSet fNuisParams;// RooArgSet specifying nuisance parameters for interval
172  RooArgSet fConditionalObs; // RooArgSet specifying the conditional observables
173  RooArgSet fGlobalObs; // RooArgSet specifying the global observables
174 
175 
176  ClassDef(CombinedCalculator,2) // A base class that is for tools that can be both HypoTestCalculators and IntervalCalculators
177 
178  };
179 }
180 
181 
182 #endif
RooStats::CombinedCalculator::ConfidenceLevel
virtual Double_t ConfidenceLevel() const
Get the Confidence level for the test.
Definition: CombinedCalculator.h:119
HypoTestCalculator.h
RooStats::CombinedCalculator::GetHypoTest
virtual HypoTestResult * GetHypoTest() const =0
main interface to get a HypoTestResult, pure virtual
RooStats::CombinedCalculator::GetInterval
virtual ConfInterval * GetInterval() const =0
Main interface to get a ConfInterval, pure virtual.
RooAbsData
Definition: RooAbsData.h:46
RooStats::CombinedCalculator::fData
RooAbsData * fData
Definition: CombinedCalculator.h:173
RooArgSet.h
RooStats::CombinedCalculator::fPdf
RooAbsPdf * fPdf
Definition: CombinedCalculator.h:172
IntervalCalculator.h
RooArgSet::add
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:88
RooStats::CombinedCalculator::SetConditionalObservables
virtual void SetConditionalObservables(const RooArgSet &set)
set conditional observables needed for computing the NLL
Definition: CombinedCalculator.h:159
RooStats::CombinedCalculator::GetPdf
RooAbsPdf * GetPdf() const
Definition: CombinedCalculator.h:167
RooStats::CombinedCalculator::SetParameters
virtual void SetParameters(const RooArgSet &set)
specify the parameters of interest in the interval
Definition: CombinedCalculator.h:147
RooStats::CombinedCalculator::SetModel
virtual void SetModel(const ModelConfig &model)
set the model (in this case can set only the parameters for the null hypothesis)
Definition: CombinedCalculator.h:127
RooStats::CombinedCalculator
Definition: CombinedCalculator.h:68
RooStats::CombinedCalculator::SetNullParameters
virtual void SetNullParameters(const RooArgSet &set)
set parameter values for the null if using a common PDF
Definition: CombinedCalculator.h:153
RooStats::CombinedCalculator::fNullParams
RooArgSet fNullParams
Definition: CombinedCalculator.h:175
RooStats::CombinedCalculator::fGlobalObs
RooArgSet fGlobalObs
Definition: CombinedCalculator.h:179
ModelConfig.h
RooAbsPdf.h
RooStats::CombinedCalculator::SetAlternateParameters
virtual void SetAlternateParameters(const RooArgSet &set)
set parameter values for the alternate if using a common PDF
Definition: CombinedCalculator.h:156
RooStats::CombinedCalculator::SetNuisanceParameters
virtual void SetNuisanceParameters(const RooArgSet &set)
specify the nuisance parameters (eg. the rest of the parameters)
Definition: CombinedCalculator.h:150
RooStats::CombinedCalculator::fPOI
RooArgSet fPOI
Definition: CombinedCalculator.h:174
RooStats::CombinedCalculator::SetPdf
virtual void SetPdf(RooAbsPdf &pdf)
Set the Pdf.
Definition: CombinedCalculator.h:144
RooStats::CombinedCalculator::SetConfidenceLevel
virtual void SetConfidenceLevel(Double_t cl)
set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
Definition: CombinedCalculator.h:115
RooStats::CombinedCalculator::SetData
virtual void SetData(RooAbsData &data)
Set the DataSet, add to the the workspace if not already there.
Definition: CombinedCalculator.h:122
RooStats::CombinedCalculator::SetGlobalObservables
virtual void SetGlobalObservables(const RooArgSet &set)
set global observables needed for computing the NLL
Definition: CombinedCalculator.h:162
RooStats::CombinedCalculator::GetData
RooAbsData * GetData() const
Definition: CombinedCalculator.h:168
RooStats::CombinedCalculator::fSize
Double_t fSize
Definition: CombinedCalculator.h:170
RooAbsData.h
Double_t
double Double_t
Definition: RtypesCore.h:59
RooStats::CombinedCalculator::fNuisParams
RooArgSet fNuisParams
Definition: CombinedCalculator.h:177
RooStats
Definition: Asimov.h:19
RooStats::CombinedCalculator::fConditionalObs
RooArgSet fConditionalObs
Definition: CombinedCalculator.h:178
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooStats::HypoTestResult
Definition: HypoTestResult.h:28
RooStats::CombinedCalculator::~CombinedCalculator
virtual ~CombinedCalculator()
destructor.
Definition: CombinedCalculator.h:103
RooStats::CombinedCalculator::fAlternateParams
RooArgSet fAlternateParams
Definition: CombinedCalculator.h:176
RooStats::CombinedCalculator::Size
virtual Double_t Size() const
Get the size of the test (eg. rate of Type I error)
Definition: CombinedCalculator.h:117
make_cnn_model.model
model
Definition: make_cnn_model.py:6
RooAbsPdf
Definition: RooAbsPdf.h:40
RooAbsCollection::removeAll
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Definition: RooAbsCollection.cxx:643
RooStats::ModelConfig
Definition: ModelConfig.h:36
RooStats::CombinedCalculator::CombinedCalculator
CombinedCalculator()
Definition: CombinedCalculator.h:72
RooStats::CombinedCalculator::SetNullModel
virtual void SetNullModel(const ModelConfig &)
Definition: CombinedCalculator.h:136
RooArgSet
Definition: RooArgSet.h:28
RooStats::CombinedCalculator::SetTestSize
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)
Definition: CombinedCalculator.h:113
RooStats::CombinedCalculator::SetAlternateModel
virtual void SetAlternateModel(const ModelConfig &)
Definition: CombinedCalculator.h:138