PdfProposal.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: PdfProposal.h 34109 2010-06-24 15:00:16Z moneta $
00002 // Authors: Kevin Belasco        17/06/2009
00003 // Authors: Kyle Cranmer         17/06/2009
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOSTATS_PdfProposal
00013 #define ROOSTATS_PdfProposal
00014 
00015 #ifndef ROOT_Rtypes
00016 #include "Rtypes.h"
00017 #endif
00018 
00019 #ifndef ROOSTATS_ProposalFunction
00020 #include "RooStats/ProposalFunction.h"
00021 #endif
00022 
00023 #ifndef ROO_ARG_SET
00024 #include "RooArgSet.h"
00025 #endif
00026 #ifndef ROO_MSG_SERVICE
00027 #include "RooMsgService.h"
00028 #endif
00029 #ifndef ROO_REAL_VAR
00030 #include "RooRealVar.h"
00031 #endif
00032 #ifndef ROO_DATA_SET
00033 #include "RooDataSet.h"
00034 #endif
00035 #ifndef ROO_ABS_PDF
00036 #include "RooAbsPdf.h"
00037 #endif
00038 
00039 #include <map>
00040 #include <string>
00041 
00042 using namespace std;
00043 
00044 namespace RooStats {
00045 
00046    class PdfProposal : public ProposalFunction {
00047 
00048    public:
00049       PdfProposal();
00050       PdfProposal(RooAbsPdf& pdf);
00051 
00052       // Populate xPrime with a new proposed point
00053       virtual void Propose(RooArgSet& xPrime, RooArgSet& x);
00054 
00055       // Determine whether or not the proposal density is symmetric for
00056       // points x1 and x2 - that is, whether the probabilty of reaching x2
00057       // from x1 is equal to the probability of reaching x1 from x2
00058       virtual Bool_t IsSymmetric(RooArgSet& x1, RooArgSet& x2);
00059 
00060       // Return the probability of proposing the point x1 given the starting
00061       // point x2
00062       virtual Double_t GetProposalDensity(RooArgSet& x1, RooArgSet& x2);
00063 
00064       // Set the PDF to be the proposal density function
00065       virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
00066 
00067       // Get the PDF is the proposal density function
00068       virtual const RooAbsPdf* GetPdf() const { return fPdf; }
00069 
00070       // specify a mapping between a parameter of the proposal function and
00071       // a parameter of interest.  this mapping is used to set the value of
00072       // proposalParam equal to the value of update to determine the
00073       // proposal function.
00074       // proposalParam is a parameter of the proposal function that must
00075       // be set to the value of update (from the current point) in order to
00076       // propose a new point.
00077       virtual void AddMapping(RooRealVar& proposalParam, RooAbsReal& update);
00078 
00079       virtual void Reset()
00080       {
00081          delete fCache;
00082          fCache = NULL;
00083          fCachePosition = 0;
00084          fLastX.removeAll();
00085       }
00086 
00087       virtual void printMappings()
00088       {
00089          map<RooRealVar*, RooAbsReal*>::iterator it;
00090          for (it = fMap.begin(); it != fMap.end(); it++)
00091          cout << it->first->GetName() << " => " << it->second->GetName() << endl;
00092       }
00093 
00094       // Set how many points to generate each time we propose from a new point
00095       // Default (and minimum) is 1
00096       virtual void SetCacheSize(Int_t size)
00097       {
00098          if (size > 0)
00099             fCacheSize = size;
00100          else
00101             coutE(Eval) << "Warning: Requested non-positive cache size: " <<
00102                            size << ". Cache size unchanged." << endl;
00103       }
00104 
00105       // set whether we own the PDF that serves as the proposal density function
00106       // By default, when constructed, PdfProposal does NOT own the PDF.
00107       virtual void SetOwnsPdf(Bool_t ownsPdf) { fOwnsPdf = ownsPdf; }
00108 
00109       //virtual void SetIsAlwaysSymmetric(Bool_t isAlwaysSymmetric)
00110       //{ fIsAlwaysSymmetric = isAlwaysSymmetric; }
00111 
00112       virtual ~PdfProposal()
00113       {
00114          delete fCache;
00115          if (fOwnsPdf)
00116             delete fPdf;
00117       }
00118 
00119    protected:
00120       RooAbsPdf* fPdf; // the proposal density function
00121       map<RooRealVar*, RooAbsReal*> fMap; // map of values in pdf to update
00122       map<RooRealVar*, RooAbsReal*>::iterator fIt; // pdf iterator
00123       RooArgSet fLastX; // the last point we were at
00124       Int_t fCacheSize; // how many points to generate each time
00125       Int_t fCachePosition; // our position in the cached proposal data set
00126       RooDataSet* fCache; // the cached proposal data set
00127       RooArgSet fMaster; // pointers to master variables needed for updates
00128       Bool_t fOwnsPdf; // whether we own the proposal density function
00129       //Bool_t fIsAlwaysSymmetric; // does Q(x1 | x2) == Q(x2 | x1) for all x1, x2
00130 
00131       // determine whether these two RooArgSets represent the same point
00132       virtual Bool_t Equals(RooArgSet& x1, RooArgSet& x2);
00133 
00134       // Interface for tools setting limits (producing confidence intervals)
00135       ClassDef(PdfProposal,1)
00136    };
00137 }
00138 
00139 #endif

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