ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProposalHelper.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Authors: Kevin Belasco 7/22/2009
3 // Authors: Kyle Cranmer 7/22/2009
4 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef RooStats_ProposalHelper
13 #define RooStats_ProposalHelper
14 
15 #ifndef ROOT_Rtypes
16 #include "Rtypes.h"
17 #endif
18 #ifndef ROOSTATS_ProposalFunction
20 #endif
21 #ifndef ROOSTATS_UniformProposal
23 #endif
24 #ifndef ROOSTATS_PdfProposal
25 #include "RooStats/PdfProposal.h"
26 #endif
27 #ifndef ROO_ARG_SET
28 #include "RooArgSet.h"
29 #endif
30 #ifndef ROO_MSG_SERVICE
31 #include "RooMsgService.h"
32 #endif
33 #ifndef ROO_REAL_VAR
34 #include "RooRealVar.h"
35 #endif
36 #ifndef ROOT_TObject
37 #include "TObject.h"
38 #endif
39 
40 
41 
42 namespace RooStats {
43 
44  class ProposalHelper : public TObject {
45 
46  public:
48 
49  // Set the PDF to be the proposal density function
50  virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
51  // Set the bank of clues to add to the current proposal density function
52  virtual void SetClues(RooDataSet& clues) { fClues = &clues; }
53 
54  // Get the ProposalFunction that we've been designing
56 
57  virtual void SetCacheSize(Int_t size)
58  {
59  if (size > 0)
60  fCacheSize = size;
61  else
62  coutE(Eval) << "Warning: Requested non-positive cache size: " <<
63  size << ". Cache size unchanged." << std::endl;
64  }
65 
66  virtual void SetUpdateProposalParameters(Bool_t updateParams)
67  { fUseUpdates = updateParams; }
68 
69  virtual void SetVariables(RooArgList& vars)
70  { fVars = &vars; }
71 
72  virtual void SetVariables(const RooArgList& vars)
73  { fVars = new RooArgList(vars); fOwnsVars = kTRUE; }
74 
75  // set what fraction of the proposal density function should come from
76  // a uniform proposal distribution
77  virtual void SetUniformFraction(Double_t uniFrac) { fUniFrac = uniFrac; }
78 
79  // set what fraction of the proposal density function should come from
80  // the bank of clues
81  virtual void SetCluesFraction(Double_t cluesFrac) { fCluesFrac = cluesFrac; }
82 
83  // set the covariance matrix to use for a multi-variate Gaussian proposal
84  virtual void SetCovMatrix(const TMatrixDSym& covMatrix)
85  { fCovMatrix = new TMatrixDSym(covMatrix); }
86 
87  // set what divisor we will use when dividing the range of a variable to
88  // determine the width of the proposal function for each dimension
89  // e.g. divisor = 6 for sigma = 1/6th
90  virtual void SetWidthRangeDivisor(Double_t divisor)
91  { if (divisor > 0.) fSigmaRangeDivisor = divisor; }
92 
93  // set the option string to pass to the RooNDKeysPdf constructor
94  // if the bank of clues pdf is being automatically generated by this
95  // ProposalHelper
96  virtual void SetCluesOptions(const Option_t* options)
97  { if (options != NULL) fCluesOptions = options; }
98 
99  virtual void SetVariables(RooArgSet& vars)
100  {
101  RooArgList* argList = new RooArgList(vars);
102  SetVariables(*argList);
103  fOwnsVars = kTRUE;
104  }
105 
106  virtual ~ProposalHelper()
107  {
108  if (fOwnsPdfProp) delete fPdfProp;
109  if (fOwnsPdf) delete fPdf;
110  if (fOwnsCluesPdf) delete fCluesPdf;
111  if (fOwnsVars) delete fVars;
112  delete fCovMatrix;
113  delete fUniformPdf;
114  }
115 
116  protected:
117  RooAbsPdf* fPdf; // the main proposal density function
118  RooAbsPdf* fCluesPdf; // proposal dens. func. with clues for certain points
119  RooAbsPdf* fUniformPdf; // uniform proposal dens. func.
120  RooDataSet* fClues; // data set of clues
121  TMatrixDSym* fCovMatrix; // covariance matrix for multi var gaussian pdf
122  PdfProposal* fPdfProp; // the PdfProposal we are (probably) going to return
123  RooArgList* fVars; // the RooRealVars to generate proposals for
124  Int_t fCacheSize; // for generating proposals from PDFs
125  Double_t fSigmaRangeDivisor; // range divisor to get sigma for each variable
126  Double_t fUniFrac; // what fraction of the PDF integral is uniform
127  Double_t fCluesFrac; // what fraction of the PDF integral comes from clues
128  Bool_t fOwnsPdfProp; // whether we own the PdfProposal; equivalent to:
129  // !(whether we have returned it in GetProposalFunction)
130  Bool_t fOwnsPdf; // whether we created (and own) the main pdf
131  Bool_t fOwnsCluesPdf; // whether we created (and own) the clues pdf
132  Bool_t fOwnsVars; // whether we own fVars
133  Bool_t fUseUpdates; // whether to set updates for proposal params in PdfProposal
134  const Option_t* fCluesOptions; // option string for clues RooNDKeysPdf
135 
136  void CreatePdf();
137  void CreateCluesPdf();
138  void CreateUniformPdf();
139  void CreateCovMatrix(RooArgList& xVec);
140 
142  };
143 }
144 #endif
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
#define coutE(a)
Definition: RooMsgService.h:35
virtual void SetClues(RooDataSet &clues)
const char Option_t
Definition: RtypesCore.h:62
virtual ProposalFunction * GetProposalFunction()
virtual void SetUpdateProposalParameters(Bool_t updateParams)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetCluesFraction(Double_t cluesFrac)
virtual void SetVariables(const RooArgList &vars)
#define ClassDef(name, id)
Definition: Rtypes.h:254
const Option_t * fCluesOptions
virtual void SetWidthRangeDivisor(Double_t divisor)
virtual void SetCacheSize(Int_t size)
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
virtual void SetUniformFraction(Double_t uniFrac)
double Double_t
Definition: RtypesCore.h:55
TMatrixTSym< Double_t > TMatrixDSym
virtual void SetPdf(RooAbsPdf &pdf)
PdfProposal is a concrete implementation of the ProposalFunction interface.
Definition: PdfProposal.h:85
virtual void SetCovMatrix(const TMatrixDSym &covMatrix)
Mother of all ROOT objects.
Definition: TObject.h:58
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
virtual void SetVariables(RooArgSet &vars)
#define NULL
Definition: Rtypes.h:82
virtual void SetCluesOptions(const Option_t *options)
void CreateCovMatrix(RooArgList &xVec)
virtual void SetVariables(RooArgList &vars)
const Bool_t kTRUE
Definition: Rtypes.h:91