3 /* Copyright(c) 2006-07, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
7 #include "TGraphSmooth.h"
10 #include "TLinearFitter.h"
11 #include "TDecompSVD.h"
12 #include "TDecompSparse.h"
13 #include "TMatrixDSparse.h"
17 #include "TClonesArray.h"
20 #include "TTreeStream.h"
22 class AliSplineFit : public TObject {
25 AliSplineFit(const AliSplineFit&);
27 AliSplineFit& operator=(const AliSplineFit&);
28 Double_t Eval(Double_t x, Int_t deriv=0) const;
29 void InitKnots(TGraph * graph, Int_t min, Int_t iter, Double_t maxDelta);
30 void MakeKnots0(TGraph * graph, Double_t maxdelta, Int_t minpoints);
31 void SplineFit(Int_t nder);
33 void MakeSmooth(TGraph * graph, Float_t ratio, Option_t * type);
34 void Update(TSpline3 *spline, Int_t nknots);
36 Int_t GetKnots() const {return fN;}
37 Double_t* GetX() const {return fX;}
38 Double_t* GetY0() const {return fY0;}
39 Double_t* GetY1() const {return fY1;}
43 TGraph * MakeGraph(Double_t xmin, Double_t xmax, Int_t npoints, Int_t deriv=0) const ;
44 TGraph * MakeDiff(TGraph * graph) const ;
45 TH1F * MakeDiffHisto(TGraph * graph) const;
47 static void Test(Int_t npoints=2000, Int_t ntracks=100, Float_t snoise=0.05);
49 static TGraph * GenerGraph(Int_t npoints, Double_t fraction, Double_t s1, Double_t s2, Double_t s3, Int_t der=0);
50 static TGraph * GenerNoise(TGraph * graph0, Double_t s0);
52 void SetGraph (TGraph* graph) { fGraph=graph; }
53 void SetMinPoints (Int_t minPoints) { fMinPoints=minPoints;}
54 Int_t GetMinPoints() const { return fMinPoints; }
59 // working parameters for spline fit
61 Int_t OptimizeKnots(Int_t nIter);
62 Float_t CheckKnot(Int_t iKnot);
63 Bool_t RefitKnot(Int_t iKnot);
65 Bool_t fBDump; // dump debug information flag
66 TGraph *fGraph; //! initial graph
67 Int_t fNmin; // number of points per one knot in iteration 0
68 Int_t fMinPoints; // minimum number of points to create AliSplineFit
69 Double_t fSigma; // locally estimated sigma
70 Double_t fMaxDelta;// maximal deviation of the spline fit
71 Int_t fN0; // number of knots in iteration 0
72 TClonesArray *fParams; // object array of parameters in knots
73 TClonesArray *fCovars; // object array of covariance in knots
74 Int_t *fIndex; //[fN0] index of point corresponding to knot
75 static TLinearFitter* fitterStatic(); // static fitter to save processing time
79 Int_t fN; // number of knots after compression
80 Double_t fChi2; // chi2 per degree of freedom
81 Double_t *fX; //[fN] - xknot value
82 Double_t *fY0; //[fN] - y value at X
83 Double_t *fY1; //[fN] - y derivative value at X
84 Double_t *fChi2I; //[fN] - chi2 on interval
85 ClassDef(AliSplineFit, 2);