MarkovChain.h

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id: MarkovChain.h 35820 2010-09-28 07:42:50Z moneta $
00002 // Authors: Kevin Belasco        17/06/2009
00003 // Authors: Kyle Cranmer         17/06/2009
00004 /*************************************************************************
00005  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOSTATS_MarkovChain
00013 #define ROOSTATS_MarkovChain
00014 
00015 #ifndef ROOT_Rtypes
00016 #include "Rtypes.h"
00017 #endif
00018 
00019 #ifndef ROOT_TNamed
00020 #include "TNamed.h"
00021 #endif
00022 
00023 #ifndef ROO_REAL_VAR
00024 #include "RooRealVar.h"
00025 #endif
00026 #ifndef ROO_DATA_SET
00027 #include "RooDataSet.h"
00028 #endif
00029 #ifndef ROO_DATA_HIST
00030 #include "RooDataHist.h"
00031 #endif
00032 #ifndef ROOT_THnSparse
00033 #include "THnSparse.h"
00034 #endif
00035 //#include "RooArgSet.h"
00036 //#include "RooMsgService.h"
00037 //#include "RooRealVar.h"
00038 
00039 using namespace std;
00040 
00041 namespace RooStats {
00042 
00043    class MarkovChain : public TNamed {
00044 
00045    public:
00046       MarkovChain();
00047       MarkovChain(RooArgSet& parameters);
00048       MarkovChain(const char* name, const char* title, RooArgSet& parameters);
00049 
00050       // safely add an entry to the chain
00051       virtual void Add(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
00052       // add an entry to the chain ONLY IF you have constructed with parameters
00053       // or called SetParameters
00054       virtual void AddFast(RooArgSet& entry, Double_t nllValue, Double_t weight = 1.0);
00055       // set which of your parameters this chain should store
00056       virtual void SetParameters(RooArgSet& parameters);
00057       // get the number of steps in the chain
00058       virtual Int_t Size() const { return fChain->numEntries(); }
00059       // get the entry at position i
00060       virtual const RooArgSet* Get(Int_t i) const { return fChain->get(i); }
00061       // get the entry at the current position
00062       virtual const RooArgSet* Get() const { return fChain->get(); }
00063       // get the weight of the current (last indexed) entry
00064       virtual Double_t Weight() const;
00065       // get the weight of entry at position i
00066       virtual Double_t Weight(Int_t i) const;
00067       // get the NLL value of entry at position i
00068       virtual Double_t NLL(Int_t i) const; 
00069       // get the NLL value of the current (last indexed) entry
00070       virtual Double_t NLL() const;
00071 
00072       // get this MarkovChain as a RooDataSet whose entries contain the values
00073       // of whichVars.  Call with whichVars = NULL (default) to get values of
00074       // all variables (including NLL value and weight);
00075       // Note: caller owns the returned data set
00076       virtual RooDataSet* GetAsDataSet(RooArgSet* whichVars = NULL) const;
00077 
00078       // Get a clone of the markov chain on which this interval is based
00079       // as a RooDataSet.  You own the returned RooDataSet*
00080       virtual RooDataSet* GetAsDataSet(const RooCmdArg& arg1,
00081                                        const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
00082                                        const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
00083                                        const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
00084                                        const RooCmdArg& arg8=RooCmdArg::none() ) const; 
00085 
00086       virtual const RooDataSet* GetAsConstDataSet() const { return fChain; }
00087 
00088       // get this MarkovChain as a RooDataHist whose entries contain the values
00089       // of whichVars.  Call with whichVars = NULL (default) to get values of
00090       // all variables (including NLL value and weight);
00091       // Note: caller owns the returned data hist
00092       virtual RooDataHist* GetAsDataHist(RooArgSet* whichVars = NULL) const;
00093 
00094       // Get a clone of the markov chain on which this interval is based
00095       // as a RooDataHist.  You own the returned RooDataHist*
00096       virtual RooDataHist* GetAsDataHist(const RooCmdArg & arg1,
00097                                          const RooCmdArg& arg2=RooCmdArg::none(), const RooCmdArg& arg3=RooCmdArg::none(),
00098                                          const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
00099                                          const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(),
00100                                          const RooCmdArg& arg8=RooCmdArg::none() ) const; 
00101 
00102       // Get a clone of the markov chain on which this interval is based
00103       // as a sparse histogram.  You own the returned THnSparse*
00104       virtual THnSparse* GetAsSparseHist(RooAbsCollection* whichVars = NULL) const;
00105       virtual THnSparse* GetAsSparseHist(RooAbsCollection& whichVars) const
00106       { return GetAsSparseHist(&whichVars); }
00107 
00108       // get a clone of the NLL variable
00109       virtual RooRealVar* GetNLLVar() const
00110       { return (RooRealVar*)fNLL->Clone(); }
00111 
00112       // get a clone of the weight variable
00113       virtual RooRealVar* GetWeightVar() const
00114       { return (RooRealVar*)fWeight->Clone(); }
00115 
00116       virtual ~MarkovChain()
00117       {
00118          delete fParameters;
00119          delete fDataEntry;
00120          delete fChain;
00121       }
00122 
00123    protected:
00124       RooArgSet * fParameters;
00125       RooArgSet * fDataEntry;
00126       RooDataSet* fChain;
00127       RooRealVar* fNLL;
00128       RooRealVar* fWeight;
00129 
00130       ClassDef(MarkovChain,1);
00131    };
00132 }
00133 
00134 #endif

Generated on Tue Jul 5 14:26:24 2011 for ROOT_528-00b_version by  doxygen 1.5.1