Logo ROOT  
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 #include "Rtypes.h"
16 
17 #include "TNamed.h"
18 
19 #include "RooRealVar.h"
20 #include "RooDataSet.h"
21 #include "RooDataHist.h"
22 #include "THnSparse.h"
23 //#include "RooArgSet.h"
24 //#include "RooMsgService.h"
25 //#include "RooRealVar.h"
26 
27 
28 namespace RooStats {
29 
30  class MarkovChain : public TNamed {
31 
32  public:
33  MarkovChain();
34  MarkovChain(RooArgSet& parameters);
35  MarkovChain(const char* name, const char* title, RooArgSet& parameters);
36 
37  /// safely add an entry to the chain
38  virtual void Add(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
39  /// add an entry to the chain ONLY IF you have constructed with parameters
40  /// or called SetParameters
41  virtual void AddFast(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
42  /// add another markov chain
43  virtual void AddWithBurnIn(MarkovChain& otherChain, Int_t burnIn = 0);
44  /// add another markov chain
45  virtual void Add(MarkovChain& otherChain, Double_t discardEntries = 0.0);
46  /// set which of your parameters this chain should store
47  virtual void SetParameters(RooArgSet& parameters);
48  /// get the number of steps in the chain
49  virtual Int_t Size() const { return fChain ? fChain->numEntries() : 0; }
50  /// get the entry at position i
51  virtual const RooArgSet* Get(Int_t i) const { return fChain->get(i); }
52  /// get the entry at the current position
53  virtual const RooArgSet* Get() const { return fChain->get(); }
54  /// get the weight of the current (last indexed) entry
55  virtual Double_t Weight() const;
56  /// get the weight of entry at position i
57  virtual Double_t Weight(Int_t i) const;
58  /// get the NLL value of entry at position i
59  virtual Double_t NLL(Int_t i) const;
60  /// get the NLL value of the current (last indexed) entry
61  virtual Double_t NLL() const;
62 
63  /// get this MarkovChain as a RooDataSet whose entries contain the values
64  /// of whichVars. Call with whichVars = NULL (default) to get values of
65  /// all variables (including NLL value and weight);
66  /// Note: caller owns the returned data set
67  virtual RooDataSet* GetAsDataSet(RooArgSet* whichVars = NULL) const;
68 
69  /// Get a clone of the markov chain on which this interval is based
70  /// as a RooDataSet. You own the returned RooDataSet*
71  virtual RooDataSet* GetAsDataSet(const RooCmdArg& arg1,
72  const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
73  const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
74  const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
75  const RooCmdArg& arg8=RooCmdArg::none() ) const;
76 
77  virtual const RooDataSet* GetAsConstDataSet() const { return fChain; }
78 
79  /// get this MarkovChain as a RooDataHist whose entries contain the values
80  /// of whichVars. Call with whichVars = NULL (default) to get values of
81  /// all variables (including NLL value and weight);
82  /// Note: caller owns the returned data hist
83  virtual RooDataHist* GetAsDataHist(RooArgSet* whichVars = NULL) const;
84 
85  /// Get a clone of the markov chain on which this interval is based
86  /// as a RooDataHist. You own the returned RooDataHist*
87  virtual RooDataHist* GetAsDataHist(const RooCmdArg & arg1,
88  const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
89  const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
90  const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
91  const RooCmdArg& arg8=RooCmdArg::none() ) const;
92 
93  /// Get a clone of the markov chain on which this interval is based
94  /// as a sparse histogram. You own the returned THnSparse*
95  virtual THnSparse* GetAsSparseHist(RooAbsCollection* whichVars = NULL) const;
96  virtual THnSparse* GetAsSparseHist(RooAbsCollection& whichVars) const
97  { return GetAsSparseHist(&whichVars); }
98 
99  /// get a clone of the NLL variable
100  virtual RooRealVar* GetNLLVar() const
101  { return (RooRealVar*)fNLL->Clone(); }
102 
103  /// get a clone of the weight variable
104  virtual RooRealVar* GetWeightVar() const
105  { return (RooRealVar*)fWeight->Clone(); }
106 
107  virtual ~MarkovChain()
108  {
109  delete fParameters;
110  delete fDataEntry;
111  delete fChain;
112  }
113 
114  protected:
118  RooRealVar* fNLL;
120 
122  };
123 }
124 
125 #endif
RooAbsArg::Clone
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:85
RooCmdArg
Definition: RooCmdArg.h:27
RooStats::MarkovChain::Get
virtual const RooArgSet * Get() const
get the entry at the current position
Definition: MarkovChain.h:65
RooStats::MarkovChain::Size
virtual Int_t Size() const
get the number of steps in the chain
Definition: MarkovChain.h:61
RooStats::MarkovChain::fDataEntry
RooArgSet * fDataEntry
Definition: MarkovChain.h:128
TNamed.h
RooStats::MarkovChain
Definition: MarkovChain.h:36
RooStats::MarkovChain::GetAsDataHist
virtual RooDataHist * GetAsDataHist(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataHist whose entries contain the values of whichVars.
Definition: MarkovChain.cxx:182
RooStats::MarkovChain::MarkovChain
MarkovChain()
Definition: MarkovChain.cxx:45
RooStats::MarkovChain::fParameters
RooArgSet * fParameters
Definition: MarkovChain.h:127
RooCmdArg::none
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:52
RooDataSet.h
RooStats::MarkovChain::GetAsSparseHist
virtual THnSparse * GetAsSparseHist(RooAbsCollection *whichVars=NULL) const
Get a clone of the markov chain on which this interval is based as a sparse histogram.
Definition: MarkovChain.cxx:213
RooDataSet::get
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
Definition: RooDataSet.cxx:1038
THnSparse
Definition: THnSparse.h:36
RooStats::MarkovChain::fChain
RooDataSet * fChain
Definition: MarkovChain.h:129
RooDataHist
Definition: RooDataHist.h:39
RooStats::MarkovChain::GetAsConstDataSet
virtual const RooDataSet * GetAsConstDataSet() const
Definition: MarkovChain.h:89
RooStats::MarkovChain::AddFast
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
Definition: MarkovChain.cxx:145
RooStats::MarkovChain::fNLL
RooRealVar * fNLL
Definition: MarkovChain.h:130
TNamed
Definition: TNamed.h:29
RooDataHist.h
RooStats::MarkovChain::Add
virtual void Add(RooArgSet &entry, Double_t nllValue, Double_t weight=1.0)
safely add an entry to the chain
Definition: MarkovChain.cxx:102
RooAbsCollection
Definition: RooAbsCollection.h:30
RooStats::MarkovChain::~MarkovChain
virtual ~MarkovChain()
Definition: MarkovChain.h:119
RooAbsData::numEntries
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:307
RooStats::MarkovChain::AddWithBurnIn
virtual void AddWithBurnIn(MarkovChain &otherChain, Int_t burnIn=0)
add another markov chain
Definition: MarkovChain.cxx:114
RooStats::MarkovChain::Weight
virtual Double_t Weight() const
get the weight of the current (last indexed) entry
Definition: MarkovChain.cxx:279
RooRealVar.h
RooStats::MarkovChain::fWeight
RooRealVar * fWeight
Definition: MarkovChain.h:131
RooStats::MarkovChain::NLL
virtual Double_t NLL() const
get the NLL value of the current (last indexed) entry
Definition: MarkovChain.cxx:271
RooStats::MarkovChain::GetAsDataSet
virtual RooDataSet * GetAsDataSet(RooArgSet *whichVars=NULL) const
get this MarkovChain as a RooDataSet whose entries contain the values of whichVars.
Definition: MarkovChain.cxx:155
RooStats::MarkovChain::SetParameters
virtual void SetParameters(RooArgSet &parameters)
set which of your parameters this chain should store
Definition: MarkovChain.cxx:77
THnSparse.h
Double_t
double Double_t
Definition: RtypesCore.h:59
RooStats::MarkovChain::GetNLLVar
virtual RooRealVar * GetNLLVar() const
get a clone of the NLL variable
Definition: MarkovChain.h:112
RooStats
Definition: Asimov.h:19
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
RooDataSet
Definition: RooDataSet.h:33
RooRealVar
Definition: RooRealVar.h:35
RooStats::MarkovChain::GetWeightVar
virtual RooRealVar * GetWeightVar() const
get a clone of the weight variable
Definition: MarkovChain.h:116
Rtypes.h
RooArgSet
Definition: RooArgSet.h:28
int