| [756] | 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" | 
|---|
| [1206] | 12 | #include "cimage.h" | 
|---|
| [756] | 13 | #include "tvector.h" | 
|---|
| [1110] | 14 | #include "histos.h" | 
|---|
|  | 15 | #include "histos2.h" | 
|---|
|  | 16 | #include "hisprof.h" | 
|---|
| [756] | 17 | #include "generalfit.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 |  | 
|---|
|  | 20 | namespace SOPHYA { | 
|---|
|  | 21 |  | 
|---|
|  | 22 | class  ObjectFitter { | 
|---|
|  | 23 | public: | 
|---|
|  | 24 | // Residus et fonction fittees sur matrix | 
|---|
| [1204] | 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.); | 
|---|
| [756] | 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.); | 
|---|
| [1204] | 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.); | 
|---|
| [756] | 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.); | 
|---|
| [1204] | 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 |  | 
|---|
| [756] | 47 | // Residus et fonction fittees sur vecteurs | 
|---|
| [1204] | 48 | static TVector<int_4> FitResidus(TVector<int_4> const & vec, GeneralFit& gfit, | 
|---|
|  | 49 | double xorg=0.,double dx=1.); | 
|---|
| [756] | 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.); | 
|---|
| [1204] | 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.); | 
|---|
| [756] | 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.); | 
|---|
| [1204] | 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 |  | 
|---|
| [1206] | 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 |  | 
|---|
| [1110] | 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); | 
|---|
| [1206] | 86 | static int_4 Fit(Histo const & h, GeneralFit& gfit | 
|---|
|  | 87 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError | 
|---|
|  | 88 | ,double errscale=1.,double errmin=1.); | 
|---|
| [1204] | 89 |  | 
|---|
| [1110] | 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); | 
|---|
| [1206] | 93 | static int_4 Fit(Histo2D const & h, GeneralFit& gfit | 
|---|
|  | 94 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError | 
|---|
|  | 95 | ,double errscale=1.,double errmin=0.); | 
|---|
| [1204] | 96 |  | 
|---|
| [1110] | 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);} | 
|---|
| [1206] | 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);} | 
|---|
| [1204] | 107 |  | 
|---|
| [1110] | 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);} | 
|---|
| [756] | 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 |  | 
|---|
| [1206] | 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 |  | 
|---|
| [756] | 139 | }  // Fin du namespace | 
|---|
|  | 140 |  | 
|---|
|  | 141 |  | 
|---|
| [805] | 142 | #endif   // OBJFITTER_SEEN | 
|---|