simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
TSFuncModel.h
1 /*
2  * TSFunc1DModel.h
3  *
4  * Created on: Aug 5, 2014
5  * Author: Silvestro di Luise
6  * Silvestro.Di.Luise@cern.ch
7  *
8  *
9  * Make an intermediate TSFuncModel: public TSFunc2D
10  * Set NDIM etc...
11  *
12  */
13 
14 #ifndef TSFUNC1DMODEL_H_
15 #define TSFUNC1DMODEL_H_
16 
17 #include <TString.h>
18 #include <TFormula.h>
19 #include <TF1.h>
20 
21 #include "TSVariable.h"
22 #include "TSParameter.h"
23 #include "TSFunction1D.h"
24 #include "TSFunction2D.h"
25 
26 
27 #include "TSArgList.h"
28 
29 /*
30  *
31  */
32 
33 class TSFuncModel: public TSFunction2D {
34 
35 public:
36 
37  TSFuncModel() {};
38  TSFuncModel(TString name,TString title);
39  TSFuncModel(TString name,TString title,const TSArgList& set);
40  TSFuncModel(TString name,TString title,const TSArgList& set, const TSArgSet &coefs);
41  TSFuncModel(TString name,TString title,TString formula,const TSArgList& set);
42  TSFuncModel(TString name,TString title,TString formula,const TSArgList& set, const TSArgSet &coefs);
43 
44 
45  virtual ~TSFuncModel();
46 
47  virtual double Eval(double x, double y=0) const =0;
48  virtual double Eval() const =0;
49  virtual double Evaluate() const =0;
50 
51  double GetNormalization() const {return fNormalization;}
52  int GetNumOfFuncs() const {return fNFuncs;}
53  int GetNumOfCoefs() const {return fNCoefs;}
54  bool HasCoefs() const {return fHasCoefs;}
55 
56  void Init();
57 
58  bool IsLinear() const {return fIsLinear;}
59  bool IsTFormula() const {return fIsTFormula;}
60 
61  TString GetFormula() const {return fExpr;}
62  TString GetTF1Formula() const {return fTF1Formula;}
63 
64  void Print() const;
65 
66  void ResetNormalization() const;
67  void SetNormalization(double integral,double binw_width_x=1,double bin_width_y=1) const;
68  void NormalizeToIntegral(const TH1 &) const;
69  void NormalizeToHistogram(const TH1 &) const;
70 
71 protected:
72 
73  int fAddCoefficients(const TSArgSet &);
74  int fAddFunctions(const TSArgSet &);
75 
76  int fAnalyseModelFormula(TString expr,const TSArgSet &funcs, const TSArgSet &coeff);
77 
78  const TSFunction1D *fFunc1D;
79  const TSParameter *fParams;
80 
81  TString fExpr;
82  TString fTF1Formula;
83 
84  TFormula fFormula;
85 
86  int fNFuncs;
87  int fNCoefs;
88  bool fHasCoefs;
89  bool fIsTFormula;
90  bool fIsLinear;
91 
92 
93  static const int NMAX_FORMULA_VARS=30;
94 
95  int func2ParamIndex[NMAX_FORMULA_VARS];
96  int coef2ParamIndex[NMAX_FORMULA_VARS];
97 
98  TSParameter *fCoefsList[NMAX_FORMULA_VARS];
99  TSFunction1D *fFunctionsList[NMAX_FORMULA_VARS];
100 
101 private:
102 
103  mutable double fNormalization;
104 
105 };
106 
107 #endif /* TSFUNC1DMODEL_H_ */
Definition: TSArgList.h:30
int fAnalyseModelFormula(TString expr, const TSArgSet &funcs, const TSArgSet &coeff)
Definition: TSFuncModel.cc:473
void NormalizeToHistogram(const TH1 &) const
Definition: TSFuncModel.cc:252
Definition: TSFunction1D.h:43
Definition: TSFuncModel.h:33
void NormalizeToIntegral(const TH1 &) const
Definition: TSFuncModel.cc:229
int fAddCoefficients(const TSArgSet &)
Definition: TSFuncModel.cc:329
Definition: TSParameter.h:39
int fAddFunctions(const TSArgSet &)
Definition: TSFuncModel.cc:377
Definition: TSFunction2D.h:27