Logo ROOT  
Reference Guide
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 #include "Rtypes.h"
18 #include "RooStats/PdfProposal.h"
19 #include "RooArgSet.h"
20 #include "RooMsgService.h"
21 #include "RooRealVar.h"
22 #include "TMatrixDSym.h"
23 #include "TObject.h"
24 
25 
26 
27 namespace RooStats {
28 
29  class ProposalHelper : public TObject {
30 
31  public:
33 
34  // Set the PDF to be the proposal density function
35  virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
36  // Set the bank of clues to add to the current proposal density function
37  virtual void SetClues(RooDataSet& clues) { fClues = &clues; }
38 
39  // Get the ProposalFunction that we've been designing
40  virtual ProposalFunction* GetProposalFunction();
41 
42  virtual void SetCacheSize(Int_t size)
43  {
44  if (size > 0)
45  fCacheSize = size;
46  else
47  coutE(Eval) << "Warning: Requested non-positive cache size: " <<
48  size << ". Cache size unchanged." << std::endl;
49  }
50 
51  virtual void SetUpdateProposalParameters(Bool_t updateParams)
52  { fUseUpdates = updateParams; }
53 
54  virtual void SetVariables(RooArgList& vars)
55  { fVars = &vars; }
56 
57  virtual void SetVariables(const RooArgList& vars)
58  { fVars = new RooArgList(vars); fOwnsVars = kTRUE; }
59 
60  // set what fraction of the proposal density function should come from
61  // a uniform proposal distribution
62  virtual void SetUniformFraction(Double_t uniFrac) { fUniFrac = uniFrac; }
63 
64  // set what fraction of the proposal density function should come from
65  // the bank of clues
66  virtual void SetCluesFraction(Double_t cluesFrac) { fCluesFrac = cluesFrac; }
67 
68  // set the covariance matrix to use for a multi-variate Gaussian proposal
69  virtual void SetCovMatrix(const TMatrixDSym& covMatrix)
70  { fCovMatrix = new TMatrixDSym(covMatrix); }
71 
72  // set what divisor we will use when dividing the range of a variable to
73  // determine the width of the proposal function for each dimension
74  // e.g. divisor = 6 for sigma = 1/6th
75  virtual void SetWidthRangeDivisor(Double_t divisor)
76  { if (divisor > 0.) fSigmaRangeDivisor = divisor; }
77 
78  // set the option string to pass to the RooNDKeysPdf constructor
79  // if the bank of clues pdf is being automatically generated by this
80  // ProposalHelper
81  virtual void SetCluesOptions(const Option_t* options)
82  { if (options != NULL) fCluesOptions = options; }
83 
84  virtual void SetVariables(RooArgSet& vars)
85  {
86  RooArgList* argList = new RooArgList(vars);
87  SetVariables(*argList);
88  fOwnsVars = kTRUE;
89  }
90 
91  virtual ~ProposalHelper()
92  {
93  if (fOwnsPdfProp) delete fPdfProp;
94  if (fOwnsPdf) delete fPdf;
95  if (fOwnsCluesPdf) delete fCluesPdf;
96  if (fOwnsVars) delete fVars;
97  delete fCovMatrix;
98  delete fUniformPdf;
99  }
100 
101  protected:
102  RooAbsPdf* fPdf; // the main proposal density function
103  RooAbsPdf* fCluesPdf; // proposal dens. func. with clues for certain points
104  RooAbsPdf* fUniformPdf; // uniform proposal dens. func.
105  RooDataSet* fClues; // data set of clues
106  TMatrixDSym* fCovMatrix; // covariance matrix for multi var gaussian pdf
107  PdfProposal* fPdfProp; // the PdfProposal we are (probably) going to return
108  RooArgList* fVars; // the RooRealVars to generate proposals for
109  Int_t fCacheSize; // for generating proposals from PDFs
110  Double_t fSigmaRangeDivisor; // range divisor to get sigma for each variable
111  Double_t fUniFrac; // what fraction of the PDF integral is uniform
112  Double_t fCluesFrac; // what fraction of the PDF integral comes from clues
113  Bool_t fOwnsPdfProp; // whether we own the PdfProposal; equivalent to:
114  // !(whether we have returned it in GetProposalFunction)
115  Bool_t fOwnsPdf; // whether we created (and own) the main pdf
116  Bool_t fOwnsCluesPdf; // whether we created (and own) the clues pdf
117  Bool_t fOwnsVars; // whether we own fVars
118  Bool_t fUseUpdates; // whether to set updates for proposal params in PdfProposal
119  const Option_t* fCluesOptions; // option string for clues RooNDKeysPdf
120 
121  void CreatePdf();
125 
127  };
128 }
129 #endif
RooStats::ProposalHelper::fCluesFrac
Double_t fCluesFrac
Definition: ProposalHelper.h:124
RooStats::ProposalHelper::fCluesPdf
RooAbsPdf * fCluesPdf
Definition: ProposalHelper.h:115
RooStats::ProposalHelper::SetPdf
virtual void SetPdf(RooAbsPdf &pdf)
Definition: ProposalHelper.h:47
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooStats::ProposalHelper::fOwnsPdf
Bool_t fOwnsPdf
Definition: ProposalHelper.h:127
RooStats::PdfProposal
Definition: PdfProposal.h:36
RooMsgService.h
UniformProposal.h
RooStats::ProposalHelper::SetVariables
virtual void SetVariables(RooArgList &vars)
Definition: ProposalHelper.h:66
RooArgSet.h
RooStats::ProposalHelper::fUniformPdf
RooAbsPdf * fUniformPdf
Definition: ProposalHelper.h:116
RooStats::ProposalHelper::CreateCluesPdf
void CreateCluesPdf()
Definition: ProposalHelper.cxx:161
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooStats::ProposalHelper::SetCluesOptions
virtual void SetCluesOptions(const Option_t *options)
Definition: ProposalHelper.h:93
RooArgList
Definition: RooArgList.h:21
RooStats::ProposalHelper::fOwnsCluesPdf
Bool_t fOwnsCluesPdf
Definition: ProposalHelper.h:128
RooStats::ProposalHelper::CreateUniformPdf
void CreateUniformPdf()
Definition: ProposalHelper.cxx:174
RooStats::ProposalHelper::SetUpdateProposalParameters
virtual void SetUpdateProposalParameters(Bool_t updateParams)
Definition: ProposalHelper.h:63
RooStats::ProposalHelper::CreatePdf
void CreatePdf()
Definition: ProposalHelper.cxx:113
TMatrixTSym
Definition: TMatrixDSymfwd.h:22
RooStats::ProposalHelper::SetCluesFraction
virtual void SetCluesFraction(Double_t cluesFrac)
Definition: ProposalHelper.h:78
RooStats::ProposalHelper::SetCacheSize
virtual void SetCacheSize(Int_t size)
Definition: ProposalHelper.h:54
bool
RooStats::ProposalHelper::fSigmaRangeDivisor
Double_t fSigmaRangeDivisor
Definition: ProposalHelper.h:122
TMatrixDSym.h
RooStats::ProposalHelper::fUniFrac
Double_t fUniFrac
Definition: ProposalHelper.h:123
RooStats::ProposalHelper
Definition: ProposalHelper.h:35
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
RooStats::ProposalHelper::ProposalHelper
ProposalHelper()
Definition: ProposalHelper.cxx:54
PdfProposal.h
RooStats::ProposalHelper::fUseUpdates
Bool_t fUseUpdates
Definition: ProposalHelper.h:130
RooStats::ProposalHelper::fPdfProp
PdfProposal * fPdfProp
Definition: ProposalHelper.h:119
RooStats::ProposalHelper::SetUniformFraction
virtual void SetUniformFraction(Double_t uniFrac)
Definition: ProposalHelper.h:74
RooRealVar.h
RooStats::ProposalHelper::fVars
RooArgList * fVars
Definition: ProposalHelper.h:120
RooStats::ProposalHelper::SetCovMatrix
virtual void SetCovMatrix(const TMatrixDSym &covMatrix)
Definition: ProposalHelper.h:81
RooStats::ProposalHelper::fCluesOptions
const Option_t * fCluesOptions
Definition: ProposalHelper.h:131
RooStats::ProposalHelper::CreateCovMatrix
void CreateCovMatrix(RooArgList &xVec)
Definition: ProposalHelper.cxx:147
RooStats::ProposalHelper::fCovMatrix
TMatrixDSym * fCovMatrix
Definition: ProposalHelper.h:118
RooStats::ProposalHelper::fCacheSize
Int_t fCacheSize
Definition: ProposalHelper.h:121
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
RooStats::ProposalHelper::fOwnsPdfProp
Bool_t fOwnsPdfProp
Definition: ProposalHelper.h:125
RooStats
Definition: Asimov.h:19
RooStats::ProposalHelper::fOwnsVars
Bool_t fOwnsVars
Definition: ProposalHelper.h:129
ProposalFunction.h
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooDataSet
Definition: RooDataSet.h:33
RooStats::ProposalHelper::SetClues
virtual void SetClues(RooDataSet &clues)
Definition: ProposalHelper.h:49
RooAbsPdf
Definition: RooAbsPdf.h:40
RooStats::ProposalHelper::SetWidthRangeDivisor
virtual void SetWidthRangeDivisor(Double_t divisor)
Definition: ProposalHelper.h:87
RooStats::ProposalHelper::fClues
RooDataSet * fClues
Definition: ProposalHelper.h:117
TMatrixDSym
TMatrixTSym< Double_t > TMatrixDSym
Definition: TMatrixDSymfwd.h:22
RooFit::Eval
@ Eval
Definition: RooGlobalFunc.h:68
RooStats::ProposalHelper::fPdf
RooAbsPdf * fPdf
Definition: ProposalHelper.h:114
Rtypes.h
RooStats::ProposalHelper::GetProposalFunction
virtual ProposalFunction * GetProposalFunction()
Definition: ProposalHelper.cxx:77
RooArgSet
Definition: RooArgSet.h:28
RooStats::ProposalHelper::~ProposalHelper
virtual ~ProposalHelper()
Definition: ProposalHelper.h:103
int