Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMultiDimFit.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Christian Holm Christensen 07/11/2000
3
4#ifndef ROOT_TMultiDimFit
5#define ROOT_TMultiDimFit
6
7#include "TNamed.h"
8#include "TVectorD.h"
9#include "TMatrixD.h"
10#include "TVirtualFitter.h"
11
12class TBrowser;
13class TList;
14
15class TMultiDimFit : public TNamed {
16
17public:
22 };
23
24private:
25 static TMultiDimFit* fgInstance; // Static instance
26protected:
27
28 TVectorD fQuantity; // Training sample, dependent quantity
29 TVectorD fSqError; // Training sample, error in quantity
30 Double_t fMeanQuantity; // Mean of dependent quantity
31 Double_t fMaxQuantity; // Max value of dependent quantity
32 Double_t fMinQuantity; // Min value of dependent quantity
33 Double_t fSumSqQuantity; // SumSquare of dependent quantity
34 Double_t fSumSqAvgQuantity; // Sum of squares away from mean
35
36 TVectorD fVariables; // Training sample, independent variables
37 Int_t fNVariables; // Number of independent variables
38 TVectorD fMeanVariables; // mean value of independent variables
39 TVectorD fMaxVariables; // max value of independent variables
40 TVectorD fMinVariables; // min value of independent variables
41
42 Int_t fSampleSize; // Size of training sample
43
44 TVectorD fTestQuantity; // Test sample, dependent quantity
45 TVectorD fTestSqError; // Test sample, Error in quantity
46 TVectorD fTestVariables; // Test sample, independent variables
47
48 Int_t fTestSampleSize; // Size of test sample
49
50 Double_t fMinAngle; // Min angle for acepting new function
51 Double_t fMaxAngle; // Max angle for acepting new function
52 Int_t fMaxTerms; // Max terms expected in final expr.
53 Double_t fMinRelativeError; // Min relative error accepted
54 Int_t *fMaxPowers; // [fNVariables] maximum powers
55 Double_t fPowerLimit; // Control parameter
56
57
58 TMatrixD fFunctions; // Functions evaluated over sample
59 Int_t fMaxFunctions; // max number of functions
60 Int_t *fFunctionCodes; // [fMaxFunctions] acceptance code
61 Int_t fMaxStudy; // max functions to study
62 Int_t fMaxFuncNV; // fMaxFunctions*fNVariables
63
64 TMatrixD fOrthFunctions; // As above, but orthogonalised
65 TVectorD fOrthFunctionNorms; // Norm of the evaluated functions
66
67
68 Int_t *fMaxPowersFinal; // [fNVariables] maximum powers from fit;
69 Int_t *fPowers; // [fMaxFuncNV] where fMaxFuncNV = fMaxFunctions*fNVariables
70 Int_t *fPowerIndex; // [fMaxTerms] Index of accepted powers
71
72 TVectorD fResiduals; // Vector of the final residuals
73 Double_t fMaxResidual; // Max redsidual value
74 Double_t fMinResidual; // Min redsidual value
75 Int_t fMaxResidualRow; // Row giving max residual
76 Int_t fMinResidualRow; // Row giving min residual
77 Double_t fSumSqResidual; // Sum of Square residuals
78
79 Int_t fNCoefficients; // Dimension of model coefficients
80 TVectorD fOrthCoefficients; // The model coefficients
82 TVectorD fCoefficients; // Vector of the final coefficients
83 TVectorD fCoefficientsRMS; // Vector of RMS of coefficients
84 Double_t fRMS; // Root mean square of fit
85 Double_t fChi2; // Chi square of fit
86 Int_t fParameterisationCode; // Exit code of parameterisation
87
88 Double_t fError; // Error from parameterization
89 Double_t fTestError; // Error from test
90 Double_t fPrecision; // Relative precision of param
91 Double_t fTestPrecision; // Relative precision of test
92 Double_t fCorrelationCoeff; // Multi Correlation coefficient
93 TMatrixD fCorrelationMatrix; // Correlation matrix
94 Double_t fTestCorrelationCoeff; // Multi Correlation coefficient
95
96 TList* fHistograms; // List of histograms
97 Byte_t fHistogramMask; // Bit pattern of hisograms used
98 Int_t fBinVarX; // Number of bin in independent variables
99 Int_t fBinVarY; // Number of bin in dependent variables
100
101 TVirtualFitter* fFitter; //! Fit object (MINUIT)
102
103 EMDFPolyType fPolyType; // Type of polynomials to use
104 Bool_t fShowCorrelation; // print correlation matrix
105 Bool_t fIsUserFunction; // Flag for user defined function
107
108 virtual Double_t EvalFactor(Int_t p, Double_t x) const;
109 virtual Double_t EvalControl(const Int_t *powers) const;
110 virtual void MakeCoefficientErrors();
111 virtual void MakeCorrelation();
112 virtual Double_t MakeGramSchmidt(Int_t function);
113 virtual void MakeCoefficients();
114 virtual void MakeCandidates();
115 virtual void MakeNormalized();
116 virtual void MakeParameterization();
117 virtual void MakeRealCode(const char *filename,
118 const char *classname,
119 Option_t *option="");
120 virtual Bool_t Select(const Int_t *iv);
121 virtual Bool_t TestFunction(Double_t squareResidual,
122 Double_t dResidur);
123public:
124 TMultiDimFit();
125 TMultiDimFit(Int_t dimension,
127 Option_t *option="");
128 virtual ~TMultiDimFit();
129
130 virtual void AddRow(const Double_t *x, Double_t D, Double_t E=0);
131 virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E=0);
132 virtual void Browse(TBrowser* b);
133 virtual void Clear(Option_t *option=""); // *MENU*
134 virtual void Draw(Option_t * ="d") { }
135 virtual Double_t Eval(const Double_t *x, const Double_t *coeff=0) const;
136 virtual Double_t EvalError(const Double_t *x, const Double_t *coeff=0) const;
137 virtual void FindParameterization(Option_t* option=""); // *MENU*
138 virtual void Fit(Option_t *option=""); // *MENU*
139
140 Double_t GetChi2() const { return fChi2; }
142 const TVectorD* GetCoefficients() const { return &fCoefficients; }
143 const TVectorD* GetCoefficientsRMS() const { return &fCoefficientsRMS; }
144 Double_t GetError() const { return fError; }
146 const TMatrixD* GetFunctions() const { return &fFunctions; }
147 virtual TList* GetHistograms() const { return fHistograms; }
148 Double_t GetMaxAngle() const { return fMaxAngle; }
150 Int_t* GetMaxPowers() const { return fMaxPowers; }
152 Int_t GetMaxStudy() const { return fMaxStudy; }
153 Int_t GetMaxTerms() const { return fMaxTerms; }
154 const TVectorD* GetMaxVariables() const { return &fMaxVariables; }
156 const TVectorD* GetMeanVariables() const { return &fMeanVariables; }
157 Double_t GetMinAngle() const { return fMinAngle; }
160 const TVectorD* GetMinVariables() const { return &fMinVariables; }
161 Int_t GetNVariables() const { return fNVariables; }
163 Int_t GetPolyType() const { return fPolyType; }
164 Int_t* GetPowerIndex() const { return fPowerIndex; }
166 const Int_t* GetPowers() const { return fPowers; }
167 Double_t GetPrecision() const { return fPrecision; }
168 const TVectorD* GetQuantity() const { return &fQuantity; }
174 Double_t GetRMS() const { return fRMS; }
175 Int_t GetSampleSize() const { return fSampleSize; }
176 const TVectorD* GetSqError() const { return &fSqError; }
179 Double_t GetTestError() const { return fTestError; }
181 const TVectorD* GetTestQuantity() const { return &fTestQuantity; }
183 const TVectorD* GetTestSqError() const { return &fTestSqError; }
184 const TVectorD* GetTestVariables() const { return &fTestVariables; }
185 const TVectorD* GetVariables() const { return &fVariables; }
186
187 static TMultiDimFit* Instance();
188 virtual Bool_t IsFolder() const { return kTRUE; }
189 virtual Double_t MakeChi2(const Double_t* coeff=0);
190 virtual void MakeCode(const char *functionName="MDF", Option_t *option=""); // *MENU*
191 virtual void MakeHistograms(Option_t* option="A"); // *MENU*
192 virtual void MakeMethod(const Char_t* className="MDF", Option_t* option=""); // *MENU*
193 virtual void Print(Option_t *option="ps") const; // *MENU*
194
195 void SetBinVarX(Int_t nbbinvarx) {fBinVarX = nbbinvarx;}
196 void SetBinVarY(Int_t nbbinvary) {fBinVarY = nbbinvary;}
197 void SetMaxAngle(Double_t angle=0);
199 void SetMaxPowers(const Int_t *powers);
201 void SetMaxTerms(Int_t terms) { fMaxTerms = terms; }
202 void SetMinRelativeError(Double_t error);
203 void SetMinAngle(Double_t angle=1);
204 void SetPowerLimit(Double_t limit=1e-3);
205 virtual void SetPowers(const Int_t *powers, Int_t terms);
206
207 ClassDef(TMultiDimFit,2) // Multi dimensional fit class
208}
209;
210#endif
#define b(i)
Definition RSha256.hxx:100
#define e(i)
Definition RSha256.hxx:103
unsigned char Byte_t
Definition RtypesCore.h:64
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
int type
Definition TGX11.cxx:121
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
A doubly linked list.
Definition TList.h:44
Multidimensional Fits in ROOT.
const TVectorD * GetQuantity() const
Double_t GetSumSqAvgQuantity() const
virtual void MakeCorrelation()
PRIVATE METHOD: Compute the correlation matrix.
Int_t GetNCoefficients() const
Double_t GetMinQuantity() const
void SetMaxStudy(Int_t n)
TVectorD fCoefficients
Double_t fPrecision
Double_t GetMaxAngle() const
Byte_t fHistogramMask
void SetBinVarX(Int_t nbbinvarx)
virtual void MakeCoefficientErrors()
PRIVATE METHOD: Compute the errors on the coefficients.
void SetMaxFunctions(Int_t n)
Double_t GetTestPrecision() const
TMatrixD fOrthCurvatureMatrix
Bool_t fShowCorrelation
Bool_t fIsUserFunction
Double_t GetError() const
Double_t GetRMS() const
Int_t fNVariables
Int_t GetSampleSize() const
Int_t fMaxResidualRow
Double_t fMinQuantity
virtual Double_t Eval(const Double_t *x, const Double_t *coeff=0) const
Evaluate parameterization at point x.
Double_t fSumSqQuantity
TVectorD fMaxVariables
Double_t GetPrecision() const
const TVectorD * GetVariables() const
Int_t GetResidualMinRow() const
const TVectorD * GetMeanVariables() const
void SetMaxTerms(Int_t terms)
Double_t GetSumSqQuantity() const
Int_t fSampleSize
Double_t GetResidualSumSq() const
Double_t fSumSqAvgQuantity
Int_t * fPowers
Double_t GetPowerLimit() const
virtual void MakeNormalized()
PRIVATE METHOD: Normalize data to the interval [-1;1].
Int_t * fMaxPowers
Int_t GetNVariables() const
TVectorD fTestQuantity
TVectorD fTestSqError
Int_t fMaxFunctions
static TMultiDimFit * Instance()
Return the static instance.
virtual ~TMultiDimFit()
Destructor.
virtual void MakeCode(const char *functionName="MDF", Option_t *option="")
Generate the file <filename> with .C appended if argument doesn't end in .cxx or ....
virtual void MakeCandidates()
PRIVATE METHOD: Create list of candidate functions for the parameterisation.
const TVectorD * GetSqError() const
const TVectorD * GetMaxVariables() const
Double_t fTestError
Double_t fMinResidual
void SetPowerLimit(Double_t limit=1e-3)
Set the user parameter for the function selection.
const TMatrixD * GetFunctions() const
virtual void FindParameterization(Option_t *option="")
Find the parameterization.
virtual Double_t MakeGramSchmidt(Int_t function)
PRIVATE METHOD: Make Gram-Schmidt orthogonalisation.
Int_t * GetMaxPowers() const
const TVectorD * GetMinVariables() const
TVectorD fSqError
virtual void AddRow(const Double_t *x, Double_t D, Double_t E=0)
Add a row consisting of fNVariables independent variables, the known, dependent quantity,...
Int_t GetTestSampleSize() const
Int_t GetResidualMaxRow() const
TVectorD fQuantity
Double_t GetMinAngle() const
TVectorD fTestVariables
TVectorD fOrthCoefficients
Int_t fTestSampleSize
TVectorD fResiduals
const Int_t * GetPowers() const
virtual Bool_t TestFunction(Double_t squareResidual, Double_t dResidur)
PRIVATE METHOD: Test whether the currently considered function contributes to the fit.
TVectorD fVariables
Double_t GetChi2() const
Double_t fCorrelationCoeff
void SetMaxPowers(const Int_t *powers)
Set the maximum power to be considered in the fit for each variable.
Int_t * fMaxPowersFinal
Int_t fMinResidualRow
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Int_t GetMaxTerms() const
virtual void SetPowers(const Int_t *powers, Int_t terms)
Define a user function.
Double_t fMaxQuantity
virtual void MakeRealCode(const char *filename, const char *classname, Option_t *option="")
PRIVATE METHOD: This is the method that actually generates the code for the evaluation the parameteri...
Double_t fRMS
TVirtualFitter * fFitter
TMatrixD fFunctions
Double_t GetResidualMin() const
virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E=0)
Add a row consisting of fNVariables independent variables, the known, dependent quantity,...
Int_t fParameterisationCode
const TVectorD * GetTestVariables() const
Double_t fMaxAngle
Int_t fNCoefficients
virtual void Fit(Option_t *option="")
Try to fit the found parameterisation to the test sample.
TMultiDimFit()
Empty CTOR. Do not use.
virtual TList * GetHistograms() const
Double_t fTestCorrelationCoeff
Int_t GetMaxStudy() const
Double_t GetMeanQuantity() const
Double_t fMinAngle
const TMatrixD * GetCorrelationMatrix() const
void SetMinRelativeError(Double_t error)
Set the acceptable relative error for when sum of square residuals is considered minimized.
Double_t fSumSqResidual
Double_t GetResidualMax() const
TVectorD fMeanVariables
void SetBinVarY(Int_t nbbinvary)
virtual void MakeMethod(const Char_t *className="MDF", Option_t *option="")
Generate the file <classname>MDF.cxx which contains the implementation of the method:
Double_t GetMinRelativeError() const
void SetMaxAngle(Double_t angle=0)
Set the max angle (in degrees) between the initial data vector to be fitted, and the new candidate fu...
Double_t fTestPrecision
const TVectorD * GetTestSqError() const
virtual void MakeCoefficients()
PRIVATE METHOD: Invert the model matrix B, and compute final coefficients.
TMatrixD fCorrelationMatrix
Int_t * GetPowerIndex() const
Int_t * fPowerIndex
TMatrixD fOrthFunctions
virtual void Clear(Option_t *option="")
Clear internal structures and variables.
virtual Double_t EvalControl(const Int_t *powers) const
PRIVATE METHOD: Calculate the control parameter from the passed powers.
virtual void Browse(TBrowser *b)
Browse the TMultiDimFit object in the TBrowser.
virtual void MakeParameterization()
PRIVATE METHOD: Find the parameterization over the training sample.
EMDFPolyType fPolyType
Fit object (MINUIT)
virtual Bool_t Select(const Int_t *iv)
Selection method.
Int_t GetMaxFunctions() const
virtual Double_t EvalError(const Double_t *x, const Double_t *coeff=0) const
Evaluate parameterization error at point x.
TList * fHistograms
Double_t GetTestError() const
Double_t fChi2
Double_t fMaxResidual
Double_t fError
Int_t * GetFunctionCodes() const
virtual Double_t EvalFactor(Int_t p, Double_t x) const
PRIVATE METHOD: Evaluate function with power p at variable value x.
const TVectorD * GetTestQuantity() const
void SetMinAngle(Double_t angle=1)
Set the min angle (in degrees) between a new candidate function and the subspace spanned by the previ...
virtual void Print(Option_t *option="ps") const
Print statistics etc.
TVectorD fMinVariables
TVectorD fOrthFunctionNorms
const TVectorD * GetCoefficientsRMS() const
Double_t fMeanQuantity
const TVectorD * GetCoefficients() const
TVectorD fCoefficientsRMS
Double_t fPowerLimit
static TMultiDimFit * fgInstance
Int_t GetPolyType() const
virtual void MakeHistograms(Option_t *option="A")
Make histograms of the result of the analysis.
Bool_t fIsVerbose
Double_t GetMaxQuantity() const
virtual void Draw(Option_t *="d")
Default Draw method for all objects.
Double_t fMinRelativeError
virtual Double_t MakeChi2(const Double_t *coeff=0)
Calculate Chi square over either the test sample.
Int_t * fFunctionCodes
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Abstract Base Class for Fitting.
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16