BCEfficiencyFitter.h
1 #ifndef __BCEFFICIENCYFITTER__H
2 #define __BCEFFICIENCYFITTER__H
3 
18 /*
19  * Copyright (C) 2007-2018, the BAT core developer team
20  * All rights reserved.
21  *
22  * For the licensing terms see doc/COPYING.
23  * For documentation see http://mpp.mpg.de/bat
24  */
25 
26 // ---------------------------------------------------------
27 
28 #include "BCFitter.h"
29 
30 #include <TH1D.h>
31 
32 #include <vector>
33 
34 // ROOT classes
35 class TGraphAsymmErrors;
36 
37 // ---------------------------------------------------------
38 
40 {
41 public:
42 
50  };
51 
60  {
61  public:
67  virtual void operator()(const std::vector<double>& expectation, const std::vector<unsigned>& toyData) = 0;
68 
71  { }
72  };
73 
75  /* @{ */
76 
83  BCEfficiencyFitter(const TH1& trials, const TH1& successes, const TF1& func, const std::string& name = "efficiency_fitter_model");
84 
87  virtual ~BCEfficiencyFitter();
88 
89  /* @} */
91  /* @{ */
92 
95  TH1& GetTrials()
96  { return fTrials; };
97 
101  { return fSuccesses; };
102 
112  bool GetUncertainties(int n, int k, double p, double& xexp, double& xmin, double& xmax);
113 
114  /* @} */
116  /* @{ */
117 
120  { fDataPointType = type; }
121 
122  /* @} */
124  /* @{ */
125 
129  // virtual double LogAPrioriProbability(const std::vector<double> & parameters);
130 
134  virtual double LogLikelihood(const std::vector<double>& parameters);
135 
139  virtual void Fit();
140 
143  virtual void DrawData(bool flaglegend = false);
144 
147  virtual void DrawFit(const std::string& options = "", bool flaglegend = false);
148 
158  double CalculatePValueFast(const std::vector<double>& par, BCEfficiencyFitter::ToyDataInterface* callback, unsigned nIterations = 100000);
159 
165  double CalculatePValueFast(const std::vector<double>& par, unsigned nIterations = 100000);
166 
167  /* @} */
168 
169 private:
172  TH1D fTrials;
173 
176  TH1D fSuccesses;
177 
180  TH1D fHistogramBinomial;
181 
183  DataPointType fDataPointType;
184 };
185 
186 // ---------------------------------------------------------
187 
188 #endif
virtual ~BCEfficiencyFitter()
The default destructor.
virtual void DrawData(bool flaglegend=false)
Draw the data in the current pad.
double CalculatePValueFast(const std::vector< double > &par, BCEfficiencyFitter::ToyDataInterface *callback, unsigned nIterations=100000)
Calculate the p-value using fast-MCMC.
Draw mean and standard deviation.
Draw mean and central 68% interval.
virtual ~ToyDataInterface()
pure abstract
A class for fitting histograms with functions.
bool GetUncertainties(int n, int k, double p, double &xexp, double &xmin, double &xmax)
Calculates the central value and the lower and upper limits for a given probability.
virtual void Fit()
Performs the fit.
virtual void DrawFit(const std::string &options="", bool flaglegend=false)
Draw the fit in the current pad.
Draw mean and smallest 68% interval.
void SetDataPointType(DataPointType type)
Set type of point to be used to plot the efficiency data.
A base class for all fitting classes.
Definition: BCFitter.h:31
BCEfficiencyFitter(const TH1 &trials, const TH1 &successes, const TF1 &func, const std::string &name="efficiency_fitter_model")
Constructor.
virtual double LogLikelihood(const std::vector< double > &parameters)
The log of the prior probability.
virtual void operator()(const std::vector< double > &expectation, const std::vector< unsigned > &toyData)=0
operator() is called for each generated toy data set of the fast p-value calculation.
Abstract class which doesn&#39;t do anything but offers the right interface to allow calculation the dist...