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(TString name,TString title);
38  TSFuncModel(TString name,TString title,const TSArgList& set);
39  TSFuncModel(TString name,TString title,const TSArgList& set, const TSArgSet &coefs);
40  TSFuncModel(TString name,TString title,TString formula,const TSArgList& set);
41  TSFuncModel(TString name,TString title,TString formula,const TSArgList& set, const TSArgSet &coefs);
42 
43 
44  virtual ~TSFuncModel();
45 
46  virtual double Eval(double x, double y=0) const =0;
47  virtual double Eval() const =0;
48  virtual double Evaluate() const =0;
49 
50  double GetNormalization() const {return fNormalization;}
51  int GetNumOfFuncs() const {return fNFuncs;}
52  int GetNumOfCoefs() const {return fNCoefs;}
53  bool HasCoefs() const {return fHasCoefs;}
54 
55  void Init();
56 
57  bool IsLinear() const {return fIsLinear;}
58  bool IsTFormula() const {return fIsTFormula;}
59 
60  TString GetFormula() const {return fExpr;}
61  TString GetTF1Formula() const {return fTF1Formula;}
62 
63  void Print() const;
64 
65  void ResetNormalization() const;
66  void SetNormalization(double integral,double binw_width_x=1,double bin_width_y=1) const;
67  void NormalizeToIntegral(const TH1 &) const;
68  void NormalizeToHistogram(const TH1 &) const;
69 
70 protected:
71 
72  int fAddCoefficients(const TSArgSet &);
73  int fAddFunctions(const TSArgSet &);
74 
75  int fAnalyseModelFormula(TString expr,const TSArgSet &funcs, const TSArgSet &coeff);
76 
77  const TSFunction1D *fFunc1D;
78  const TSParameter *fParams;
79 
80  TString fExpr;
81  TString fTF1Formula;
82 
83  TFormula fFormula;
84 
85  int fNFuncs;
86  int fNCoefs;
87  bool fHasCoefs;
88  bool fIsTFormula;
89  bool fIsLinear;
90 
91 
92  static const int NMAX_FORMULA_VARS=30;
93 
94  int func2ParamIndex[NMAX_FORMULA_VARS];
95  int coef2ParamIndex[NMAX_FORMULA_VARS];
96 
97  TSParameter *fCoefsList[NMAX_FORMULA_VARS];
98  TSFunction1D *fFunctionsList[NMAX_FORMULA_VARS];
99 
100 private:
101 
102  mutable double fNormalization;
103 
104 };
105 
106 #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