| 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| 2 | // | 
|---|
| 3 | // Methode d'ajustement non-lineaire sur des objets | 
|---|
| 4 | //                                   R. Ansari    02/2000 | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef OBJFITTER_SEEN | 
|---|
| 7 | #define OBJFITTER_SEEN | 
|---|
| 8 |  | 
|---|
| 9 | #include "machdefs.h" | 
|---|
| 10 |  | 
|---|
| 11 | #include "tmatrix.h" | 
|---|
| 12 | #include "cimage.h" | 
|---|
| 13 | #include "tvector.h" | 
|---|
| 14 | #include "histos.h" | 
|---|
| 15 | #include "histos2.h" | 
|---|
| 16 | #include "hisprof.h" | 
|---|
| 17 | #include "generalfit.h" | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | namespace SOPHYA { | 
|---|
| 21 |  | 
|---|
| 22 | class  ObjectFitter { | 
|---|
| 23 | public: | 
|---|
| 24 | // Residus et fonction fittees sur matrix | 
|---|
| 25 | static TMatrix<int_4> FitResidus(TMatrix<int_4> const & mtx, GeneralFit& gfit, | 
|---|
| 26 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 27 | static TMatrix<r_4> FitResidus(TMatrix<r_4> const & mtx, GeneralFit& gfit, | 
|---|
| 28 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 29 | static TMatrix<r_8> FitResidus(TMatrix<r_8> const & mtx, GeneralFit& gfit, | 
|---|
| 30 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 31 | static TMatrix< complex<r_4> > FitResidus(TMatrix< complex<r_4> > const & mtx, GeneralFit& gfit, | 
|---|
| 32 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 33 | static TMatrix< complex<r_8> > FitResidus(TMatrix< complex<r_8> > const & mtx, GeneralFit& gfit, | 
|---|
| 34 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 35 |  | 
|---|
| 36 | static TMatrix<int_4> FitFunction(TMatrix<int_4> const & mtx, GeneralFit& gfit, | 
|---|
| 37 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 38 | static TMatrix<r_4> FitFunction(TMatrix<r_4> const & mtx, GeneralFit& gfit, | 
|---|
| 39 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 40 | static TMatrix<r_8> FitFunction(TMatrix<r_8> const & mtx, GeneralFit& gfit, | 
|---|
| 41 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 42 | static TMatrix< complex<r_4> > FitFunction(TMatrix< complex<r_4> > const & mtx, GeneralFit& gfit, | 
|---|
| 43 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 44 | static TMatrix< complex<r_8> > FitFunction(TMatrix< complex<r_8> > const & mtx, GeneralFit& gfit, | 
|---|
| 45 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 46 |  | 
|---|
| 47 | // Residus et fonction fittees sur vecteurs | 
|---|
| 48 | static TVector<int_4> FitResidus(TVector<int_4> const & vec, GeneralFit& gfit, | 
|---|
| 49 | double xorg=0.,double dx=1.); | 
|---|
| 50 | static TVector<r_4> FitResidus(TVector<r_4> const & vec, GeneralFit& gfit, | 
|---|
| 51 | double xorg=0.,double dx=1.); | 
|---|
| 52 | static TVector<r_8> FitResidus(TVector<r_8> const & vec, GeneralFit& gfit, | 
|---|
| 53 | double xorg=0.,double dx=1.); | 
|---|
| 54 | static TVector< complex<r_4> > FitResidus(TVector< complex<r_4> > const & vec, GeneralFit& gfit, | 
|---|
| 55 | double xorg=0.,double dx=1.); | 
|---|
| 56 | static TVector< complex<r_8> > FitResidus(TVector< complex<r_8> > const & vec, GeneralFit& gfit, | 
|---|
| 57 | double xorg=0.,double dx=1.); | 
|---|
| 58 |  | 
|---|
| 59 | static TVector<int_4> FitFunction(TVector<int_4> const & vec, GeneralFit& gfit, | 
|---|
| 60 | double xorg=0.,double dx=1.); | 
|---|
| 61 | static TVector<r_4> FitFunction(TVector<r_4> const & vec, GeneralFit& gfit, | 
|---|
| 62 | double xorg=0.,double dx=1.); | 
|---|
| 63 | static TVector<r_8> FitFunction(TVector<r_8> const & vec, GeneralFit& gfit, | 
|---|
| 64 | double xorg=0.,double dx=1.); | 
|---|
| 65 | static TVector< complex<r_4> > FitFunction(TVector< complex<r_4> > const & vec, GeneralFit& gfit, | 
|---|
| 66 | double xorg=0.,double dx=1.); | 
|---|
| 67 | static TVector< complex<r_8> > FitFunction(TVector< complex<r_8> > const & vec, GeneralFit& gfit, | 
|---|
| 68 | double xorg=0.,double dx=1.); | 
|---|
| 69 |  | 
|---|
| 70 | // Residus et fonction fittees sur Image | 
|---|
| 71 | static Image<uint_2> FitResidus(Image<uint_2> const & im, GeneralFit& gfit); | 
|---|
| 72 | static Image<int_4> FitResidus(Image<int_4> const & im, GeneralFit& gfit); | 
|---|
| 73 | static Image<int_8> FitResidus(Image<int_8> const & im, GeneralFit& gfit); | 
|---|
| 74 | static Image<r_4> FitResidus(Image<r_4> const & im, GeneralFit& gfit); | 
|---|
| 75 | static Image<r_8> FitResidus(Image<r_8> const & im, GeneralFit& gfit); | 
|---|
| 76 |  | 
|---|
| 77 | static Image<uint_2> FitFunction(Image<uint_2> const & im, GeneralFit& gfit); | 
|---|
| 78 | static Image<int_4> FitFunction(Image<int_4> const & im, GeneralFit& gfit); | 
|---|
| 79 | static Image<int_8> FitFunction(Image<int_8> const & im, GeneralFit& gfit); | 
|---|
| 80 | static Image<r_4> FitFunction(Image<r_4> const & im, GeneralFit& gfit); | 
|---|
| 81 | static Image<r_8> FitFunction(Image<r_8> const & im, GeneralFit& gfit); | 
|---|
| 82 |  | 
|---|
| 83 | // Residus et fonction fittees sur Histo | 
|---|
| 84 | static Histo FitResidus(Histo const& h, GeneralFit& gfit); | 
|---|
| 85 | static Histo FitFunction(Histo const& h, GeneralFit& gfit); | 
|---|
| 86 | static int_4 Fit(Histo const & h, GeneralFit& gfit | 
|---|
| 87 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError | 
|---|
| 88 | ,double errscale=1.,double errmin=1.); | 
|---|
| 89 |  | 
|---|
| 90 | // Residus et fonction fittees sur Histo2D | 
|---|
| 91 | static Histo2D FitResidus(Histo2D const& h, GeneralFit& gfit); | 
|---|
| 92 | static Histo2D FitFunction(Histo2D const& h, GeneralFit& gfit); | 
|---|
| 93 | static int_4 Fit(Histo2D const & h, GeneralFit& gfit | 
|---|
| 94 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError | 
|---|
| 95 | ,double errscale=1.,double errmin=0.); | 
|---|
| 96 |  | 
|---|
| 97 | // Residus et fonction fittees sur HProf | 
|---|
| 98 | static inline Histo FitResidus(HProf const& h, GeneralFit& gfit) | 
|---|
| 99 | {h.UpdateHisto(); return FitResidus((Histo const&) h,gfit);} | 
|---|
| 100 | static inline Histo FitFunction(HProf const& h, GeneralFit& gfit) | 
|---|
| 101 | {h.UpdateHisto(); return FitFunction((Histo const&) h,gfit);} | 
|---|
| 102 | static int_4 Fit(HProf const & h, GeneralFit& gfit | 
|---|
| 103 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError | 
|---|
| 104 | ,double errscale=1.,double errmin=0.) | 
|---|
| 105 | {h.UpdateHisto(); | 
|---|
| 106 | return Fit((Histo const&) h,gfit,errtype,errscale,errmin);} | 
|---|
| 107 |  | 
|---|
| 108 | // Residus et fonction fittees sur GeneralFitData | 
|---|
| 109 | static inline GeneralFitData FitResidus(GeneralFitData const& g, GeneralFit& gfit) | 
|---|
| 110 | {return g.FitResidus(gfit);} | 
|---|
| 111 | static inline GeneralFitData FitFunction(GeneralFitData const& g, GeneralFit& gfit) | 
|---|
| 112 | {return g.FitFunction(gfit);} | 
|---|
| 113 | }; | 
|---|
| 114 |  | 
|---|
| 115 | //  Classe template pour ajustement sur tableaux (Vecteurs, Matrices) | 
|---|
| 116 | template <class T> | 
|---|
| 117 | class  ArrayFitter { | 
|---|
| 118 | public: | 
|---|
| 119 | // Residus et fonction fittees sur matrix | 
|---|
| 120 | static TMatrix<T> FitResidus(TMatrix<T> const & mtx, GeneralFit& gfit, | 
|---|
| 121 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 122 | static TMatrix<T> FitFunction(TMatrix<T> const & mtx, GeneralFit& gfit, | 
|---|
| 123 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.); | 
|---|
| 124 | // Residus et fonction fittees sur vecteurs | 
|---|
| 125 | static TVector<T> FitResidus(TVector<T> const & vec, GeneralFit& gfit, | 
|---|
| 126 | double xorg=0.,double dx=1.); | 
|---|
| 127 | static TVector<T> FitFunction(TVector<T> const & vec, GeneralFit& gfit, | 
|---|
| 128 | double xorg=0.,double dx=1.); | 
|---|
| 129 | }; | 
|---|
| 130 |  | 
|---|
| 131 | //  Classe template pour ajustement sur images | 
|---|
| 132 | template <class T> | 
|---|
| 133 | class  ImageFitter { | 
|---|
| 134 | public: | 
|---|
| 135 | static Image<T> FitResidus(Image<T> const & mtx, GeneralFit& gfit); | 
|---|
| 136 | static Image<T> FitFunction(Image<T> const & mtx, GeneralFit& gfit); | 
|---|
| 137 | }; | 
|---|
| 138 |  | 
|---|
| 139 | }  // Fin du namespace | 
|---|
| 140 |  | 
|---|
| 141 |  | 
|---|
| 142 | #endif   // OBJFITTER_SEEN | 
|---|