4b23a517 |
1 | #ifndef AliTMINUITTOOLKIT_H |
2 | #define AliTMINUITTOOLKIT_H |
3 | |
4 | |
5 | #include <TNamed.h> |
6 | #include <TVirtualFitter.h> |
7 | #include <TH1F.h> |
8 | #include <TH2F.h> |
9 | #include <TF1.h> |
10 | #include <TFormula.h> |
11 | #include <TVectorD.h> |
12 | #include <TMatrixD.h> |
13 | #include <TMath.h> |
14 | #include <TString.h> |
15 | |
16 | |
17 | class AliTMinuitToolkit: public TNamed{ |
18 | // |
19 | // |
20 | // |
21 | public: |
22 | AliTMinuitToolkit(); |
23 | virtual ~AliTMinuitToolkit(); |
24 | |
25 | void FitHistogram(TH1F * his); |
26 | void FitHistogram(TH2F * his); |
27 | void SetInitialParam(TVectorD *param) { fParam=param;}; |
28 | void SetParamLimits(TMatrixD *paramLimits) { fParamLimits=paramLimits;}; |
29 | // |
30 | void SetFitFunction(TFormula * formula) {fFormula=formula;}; |
31 | void SetWeightFunction(TFormula * weightFunction) {fWeightFunction=weightFunction;}; |
32 | void SetWeightFunction(Char_t * name, Float_t param1, Float_t param2 = 0.1); |
33 | void SetFitAlgorithm(Char_t * name) {fFitAlgorithm=name;}; |
34 | void SetMaxCalls(Int_t calls) {fMaxCalls = calls;}; |
35 | void SetTolerance(Double_t tol) {fPrecision = tol;}; |
36 | void SetPoints(TMatrixD * points) {fPoints = points;}; |
37 | void Test(); |
38 | static void FitterFCN(int &npar, double *dummy, double &fchisq, double *gin, int iflag); |
39 | void Fit(); |
40 | // |
41 | TMatrixD * GetPoints() {return fPoints;}; |
42 | TFormula * GetFormula() {return fFormula;}; |
43 | TVectorD * GetParameters() {return fParam;}; |
44 | TFormula * GetWeightFunction() {return fWeightFunction;}; |
45 | TMatrixD * GetCovarianceMatrix() {return fCovar;}; |
46 | |
47 | private: |
da7c9ae3 |
48 | // |
49 | AliTMinuitToolkit(const AliTMinuitToolkit&); // fake copy constr. to suppress warnings |
50 | AliTMinuitToolkit& operator=(const AliTMinuitToolkit&); // fake -- suppress warnings |
4b23a517 |
51 | // |
52 | TFormula * fFormula; // formula of the fitted function |
53 | TFormula * fWeightFunction; // weight function, must be defined between 0 and 1 |
54 | Char_t * fFitAlgorithm; // fit algorithm for TMinuit: migrad, simplex, ... |
55 | // |
56 | // |
57 | TMatrixD * fPoints; // fitted points |
58 | TVectorD * fParam; // parameter values |
59 | TMatrixD * fParamLimits; // limits of the parameters (up, down) |
60 | TMatrixD * fCovar; // covariance matrix |
61 | Double_t * fChi2; // chi-square |
62 | Int_t fMaxCalls; // maximum number of calls, default value depends on fit algorithm |
63 | Double_t fPrecision; // normalized tolerance, default value depends on fit algorithm |
64 | // |
65 | ClassDef(AliTMinuitToolkit,1); |
66 | }; |
67 | |
68 | |
69 | |
70 | #endif |