BAT  0.9.4
The Bayesian analysis toolkit
 All Classes Namespaces Functions Variables Enumerations
BCFitter.h
1 #ifndef __BCFITTER__H
2 #define __BCFITTER__H
3 
13 /*
14  * Copyright (C) 2007-2014, the BAT core developer team
15  * All rights reserved.
16  *
17  * For the licensing terms see doc/COPYING.
18  * For documentation see http://mpp.mpg.de/bat
19  */
20 
21 // ---------------------------------------------------------
22 
23 #include "../../BAT/BCModel.h"
24 
25 // ---------------------------------------------------------
26 
27 class BCFitter : public BCModel
28 {
29  public:
30 
32  /* @{ */
33 
36  BCFitter();
37 
41  BCFitter(const char * name);
42 
45  ~BCFitter();
46 
47  /* @} */
48 
50  /* @{ */
51 
54  TGraph * GetErrorBand()
55  { return fErrorBand; };
56 
60  TH2D * GetErrorBandXY() const
61  { return fErrorBandXY; }
62 
63  TH2D * GetErrorBandXY_yellow(double level=.68, int nsmooth=0) const;
64 
69  std::vector<double> GetErrorBand(double level) const;
70 
71  TGraph * GetErrorBandGraph(double level1, double level2) const;
72 
73  TGraph * GetFitFunctionGraph(const std::vector<double> &parameters);
74 
75  TGraph * GetFitFunctionGraph()
76  { return GetFitFunctionGraph(GetBestFitParameters()); }
77 
78  TGraph * GetFitFunctionGraph(const std::vector<double> &parameters, double xmin, double xmax, int n=1000);
79 
80  void FixDataAxis(unsigned int index, bool fixed);
81 
82  bool GetFixedDataAxis(unsigned int index) const;
83 
84  /* @} */
85 
87  /* @{ */
88 
92  void SetFillErrorBand(bool flag = true)
93  { fFlagFillErrorBand=flag; }
94 
97  void SetErrorBandHisto(TH2D * h)
98  { fErrorBandXY = h; }
99 
104  { fFlagFillErrorBand=false; }
105 
109  void SetFitFunctionIndexX(int index)
110  { fFitFunctionIndexX = index; }
111 
115  void SetFitFunctionIndexY(int index)
116  { fFitFunctionIndexY = index; }
117 
122  void SetFitFunctionIndices(int indexx, int indexy)
123  { SetFitFunctionIndexX(indexx);
124  SetFitFunctionIndexY(indexy); }
125 
128  void SetErrorBandContinuous(bool flag);
129 
135  virtual double FitFunction(const std::vector<double> &/*x*/, const std::vector<double> &/*parameters*/)
136  { return 0; }
137 
138  /* @} */
140  /* @{ */
141 
144  int ReadErrorBandFromFile(const char * file);
145 
149  virtual int Fit() = 0;
150 
153  virtual void DrawFit(const char * options, bool flaglegend = false) = 0;
154 
157  void MCMCIterationInterface();
158 
161  void MarginalizePreprocess();
162 
166  {;};
167 
170  void FillErrorBand();
171 
172  /* @} */
173 
174  private:
175 
178  TGraph * fErrorBand;
179 
182  bool fFlagFillErrorBand;
183 
186  int fFitFunctionIndexX;
187  int fFitFunctionIndexY;
188 
191  bool fErrorBandContinuous;
192  std::vector<double> fErrorBandX;
193 
196  unsigned fErrorBandNbinsX;
197 
200  unsigned fErrorBandNbinsY;
201 
202  protected:
203 
206  TH2D * fErrorBandXY;
207 
208 };
209 
210 // ---------------------------------------------------------
211 
212 #endif
TH2D * GetErrorBandXY() const
Definition: BCFitter.h:60
virtual double FitFunction(const std::vector< double > &, const std::vector< double > &)
Definition: BCFitter.h:135
virtual void DrawFit(const char *options, bool flaglegend=false)=0
TH2D * fErrorBandXY
Definition: BCFitter.h:206
void MarginalizePreprocess()
Definition: BCFitter.cxx:69
void UnsetFillErrorBand()
Definition: BCFitter.h:103
The base class for all user-defined models.
Definition: BCModel.h:50
void SetFitFunctionIndices(int indexx, int indexy)
Definition: BCFitter.h:122
int ReadErrorBandFromFile(const char *file)
Definition: BCFitter.cxx:297
virtual int Fit()=0
void FillErrorBand()
Definition: BCFitter.cxx:102
void SetErrorBandContinuous(bool flag)
Definition: BCFitter.cxx:352
void MCMCIterationInterface()
Definition: BCFitter.cxx:58
void SetFitFunctionIndexY(int index)
Definition: BCFitter.h:115
void SetErrorBandHisto(TH2D *h)
Definition: BCFitter.h:97
void MarginalizePostprocess()
Definition: BCFitter.h:165
void SetFitFunctionIndexX(int index)
Definition: BCFitter.h:109
TGraph * GetErrorBand()
Definition: BCFitter.h:54
void SetFillErrorBand(bool flag=true)
Definition: BCFitter.h:92
BCFitter()
Definition: BCFitter.cxx:25
A base class for all fitting classes.
Definition: BCFitter.h:27
~BCFitter()
Definition: BCFitter.cxx:53