NeymanConstruction.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: NeymanConstruction.h 37403 2010-12-08 15:59:22Z moneta $
00002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #ifndef ROOSTATS_NeymanConstruction
00012 #define ROOSTATS_NeymanConstruction
00013 
00014 
00015 #ifndef ROOT_Rtypes
00016 #include "Rtypes.h"
00017 #endif
00018 
00019 #ifndef ROOSTATS_IntervalCalculator
00020 #include "RooStats/IntervalCalculator.h"
00021 #endif
00022 
00023 #include "RooStats/TestStatSampler.h"
00024 #include "RooStats/ModelConfig.h"
00025 #include "RooStats/ConfidenceBelt.h"
00026 #include "RooStats/PointSetInterval.h"
00027 
00028 #include "RooAbsData.h"
00029 #include "RooAbsPdf.h"
00030 #include "RooArgSet.h"
00031 #include "TList.h"
00032 
00033 class RooAbsData; 
00034 
00035 namespace RooStats {
00036 
00037    class ConfInterval; 
00038 
00039    class NeymanConstruction : public IntervalCalculator{
00040 
00041    public:
00042 
00043      //     NeymanConstruction();
00044      NeymanConstruction(RooAbsData& data, ModelConfig& model);
00045 
00046      virtual ~NeymanConstruction();
00047     
00048       // Main interface to get a ConfInterval (will be a PointSetInterval)
00049      virtual PointSetInterval* GetInterval() const;
00050 
00051       // in addition to interface we also need:
00052       // Set the TestStatSampler (eg. ToyMC or FFT, includes choice of TestStatistic)
00053       void SetTestStatSampler(TestStatSampler& sampler) {fTestStatSampler = &sampler;}
00054       // fLeftSideTailFraction*fSize defines lower edge of acceptance region.
00055       // Unified limits use 0, central limits use 0.5, 
00056       // for upper/lower limits it is 0/1 depends on sign of test statistic w.r.t. parameter
00057       void SetLeftSideTailFraction(Double_t leftSideFraction = 0.) {fLeftSideFraction = leftSideFraction;} 
00058 
00059       // User-defined set of points to test
00060       void SetParameterPointsToTest(RooAbsData& pointsToTest) {
00061         fPointsToTest = &pointsToTest;
00062         fConfBelt = new ConfidenceBelt("ConfBelt",pointsToTest);
00063       }
00064       // This class can make regularly spaced scans based on range stored in RooRealVars.
00065       // Choose number of steps for a rastor scan (common for each dimension)
00066       //      void SetNumSteps(Int_t);
00067       // This class can make regularly spaced scans based on range stored in RooRealVars.
00068       // Choose number of steps for a rastor scan (specific for each dimension)
00069       //      void SetNumSteps(map<RooAbsArg, Int_t>)
00070 
00071       // Get the size of the test (eg. rate of Type I error)
00072       virtual Double_t Size() const {return fSize;}
00073 
00074       // Get the Confidence level for the test
00075       virtual Double_t ConfidenceLevel()  const {return 1.-fSize;}  
00076 
00077       // Set ModelConfig
00078       virtual void SetModel(const ModelConfig &model) {fModel = model;}
00079 
00080       // Set the DataSet 
00081       virtual void SetData(RooAbsData& data) { fData = data; }
00082 
00083       // Set the Pdf, add to the the workspace if not already there
00084       virtual void SetPdf(RooAbsPdf& /*pdf*/) { 
00085         cout << "DEPRECATED, use ModelConfig"<<endl;
00086       }  
00087 
00088       // specify the parameters of interest in the interval
00089       virtual void SetParameters(const RooArgSet& /*set*/) {
00090         cout << "DEPRECATED, use ModelConfig"<<endl;
00091       }
00092 
00093       // specify the nuisance parameters (eg. the rest of the parameters)
00094       virtual void SetNuisanceParameters(const RooArgSet& /*set*/) {
00095         cout << "DEPRECATED, use ModelConfig"<<endl;
00096       }
00097 
00098       // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
00099       virtual void SetTestSize(Double_t size) {fSize = size;}
00100       // set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
00101       virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}
00102 
00103       // get confidence belt
00104       ConfidenceBelt* GetConfidenceBelt() {return fConfBelt;}
00105 
00106       // adaptive sampling algorithm to speed up interval caculation
00107       void UseAdaptiveSampling(bool flag=true){fAdaptiveSampling=flag;}
00108 
00109       // give user ability to ask for more toys
00110       void AdditionalNToysFactor(double fact){fAdditionalNToysFactor = fact;}
00111 
00112       // save teh confidence belt to a file
00113       void SaveBeltToFile(bool flag=true){
00114         fSaveBeltToFile = flag;
00115         if(flag) fCreateBelt = true;
00116       }
00117       // should create confidence belt
00118       void CreateConfBelt(bool flag=true){fCreateBelt = flag;}
00119 
00120       // Returns instance of TestStatSampler. Use to change properties of
00121       // TestStatSampler, e.g. GetTestStatSampler.SetTestSize(Double_t size);
00122       TestStatSampler* GetTestStatSampler(void) { return fTestStatSampler; }
00123 
00124       
00125    private:
00126 
00127       Double_t fSize; // size of the test (eg. specified rate of Type I error)
00128       RooAbsData& fData; // data set 
00129       ModelConfig &fModel;
00130       /*
00131       RooAbsPdf * fPdf; // common PDF
00132       mutable RooArgSet fPOI; // RooArgSet specifying  parameters of interest for interval
00133       RooArgSet fNuisParams;// RooArgSet specifying  nuisance parameters for interval
00134       */
00135 
00136       TestStatSampler* fTestStatSampler;
00137       RooAbsData* fPointsToTest;
00138       Double_t fLeftSideFraction;
00139       ConfidenceBelt* fConfBelt;
00140       bool fAdaptiveSampling; // controls use of adaptive sampling algorithm
00141       Double_t fAdditionalNToysFactor; // give user ability to ask for more toys
00142       bool fSaveBeltToFile; // controls use if ConfidenceBelt should be saved to a TFile
00143       bool fCreateBelt; // controls use if ConfidenceBelt should be saved to a TFile
00144 
00145    protected:
00146       ClassDef(NeymanConstruction,1)   // Interface for tools setting limits (producing confidence intervals)
00147    };
00148 }
00149 
00150 
00151 #endif

Generated on Tue Jul 5 14:26:25 2011 for ROOT_528-00b_version by  doxygen 1.5.1