ROOT logo
// @(#)root/roostats:$Id: BayesianCalculator.h 31742 2009-12-09 17:34:15Z moneta $
// 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_BayesianCalculator
#define ROOSTATS_BayesianCalculator

#include "TNamed.h"

#ifndef ROO_ARG_SET
#include "RooArgSet.h"
#endif

#ifndef ROOSTATS_IntervalCalculator
#include "RooStats/IntervalCalculator.h"
#endif

#ifndef ROOSTATS_SimpleInterval
#include "RooStats/SimpleInterval.h"
#endif

class RooAbsData; 
class RooAbsPdf; 
class RooPlot; 
class RooAbsReal;

namespace RooStats {

   class ModelConfig; 
   class SimpleInterval; 

   class BayesianCalculator : public IntervalCalculator, public TNamed {

   public:

      // constructor
      BayesianCalculator( );

      BayesianCalculator( RooAbsData& data,
                          RooAbsPdf& pdf,
                          const RooArgSet& POI,
                          RooAbsPdf& priorPOI,
                          const RooArgSet* nuisanceParameters = 0 );

      BayesianCalculator( RooAbsData& data,
                          ModelConfig& model );

      // destructor
      virtual ~BayesianCalculator();

      RooPlot* GetPosteriorPlot() const; 

      // return posterior pdf (object is managed by the BayesianCalculator class)
      RooAbsPdf* GetPosteriorPdf() const; 

      virtual SimpleInterval* GetInterval() const ; 

      virtual void SetData( RooAbsData & data ) { fData = &data; }

      virtual void SetModel( const ModelConfig& model ); 

      // 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;
         if (fInterval) delete fInterval;
	 fInterval = 0;  
      }
      // set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
      virtual void SetConfidenceLevel( Double_t cl ) { SetTestSize(1.-cl); }
      // Get the size of the test (eg. rate of Type I error)
      virtual Double_t Size() const { return fSize; }
      // Get the Confidence level for the test
      virtual Double_t ConfidenceLevel() const { return 1.-fSize; }

   protected:

      void ClearAll() const; 
   
   private:

      // compute the most probable value: move to public once implemented
      // returns a RooArgSet
      RooArgSet* GetMode( RooArgSet* parameters ) const;
      // plan to replace the above: return a SimpleInterval integrating 
      // over all other parameters except the one specified as argument
      //virtual SimpleInterval* GetInterval( RooRealVar* parameter  ) const { return 0; }
    
      RooAbsData* fData;
      RooAbsPdf* fPdf;
      RooArgSet fPOI;
      RooAbsPdf* fPriorPOI;
      RooArgSet fNuisanceParameters;

      mutable RooAbsPdf* fProductPdf; 
      mutable RooAbsReal* fLogLike; 
      mutable RooAbsReal* fLikelihood; 
      mutable RooAbsReal* fIntegratedLikelihood; 
      mutable RooAbsPdf* fPosteriorPdf; 
      mutable SimpleInterval* fInterval;  // cached pointer to resulting interval

      double fSize;  // size used for getting the interval

   protected:

      ClassDef(BayesianCalculator,1)  // BayesianCalculator class

   };
}

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