StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPolinom.h
1 #ifndef TPOLINOM_H
2 #define TPOLINOM_H
3 #include "TObject.h"
4 #include "TArrayD.h"
5 #include "TMatrixD.h"
6 
7 class TPolinom : public TObject
8 {
9 public:
10  TPolinom(int npw=-1,const double *coefs=0);
11  TPolinom(const TPolinom &from);
12  TPolinom(double c0);
13  TPolinom(double c0,double c1);
14  TPolinom(double c0,double c1,double c2);
15 TPolinom &operator=(const TPolinom &from);
16 virtual ~TPolinom();
17  void Backward();
18 virtual void Print(const char* chopt = "") const;
19 virtual void Clear(const char *opt ="");
20  double Eval (double x) const;
21  double operator()(double x) const {return Eval(x);}
22  double Evrr (double x) const;
23  double Deriv(double x) const;
24  void Move(double x);
25  const double *Coe() const {return fCoe;}
26  const double *Emx() const {return fEmx;}
27  double GetEmx(int i,int j) const;
28  void SetCoefs(int npw=0,const double *coefs=0);
29  void SetCoeff(int idx,double val) {fCoe[idx]=val;}
30 // statics
31 static double Eval (double x,int n,double *coe);
32 
33 
34 protected:
35 int fNP;
36 double *fCoe;
37 double *fEmx;
38 double f2Coe[3];
39 ClassDef(TPolinom,0)
40 };
41 
42 
43 class TPoliFitter: public TPolinom
44 {
45 public:
46  TPoliFitter(int np);
47  TPoliFitter(const TPoliFitter &from);
48 virtual ~TPoliFitter(){;}
49 void Add(double x, double y,double err2=1);
50 void AddErr(double err2);
51 const double *GetX(int i=0) const;
52  double *GetX(int i=0);
53 double Fit();
54 void MakeErrs();
55 double Chi2() const {return fChi2;}
56 int NPts() const {return fN/3 ;}
57 int Ndf() const {return fNdf ;}
58 int Size() const {return fNuse;}
59 double Wtot() const {return fWtot;}
60 const double *CoeOrt() const {return fC ;}
61 double EvalOrt(int idx,double x) const;
62 
63 double EvalChi2();
64 void Clear(const char *opt ="");
65 void Print(const char* chopt = "") const;
66 void Show() const;
67 double FixAt(double x,double y);
68 void Skip(int idx);
69 void DCoeDy(int iy,double *dcoe) const;
70 void SetNdf(int ndf);
71 double MakeMatrix(TMatrixD &Aij) const;
72 static void Test(int kase=0);
73 static void TestCorr();
74 static void Dest(int kase=0);
75 static void Test2();
76 private:
77 void Prepare();
78 
79 private:
80 TArrayD fArr;
81 char fBeg[1];
82 int fN;
83 int fNuse;
84 double *fDat;
85 double *fP;
86 double *fC;
87 double fWtot;
88 double fChi2;
89 int fNdf;
90 char fEnd[1];
91 ClassDef(TPoliFitter,0)
92 };
93 
94 #endif // TPOLINOM_H