]>
Commit | Line | Data |
---|---|---|
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 SetWeights(TVectorD * weights) {fWeights = weights;}; | |
38 | static void Test(); | |
39 | static void FitterFCN(int &npar, double *dummy, double &fchisq, double *gin, int iflag); | |
40 | void Fit(); | |
41 | void EnableRobust(Bool_t b) {fUseRobust = b;}; | |
42 | void EnableRobust(Bool_t b, Double_t sigma) {fUseRobust = b; fExpectedSigma = sigma;}; | |
43 | // | |
44 | TMatrixD * GetPoints() {return fPoints;}; | |
45 | TVectorD * GetWeights() {return fWeights;}; | |
46 | TFormula * GetFormula() {return fFormula;}; | |
47 | TVectorD * GetParameters() {return fParam;}; | |
48 | TFormula * GetWeightFunction() {return fWeightFunction;}; | |
49 | TMatrixD * GetCovarianceMatrix() {return fCovar;}; | |
50 | Bool_t GetStatus() {return fUseRobust;}; | |
51 | Double_t GetExpectedSigma() {return fExpectedSigma;}; | |
52 | ||
53 | private: | |
54 | // | |
55 | AliTMinuitToolkit(const AliTMinuitToolkit&); // fake copy constr. -- suppress warnings | |
56 | AliTMinuitToolkit& operator=(const AliTMinuitToolkit&); // fake -- suppress warnings | |
57 | // | |
58 | TFormula * fFormula; // formula of the fitted function | |
59 | TFormula * fWeightFunction; // weight function, must be defined between 0 and 1 | |
60 | Char_t * fFitAlgorithm; // fit algorithm for TMinuit: migrad, simplex, ... | |
61 | // | |
62 | // | |
63 | TMatrixD * fPoints; // fitted points | |
64 | TVectorD * fWeights; // weights of the points | |
65 | TVectorD * fParam; // parameter values | |
66 | TMatrixD * fParamLimits; // limits of the parameters (up, down) | |
67 | TMatrixD * fCovar; // covariance matrix | |
68 | Double_t * fChi2; // chi-square | |
69 | Int_t fMaxCalls; // maximum number of calls, default value depends on fit algorithm | |
70 | Double_t fPrecision; // normalized tolerance, default value depends on fit algorithm | |
71 | Bool_t fUseRobust; // switch on/off robust option, default: kFalse | |
72 | Double_t fExpectedSigma; // expected sigma to normalize robust fitting | |
73 | // | |
74 | ClassDef(AliTMinuitToolkit,1); | |
75 | }; | |
76 | ||
77 | ||
78 | ||
79 | #endif |