BayesianAnalysisToolkit  0.9.3
BCRooInterface.h
Go to the documentation of this file.
1 #ifndef __BCROOINTERFACE__H
2 #define __BCROOINTERFACE__H
3 
4 #include "../../BAT/BCModel.h"
5 
6 #include <RooStats/MarkovChain.h>
7 #include <RooRealVar.h>
8 
9 #include <list>
10 #include <utility>
11 
12 class RooAbsReal;
13 class RooAbsData;
14 class RooAbsPdf;
15 class RooArgSet;
16 class RooArgList;
17 
18 /* ---------------------------------------------------------
19  * interface allowing to run BAT on a problem/data defined in a
20  * standard RooFit workspace format
21  * --------------------------------------------------------- */
22 
23 class BCRooInterface : public BCModel
24 {
25 
26  public:
27 
28  BCRooInterface( const char* name = "", bool fillChain = false );
29 
31 
32  // Overloaded methods
33  void DefineParameters();
34  double LogAPrioriProbability(const std::vector<double> & parameters);
35  double LogLikelihood(const std::vector<double> &parameters);
36 
37  // Other method of this class
38  void Initialize( RooAbsData& data,
39  RooAbsPdf& model,
40  RooAbsPdf& prior,
41  const RooArgSet* params,
42  const RooArgSet& listPOI );
43 
44  void Initialize( const char* rootFile,
45  const char* wsName = "batWS",
46  const char* dataName = "data",
47  const char* modelName = "model",
48  const char* priorName = "priorPOI",
49  const char* priorNuisanceName= "priorNuisance",
50  const char* paramsName = "parameters",
51  const char* listPOIName = "POI" );
52 
53  //set the number of histogram bins for a specific parameter
54  void SetNumBins(const char * parname, int nbins);
55  //set the number of histogram bins for all parameters
56  void SetNumBins(int nbins);
57  //setup RooStats Markov Chain
59  //overloaded function from BCIntegrate to fill RooStats Markov Chain with every accepted step
61  //return the RooStats Markov Chain (empty if corresponding constructor option not set)
62  RooStats::MarkovChain * GetRooStatsMarkovChain(){ return _roostatsMarkovChain;}
64  //RooArgSet GetArgSetForMarkovChainTest(){return _parametersForMarkovChain_test;}
65 
66 
67  private:
68 
69  void AddToCurrentChainElement(double xij, int chainNum, int poiNum); //help function for construction of RooStats Markov Chain
70  bool EqualsLastChainElement(int chainNum); //help function for construction of RooStats Markov Chain
71  double GetWeightForChain(int chainNum); //help function for construction of RooStats Markov Chain
72 
73  RooAbsData* fData; // data to test
74  RooAbsPdf* fModel; // likelihood model describing the observables
75  RooAbsReal* fNll; // pointer to negative log-likelihood function
76  RooArgSet* fObservables; // list of observables measured for each event
77  RooArgList* fParams; // list of parameters
78  RooArgList* fParamsPOI; // list of parameters of interest
79  RooAbsPdf* fPrior; // function describing the prior probability of the parameters
81 
82  RooRealVar* priorhelpvar;
84 
85  bool _fillChain; //decides if a RooStats Markov Chain is constructed along the way
86  bool fFirstComparison; // checks if it is the first chain step (bookkeeping required for construction of the RooStats MarkovChain object)
87  RooStats::MarkovChain * _roostatsMarkovChain;
88  RooArgSet _parametersForMarkovChainPrevious; // parameters of interest in previous step (bookkeeping required for construction of the RooStats MarkovChain object)
89  RooArgSet _parametersForMarkovChainCurrent; // parameters of interest in previous step (bookkeeping required for construction of the RooStats MarkovChain object)
90 
91  std::vector< std::vector<double> > fPreviousStep; // bookkeeping required for construction of the RooStats MarkovChain object
92  std::vector< std::vector<double> > fCurrentStep; // bookkeeping required for construction of the RooStats MarkovChain object
93  std::vector< double > fVecWeights; // keep track of weights if proposal step not accepted (bookkeeping required for construction of the RooStats MarkovChain object)
94 
95  std::list< std::pair<const char*,int> > _nbins_list;
96 };
97 
98 #endif