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<uint_2> FitResidus(TMatrix<uint_2> const & mtx, GeneralFit& gfit,
|
---|
26 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
27 | static TMatrix<int_2> FitResidus(TMatrix<int_2> const & mtx, GeneralFit& gfit,
|
---|
28 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
29 | static TMatrix<int_4> FitResidus(TMatrix<int_4> const & mtx, GeneralFit& gfit,
|
---|
30 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
31 | static TMatrix<int_8> FitResidus(TMatrix<int_8> const & mtx, GeneralFit& gfit,
|
---|
32 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
33 | static TMatrix<r_4> FitResidus(TMatrix<r_4> const & mtx, GeneralFit& gfit,
|
---|
34 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
35 | static TMatrix<r_8> FitResidus(TMatrix<r_8> const & mtx, GeneralFit& gfit,
|
---|
36 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
37 | static TMatrix< complex<r_4> > FitResidus(TMatrix< complex<r_4> > const & mtx, GeneralFit& gfit,
|
---|
38 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
39 | static TMatrix< complex<r_8> > FitResidus(TMatrix< complex<r_8> > const & mtx, GeneralFit& gfit,
|
---|
40 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
41 |
|
---|
42 | static TMatrix<uint_2> FitFunction(TMatrix<uint_2> const & mtx, GeneralFit& gfit,
|
---|
43 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
44 | static TMatrix<int_2> FitFunction(TMatrix<int_2> const & mtx, GeneralFit& gfit,
|
---|
45 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
46 | static TMatrix<int_4> FitFunction(TMatrix<int_4> const & mtx, GeneralFit& gfit,
|
---|
47 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
48 | static TMatrix<int_8> FitFunction(TMatrix<int_8> const & mtx, GeneralFit& gfit,
|
---|
49 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
50 | static TMatrix<r_4> FitFunction(TMatrix<r_4> const & mtx, GeneralFit& gfit,
|
---|
51 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
52 | static TMatrix<r_8> FitFunction(TMatrix<r_8> const & mtx, GeneralFit& gfit,
|
---|
53 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
54 | static TMatrix< complex<r_4> > FitFunction(TMatrix< complex<r_4> > const & mtx, GeneralFit& gfit,
|
---|
55 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
56 | static TMatrix< complex<r_8> > FitFunction(TMatrix< complex<r_8> > const & mtx, GeneralFit& gfit,
|
---|
57 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
58 |
|
---|
59 | // Residus et fonction fittees sur vecteurs
|
---|
60 | static TVector<uint_2> FitResidus(TVector<uint_2> const & vec, GeneralFit& gfit,
|
---|
61 | double xorg=0.,double dx=1.);
|
---|
62 | static TVector<int_2> FitResidus(TVector<int_2> const & vec, GeneralFit& gfit,
|
---|
63 | double xorg=0.,double dx=1.);
|
---|
64 | static TVector<int_4> FitResidus(TVector<int_4> const & vec, GeneralFit& gfit,
|
---|
65 | double xorg=0.,double dx=1.);
|
---|
66 | static TVector<int_8> FitResidus(TVector<int_8> const & vec, GeneralFit& gfit,
|
---|
67 | double xorg=0.,double dx=1.);
|
---|
68 | static TVector<r_4> FitResidus(TVector<r_4> const & vec, GeneralFit& gfit,
|
---|
69 | double xorg=0.,double dx=1.);
|
---|
70 | static TVector<r_8> FitResidus(TVector<r_8> const & vec, GeneralFit& gfit,
|
---|
71 | double xorg=0.,double dx=1.);
|
---|
72 | static TVector< complex<r_4> > FitResidus(TVector< complex<r_4> > const & vec, GeneralFit& gfit,
|
---|
73 | double xorg=0.,double dx=1.);
|
---|
74 | static TVector< complex<r_8> > FitResidus(TVector< complex<r_8> > const & vec, GeneralFit& gfit,
|
---|
75 | double xorg=0.,double dx=1.);
|
---|
76 |
|
---|
77 | static TVector<uint_2> FitFunction(TVector<uint_2> const & vec, GeneralFit& gfit,
|
---|
78 | double xorg=0.,double dx=1.);
|
---|
79 | static TVector<int_2> FitFunction(TVector<int_2> const & vec, GeneralFit& gfit,
|
---|
80 | double xorg=0.,double dx=1.);
|
---|
81 | static TVector<int_4> FitFunction(TVector<int_4> const & vec, GeneralFit& gfit,
|
---|
82 | double xorg=0.,double dx=1.);
|
---|
83 | static TVector<int_8> FitFunction(TVector<int_8> const & vec, GeneralFit& gfit,
|
---|
84 | double xorg=0.,double dx=1.);
|
---|
85 | static TVector<r_4> FitFunction(TVector<r_4> const & vec, GeneralFit& gfit,
|
---|
86 | double xorg=0.,double dx=1.);
|
---|
87 | static TVector<r_8> FitFunction(TVector<r_8> const & vec, GeneralFit& gfit,
|
---|
88 | double xorg=0.,double dx=1.);
|
---|
89 | static TVector< complex<r_4> > FitFunction(TVector< complex<r_4> > const & vec, GeneralFit& gfit,
|
---|
90 | double xorg=0.,double dx=1.);
|
---|
91 | static TVector< complex<r_8> > FitFunction(TVector< complex<r_8> > const & vec, GeneralFit& gfit,
|
---|
92 | double xorg=0.,double dx=1.);
|
---|
93 |
|
---|
94 | // Residus et fonction fittees sur Image
|
---|
95 | static Image<uint_2> FitResidus(Image<uint_2> const & im, GeneralFit& gfit);
|
---|
96 | static Image<int_4> FitResidus(Image<int_4> const & im, GeneralFit& gfit);
|
---|
97 | static Image<int_8> FitResidus(Image<int_8> const & im, GeneralFit& gfit);
|
---|
98 | static Image<r_4> FitResidus(Image<r_4> const & im, GeneralFit& gfit);
|
---|
99 | static Image<r_8> FitResidus(Image<r_8> const & im, GeneralFit& gfit);
|
---|
100 |
|
---|
101 | static Image<uint_2> FitFunction(Image<uint_2> const & im, GeneralFit& gfit);
|
---|
102 | static Image<int_4> FitFunction(Image<int_4> const & im, GeneralFit& gfit);
|
---|
103 | static Image<int_8> FitFunction(Image<int_8> const & im, GeneralFit& gfit);
|
---|
104 | static Image<r_4> FitFunction(Image<r_4> const & im, GeneralFit& gfit);
|
---|
105 | static Image<r_8> FitFunction(Image<r_8> const & im, GeneralFit& gfit);
|
---|
106 |
|
---|
107 | // Residus et fonction fittees sur Histo
|
---|
108 | static Histo FitResidus(Histo const& h, GeneralFit& gfit);
|
---|
109 | static Histo FitFunction(Histo const& h, GeneralFit& gfit);
|
---|
110 | static int_4 Fit(Histo const & h, GeneralFit& gfit
|
---|
111 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError
|
---|
112 | ,double errscale=1.,double errmin=1.);
|
---|
113 |
|
---|
114 | // Residus et fonction fittees sur Histo2D
|
---|
115 | static Histo2D FitResidus(Histo2D const& h, GeneralFit& gfit);
|
---|
116 | static Histo2D FitFunction(Histo2D const& h, GeneralFit& gfit);
|
---|
117 | static int_4 Fit(Histo2D const & h, GeneralFit& gfit
|
---|
118 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError
|
---|
119 | ,double errscale=1.,double errmin=0.);
|
---|
120 |
|
---|
121 | // Residus et fonction fittees sur HProf
|
---|
122 | static inline Histo FitResidus(HProf const& h, GeneralFit& gfit)
|
---|
123 | {h.UpdateHisto(); return FitResidus((Histo const&) h,gfit);}
|
---|
124 | static inline Histo FitFunction(HProf const& h, GeneralFit& gfit)
|
---|
125 | {h.UpdateHisto(); return FitFunction((Histo const&) h,gfit);}
|
---|
126 | static int_4 Fit(HProf const & h, GeneralFit& gfit
|
---|
127 | ,GeneralFitData::FitErrType errtype=GeneralFitData::DefaultError
|
---|
128 | ,double errscale=1.,double errmin=0.)
|
---|
129 | {h.UpdateHisto();
|
---|
130 | return Fit((Histo const&) h,gfit,errtype,errscale,errmin);}
|
---|
131 |
|
---|
132 | // Residus et fonction fittees sur GeneralFitData
|
---|
133 | static inline GeneralFitData FitResidus(GeneralFitData const& g, GeneralFit& gfit)
|
---|
134 | {return g.FitResidus(gfit);}
|
---|
135 | static inline GeneralFitData FitFunction(GeneralFitData const& g, GeneralFit& gfit)
|
---|
136 | {return g.FitFunction(gfit);}
|
---|
137 | };
|
---|
138 |
|
---|
139 | // Classe template pour ajustement sur tableaux (Vecteurs, Matrices)
|
---|
140 | template <class T>
|
---|
141 | class ArrayFitter {
|
---|
142 | public:
|
---|
143 | // Residus et fonction fittees sur matrix
|
---|
144 | static TMatrix<T> FitResidus(TMatrix<T> const & mtx, GeneralFit& gfit,
|
---|
145 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
146 | static TMatrix<T> FitFunction(TMatrix<T> const & mtx, GeneralFit& gfit,
|
---|
147 | double xorg=0.,double yorg=0.,double dx=1.,double dy=1.);
|
---|
148 | // Residus et fonction fittees sur vecteurs
|
---|
149 | static TVector<T> FitResidus(TVector<T> const & vec, GeneralFit& gfit,
|
---|
150 | double xorg=0.,double dx=1.);
|
---|
151 | static TVector<T> FitFunction(TVector<T> const & vec, GeneralFit& gfit,
|
---|
152 | double xorg=0.,double dx=1.);
|
---|
153 | };
|
---|
154 |
|
---|
155 | // Classe template pour ajustement sur images
|
---|
156 | template <class T>
|
---|
157 | class ImageFitter {
|
---|
158 | public:
|
---|
159 | static Image<T> FitResidus(Image<T> const & mtx, GeneralFit& gfit);
|
---|
160 | static Image<T> FitFunction(Image<T> const & mtx, GeneralFit& gfit);
|
---|
161 | };
|
---|
162 |
|
---|
163 | } // Fin du namespace
|
---|
164 |
|
---|
165 |
|
---|
166 | #endif // OBJFITTER_SEEN
|
---|