Logo ROOT   6.07/09
Reference Guide
MarkovChain.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_MarkovChain
13 #define ROOSTATS_MarkovChain
14 
15 #ifndef ROOT_Rtypes
16 #include "Rtypes.h"
17 #endif
18 
19 #ifndef ROOT_TNamed
20 #include "TNamed.h"
21 #endif
22 
23 #ifndef ROO_REAL_VAR
24 #include "RooRealVar.h"
25 #endif
26 #ifndef ROO_DATA_SET
27 #include "RooDataSet.h"
28 #endif
29 #ifndef ROO_DATA_HIST
30 #include "RooDataHist.h"
31 #endif
32 #ifndef ROOT_THnSparse
33 #include "THnSparse.h"
34 #endif
35 //#include "RooArgSet.h"
36 //#include "RooMsgService.h"
37 //#include "RooRealVar.h"
38 
39 
40 namespace RooStats {
41 
42  /**
43 
44 Stores the steps in a Markov Chain of points. Allows user to access the
45 weight and NLL value (if applicable) with which a point was added to the
46 MarkovChain.
47 
48 \ingroup Roostats
49 
50 */
51 
52 
53  class MarkovChain : public TNamed {
54 
55  public:
56  MarkovChain();
57  MarkovChain(RooArgSet& parameters);
58  MarkovChain(const char* name, const char* title, RooArgSet& parameters);
59 
60  /// safely add an entry to the chain
61  virtual void Add(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
62  /// add an entry to the chain ONLY IF you have constructed with parameters
63  /// or called SetParameters
64  virtual void AddFast(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
65  /// add another markov chain
66  virtual void AddWithBurnIn(MarkovChain& otherChain, Int_t burnIn = 0);
67  /// add another markov chain
68  virtual void Add(MarkovChain& otherChain, Double_t discardEntries = 0.0);
69  /// set which of your parameters this chain should store
70  virtual void SetParameters(RooArgSet& parameters);
71  /// get the number of steps in the chain
72  virtual Int_t Size() const { return fChain ? fChain->numEntries() : 0; }
73  /// get the entry at position i
74  virtual const RooArgSet* Get(Int_t i) const { return fChain->get(i); }
75  /// get the entry at the current position
76  virtual const RooArgSet* Get() const { return fChain->get(); }
77  /// get the weight of the current (last indexed) entry
78  virtual Double_t Weight() const;
79  /// get the weight of entry at position i
80  virtual Double_t Weight(Int_t i) const;
81  /// get the NLL value of entry at position i
82  virtual Double_t NLL(Int_t i) const;
83  /// get the NLL value of the current (last indexed) entry
84  virtual Double_t NLL() const;
85 
86  /// get this MarkovChain as a RooDataSet whose entries contain the values
87  /// of whichVars. Call with whichVars = NULL (default) to get values of
88  /// all variables (including NLL value and weight);
89  /// Note: caller owns the returned data set
90  virtual RooDataSet* GetAsDataSet(RooArgSet* whichVars = NULL) const;
91 
92  /// Get a clone of the markov chain on which this interval is based
93  /// as a RooDataSet. You own the returned RooDataSet*
94  virtual RooDataSet* GetAsDataSet(const RooCmdArg& arg1,
95  const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
96  const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
97  const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
98  const RooCmdArg& arg8=RooCmdArg::none() ) const;
99 
100  virtual const RooDataSet* GetAsConstDataSet() const { return fChain; }
101 
102  /// get this MarkovChain as a RooDataHist whose entries contain the values
103  /// of whichVars. Call with whichVars = NULL (default) to get values of
104  /// all variables (including NLL value and weight);
105  /// Note: caller owns the returned data hist
106  virtual RooDataHist* GetAsDataHist(RooArgSet* whichVars = NULL) const;
107 
108  /// Get a clone of the markov chain on which this interval is based
109  /// as a RooDataHist. You own the returned RooDataHist*
110  virtual RooDataHist* GetAsDataHist(const RooCmdArg & arg1,
111  const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
112  const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
113  const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
114  const RooCmdArg& arg8=RooCmdArg::none() ) const;
115 
116  /// Get a clone of the markov chain on which this interval is based
117  /// as a sparse histogram. You own the returned THnSparse*
118  virtual THnSparse* GetAsSparseHist(RooAbsCollection* whichVars = NULL) const;
119  virtual THnSparse* GetAsSparseHist(RooAbsCollection& whichVars) const
120  { return GetAsSparseHist(&whichVars); }
121 
122  /// get a clone of the NLL variable
123  virtual RooRealVar* GetNLLVar() const
124  { return (RooRealVar*)fNLL->Clone(); }
125 
126  /// get a clone of the weight variable
127  virtual RooRealVar* GetWeightVar() const
128  { return (RooRealVar*)fWeight->Clone(); }
129 
130  virtual ~MarkovChain()
131  {
132  delete fParameters;
133  delete fDataEntry;
134  delete fChain;
135  }
136 
137  protected:
143 
145  };
146 }
147 
148 #endif
RooArgSet * fDataEntry
Definition: MarkovChain.h:139
RooArgSet * fParameters
Definition: MarkovChain.h:138
int Int_t
Definition: RtypesCore.h:41
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:50
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
#define ClassDef(name, id)
Definition: Rtypes.h:254
Efficient multidimensional histogram.
Definition: THnSparse.h:52
virtual const RooDataSet * GetAsConstDataSet() const
Definition: MarkovChain.h:100
virtual THnSparse * GetAsSparseHist(RooAbsCollection &whichVars) const
Definition: MarkovChain.h:119
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
RooDataSet * fChain
Definition: MarkovChain.h:140
virtual RooDataHist * GetAsDataHist(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataHist whose entries contain the values of whichVars.
virtual void Add(RooArgSet &entry, Double_t nllValue, Double_t weight=1.0)
safely add an entry to the chain
virtual RooDataSet * GetAsDataSet(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataSet whose entries contain the values of whichVars.
virtual void AddWithBurnIn(MarkovChain &otherChain, Int_t burnIn=0)
add another markov chain
virtual const RooArgSet * Get() const
get the entry at the current position
Definition: MarkovChain.h:76
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:37
virtual void AddFast(RooArgSet &entry, Double_t nllValue, Double_t weight=1.0)
add an entry to the chain ONLY IF you have constructed with parameters or called SetParameters ...
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:269
virtual THnSparse * GetAsSparseHist(RooAbsCollection *whichVars=NULL) const
Get a clone of the markov chain on which this interval is based as a sparse histogram.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
Stores the steps in a Markov Chain of points.
Definition: MarkovChain.h:53
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:75
virtual RooRealVar * GetNLLVar() const
get a clone of the NLL variable
Definition: MarkovChain.h:123
virtual void SetParameters(RooArgSet &parameters)
set which of your parameters this chain should store
Definition: MarkovChain.cxx:90
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects...
virtual RooRealVar * GetWeightVar() const
get a clone of the weight variable
Definition: MarkovChain.h:127
RooRealVar * fWeight
Definition: MarkovChain.h:142
#define NULL
Definition: Rtypes.h:82
virtual Int_t Size() const
get the number of steps in the chain
Definition: MarkovChain.h:72
virtual const RooArgSet * Get(Int_t i) const
get the entry at position i
Definition: MarkovChain.h:74
virtual Double_t NLL() const
get the NLL value of the current (last indexed) entry
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
char name[80]
Definition: TGX11.cxx:109
virtual Double_t Weight() const
get the weight of the current (last indexed) entry
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27