ROOT logo
// @(#)root/roostats:$Id: DebuggingSampler.h 26805 2009-01-13 17:45:57Z cranmer $
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOSTATS_DebuggingSampler
#define ROOSTATS_DebuggingSampler

//_________________________________________________
/*
BEGIN_HTML
<p>
DebuggingSampler is a simple implementation of the DistributionCreator interface used for debugging.
The sampling distribution is uniformly random between [0,1] and is INDEPENDENT of the data.  So it is not useful
for true statistical tests, but it is useful for debugging.
</p>
END_HTML
*/
//

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

#include <vector>

#include "RooStats/TestStatSampler.h"
#include "RooStats/SamplingDistribution.h"

#include "RooRealVar.h"
#include "TRandom.h"

namespace RooStats {

 class DebuggingSampler: public TestStatSampler {

   public:
     DebuggingSampler() {
       fTestStatistic = new RooRealVar("UniformTestStatistic","UniformTestStatistic",0,0,1);
       fRand = new TRandom();
     }
     virtual ~DebuggingSampler() {
       delete fRand;
       delete fTestStatistic;
     }
    
      // Main interface to get a ConfInterval, pure virtual
     virtual SamplingDistribution* GetSamplingDistribution(RooArgSet& paramsOfInterest)  {
       paramsOfInterest = paramsOfInterest; // avoid warning
       // normally this method would be complex, but here it is simple for debugging
       std::vector<Double_t> testStatVec;
       for(Int_t i=0; i<1000; ++i){
	 testStatVec.push_back( fRand->Uniform() );
       }
       return new SamplingDistribution("UniformSamplingDist", "for debugging", testStatVec );
     } 

      // Main interface to evaluate the test statistic on a dataset
     virtual Double_t EvaluateTestStatistic(RooAbsData& /*data*/, RooArgSet& /*paramsOfInterest*/)  {
       //       data = data; // avoid warning
       //       paramsOfInterest = paramsOfInterest; // avoid warning
       return fRand->Uniform();
     }

      // Get the TestStatistic
      virtual const RooAbsArg* GetTestStatistic()  const {return fTestStatistic;}  
    
      // Get the Confidence level for the test
      virtual Double_t ConfidenceLevel()  const {return 1.-fSize;}  

      // Common Initialization
      virtual void Initialize(RooAbsArg& /* testStatistic */, RooArgSet& /* paramsOfInterest */, RooArgSet& /* nuisanceParameters */ ) {
      }

      // Set the Pdf, add to the the workspace if not already there
      virtual void SetPdf(RooAbsPdf&) {}

      // specify the parameters of interest in the interval
      virtual void SetParameters(RooArgSet&) {}
      // specify the nuisance parameters (eg. the rest of the parameters)
      virtual void SetNuisanceParameters(RooArgSet&) {}

      // set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
      virtual void SetTestSize(Double_t size) {fSize = size;}
      // set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
      virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl;}

      // Set the TestStatistic (want the argument to be a function of the data & parameter points
      virtual void SetTestStatistic(RooAbsArg&)  const {}  
      
   private:
      Double_t fSize;
      RooRealVar* fTestStatistic;
      TRandom* fRand;

   protected:
      ClassDef(DebuggingSampler,1)   // A simple implementation of the DistributionCreator interface
   };
}


#endif
 DebuggingSampler.h:1
 DebuggingSampler.h:2
 DebuggingSampler.h:3
 DebuggingSampler.h:4
 DebuggingSampler.h:5
 DebuggingSampler.h:6
 DebuggingSampler.h:7
 DebuggingSampler.h:8
 DebuggingSampler.h:9
 DebuggingSampler.h:10
 DebuggingSampler.h:11
 DebuggingSampler.h:12
 DebuggingSampler.h:13
 DebuggingSampler.h:14
 DebuggingSampler.h:15
 DebuggingSampler.h:16
 DebuggingSampler.h:17
 DebuggingSampler.h:18
 DebuggingSampler.h:19
 DebuggingSampler.h:20
 DebuggingSampler.h:21
 DebuggingSampler.h:22
 DebuggingSampler.h:23
 DebuggingSampler.h:24
 DebuggingSampler.h:25
 DebuggingSampler.h:26
 DebuggingSampler.h:27
 DebuggingSampler.h:28
 DebuggingSampler.h:29
 DebuggingSampler.h:30
 DebuggingSampler.h:31
 DebuggingSampler.h:32
 DebuggingSampler.h:33
 DebuggingSampler.h:34
 DebuggingSampler.h:35
 DebuggingSampler.h:36
 DebuggingSampler.h:37
 DebuggingSampler.h:38
 DebuggingSampler.h:39
 DebuggingSampler.h:40
 DebuggingSampler.h:41
 DebuggingSampler.h:42
 DebuggingSampler.h:43
 DebuggingSampler.h:44
 DebuggingSampler.h:45
 DebuggingSampler.h:46
 DebuggingSampler.h:47
 DebuggingSampler.h:48
 DebuggingSampler.h:49
 DebuggingSampler.h:50
 DebuggingSampler.h:51
 DebuggingSampler.h:52
 DebuggingSampler.h:53
 DebuggingSampler.h:54
 DebuggingSampler.h:55
 DebuggingSampler.h:56
 DebuggingSampler.h:57
 DebuggingSampler.h:58
 DebuggingSampler.h:59
 DebuggingSampler.h:60
 DebuggingSampler.h:61
 DebuggingSampler.h:62
 DebuggingSampler.h:63
 DebuggingSampler.h:64
 DebuggingSampler.h:65
 DebuggingSampler.h:66
 DebuggingSampler.h:67
 DebuggingSampler.h:68
 DebuggingSampler.h:69
 DebuggingSampler.h:70
 DebuggingSampler.h:71
 DebuggingSampler.h:72
 DebuggingSampler.h:73
 DebuggingSampler.h:74
 DebuggingSampler.h:75
 DebuggingSampler.h:76
 DebuggingSampler.h:77
 DebuggingSampler.h:78
 DebuggingSampler.h:79
 DebuggingSampler.h:80
 DebuggingSampler.h:81
 DebuggingSampler.h:82
 DebuggingSampler.h:83
 DebuggingSampler.h:84
 DebuggingSampler.h:85
 DebuggingSampler.h:86
 DebuggingSampler.h:87
 DebuggingSampler.h:88
 DebuggingSampler.h:89
 DebuggingSampler.h:90
 DebuggingSampler.h:91
 DebuggingSampler.h:92
 DebuggingSampler.h:93
 DebuggingSampler.h:94
 DebuggingSampler.h:95
 DebuggingSampler.h:96
 DebuggingSampler.h:97
 DebuggingSampler.h:98
 DebuggingSampler.h:99
 DebuggingSampler.h:100
 DebuggingSampler.h:101
 DebuggingSampler.h:102
 DebuggingSampler.h:103
 DebuggingSampler.h:104
 DebuggingSampler.h:105
 DebuggingSampler.h:106
 DebuggingSampler.h:107