Logo ROOT  
Reference Guide
PdfProposal.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Authors: Kevin Belasco 17/06/2009
3 // Authors: Kyle Cranmer 17/06/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_PdfProposal
13 #define ROOSTATS_PdfProposal
14 
15 #include "Rtypes.h"
16 
18 
19 #include "RooArgSet.h"
20 #include "RooMsgService.h"
21 #include "RooRealVar.h"
22 #include "RooDataSet.h"
23 #include "RooAbsPdf.h"
24 
25 #include <map>
26 
27 
28 namespace RooStats {
29 
30  class PdfProposal : public ProposalFunction {
31 
32  public:
33  PdfProposal();
34  PdfProposal(RooAbsPdf& pdf);
35 
36  /// Populate xPrime with a new proposed point
37  virtual void Propose(RooArgSet& xPrime, RooArgSet& x);
38 
39  /// Determine whether or not the proposal density is symmetric for
40  /// points x1 and x2 - that is, whether the probabilty of reaching x2
41  /// from x1 is equal to the probability of reaching x1 from x2
43 
44  /// Return the probability of proposing the point x1 given the starting
45  /// point x2
47 
48  /// Set the PDF to be the proposal density function
49  virtual void SetPdf(RooAbsPdf& pdf) { fPdf = &pdf; }
50 
51  /// Get the PDF is the proposal density function
52  virtual const RooAbsPdf* GetPdf() const { return fPdf; }
53 
54  /// specify a mapping between a parameter of the proposal function and
55  /// a parameter of interest. this mapping is used to set the value of
56  /// proposalParam equal to the value of update to determine the
57  /// proposal function.
58  /// proposalParam is a parameter of the proposal function that must
59  /// be set to the value of update (from the current point) in order to
60  /// propose a new point.
61  virtual void AddMapping(RooRealVar& proposalParam, RooAbsReal& update);
62 
63  virtual void Reset()
64  {
65  delete fCache;
66  fCache = NULL;
67  fCachePosition = 0;
68  fLastX.removeAll();
69  }
70 
71  virtual void printMappings()
72  {
73  std::map<RooRealVar*, RooAbsReal*>::iterator it;
74  for (it = fMap.begin(); it != fMap.end(); it++)
75  std::cout << it->first->GetName() << " => " << it->second->GetName() << std::endl;
76  }
77 
78  /// Set how many points to generate each time we propose from a new point
79  /// Default (and minimum) is 1
80  virtual void SetCacheSize(Int_t size)
81  {
82  if (size > 0)
83  fCacheSize = size;
84  else
85  coutE(Eval) << "Warning: Requested non-positive cache size: " <<
86  size << ". Cache size unchanged." << std::endl;
87  }
88 
89  /// set whether we own the PDF that serves as the proposal density function
90  /// By default, when constructed, PdfProposal does NOT own the PDF.
91  virtual void SetOwnsPdf(Bool_t ownsPdf) { fOwnsPdf = ownsPdf; }
92 
93  //virtual void SetIsAlwaysSymmetric(Bool_t isAlwaysSymmetric)
94  //{ fIsAlwaysSymmetric = isAlwaysSymmetric; }
95 
96  virtual ~PdfProposal()
97  {
98  delete fCache;
99  if (fOwnsPdf)
100  delete fPdf;
101  }
102 
103  protected:
104  RooAbsPdf* fPdf; /// the proposal density function
105  std::map<RooRealVar*, RooAbsReal*> fMap; /// map of values in pdf to update
106  std::map<RooRealVar*, RooAbsReal*>::iterator fIt; /// pdf iterator
107  RooArgSet fLastX; /// the last point we were at
108  Int_t fCacheSize; /// how many points to generate each time
109  Int_t fCachePosition; /// our position in the cached proposal data set
110  RooDataSet* fCache; /// the cached proposal data set
111  RooArgSet fMaster; /// pointers to master variables needed for updates
112  Bool_t fOwnsPdf; /// whether we own the proposal density function
113  //Bool_t fIsAlwaysSymmetric; // does Q(x1 | x2) == Q(x2 | x1) for all x1, x2
114 
115  /// determine whether these two RooArgSets represent the same point
117 
118  /// Interface for tools setting limits (producing confidence intervals)
120  };
121 }
122 
123 #endif
RooStats::PdfProposal::fPdf
RooAbsPdf * fPdf
Definition: PdfProposal.h:116
RooStats::PdfProposal::fCachePosition
Int_t fCachePosition
how many points to generate each time
Definition: PdfProposal.h:121
RooStats::PdfProposal
Definition: PdfProposal.h:36
RooMsgService.h
RooArgSet.h
coutE
#define coutE(a)
Definition: RooMsgService.h:33
RooStats::PdfProposal::Equals
virtual Bool_t Equals(RooArgSet &x1, RooArgSet &x2)
whether we own the proposal density function
Definition: PdfProposal.cxx:100
x
Double_t x[n]
Definition: legend1.C:17
RooAbsReal
Definition: RooAbsReal.h:61
RooStats::PdfProposal::fCacheSize
Int_t fCacheSize
the last point we were at
Definition: PdfProposal.h:120
RooStats::PdfProposal::fIt
std::map< RooRealVar *, RooAbsReal * >::iterator fIt
map of values in pdf to update
Definition: PdfProposal.h:118
RooDataSet.h
bool
RooStats::PdfProposal::printMappings
virtual void printMappings()
Definition: PdfProposal.h:83
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
RooStats::PdfProposal::GetProposalDensity
virtual Double_t GetProposalDensity(RooArgSet &x1, RooArgSet &x2)
Return the probability of proposing the point x1 given the starting point x2.
Definition: PdfProposal.cxx:180
update
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
Definition: RooAdaptiveGaussKronrodIntegrator1D.cxx:652
RooStats::PdfProposal::Reset
virtual void Reset()
Definition: PdfProposal.h:75
RooStats::PdfProposal::SetOwnsPdf
virtual void SetOwnsPdf(Bool_t ownsPdf)
set whether we own the PDF that serves as the proposal density function By default,...
Definition: PdfProposal.h:103
RooAbsPdf.h
RooStats::PdfProposal::SetCacheSize
virtual void SetCacheSize(Int_t size)
Set how many points to generate each time we propose from a new point Default (and minimum) is 1.
Definition: PdfProposal.h:92
RooStats::PdfProposal::~PdfProposal
virtual ~PdfProposal()
Definition: PdfProposal.h:108
RooStats::PdfProposal::AddMapping
virtual void AddMapping(RooRealVar &proposalParam, RooAbsReal &update)
specify a mapping between a parameter of the proposal function and a parameter of interest.
Definition: PdfProposal.cxx:200
RooStats::PdfProposal::fLastX
RooArgSet fLastX
pdf iterator
Definition: PdfProposal.h:119
RooRealVar.h
RooStats::PdfProposal::Propose
virtual void Propose(RooArgSet &xPrime, RooArgSet &x)
Populate xPrime with a new proposed point.
Definition: PdfProposal.cxx:119
RooStats::PdfProposal::PdfProposal
PdfProposal()
By default, PdfProposal does NOT own the PDF that serves as the proposal density function.
Definition: PdfProposal.cxx:75
RooStats::PdfProposal::fCache
RooDataSet * fCache
our position in the cached proposal data set
Definition: PdfProposal.h:122
RooStats::PdfProposal::fOwnsPdf
Bool_t fOwnsPdf
pointers to master variables needed for updates
Definition: PdfProposal.h:124
RooStats::PdfProposal::fMap
std::map< RooRealVar *, RooAbsReal * > fMap
the proposal density function
Definition: PdfProposal.h:117
RooStats::PdfProposal::IsSymmetric
virtual Bool_t IsSymmetric(RooArgSet &x1, RooArgSet &x2)
Determine whether or not the proposal density is symmetric for points x1 and x2 - that is,...
Definition: PdfProposal.cxx:170
Double_t
double Double_t
Definition: RtypesCore.h:59
RooStats
Definition: Asimov.h:19
ProposalFunction.h
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
RooDataSet
Definition: RooDataSet.h:33
RooAbsPdf
Definition: RooAbsPdf.h:40
RooStats::PdfProposal::fMaster
RooArgSet fMaster
the cached proposal data set
Definition: PdfProposal.h:123
RooRealVar
Definition: RooRealVar.h:35
RooAbsCollection::removeAll
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Definition: RooAbsCollection.cxx:643
RooFit::Eval
@ Eval
Definition: RooGlobalFunc.h:68
RooStats::PdfProposal::SetPdf
virtual void SetPdf(RooAbsPdf &pdf)
Set the PDF to be the proposal density function.
Definition: PdfProposal.h:61
Rtypes.h
RooArgSet
Definition: RooArgSet.h:28
RooStats::PdfProposal::GetPdf
virtual const RooAbsPdf * GetPdf() const
Get the PDF is the proposal density function.
Definition: PdfProposal.h:64
int