BCTF1Prior.h
1 #ifndef __BCTF1PRIOR__H
2 #define __BCTF1PRIOR__H
3 
14 /*
15  * Copyright (C) 2007-2018, the BAT core developer team
16  * All rights reserved.
17  *
18  * For the licensing terms see doc/COPYING.
19  * For documentation see http://mpp.mpg.de/bat
20  */
21 
22 // ---------------------------------------------------------
23 
24 #include "BCPrior.h"
25 
26 #include <limits>
27 
28 #include <TF1.h>
29 
30 // ---------------------------------------------------------
31 
32 class BCTF1Prior : public BCPrior
33 {
34 public:
39  BCTF1Prior(TF1& f);
40 
42  BCTF1Prior(const std::string& formula, double xmin, double xmax);
43 
45  virtual ~BCTF1Prior() {};
46 
53  virtual BCPrior* Clone() const
54  { return new BCTF1Prior(*this); }
55 
58  virtual bool IsValid() const
59  { return true; }
60 
66  virtual double GetPrior(double x, bool normalize = false)
67  { return fPriorFunction.Eval(x) * ((normalize) ? exp(-fLogIntegral) : 1); }
68 
73  virtual double GetLogPrior(double x)
74  { return log(fPriorFunction.Eval(x)); }
75 
78 };
79 
80 #endif
A class to represent the prior of a parameter.
Definition: BCPrior.h:49
virtual bool IsValid() const
Definition: BCTF1Prior.h:58
A class to represent the prior of a parameter by a formula through a TF1.
Definition: BCTF1Prior.h:32
virtual BCPrior * Clone() const
Clone function.
Definition: BCTF1Prior.h:53
TF1 fPriorFunction
Definition: BCPrior.h:291
virtual ~BCTF1Prior()
Destrcutor.
Definition: BCTF1Prior.h:45
BCTF1Prior(TF1 &f)
Constructor taking TF1.
Definition: BCTF1Prior.cxx:16
virtual double GetPrior(double x, bool normalize=false)
Get prior.
Definition: BCTF1Prior.h:66
virtual double GetLogPrior(double x)
Get prior.
Definition: BCTF1Prior.h:73
double fLogIntegral
Log of integral of unnormalized pdf over the range.
Definition: BCPrior.h:293