File indexing completed on 2025-12-16 10:29:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOSTATS_MarkovChain
0013 #define ROOSTATS_MarkovChain
0014
0015 #include "Rtypes.h"
0016
0017 #include "TNamed.h"
0018
0019 #include "RooRealVar.h"
0020 #include "RooDataSet.h"
0021 #include "RooDataHist.h"
0022 #include "THnSparse.h"
0023
0024 namespace RooStats {
0025
0026 class MarkovChain : public TNamed {
0027
0028 public:
0029 MarkovChain();
0030 MarkovChain(RooArgSet& parameters);
0031 MarkovChain(const char* name, const char* title, RooArgSet& parameters);
0032
0033
0034 virtual void Add(RooArgSet& entry, double nllValue, double weight = 1.0);
0035
0036
0037 virtual void AddFast(RooArgSet& entry, double nllValue, double weight = 1.0);
0038
0039 virtual void AddWithBurnIn(MarkovChain& otherChain, Int_t burnIn = 0);
0040
0041 virtual void Add(MarkovChain& otherChain, double discardEntries = 0.0);
0042
0043 virtual void SetParameters(RooArgSet& parameters);
0044
0045 virtual Int_t Size() const { return fChain ? fChain->numEntries() : 0; }
0046
0047 virtual const RooArgSet* Get(Int_t i) const { return fChain->get(i); }
0048
0049 virtual const RooArgSet* Get() const { return fChain->get(); }
0050
0051 virtual double Weight() const;
0052
0053 virtual double Weight(Int_t i) const;
0054
0055 virtual double NLL(Int_t i) const;
0056
0057 virtual double NLL() const;
0058
0059
0060
0061
0062
0063 virtual RooFit::OwningPtr<RooDataSet> GetAsDataSet(RooArgSet* whichVars = nullptr) const;
0064 virtual const RooDataSet* GetAsConstDataSet() const { return fChain; }
0065
0066
0067
0068
0069
0070 virtual RooFit::OwningPtr<RooDataHist> GetAsDataHist(RooArgSet* whichVars = nullptr) const;
0071
0072
0073
0074 virtual THnSparse* GetAsSparseHist(RooAbsCollection* whichVars = nullptr) const;
0075 virtual THnSparse* GetAsSparseHist(RooAbsCollection& whichVars) const
0076 { return GetAsSparseHist(&whichVars); }
0077
0078
0079 virtual RooRealVar* GetNLLVar() const
0080 { return (RooRealVar*)fNLL->Clone(); }
0081
0082
0083 virtual RooRealVar* GetWeightVar() const
0084 { return static_cast<RooRealVar*>(fChain->weightVar()->Clone()); }
0085
0086 ~MarkovChain() override
0087 {
0088 delete fParameters;
0089 delete fDataEntry;
0090 delete fChain;
0091 }
0092
0093 protected:
0094 RooArgSet *fParameters = nullptr;
0095 RooArgSet *fDataEntry = nullptr;
0096 RooDataSet *fChain = nullptr;
0097 RooRealVar *fNLL = nullptr;
0098
0099 ClassDefOverride(MarkovChain,2);
0100 };
0101 }
0102
0103 #endif