]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliSplineFit.h
Execution time printout via AliInfo
[u/mrichter/AliRoot.git] / STEER / AliSplineFit.h
1 #ifndef ALISPLINEFIT_H
2 #define ALISPLINEFIT_H
3 /* Copyright(c) 2006-07, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 #include "TGraph.h"
7 #include "TGraphSmooth.h"
8 #include "TRandom.h"
9 #include "TSpline.h"
10 #include "TLinearFitter.h"
11 #include "TDecompSVD.h"
12 #include "TDecompSparse.h"
13 #include "TMatrixDSparse.h"
14 #include "TF1.h"
15 #include "TH1F.h"
16 #include "TObject.h"
17 #include "TClonesArray.h"
18
19 #include "TTreeStream.h"
20
21 class AliSplineFit : public TObject {
22  public:
23   AliSplineFit();
24   AliSplineFit(const AliSplineFit&);
25   ~AliSplineFit();
26   AliSplineFit& operator=(const AliSplineFit&);
27   Double_t   Eval(Double_t x, Int_t deriv=0) const;
28   void       InitKnots(TGraph * graph, Int_t min, Int_t iter, Double_t maxDelta);
29   void       MakeKnots0(TGraph * graph, Double_t maxdelta, Int_t minpoints);
30   void       SplineFit(Int_t nder);
31   void       MakeSmooth(TGraph * graph, Float_t ratio, char * type);
32   void       Update(TSpline3 *spline, Int_t nknots);
33   void       Cleanup();
34   Int_t      GetKnots() const {return fN;} 
35   Double_t*  GetX() const {return fX;}
36   Double_t*  GetY0() const {return fY0;}
37   Double_t*  GetY1() const {return fY1;}
38   //
39   // Test functions
40   //
41   TGraph * MakeGraph(Double_t xmin, Double_t xmax, Int_t npoints, Int_t deriv=0) const ;
42   TGraph * MakeDiff(TGraph * graph) const ;
43   TH1F   * MakeDiffHisto(TGraph * graph) const;
44   //
45   static void Test(Int_t npoints=2000, Int_t ntracks=100, Float_t snoise=0.05);
46   //
47   static TGraph * GenerGraph(Int_t npoints, Double_t fraction, Double_t s1, Double_t s2, Double_t s3, Int_t der=0);
48   static TGraph * GenerNoise(TGraph * graph0, Double_t s0);
49
50  protected:
51
52   //
53   // working parameters for spline fit
54   //
55   Int_t    OptimizeKnots(Int_t nIter);
56   Float_t  CheckKnot(Int_t iKnot);
57   Bool_t   RefitKnot(Int_t iKnot);
58   //
59   Bool_t        fBDump;   //  dump debug information flag
60   TGraph       *fGraph;   //! initial graph
61   Int_t         fNmin;    //  number of points per one knot in iteration 0
62   Double_t      fSigma;   //  locally estimated sigma
63   Double_t      fMaxDelta;//  maximal deviation of the spline fit 
64   Int_t         fN0;      //  number of knots in iteration 0 
65   TClonesArray *fParams;  //  object array of parameters in knots
66   TClonesArray *fCovars;  //  object array of covariance in knots
67   Int_t        *fIndex;   //[fN0] index of point corresponding to knot
68   static TLinearFitter* fitterStatic(); // static fitter to save processing time
69   //
70   // 
71   //
72   Int_t    fN;            //  number of knots after compression 
73   Double_t fChi2;         //  chi2 per degree of freedom 
74   Double_t *fX;           //[fN] - xknot value
75   Double_t *fY0;          //[fN] - y value at X
76   Double_t *fY1;          //[fN] - y derivative value at X
77   Double_t *fChi2I;       //[fN] - chi2 on interval
78   ClassDef(AliSplineFit, 1);
79 };
80 #endif