ProposalHelper.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: ProposalHelper.h 31276 2009-11-18 15:06:42Z moneta $
00002 // Authors: Kevin Belasco        7/22/2009
00003 // Authors: Kyle Cranmer         7/22/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_ProposalHelper
00013 #define RooStats_ProposalHelper
00014 
00015 #ifndef ROOT_Rtypes
00016 #include "Rtypes.h"
00017 #endif
00018 #ifndef ROOSTATS_ProposalFunction
00019 #include "RooStats/ProposalFunction.h"
00020 #endif
00021 #ifndef ROOSTATS_UniformProposal
00022 #include "RooStats/UniformProposal.h"
00023 #endif
00024 #ifndef ROOSTATS_PdfProposal
00025 #include "RooStats/PdfProposal.h"
00026 #endif
00027 #ifndef ROO_ARG_SET
00028 #include "RooArgSet.h"
00029 #endif
00030 #ifndef ROO_MSG_SERVICE
00031 #include "RooMsgService.h"
00032 #endif
00033 #ifndef ROO_REAL_VAR
00034 #include "RooRealVar.h"
00035 #endif
00036 #ifndef ROOT_TObject
00037 #include "TObject.h"
00038 #endif
00039 
00040 #include <map>
00041 
00042 using namespace std;
00043 
00044 namespace RooStats {
00045 
00046    class ProposalHelper : public TObject {
00047 
00048    public:
00049       ProposalHelper();
00050 
00051       // Set the PDF to be the proposal density function
00052       virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
00053       // Set the bank of clues to add to the current proposal density function
00054       virtual void SetClues(RooDataSet& clues) { fClues = &clues; }
00055 
00056       // Get the ProposalFunction that we've been designing
00057       virtual ProposalFunction* GetProposalFunction();
00058 
00059       virtual void SetCacheSize(Int_t size)
00060       {
00061          if (size > 0)
00062             fCacheSize = size;
00063          else
00064             coutE(Eval) << "Warning: Requested non-positive cache size: " <<
00065                            size << ". Cache size unchanged." << endl;
00066       }
00067 
00068       virtual void SetUpdateProposalParameters(Bool_t updateParams)
00069       { fUseUpdates = updateParams; }
00070 
00071       virtual void SetVariables(RooArgList& vars)
00072       { fVars = &vars; }
00073 
00074       virtual void SetVariables(const RooArgList& vars)
00075       { fVars = new RooArgList(vars); fOwnsVars = kTRUE; }
00076 
00077       // set what fraction of the proposal density function should come from
00078       // a uniform proposal distribution
00079       virtual void SetUniformFraction(Double_t uniFrac) { fUniFrac = uniFrac; }
00080 
00081       // set what fraction of the proposal density function should come from
00082       // the bank of clues
00083       virtual void SetCluesFraction(Double_t cluesFrac) { fCluesFrac = cluesFrac; }
00084 
00085       // set the covariance matrix to use for a multi-variate Gaussian proposal
00086       virtual void SetCovMatrix(const TMatrixDSym& covMatrix)
00087       { fCovMatrix = new TMatrixDSym(covMatrix); }
00088 
00089       // set what divisor we will use when dividing the range of a variable to
00090       // determine the width of the proposal function for each dimension
00091       // e.g. divisor = 6 for sigma = 1/6th
00092       virtual void SetWidthRangeDivisor(Double_t divisor)
00093       { if (divisor > 0.) fSigmaRangeDivisor = divisor; }
00094 
00095       // set the option string to pass to the RooNDKeysPdf constructor
00096       // if the bank of clues pdf is being automatically generated by this
00097       // ProposalHelper
00098       virtual void SetCluesOptions(const Option_t* options)
00099       { if (options != NULL) fCluesOptions = options; }
00100 
00101       virtual void SetVariables(RooArgSet& vars)
00102       {
00103          RooArgList* argList = new RooArgList(vars);
00104          SetVariables(*argList);
00105          fOwnsVars = kTRUE;
00106       }
00107 
00108       virtual ~ProposalHelper()
00109       {
00110          if (fOwnsPdfProp)      delete fPdfProp;
00111          if (fOwnsPdf)          delete fPdf;
00112          if (fOwnsCluesPdf)     delete fCluesPdf;
00113          if (fOwnsVars)         delete fVars;
00114          delete fCovMatrix;
00115          delete fUniformPdf;
00116       }
00117 
00118    protected:
00119       RooAbsPdf* fPdf; // the main proposal density function
00120       RooAbsPdf* fCluesPdf; // proposal dens. func. with clues for certain points
00121       RooAbsPdf* fUniformPdf; // uniform proposal dens. func.
00122       RooDataSet* fClues; // data set of clues
00123       TMatrixDSym* fCovMatrix; // covariance matrix for multi var gaussian pdf
00124       PdfProposal* fPdfProp; // the PdfProposal we are (probably) going to return
00125       RooArgList* fVars; // the RooRealVars to generate proposals for
00126       Int_t fCacheSize; // for generating proposals from PDFs
00127       Double_t fSigmaRangeDivisor; // range divisor to get sigma for each variable
00128       Double_t fUniFrac; // what fraction of the PDF integral is uniform
00129       Double_t fCluesFrac; // what fraction of the PDF integral comes from clues
00130       Bool_t fOwnsPdfProp; // whether we own the PdfProposal; equivalent to:
00131                            // !(whether we have returned it in GetProposalFunction)
00132       Bool_t fOwnsPdf; // whether we created (and own) the main pdf
00133       Bool_t fOwnsCluesPdf; // whether we created (and own) the clues pdf
00134       Bool_t fOwnsVars; // whether we own fVars
00135       Bool_t fUseUpdates; // whether to set updates for proposal params in PdfProposal
00136       const Option_t* fCluesOptions; // option string for clues RooNDKeysPdf
00137 
00138       void CreatePdf();
00139       void CreateCluesPdf();
00140       void CreateUniformPdf();
00141       void CreateCovMatrix(RooArgList& xVec);
00142 
00143       ClassDef(ProposalHelper,1)
00144    };
00145 }
00146 #endif

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