Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
NeymanConstruction.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_NeymanConstruction
12 #define ROOSTATS_NeymanConstruction
13 
14 
15 #include "Rtypes.h"
16 
18 
20 #include "RooStats/ModelConfig.h"
23 
24 #include "RooAbsData.h"
25 #include "RooAbsPdf.h"
26 #include "RooArgSet.h"
27 #include "TList.h"
28 
29 class RooAbsData;
30 
31 namespace RooStats {
32 
33  class ConfInterval;
34 
35  class NeymanConstruction : public IntervalCalculator{
36 
37  public:
38 
39  /// NeymanConstruction();
40  NeymanConstruction(RooAbsData& data, ModelConfig& model);
41 
42  virtual ~NeymanConstruction();
43 
44  /// Main interface to get a ConfInterval (will be a PointSetInterval)
45  virtual PointSetInterval* GetInterval() const;
46 
47  /// in addition to interface we also need:
48  /// Set the TestStatSampler (eg. ToyMC or FFT, includes choice of TestStatistic)
49  void SetTestStatSampler(TestStatSampler& sampler) {fTestStatSampler = &sampler;}
50  /// fLeftSideTailFraction*fSize defines lower edge of acceptance region.
51  /// Unified limits use 0, central limits use 0.5,
52  /// for upper/lower limits it is 0/1 depends on sign of test statistic w.r.t. parameter
53  void SetLeftSideTailFraction(Double_t leftSideFraction = 0.) {fLeftSideFraction = leftSideFraction;}
54 
55  /// User-defined set of points to test
56  void SetParameterPointsToTest(RooAbsData& pointsToTest) {
57  fPointsToTest = &pointsToTest;
58  fConfBelt = new ConfidenceBelt("ConfBelt",pointsToTest);
59  }
60  /// This class can make regularly spaced scans based on range stored in RooRealVars.
61  /// Choose number of steps for a rastor scan (common for each dimension)
62  /// void SetNumSteps(Int_t);
63  /// This class can make regularly spaced scans based on range stored in RooRealVars.
64  /// Choose number of steps for a rastor scan (specific for each dimension)
65  /// void SetNumSteps(std::map<RooAbsArg, Int_t>)
66 
67  /// Get the size of the test (eg. rate of Type I error)
68  virtual Double_t Size() const {return fSize;}
69 
70  /// Get the Confidence level for the test
71  virtual Double_t ConfidenceLevel() const {return 1.-fSize;}
72 
73  /// Set ModelConfig
74  virtual void SetModel(const ModelConfig &model) {fModel = model;}
75 
76  /// Set the DataSet
77  virtual void SetData(RooAbsData& data) { fData = data; }
78 
79  /// Set the Pdf, add to the the workspace if not already there
80  virtual void SetPdf(RooAbsPdf& /*pdf*/) {
81  std::cout << "DEPRECATED, use ModelConfig"<<std::endl;
82  }
83 
84  /// specify the parameters of interest in the interval
85  virtual void SetParameters(const RooArgSet& /*set*/) {
86  std::cout << "DEPRECATED, use ModelConfig"<<std::endl;
87  }
88 
89  /// specify the nuisance parameters (eg. the rest of the parameters)
90  virtual void SetNuisanceParameters(const RooArgSet& /*set*/) {
91  std::cout << "DEPRECATED, use ModelConfig"<<std::endl;
92  }
93 
94  /// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
95  virtual void SetTestSize(Double_t size) {fSize = size;}
96  /// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
97  virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}
98 
99  /// get confidence belt
100  ConfidenceBelt* GetConfidenceBelt() {return fConfBelt;}
101 
102  /// adaptive sampling algorithm to speed up interval calculation
103  void UseAdaptiveSampling(bool flag=true){fAdaptiveSampling=flag;}
104 
105  /// give user ability to ask for more toys
106  void AdditionalNToysFactor(double fact){fAdditionalNToysFactor = fact;}
107 
108  /// save the confidence belt to a file
109  void SaveBeltToFile(bool flag=true){
110  fSaveBeltToFile = flag;
111  if(flag) fCreateBelt = true;
112  }
113  /// should create confidence belt
114  void CreateConfBelt(bool flag=true){fCreateBelt = flag;}
115 
116  /// Returns instance of TestStatSampler. Use to change properties of
117  /// TestStatSampler, e.g. GetTestStatSampler.SetTestSize(Double_t size);
118  TestStatSampler* GetTestStatSampler(void) { return fTestStatSampler; }
119 
120 
121  private:
122 
123  Double_t fSize; /// size of the test (eg. specified rate of Type I error)
124  RooAbsData& fData; /// data set
125  ModelConfig &fModel;
126  /*
127  RooAbsPdf * fPdf; // common PDF
128  mutable RooArgSet fPOI; // RooArgSet specifying parameters of interest for interval
129  RooArgSet fNuisParams;// RooArgSet specifying nuisance parameters for interval
130  */
131 
132  TestStatSampler* fTestStatSampler;
133  RooAbsData* fPointsToTest;
134  Double_t fLeftSideFraction;
135  ConfidenceBelt* fConfBelt;
136  bool fAdaptiveSampling; // controls use of adaptive sampling algorithm
137  Double_t fAdditionalNToysFactor; // give user ability to ask for more toys
138  bool fSaveBeltToFile; // controls use if ConfidenceBelt should be saved to a TFile
139  bool fCreateBelt; // controls use if ConfidenceBelt should be saved to a TFile
140 
141  protected:
142  ClassDef(NeymanConstruction,1) // Interface for tools setting limits (producing confidence intervals)
143  };
144 }
145 
146 
147 #endif