1 | //
|
---|
2 | // cmv 05/08/96
|
---|
3 | //
|
---|
4 |
|
---|
5 | #include "defs.h"
|
---|
6 |
|
---|
7 | #include <string.h>
|
---|
8 | #include <new.h>
|
---|
9 | #include <stdlib.h>
|
---|
10 | #include <stdio.h>
|
---|
11 | #ifndef __mac__
|
---|
12 | #include <values.h>
|
---|
13 | #endif
|
---|
14 |
|
---|
15 | #include "histos2.h"
|
---|
16 | #include "generalfit.h"
|
---|
17 |
|
---|
18 | //++
|
---|
19 | // Class Histo2D
|
---|
20 | // Lib Outils++
|
---|
21 | // include histos2.h
|
---|
22 | //
|
---|
23 | // Classe d'histogrammes 2D
|
---|
24 | //--
|
---|
25 |
|
---|
26 | ///////////////////////////////////////////////////////////////////
|
---|
27 | //++
|
---|
28 | // Titre Constructeurs
|
---|
29 | //--
|
---|
30 |
|
---|
31 | //++
|
---|
32 | Histo2D::Histo2D(float xMin, float xMax, int nxBin
|
---|
33 | ,float yMin, float yMax, int nyBin)
|
---|
34 | //
|
---|
35 | // Createur d'un histogramme 2D ayant nxBin,nyBin bins
|
---|
36 | // entre xMin,xMax et yMin,yMax.
|
---|
37 | //--
|
---|
38 | : data(new float[nxBin*nyBin]), err2(NULL)
|
---|
39 | , nHist(0), nEntries(0)
|
---|
40 | , nx(nxBin), ny(nyBin), nxy(nxBin*nyBin)
|
---|
41 | , xmin(xMin), xmax(xMax), ymin(yMin), ymax(yMax)
|
---|
42 | , wbinx((xMax - xMin)/nxBin), wbiny((yMax - yMin)/nyBin)
|
---|
43 | , hprojx(NULL), hprojy(NULL)
|
---|
44 | {
|
---|
45 | DBASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);
|
---|
46 | for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
|
---|
47 | Zero();
|
---|
48 | b_s.H = NULL;
|
---|
49 | END_CONSTRUCTOR
|
---|
50 | }
|
---|
51 |
|
---|
52 | //++
|
---|
53 | Histo2D::Histo2D(const Histo2D& h)
|
---|
54 | //
|
---|
55 | // Constructeur par copie.
|
---|
56 | //--
|
---|
57 | {
|
---|
58 | int i,j;
|
---|
59 | data = new float[h.nxy];
|
---|
60 | memcpy(data, h.data, h.nxy*sizeof(float));
|
---|
61 |
|
---|
62 | err2 = NULL;
|
---|
63 | if(h.err2) {
|
---|
64 | err2 = new double[h.nxy];
|
---|
65 | memcpy(err2, h.err2, h.nxy*sizeof(double));
|
---|
66 | }
|
---|
67 |
|
---|
68 | nHist = h.nHist; nEntries = h.nEntries;
|
---|
69 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j]=h.over[i][j];
|
---|
70 | nx = h.nx; ny = h.ny; nxy = h.nxy;
|
---|
71 | xmin = h.xmin; xmax = h.xmax; ymin = h.ymin; ymax = h.ymax;
|
---|
72 | wbinx = h.wbinx; wbiny = h.wbiny;
|
---|
73 | b_s.H = NULL;
|
---|
74 |
|
---|
75 | hprojx = hprojy = NULL;
|
---|
76 | if(h.hprojx) {
|
---|
77 | SetProjX();
|
---|
78 | *hprojx = *(h.hprojx);
|
---|
79 | }
|
---|
80 | if(h.hprojy) {
|
---|
81 | SetProjY();
|
---|
82 | *hprojy = *(h.hprojy);
|
---|
83 | }
|
---|
84 |
|
---|
85 | int nb;
|
---|
86 | float min,max;
|
---|
87 | nb = h.NSliX();
|
---|
88 | if(nb>0) {
|
---|
89 | SetSliX(nb);
|
---|
90 | for(i=0; i<NSliX();i++) *HSliX(i) = *(h.HSliX(i));
|
---|
91 | }
|
---|
92 | nb = h.NSliY();
|
---|
93 | if(nb>0) {
|
---|
94 | SetSliY(nb);
|
---|
95 | for(i=0; i<NSliY();i++) *HSliY(i) = *(h.HSliY(i));
|
---|
96 | }
|
---|
97 |
|
---|
98 | nb = h.NBandX();
|
---|
99 | if(nb>0) {
|
---|
100 | for(i=0; i<nb;i++) {
|
---|
101 | h.GetBandX(i,min,max);
|
---|
102 | SetBandX(min,max);
|
---|
103 | *HBandX(i) = *(h.HBandX(i));
|
---|
104 | }
|
---|
105 | for(i=0; i<NBandX();i++) *HBandX(i) = *(h.HBandX(i));
|
---|
106 | }
|
---|
107 | nb = h.NBandY();
|
---|
108 | if(nb>0) {
|
---|
109 | for(i=0; i<nb;i++) {
|
---|
110 | h.GetBandY(i,min,max);
|
---|
111 | SetBandY(min,max);
|
---|
112 | *HBandY(i) = *(h.HBandY(i));
|
---|
113 | }
|
---|
114 | for(i=0; i<NBandY();i++) *HBandY(i) = *(h.HBandY(i));
|
---|
115 | }
|
---|
116 |
|
---|
117 | END_CONSTRUCTOR
|
---|
118 | }
|
---|
119 |
|
---|
120 | //++
|
---|
121 | Histo2D::Histo2D()
|
---|
122 | //
|
---|
123 | // Constructeur par defaut.
|
---|
124 | //--
|
---|
125 | : data(NULL), err2(NULL)
|
---|
126 | , nHist(0), nEntries(0)
|
---|
127 | , nx(0), ny(0), nxy(0)
|
---|
128 | , xmin(0), xmax(0), ymin(0), ymax(0)
|
---|
129 | , wbinx(0), wbiny(0)
|
---|
130 | , hprojx(NULL), hprojy(NULL)
|
---|
131 | {
|
---|
132 | for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
|
---|
133 | b_s.H = NULL;
|
---|
134 | END_CONSTRUCTOR
|
---|
135 | }
|
---|
136 |
|
---|
137 | //++
|
---|
138 | Histo2D::Histo2D(char *flnm)
|
---|
139 | //
|
---|
140 | // Constructeur par lecture d'un fichier ppersist.
|
---|
141 | //--
|
---|
142 | : data(NULL), err2(NULL)
|
---|
143 | , nHist(0), nEntries(0)
|
---|
144 | , nx(0), ny(0), nxy(0)
|
---|
145 | , xmin(0), xmax(0), ymin(0), ymax(0)
|
---|
146 | , wbinx(0), wbiny(0)
|
---|
147 | , hprojx(NULL), hprojy(NULL)
|
---|
148 | {
|
---|
149 | b_s.H = NULL;
|
---|
150 | PInPersist s(flnm);
|
---|
151 | Read(s);
|
---|
152 | END_CONSTRUCTOR
|
---|
153 | }
|
---|
154 |
|
---|
155 | ///////////////////////////////////////////////////////////////////
|
---|
156 | //++
|
---|
157 | void Histo2D::Delete()
|
---|
158 | //
|
---|
159 | // Desallocation de la place de l'histogramme (fct privee).
|
---|
160 | //--
|
---|
161 | {
|
---|
162 | if( data != NULL ) { delete[] data; data = NULL;}
|
---|
163 |
|
---|
164 | if( err2 != NULL ) { delete[] err2; err2 = NULL;}
|
---|
165 |
|
---|
166 | DelProj();
|
---|
167 |
|
---|
168 | DelBandX();
|
---|
169 | DelBandY();
|
---|
170 |
|
---|
171 | DelSliX();
|
---|
172 | DelSliY();
|
---|
173 |
|
---|
174 | nHist = 0;
|
---|
175 | nEntries = 0;
|
---|
176 | nx = 0; ny = 0; nxy = 0;
|
---|
177 | xmin = 0; xmax = 0; ymin = 0; ymax = 0;
|
---|
178 | wbinx = 0; wbiny = 0;
|
---|
179 | for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
|
---|
180 | b_s.H = NULL;
|
---|
181 | }
|
---|
182 |
|
---|
183 | //++
|
---|
184 | Histo2D::~Histo2D()
|
---|
185 | //
|
---|
186 | // Destructeur.
|
---|
187 | //--
|
---|
188 | {
|
---|
189 | Delete();
|
---|
190 | }
|
---|
191 |
|
---|
192 | ///////////////////////////////////////////////////////////////////
|
---|
193 | //++
|
---|
194 | // Titre Methodes generales
|
---|
195 | //--
|
---|
196 |
|
---|
197 | //++
|
---|
198 | void Histo2D::Zero()
|
---|
199 | //
|
---|
200 | // Remise a zero du contenu, des erreurs et des valeurs.
|
---|
201 | //--
|
---|
202 | {
|
---|
203 | nHist = nEntries = 0;
|
---|
204 | for(int i=0;i<3;i++) for(int j=0;j<3;j++) over[i][j]=0.;
|
---|
205 | memset(data, 0, nxy*sizeof(float));
|
---|
206 | memset(over, 0, 9*sizeof(float));
|
---|
207 |
|
---|
208 | if( err2 != NULL ) memset(err2, 0, nxy*sizeof(double));
|
---|
209 |
|
---|
210 | ZeroProj();
|
---|
211 |
|
---|
212 | ZeroBandX();
|
---|
213 | ZeroBandY();
|
---|
214 |
|
---|
215 | ZeroSliX();
|
---|
216 | ZeroSliY();
|
---|
217 | }
|
---|
218 |
|
---|
219 | ///////////////////////////////////////////////////////////////////
|
---|
220 | //++
|
---|
221 | void Histo2D::Errors()
|
---|
222 | //
|
---|
223 | // Pour avoir le calcul des erreurs.
|
---|
224 | //--
|
---|
225 | {
|
---|
226 | if( nxy > 0 ) {
|
---|
227 | if(err2==NULL) err2 = new double[nxy];
|
---|
228 | memset(err2, 0, nxy*sizeof(double));
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 | ///////////////////////////////////////////////////////////////////
|
---|
233 | //++
|
---|
234 | Histo2D& Histo2D::operator = (const Histo2D& h)
|
---|
235 | //
|
---|
236 | //--
|
---|
237 | {
|
---|
238 | int i,j,nb;
|
---|
239 | float min,max;
|
---|
240 |
|
---|
241 | if(this == &h) return *this;
|
---|
242 | if( h.nxy > nxy ) Delete();
|
---|
243 | if(!data) data = new float[h.nxy];
|
---|
244 | if( !h.err2 && err2 ) { delete [] err2; err2=NULL;}
|
---|
245 | if( h.err2 && !err2 ) err2 = new double[h.nxy];
|
---|
246 |
|
---|
247 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] = h.over[i][j];
|
---|
248 | nHist = h.nHist;
|
---|
249 | nEntries = h.nEntries;
|
---|
250 | nx = h.nx; ny = h.ny; nxy = h.nxy;
|
---|
251 | xmin = h.xmin; xmax = h.xmax; wbinx = h.wbinx;
|
---|
252 | ymin = h.ymin; ymax = h.ymax; wbiny = h.wbiny;
|
---|
253 |
|
---|
254 | memcpy(data, h.data, nxy*sizeof(float));
|
---|
255 | if(err2) memcpy(err2, h.err2, nxy*sizeof(double));
|
---|
256 |
|
---|
257 | DelProjX();
|
---|
258 | if(h.hprojx) {
|
---|
259 | SetProjX();
|
---|
260 | *hprojx = *(h.hprojx);
|
---|
261 | }
|
---|
262 | DelProjY();
|
---|
263 | if(h.hprojy) {
|
---|
264 | SetProjY();
|
---|
265 | *hprojy = *(h.hprojy);
|
---|
266 | }
|
---|
267 |
|
---|
268 | DelSliX();
|
---|
269 | nb = h.NSliX();
|
---|
270 | if(nb>0) {
|
---|
271 | SetSliX(nb);
|
---|
272 | for(i=0; i<NSliX();i++) *HSliX(i) = *(h.HSliX(i));
|
---|
273 | }
|
---|
274 | DelSliY();
|
---|
275 | nb = h.NSliY();
|
---|
276 | if(nb>0) {
|
---|
277 | SetSliY(nb);
|
---|
278 | for(i=0; i<NSliY();i++) *HSliY(i) = *(h.HSliY(i));
|
---|
279 | }
|
---|
280 |
|
---|
281 | DelBandX();
|
---|
282 | nb = h.NBandX();
|
---|
283 | if(nb>0) {
|
---|
284 | for(i=0; i<nb;i++) {
|
---|
285 | h.GetBandX(i,min,max);
|
---|
286 | SetBandX(min,max);
|
---|
287 | *HBandX(i) = *(h.HBandX(i));
|
---|
288 | }
|
---|
289 | for(i=0; i<NBandX();i++) *HBandX(i) = *(h.HBandX(i));
|
---|
290 | }
|
---|
291 | DelBandY();
|
---|
292 | nb = h.NBandY();
|
---|
293 | if(nb>0) {
|
---|
294 | for(i=0; i<nb;i++) {
|
---|
295 | h.GetBandY(i,min,max);
|
---|
296 | SetBandY(min,max);
|
---|
297 | *HBandY(i) = *(h.HBandY(i));
|
---|
298 | }
|
---|
299 | for(i=0; i<NBandY();i++) *HBandY(i) = *(h.HBandY(i));
|
---|
300 | }
|
---|
301 |
|
---|
302 | return *this;
|
---|
303 | }
|
---|
304 |
|
---|
305 | ///////////////////////////////////////////////////////////////////
|
---|
306 | //++
|
---|
307 | Histo2D& Histo2D::operator *= (double b)
|
---|
308 | //
|
---|
309 | //--
|
---|
310 | {
|
---|
311 | int i,j;
|
---|
312 | double b2 = b*b;
|
---|
313 | for(i=0;i<nxy;i++) {
|
---|
314 | data[i] *= b;
|
---|
315 | if(err2) err2[i] *= b2;
|
---|
316 | }
|
---|
317 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] *= b;
|
---|
318 | nHist *= b;
|
---|
319 |
|
---|
320 | if(hprojx) *hprojx *= b;
|
---|
321 | if(hprojy) *hprojy *= b;
|
---|
322 | if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) *= b;
|
---|
323 | if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) *= b;
|
---|
324 | if(NBandX()>0) for(i=0; i<NBandX();i++) *HBandX(i) *= b;
|
---|
325 | if(NBandY()>0) for(i=0; i<NBandY();i++) *HBandY(i) *= b;
|
---|
326 |
|
---|
327 | return *this;
|
---|
328 | }
|
---|
329 |
|
---|
330 | //++
|
---|
331 | Histo2D& Histo2D::operator /= (double b)
|
---|
332 | //
|
---|
333 | //--
|
---|
334 | {
|
---|
335 | int i,j;
|
---|
336 | if (b==0.) THROW(inconsistentErr);
|
---|
337 | double b2 = b*b;
|
---|
338 | for(i=0;i<nxy;i++) {
|
---|
339 | data[i] /= b;
|
---|
340 | if(err2) err2[i] /= b2;
|
---|
341 | }
|
---|
342 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] /= b;
|
---|
343 | nHist /= b;
|
---|
344 |
|
---|
345 | if(hprojx) *hprojx /= b;
|
---|
346 | if(hprojy) *hprojy /= b;
|
---|
347 | if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) /= b;
|
---|
348 | if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) /= b;
|
---|
349 | if(NBandX()>0) for(i=0; i<NBandX();i++) *HBandX(i) /= b;
|
---|
350 | if(NBandY()>0) for(i=0; i<NBandY();i++) *HBandY(i) /= b;
|
---|
351 |
|
---|
352 | return *this;
|
---|
353 | }
|
---|
354 |
|
---|
355 | //++
|
---|
356 | Histo2D& Histo2D::operator += (double b)
|
---|
357 | //
|
---|
358 | //--
|
---|
359 | {
|
---|
360 | int i,j;
|
---|
361 | float min,max;
|
---|
362 | for(i=0;i<nxy;i++) data[i] += b;
|
---|
363 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += b;
|
---|
364 | nHist += nxy*b;
|
---|
365 |
|
---|
366 | if(hprojx) *hprojx += b*ny;
|
---|
367 | if(hprojy) *hprojy += b*nx;
|
---|
368 | if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) += b*ny/NSliX();
|
---|
369 | if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) += b*nx/NSliY();
|
---|
370 | if(NBandX()>0) for(i=0; i<NBandX();i++) {
|
---|
371 | GetBandX(i,min,max);
|
---|
372 | *HBandX(i) += b*(max-min)/(ymax-ymin)*ny;
|
---|
373 | }
|
---|
374 | if(NBandY()>0) for(i=0; i<NBandY();i++) {
|
---|
375 | GetBandY(i,min,max);
|
---|
376 | *HBandY(i) += b*(max-min)/(xmax-xmin)*nx;
|
---|
377 | }
|
---|
378 |
|
---|
379 | return *this;
|
---|
380 | }
|
---|
381 |
|
---|
382 | //++
|
---|
383 | Histo2D& Histo2D::operator -= (double b)
|
---|
384 | //
|
---|
385 | //--
|
---|
386 | {
|
---|
387 | int i,j;
|
---|
388 | float min,max;
|
---|
389 | for(i=0;i<nxy;i++) data[i] -= b;
|
---|
390 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] -= b;
|
---|
391 | nHist -= nxy*b;
|
---|
392 |
|
---|
393 | if(hprojx) *hprojx -= b*ny;
|
---|
394 | if(hprojy) *hprojy -= b*nx;
|
---|
395 | if(NSliX()>0) for(i=0; i<NSliX();i++) *HSliX(i) -= b*ny/NSliX();
|
---|
396 | if(NSliY()>0) for(i=0; i<NSliY();i++) *HSliY(i) -= b*nx/NSliY();
|
---|
397 | if(NBandX()>0) for(i=0; i<NBandX();i++) {
|
---|
398 | GetBandX(i,min,max);
|
---|
399 | *HBandX(i) -= b*(max-min)/(ymax-ymin)*ny;
|
---|
400 | }
|
---|
401 | if(NBandY()>0) for(i=0; i<NBandY();i++) {
|
---|
402 | GetBandY(i,min,max);
|
---|
403 | *HBandY(i) -= b*(max-min)/(xmax-xmin)*nx;
|
---|
404 | }
|
---|
405 |
|
---|
406 | return *this;
|
---|
407 | }
|
---|
408 |
|
---|
409 | ///////////////////////////////////////////////////////////////////
|
---|
410 | //++
|
---|
411 | Histo2D operator * (const Histo2D& a, double b)
|
---|
412 | //
|
---|
413 | //--
|
---|
414 | {
|
---|
415 | Histo2D result(a);
|
---|
416 | return (result *= b);
|
---|
417 | }
|
---|
418 |
|
---|
419 | //++
|
---|
420 | Histo2D operator * (double b, const Histo2D& a)
|
---|
421 | //
|
---|
422 | //--
|
---|
423 | {
|
---|
424 | Histo2D result(a);
|
---|
425 | return (result *= b);
|
---|
426 | }
|
---|
427 |
|
---|
428 | //++
|
---|
429 | Histo2D operator / (const Histo2D& a, double b)
|
---|
430 | //
|
---|
431 | //--
|
---|
432 | {
|
---|
433 | Histo2D result(a);
|
---|
434 | return (result /= b);
|
---|
435 | }
|
---|
436 |
|
---|
437 | //++
|
---|
438 | Histo2D operator + (const Histo2D& a, double b)
|
---|
439 | //
|
---|
440 | //--
|
---|
441 | {
|
---|
442 | Histo2D result(a);
|
---|
443 | return (result += b);
|
---|
444 | }
|
---|
445 |
|
---|
446 | //++
|
---|
447 | Histo2D operator + (double b, const Histo2D& a)
|
---|
448 | //
|
---|
449 | //--
|
---|
450 | {
|
---|
451 | Histo2D result(a);
|
---|
452 | return (result += b);
|
---|
453 | }
|
---|
454 |
|
---|
455 | //++
|
---|
456 | Histo2D operator - (const Histo2D& a, double b)
|
---|
457 | //
|
---|
458 | //--
|
---|
459 | {
|
---|
460 | Histo2D result(a);
|
---|
461 | return (result -= b);
|
---|
462 | }
|
---|
463 |
|
---|
464 | //++
|
---|
465 | Histo2D operator - (double b, const Histo2D& a)
|
---|
466 | //
|
---|
467 | //--
|
---|
468 | {
|
---|
469 | Histo2D result(a);
|
---|
470 | result *= -1.;
|
---|
471 | return (result += b);
|
---|
472 | }
|
---|
473 |
|
---|
474 | ///////////////////////////////////////////////////////////////////
|
---|
475 | //++
|
---|
476 | Histo2D& Histo2D::operator += (const Histo2D& a)
|
---|
477 | //
|
---|
478 | //--
|
---|
479 | {
|
---|
480 | int i,j;
|
---|
481 | if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
|
---|
482 | for(i=0;i<nxy;i++) {
|
---|
483 | data[i] += a.data[i];
|
---|
484 | if(err2 && a.err2) err2[i] += a.err2[i];
|
---|
485 | }
|
---|
486 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += a.over[i][j];
|
---|
487 | nHist += a.nHist;
|
---|
488 | nEntries += a.nEntries;
|
---|
489 |
|
---|
490 | if(hprojx && a.hprojx) *hprojx += *(a.hprojx);
|
---|
491 | if(hprojy && a.hprojy) *hprojy += *(a.hprojy);
|
---|
492 | ZeroSliX(); ZeroSliY();
|
---|
493 | ZeroBandX(); ZeroBandY();
|
---|
494 |
|
---|
495 | return *this;
|
---|
496 | }
|
---|
497 |
|
---|
498 | //++
|
---|
499 | Histo2D& Histo2D::operator -= (const Histo2D& a)
|
---|
500 | //
|
---|
501 | //--
|
---|
502 | {
|
---|
503 | int i,j;
|
---|
504 | if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
|
---|
505 | for(i=0;i<nxy;i++) {
|
---|
506 | data[i] -= a.data[i];
|
---|
507 | if(err2 && a.err2) err2[i] += a.err2[i];
|
---|
508 | }
|
---|
509 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] += a.over[i][j];
|
---|
510 | nHist -= a.nHist;
|
---|
511 | nEntries += a.nEntries;
|
---|
512 |
|
---|
513 | if(hprojx && a.hprojx) *hprojx -= *(a.hprojx);
|
---|
514 | if(hprojy && a.hprojy) *hprojy -= *(a.hprojy);
|
---|
515 | ZeroSliX(); ZeroSliY();
|
---|
516 | ZeroBandX(); ZeroBandY();
|
---|
517 |
|
---|
518 | return *this;
|
---|
519 | }
|
---|
520 |
|
---|
521 | //++
|
---|
522 | Histo2D& Histo2D::operator *= (const Histo2D& a)
|
---|
523 | //
|
---|
524 | //--
|
---|
525 | {
|
---|
526 | int i,j;
|
---|
527 | if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
|
---|
528 | nHist = 0.;
|
---|
529 | for(i=0;i<nxy;i++) {
|
---|
530 | if(err2 && a.err2)
|
---|
531 | err2[i] = a.data[i]*a.data[i]*err2[i] + data[i]*data[i]*a.err2[i];
|
---|
532 | data[i] *= a.data[i];
|
---|
533 | nHist += data[i];
|
---|
534 | }
|
---|
535 | for(i=0;i<3;i++) for(j=0;j<3;j++) over[i][j] *= a.over[i][j];
|
---|
536 | nEntries += a.nEntries;
|
---|
537 |
|
---|
538 | if(hprojx && a.hprojx) *hprojx *= *(a.hprojx);
|
---|
539 | if(hprojy && a.hprojy) *hprojy *= *(a.hprojy);
|
---|
540 | ZeroSliX(); ZeroSliY();
|
---|
541 | ZeroBandX(); ZeroBandY();
|
---|
542 |
|
---|
543 | return *this;
|
---|
544 | }
|
---|
545 |
|
---|
546 | //++
|
---|
547 | Histo2D& Histo2D::operator /= (const Histo2D& a)
|
---|
548 | //
|
---|
549 | //--
|
---|
550 | {
|
---|
551 | int i,j;
|
---|
552 | if(nx!=a.nx || ny!=a.ny) THROW(sizeMismatchErr);
|
---|
553 | nHist = 0.;
|
---|
554 | for(i=0;i<nxy;i++) {
|
---|
555 | if(a.data[i]==0.) {
|
---|
556 | data[i]=0.;
|
---|
557 | if(err2) err2[i]=0.;
|
---|
558 | continue;
|
---|
559 | }
|
---|
560 | if(err2 && a.err2)
|
---|
561 | err2[i] = (err2[i] + data[i]/a.data[i]*data[i]/a.data[i]*a.err2[i])
|
---|
562 | /(a.data[i]*a.data[i]);
|
---|
563 | data[i] /= a.data[i];
|
---|
564 | nHist += data[i];
|
---|
565 | }
|
---|
566 | for(i=0;i<3;i++) for(j=0;j<3;j++)
|
---|
567 | if(a.over[i][j]!=0.) over[i][j] *= a.over[i][j]; else over[i][j] = 0.;
|
---|
568 | nEntries += a.nEntries;
|
---|
569 |
|
---|
570 | if(hprojx && a.hprojx) *hprojx /= *(a.hprojx);
|
---|
571 | if(hprojy && a.hprojy) *hprojy /= *(a.hprojy);
|
---|
572 | ZeroSliX(); ZeroSliY();
|
---|
573 | ZeroBandX(); ZeroBandY();
|
---|
574 |
|
---|
575 | return *this;
|
---|
576 | }
|
---|
577 |
|
---|
578 | ///////////////////////////////////////////////////////////////////
|
---|
579 | //++
|
---|
580 | Histo2D operator + (const Histo2D& a, const Histo2D& b)
|
---|
581 | //
|
---|
582 | //--
|
---|
583 | {
|
---|
584 | if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
|
---|
585 | Histo2D c(a);
|
---|
586 | return (c += b);
|
---|
587 | }
|
---|
588 |
|
---|
589 | //++
|
---|
590 | Histo2D operator - (const Histo2D& a, const Histo2D& b)
|
---|
591 | //
|
---|
592 | //--
|
---|
593 | {
|
---|
594 | if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
|
---|
595 | Histo2D c(a);
|
---|
596 | return (c -= b);
|
---|
597 | }
|
---|
598 |
|
---|
599 | //++
|
---|
600 | Histo2D operator * (const Histo2D& a, const Histo2D& b)
|
---|
601 | //
|
---|
602 | //--
|
---|
603 | {
|
---|
604 | if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
|
---|
605 | Histo2D c(a);
|
---|
606 | return (c *= b);
|
---|
607 | }
|
---|
608 |
|
---|
609 | //++
|
---|
610 | Histo2D operator / (const Histo2D& a, const Histo2D& b)
|
---|
611 | //
|
---|
612 | //--
|
---|
613 | {
|
---|
614 | if (b.nx!=a.nx || b.ny!=a.ny) THROW(sizeMismatchErr);
|
---|
615 | Histo2D c(a);
|
---|
616 | return (c /= b);
|
---|
617 | }
|
---|
618 |
|
---|
619 | ///////////////////////////////////////////////////////////////////
|
---|
620 | //++
|
---|
621 | void Histo2D::GetXCoor(Vector &v)
|
---|
622 | //
|
---|
623 | // Remplissage d'un tableau avec les valeurs des abscisses.
|
---|
624 | //--
|
---|
625 | {
|
---|
626 | float x,y;
|
---|
627 | v.Realloc(nx);
|
---|
628 | for(int i=0;i<nx;i++) {BinLowEdge(i,0,x,y); v(i) = x;}
|
---|
629 | return;
|
---|
630 | }
|
---|
631 |
|
---|
632 | //++
|
---|
633 | void Histo2D::GetYCoor(Vector &v)
|
---|
634 | //
|
---|
635 | // Remplissage d'un tableau avec les valeurs des ordonnees.
|
---|
636 | //--
|
---|
637 | {
|
---|
638 | float x,y;
|
---|
639 | v.Realloc(ny);
|
---|
640 | for(int i=0;i<ny;i++) {BinLowEdge(0,i,x,y); v(i) = y;}
|
---|
641 | return;
|
---|
642 | }
|
---|
643 |
|
---|
644 | //++
|
---|
645 | //| Remarque sur les indices:
|
---|
646 | //| H(i,j) -> i = coord x (0<i<nx), j = coord y (0<j<ny)
|
---|
647 | //| v(ii,jj) -> ii = ligne (0<i<NRows()), jj = colonne (0<i<NCol())
|
---|
648 | //| On fait une correspondance directe i<->ii et j<->jj
|
---|
649 | //| ce qui, en representation classique des histos2D et des matrices
|
---|
650 | //| entraine une inversion x<->y cad une symetrie / diagonale principale
|
---|
651 | //| H(0,...) represente ^ mais v(0,...) represente
|
---|
652 | //| |x....... |xxxxxxxx|
|
---|
653 | //| |x....... |........|
|
---|
654 | //| |x....... |........|
|
---|
655 | //| |x....... |........|
|
---|
656 | //| |x....... |........|
|
---|
657 | //| --------->
|
---|
658 | //| colonne no 1 ligne no 1
|
---|
659 | //--
|
---|
660 |
|
---|
661 | //++
|
---|
662 | void Histo2D::GetValue(Matrix &v)
|
---|
663 | //
|
---|
664 | // Remplissage d'un tableau avec les valeurs du contenu.
|
---|
665 | //--
|
---|
666 | {
|
---|
667 | v.Realloc(nx,ny);
|
---|
668 | for(int i=0;i<nx;i++)
|
---|
669 | for(int j=0;j<ny;j++) v(i,j) = (*this)(i,j);
|
---|
670 | return;
|
---|
671 | }
|
---|
672 |
|
---|
673 | //++
|
---|
674 | void Histo2D::GetError2(Matrix &v)
|
---|
675 | //
|
---|
676 | // Remplissage d'un tableau avec les valeurs du carre des erreurs.
|
---|
677 | //--
|
---|
678 | {
|
---|
679 | int i,j;
|
---|
680 | v.Realloc(nx,ny);
|
---|
681 | if(!err2) for(i=0;i<nx;i++)
|
---|
682 | for(j=0;j<ny;j++) { v(i,j) = 0.; return;}
|
---|
683 | for(i=0;i<nx;i++)
|
---|
684 | for(j=0;j<ny;j++) v(i,j) = Error2(i,j);
|
---|
685 | return;
|
---|
686 | }
|
---|
687 |
|
---|
688 | //++
|
---|
689 | void Histo2D::GetError(Matrix &v)
|
---|
690 | //
|
---|
691 | // Remplissage d'un tableau avec les valeurs des erreurs.
|
---|
692 | //--
|
---|
693 | {
|
---|
694 | int i,j;
|
---|
695 | v.Realloc(nx,ny);
|
---|
696 | if(!err2) for(i=0;i<nx;i++)
|
---|
697 | for(j=0;j<ny;j++) { v(i,j) = 0.; return;}
|
---|
698 | for(i=0;i<nx;i++)
|
---|
699 | for(j=0;j<ny;j++) v(i,j) = Error(i,j);
|
---|
700 | return;
|
---|
701 | }
|
---|
702 |
|
---|
703 | ///////////////////////////////////////////////////////////////////
|
---|
704 | //++
|
---|
705 | void Histo2D::PutValue(Matrix &v, int ierr)
|
---|
706 | //
|
---|
707 | // Remplissage du contenu de l'histo avec les valeurs d'un tableau.
|
---|
708 | //--
|
---|
709 | {
|
---|
710 | int i,j;
|
---|
711 | if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
|
---|
712 | for(i=0;i<nx;i++) for(j=0;j<ny;j++) {
|
---|
713 | (*this)(i,j) = v(i,j);
|
---|
714 | if(err2 && ierr) Error2(i,j) = fabs(v(i,j));
|
---|
715 | }
|
---|
716 | return;
|
---|
717 | }
|
---|
718 |
|
---|
719 | //++
|
---|
720 | void Histo2D::PutValueAdd(Matrix &v, int ierr)
|
---|
721 | //
|
---|
722 | // Addition du contenu de l'histo avec les valeurs d'un tableau.
|
---|
723 | //--
|
---|
724 | {
|
---|
725 | int i,j;
|
---|
726 | if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
|
---|
727 | for(i=0;i<nx;i++) for(j=0;j<ny;j++) {
|
---|
728 | (*this)(i,j) += v(i,j);
|
---|
729 | if(err2 && ierr) Error2(i,j) += fabs(v(i,j));
|
---|
730 | }
|
---|
731 | return;
|
---|
732 | }
|
---|
733 |
|
---|
734 | //++
|
---|
735 | void Histo2D::PutError2(Matrix &v)
|
---|
736 | //
|
---|
737 | // Remplissage des erreurs au carre de l'histo
|
---|
738 | // avec les valeurs d'un tableau.
|
---|
739 | //--
|
---|
740 | {
|
---|
741 | int i,j;
|
---|
742 | if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
|
---|
743 | if(!err2) Errors();
|
---|
744 | for(i=0;i<nx;i++) for(j=0;j<ny;j++) Error2(i,j) = v(i,j);
|
---|
745 | return;
|
---|
746 | }
|
---|
747 |
|
---|
748 | //++
|
---|
749 | void Histo2D::PutError2Add(Matrix &v)
|
---|
750 | //
|
---|
751 | // Addition des erreurs au carre de l'histo
|
---|
752 | // avec les valeurs d'un tableau.
|
---|
753 | //--
|
---|
754 | {
|
---|
755 | int i,j;
|
---|
756 | if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
|
---|
757 | if(!err2) Errors();
|
---|
758 | for(i=0;i<nx;i++) for(j=0;j<ny;j++)
|
---|
759 | if(v(i,j)>0.) Error2(i,j) += v(i,j);
|
---|
760 | return;
|
---|
761 | }
|
---|
762 |
|
---|
763 | //++
|
---|
764 | void Histo2D::PutError(Matrix &v)
|
---|
765 | //
|
---|
766 | // Remplissage des erreurs de l'histo avec les valeurs d'un tableau.
|
---|
767 | //--
|
---|
768 | {
|
---|
769 | int i,j;
|
---|
770 | if(v.NRows()!=nx || v.NCol()!=ny) THROW(sizeMismatchErr);
|
---|
771 | if(!err2) Errors();
|
---|
772 | for(i=0;i<nx;i++) for(j=0;j<ny;j++)
|
---|
773 | if(v(i,j)>0.) Error2(i,j)=v(i,j)*v(i,j); else Error2(i,j)= -v(i,j)*v(i,j);
|
---|
774 | return;
|
---|
775 | }
|
---|
776 |
|
---|
777 | ///////////////////////////////////////////////////////////////////
|
---|
778 | /********* Methode *********/
|
---|
779 | //++
|
---|
780 | void Histo2D::Add(float x, float y, float w)
|
---|
781 | //
|
---|
782 | // Addition du contenu de l'histo pour x,y poids w.
|
---|
783 | //--
|
---|
784 | {
|
---|
785 | list<bande_slice>::iterator it;
|
---|
786 | int i,j;
|
---|
787 | FindBin(x,y,i,j);
|
---|
788 |
|
---|
789 | if( hprojx != NULL ) hprojx->Add(x,w);
|
---|
790 | if( hprojy != NULL ) hprojy->Add(y,w);
|
---|
791 |
|
---|
792 | if(lbandx.size()>0)
|
---|
793 | for( it = lbandx.begin(); it != lbandx.end(); it++)
|
---|
794 | if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
|
---|
795 |
|
---|
796 | if(lbandy.size()>0)
|
---|
797 | for( it = lbandy.begin(); it != lbandy.end(); it++)
|
---|
798 | if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
|
---|
799 |
|
---|
800 | if(lslix.size()>0)
|
---|
801 | for( it = lslix.begin(); it != lslix.end(); it++)
|
---|
802 | if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
|
---|
803 |
|
---|
804 | if(lsliy.size()>0)
|
---|
805 | for( it = lsliy.begin(); it != lsliy.end(); it++)
|
---|
806 | if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
|
---|
807 |
|
---|
808 | if( i<0 || i>=nx || j<0 || j>=ny ) {
|
---|
809 | if(i<0) i=0; else if(i>=nx) i=2; else i=1;
|
---|
810 | if(j<0) j=0; else if(j>=ny) j=2; else j=1;
|
---|
811 | over[i][j] += w;
|
---|
812 | over[1][1] += w;
|
---|
813 | return;
|
---|
814 | }
|
---|
815 |
|
---|
816 | data[j*nx+i] += w;
|
---|
817 | if(err2!=NULL) err2[j*nx+i] += w*w;
|
---|
818 | nHist += w;
|
---|
819 | nEntries++;
|
---|
820 | }
|
---|
821 |
|
---|
822 | ///////////////////////////////////////////////////////////////////
|
---|
823 | //++
|
---|
824 | void Histo2D::IJMax(int& imax,int& jmax,int il,int ih,int jl,int jh)
|
---|
825 | //
|
---|
826 | // Recherche du bin du maximum dans le pave [il,ih][jl,jh].
|
---|
827 | //--
|
---|
828 | {
|
---|
829 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
830 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
831 | if( il < 0 ) il = 0;
|
---|
832 | if( jl < 0 ) jl = 0;
|
---|
833 | if( ih >= nx ) ih = nx-1;
|
---|
834 | if( jh >= ny ) jh = ny-1;
|
---|
835 |
|
---|
836 | imax = jmax = 0;
|
---|
837 | if(nxy==1) return;
|
---|
838 |
|
---|
839 | float mx=(*this)(il,jl);
|
---|
840 | for (int i=il; i<=ih; i++)
|
---|
841 | for (int j=jl; j<=jh; j++)
|
---|
842 | if ((*this)(i,j)>mx) {imax = i; jmax = j; mx=(*this)(i,j);}
|
---|
843 | }
|
---|
844 |
|
---|
845 | //++
|
---|
846 | void Histo2D::IJMin(int& imax,int& jmax,int il,int ih,int jl,int jh)
|
---|
847 | //
|
---|
848 | // Recherche du bin du minimum dans le pave [il,ih][jl,jh].
|
---|
849 | //--
|
---|
850 | {
|
---|
851 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
852 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
853 | if( il < 0 ) il = 0;
|
---|
854 | if( jl < 0 ) jl = 0;
|
---|
855 | if( ih >= nx ) ih = nx-1;
|
---|
856 | if( jh >= ny ) jh = ny-1;
|
---|
857 |
|
---|
858 | imax = jmax = 0;
|
---|
859 | if(nxy==1) return;
|
---|
860 |
|
---|
861 | float mx=(*this)(il,jl);
|
---|
862 | for (int i=il; i<=ih; i++)
|
---|
863 | for (int j=jl; j<=jh; j++)
|
---|
864 | if ((*this)(i,j)<mx) {imax = i; jmax = j; mx=(*this)(i,j);}
|
---|
865 | }
|
---|
866 |
|
---|
867 |
|
---|
868 | //++
|
---|
869 | float Histo2D::VMax(int il,int ih,int jl,int jh) const
|
---|
870 | //
|
---|
871 | // Recherche du maximum dans le pave [il,ih][jl,jh].
|
---|
872 | //--
|
---|
873 | {
|
---|
874 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
875 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
876 | if( il < 0 ) il = 0;
|
---|
877 | if( jl < 0 ) jl = 0;
|
---|
878 | if( ih >= nx ) ih = nx-1;
|
---|
879 | if( jh >= ny ) jh = ny-1;
|
---|
880 |
|
---|
881 | float mx=(*this)(il,jl);
|
---|
882 | if(nxy==1) return mx;
|
---|
883 | for (int i=il; i<=ih; i++)
|
---|
884 | for (int j=jl; j<=jh; j++)
|
---|
885 | if ((*this)(i,j)>mx) mx=(*this)(i,j);
|
---|
886 | return mx;
|
---|
887 | }
|
---|
888 |
|
---|
889 | //++
|
---|
890 | float Histo2D::VMin(int il,int ih,int jl,int jh) const
|
---|
891 | //
|
---|
892 | // Recherche du minimum dans le pave [il,ih][jl,jh].
|
---|
893 | //--
|
---|
894 | {
|
---|
895 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
896 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
897 | if( il < 0 ) il = 0;
|
---|
898 | if( jl < 0 ) jl = 0;
|
---|
899 | if( ih >= nx ) ih = nx-1;
|
---|
900 | if( jh >= ny ) jh = ny-1;
|
---|
901 |
|
---|
902 | float mx=(*this)(il,jl);
|
---|
903 | if(nxy==1) return mx;
|
---|
904 | for (int i=il; i<=ih; i++)
|
---|
905 | for (int j=jl; j<=jh; j++)
|
---|
906 | if ((*this)(i,j)<mx) mx=(*this)(i,j);
|
---|
907 | return mx;
|
---|
908 | }
|
---|
909 |
|
---|
910 | ///////////////////////////////////////////////////////////////////
|
---|
911 | //++
|
---|
912 | float Histo2D::NOver(int i,int j) const
|
---|
913 | //
|
---|
914 | // Renvoie les under.overflow dans les 8 quadrants.
|
---|
915 | //| over[3][3]: 20 | 21 | 22
|
---|
916 | //| | |
|
---|
917 | //| --------------
|
---|
918 | //| | |
|
---|
919 | //| 10 | 11 | 12 11 = all overflow+underflow
|
---|
920 | //| | |
|
---|
921 | //| --------------
|
---|
922 | //| | |
|
---|
923 | //| 00 | 01 | 02
|
---|
924 | //--
|
---|
925 | {
|
---|
926 | if( i < 0 || i>=3 || j < 0 || j>=3 ) return over[1][1];
|
---|
927 | return over[i][j];
|
---|
928 | }
|
---|
929 |
|
---|
930 |
|
---|
931 | ///////////////////////////////////////////////////////////////////
|
---|
932 | //++
|
---|
933 | int Histo2D::BinNonNul() const
|
---|
934 | //
|
---|
935 | // Retourne le nombre de bins non-nuls.
|
---|
936 | //--
|
---|
937 | {
|
---|
938 | int non=0;
|
---|
939 | for (int i=0;i<nxy;i++) if( data[i] != 0. ) non++;
|
---|
940 | return non;
|
---|
941 | }
|
---|
942 |
|
---|
943 | //++
|
---|
944 | int Histo2D::ErrNonNul() const
|
---|
945 | //
|
---|
946 | // Retourne le nombre de bins avec erreurs non-nulles.
|
---|
947 | //--
|
---|
948 | {
|
---|
949 | if(err2==NULL) return -1;
|
---|
950 | int non=0;
|
---|
951 | for (int i=0;i<nxy;i++) if( err2[i] != 0. ) non++;
|
---|
952 | return non;
|
---|
953 | }
|
---|
954 |
|
---|
955 | ///////////////////////////////////////////////////////////////////
|
---|
956 | //++
|
---|
957 | int Histo2D::EstimeMax(float& xm,float& ym,int SzPav
|
---|
958 | ,int il,int ih,int jl,int jh)
|
---|
959 | //
|
---|
960 | // Idem EstimeMax(int...) mais retourne x,y.
|
---|
961 | //--
|
---|
962 | {
|
---|
963 | int im,jm;
|
---|
964 | IJMax(im,jm,il,ih,jl,jh);
|
---|
965 | return EstimeMax(im,jm,xm,ym,SzPav);
|
---|
966 | }
|
---|
967 |
|
---|
968 | //++
|
---|
969 | int Histo2D::EstimeMax(int im,int jm,float& xm,float& ym,int SzPav)
|
---|
970 | //
|
---|
971 | // Determine les abscisses et ordonnees du maximum donne par im,jm
|
---|
972 | // en moyennant dans un pave SzPav x SzPav autour du maximum.
|
---|
973 | //| Return:
|
---|
974 | //| 0 = si fit maximum reussi avec SzPav pixels
|
---|
975 | //| 1 = si fit maximum reussi avec moins que SzPav pixels
|
---|
976 | //| dans au moins 1 direction
|
---|
977 | //| 2 = si fit maximum echoue et renvoit BinCenter()
|
---|
978 | //| -1 = si echec: SzPav <= 0 ou im,jm hors limites
|
---|
979 | //--
|
---|
980 | {
|
---|
981 | xm = ym = 0;
|
---|
982 | if( SzPav <= 0 ) return -1;
|
---|
983 | if( im < 0 || im >= nx ) return -1;
|
---|
984 | if( jm < 0 || jm >= ny ) return -1;
|
---|
985 |
|
---|
986 | if( SzPav%2 == 0 ) SzPav++;
|
---|
987 | SzPav = (SzPav-1)/2;
|
---|
988 |
|
---|
989 | int rc = 0;
|
---|
990 | double dxm = 0, dym = 0, wx = 0;
|
---|
991 | for(int i=im-SzPav;i<=im+SzPav;i++) {
|
---|
992 | if( i<0 || i>= nx ) {rc=1; continue;}
|
---|
993 | for(int j=jm-SzPav;j<=jm+SzPav;j++) {
|
---|
994 | if( j<0 || j>= ny ) {rc=1; continue;}
|
---|
995 | float x,y;
|
---|
996 | BinCenter(i,j,x,y);
|
---|
997 | dxm += x * (*this)(i,j);
|
---|
998 | dym += y * (*this)(i,j);
|
---|
999 | wx += (*this)(i,j);
|
---|
1000 | }
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | if( wx > 0. ) {
|
---|
1004 | xm = dxm/wx;
|
---|
1005 | ym = dym/wx;
|
---|
1006 | return rc;
|
---|
1007 | } else {
|
---|
1008 | BinCenter(im,jm,xm,ym);
|
---|
1009 | return 2;
|
---|
1010 | }
|
---|
1011 |
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | //++
|
---|
1015 | int Histo2D::FindMax(int& im,int& jm,int SzPav,float Dz
|
---|
1016 | ,int il,int ih,int jl,int jh)
|
---|
1017 | //
|
---|
1018 | // Pour trouver le maximum de l'histogramme en tenant compte
|
---|
1019 | // des fluctuations.
|
---|
1020 | //| Methode:
|
---|
1021 | //| 1-/ On recherche le bin maximum MAX de l'histogramme
|
---|
1022 | //| 2-/ On considere que tous les pixels compris entre [MAX-Dz,MAX]
|
---|
1023 | //| peuvent etre des pixels maxima.
|
---|
1024 | //| 3-/ On identifie le bin maximum en choissisant le pixel du 2-/
|
---|
1025 | //| tel que la somme des pixels dans un pave SzPav x SzPav soit maximale.
|
---|
1026 | //| INPUT:
|
---|
1027 | //| SzPav = taille du pave pour departager
|
---|
1028 | //| Dz = tolerance pour identifier tous les pixels "maximum"
|
---|
1029 | //| OUTPUT:
|
---|
1030 | //| im,jm = pixel maximum trouve
|
---|
1031 | //| RETURN:
|
---|
1032 | //| <0 = Echec
|
---|
1033 | //| >0 = nombre de pixels possibles pour le maximum
|
---|
1034 | //--
|
---|
1035 | {
|
---|
1036 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
1037 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
1038 | if( il < 0 ) il = 0;
|
---|
1039 | if( jl < 0 ) jl = 0;
|
---|
1040 | if( ih >= nx ) ih = nx-1;
|
---|
1041 | if( jh >= ny ) jh = ny-1;
|
---|
1042 | if( SzPav < 0 ) SzPav = 0;
|
---|
1043 | else { if( SzPav%2 == 0 ) SzPav++; SzPav = (SzPav-1)/2;}
|
---|
1044 | if( Dz < 0 ) Dz = 0.;
|
---|
1045 | float max = VMax(il,ih,jl,jh) - Dz;
|
---|
1046 | int nmax = 0;
|
---|
1047 | float sumx = -MAXFLOAT;
|
---|
1048 | for(int i=il;i<=ih;i++) for(int j=jl;j<=jh;j++) {
|
---|
1049 | if( (*this)(i,j) < max) continue;
|
---|
1050 | nmax++;
|
---|
1051 | float sum = 0.;
|
---|
1052 | for(int ii=i-SzPav;ii<=i+SzPav;ii++) {
|
---|
1053 | if( ii<0 || ii >= nx ) continue;
|
---|
1054 | for(int jj=j-SzPav;jj<=j+SzPav;jj++) {
|
---|
1055 | if( jj<0 || jj >= ny ) continue;
|
---|
1056 | sum += (*this)(ii,jj);
|
---|
1057 | }
|
---|
1058 | }
|
---|
1059 | if( sum > sumx ) { im = i; jm = j; sumx = sum;}
|
---|
1060 | }
|
---|
1061 | if( nmax <= 0 ) { IJMax(im,jm,il,ih,jl,jh); return 1;}
|
---|
1062 | return nmax;
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | //////////////////////////////////////////////////////////
|
---|
1066 |
|
---|
1067 | //////////////////////////////////////////////////////////
|
---|
1068 | //++
|
---|
1069 | int Histo2D::Fit(GeneralFit& gfit,unsigned short typ_err)
|
---|
1070 | //
|
---|
1071 | // Fit de l'histogramme par ``gfit''.
|
---|
1072 | //| typ_err = 0 :
|
---|
1073 | //| - erreur attachee au bin si elle existe
|
---|
1074 | //| - sinon 1
|
---|
1075 | //| typ_err = 1 :
|
---|
1076 | //| - erreur attachee au bin si elle existe
|
---|
1077 | //| - sinon max( sqrt(abs(bin) ,1 )
|
---|
1078 | //| typ_err = 2 :
|
---|
1079 | //| - erreur forcee a 1
|
---|
1080 | //| typ_err = 3 :
|
---|
1081 | //| - erreur forcee a max( sqrt(abs(bin) ,1 )
|
---|
1082 | //| typ_err = 4 :
|
---|
1083 | //| - erreur forcee a 1, nulle si bin a zero.
|
---|
1084 | //| typ_err = 5 :
|
---|
1085 | //| - erreur forcee a max( sqrt(abs(bin) ,1 ),
|
---|
1086 | //| nulle si bin a zero.
|
---|
1087 | //--
|
---|
1088 | {
|
---|
1089 | if(NBinX()*NBinY()<=0) return -1000;
|
---|
1090 | if(typ_err>5) typ_err=0;
|
---|
1091 |
|
---|
1092 | GeneralFitData mydata(2,NBinX()*NBinY());
|
---|
1093 |
|
---|
1094 | for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
|
---|
1095 | float x,y;
|
---|
1096 | BinCenter(i,j,x,y);
|
---|
1097 | double f = (double) (*this)(i,j);
|
---|
1098 | double saf = sqrt(fabs(f)); if(saf<1.) saf=1.;
|
---|
1099 | double e;
|
---|
1100 | if(typ_err==0) {if(HasErrors()) e=Error(i,j); else e=1.;}
|
---|
1101 | else if(typ_err==1) {if(HasErrors()) e=Error(i,j); else e=saf;}
|
---|
1102 | else if(typ_err==2) e=1.;
|
---|
1103 | else if(typ_err==3) e=saf;
|
---|
1104 | else if(typ_err==4) e=(f==0.)?0.:1.;
|
---|
1105 | else if(typ_err==5) e=(f==0.)?0.:saf;
|
---|
1106 | mydata.AddData2((double) x,(double) y,f,e);
|
---|
1107 | }
|
---|
1108 |
|
---|
1109 | gfit.SetData(&mydata);
|
---|
1110 |
|
---|
1111 | return gfit.Fit();
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | //++
|
---|
1115 | Histo2D* Histo2D::FitResidus(GeneralFit& gfit)
|
---|
1116 | //
|
---|
1117 | // Retourne une classe contenant les residus du fit ``gfit''.
|
---|
1118 | //--
|
---|
1119 | {
|
---|
1120 | if(NBinX()<=0 || NBinY()<=0) return NULL;
|
---|
1121 | GeneralFunction* f = gfit.GetFunction();
|
---|
1122 | if(f==NULL) return NULL;
|
---|
1123 | Vector par = gfit.GetParm();
|
---|
1124 | Histo2D* h2 = new Histo2D(*this);
|
---|
1125 | for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
|
---|
1126 | float xc,yc;
|
---|
1127 | BinCenter(i,j,xc,yc);
|
---|
1128 | double x[2] = {(double)xc,(double)yc};
|
---|
1129 | (*h2)(i,j) -= (float) f->Value(x,par.Data());
|
---|
1130 | }
|
---|
1131 | return h2;
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | //++
|
---|
1135 | Histo2D* Histo2D::FitFunction(GeneralFit& gfit)
|
---|
1136 | //
|
---|
1137 | // Retourne une classe contenant la fonction du fit ``gfit''.
|
---|
1138 | //--
|
---|
1139 | {
|
---|
1140 | if(NBinX()<=0 || NBinY()<=0) return NULL;
|
---|
1141 | GeneralFunction* f = gfit.GetFunction();
|
---|
1142 | if(f==NULL) return NULL;
|
---|
1143 | Vector par = gfit.GetParm();
|
---|
1144 | Histo2D* h2 = new Histo2D(*this);
|
---|
1145 | for(int i=0;i<NBinX();i++) for(int j=0;j<NBinY();j++) {
|
---|
1146 | float xc,yc;
|
---|
1147 | BinCenter(i,j,xc,yc);
|
---|
1148 | double x[2] = {(double)xc,(double)yc};
|
---|
1149 | (*h2)(i,j) = (float) f->Value(x,par.Data());
|
---|
1150 | }
|
---|
1151 | return h2;
|
---|
1152 | }
|
---|
1153 |
|
---|
1154 | ///////////////////////////////////////////////////////////////////
|
---|
1155 | //++
|
---|
1156 | void Histo2D::PrintStatus()
|
---|
1157 | //
|
---|
1158 | // Impression des informations sur l'histogramme.
|
---|
1159 | //--
|
---|
1160 | {
|
---|
1161 | printf("~Histo::Print nHist=%g nEntries=%d\n",nHist,nEntries);
|
---|
1162 | printf("over: [ %g %g %g // %g %g %g // %g %g %g ]\n"
|
---|
1163 | ,over[2][0],over[2][1],over[2][2]
|
---|
1164 | ,over[1][0],over[1][1],over[1][2]
|
---|
1165 | ,over[0][0],over[0][1],over[0][2]);
|
---|
1166 | printf(" nx=%d xmin=%g xmax=%g binx=%g ",nx,xmin,xmax,wbinx);
|
---|
1167 | printf(" ny=%d ymin=%g ymax=%g biny=%g\n",ny,ymin,ymax,wbiny);
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | ///////////////////////////////////////////////////////////////////
|
---|
1171 | //++
|
---|
1172 | void Histo2D::Print(float min,float max
|
---|
1173 | ,int il,int ih,int jl,int jh)
|
---|
1174 | //
|
---|
1175 | // Impression de l'histogramme sur stdout entre [il,ih] et [jl,jh].
|
---|
1176 | //--
|
---|
1177 | {
|
---|
1178 | int ns = 35;
|
---|
1179 | // numero d'index: 00000000001111111111222222222233333
|
---|
1180 | // 01234567890123456789012345678901234
|
---|
1181 | // valeur entiere: 00000000001111111111222222222233333
|
---|
1182 | // 12345678901234567890123456789012345
|
---|
1183 | const char *s = "+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
---|
1184 |
|
---|
1185 | if( il > ih ) { il = 0; ih = nx-1; }
|
---|
1186 | if( jl > jh ) { jl = 0; jh = ny-1; }
|
---|
1187 | if( il < 0 ) il = 0;
|
---|
1188 | if( jl < 0 ) jl = 0;
|
---|
1189 | if( ih >= nx ) ih = nx-1;
|
---|
1190 | if( jh >= ny ) jh = ny-1;
|
---|
1191 |
|
---|
1192 | PrintStatus();
|
---|
1193 |
|
---|
1194 | if( il != 0 || ih != nx-1 || jl != 0 || jh != ny-1 ) {
|
---|
1195 | float xl,xh,yl,yh;
|
---|
1196 | BinLowEdge(il,jl,xl,yl);
|
---|
1197 | BinHighEdge(ih,jh,xh,yh);
|
---|
1198 | printf(" impression");
|
---|
1199 | printf(" en X: %d=[%d,%d] xmin=%g xmax=%g "
|
---|
1200 | ,ih-il+1,il,ih,xl,xh);
|
---|
1201 | printf(" en Y: %d=[%d,%d] ymin=%g ymax=%g\n"
|
---|
1202 | ,jh-jl+1,jl,jh,yl,yh);
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | if(min >= max) { if(min != 0.) min = VMin(il,ih,jl,jh); else min=0.;
|
---|
1206 | max = VMax(il,ih,jl,jh); }
|
---|
1207 | if(min>max) return;
|
---|
1208 | if(min==max) {min -= 1.; max += 1.;}
|
---|
1209 | printf(" min=%g max=%g\n",min,max);
|
---|
1210 |
|
---|
1211 | // imprime numero de bin en colonne
|
---|
1212 | printf("\n");
|
---|
1213 | if( nx-1 >= 100 ) {
|
---|
1214 | printf(" ");
|
---|
1215 | for(int i=il;i<=ih;i++) printf("%1d",(int) (i%1000)/100);
|
---|
1216 | printf("\n");
|
---|
1217 | }
|
---|
1218 | if( nx-1 >= 10 ) {
|
---|
1219 | printf(" ");
|
---|
1220 | for(int i=il;i<=ih;i++) printf("%1d",(int) (i%100)/10);
|
---|
1221 | printf("\n");
|
---|
1222 | }
|
---|
1223 | printf(" ");
|
---|
1224 | for(int i=il;i<=ih;i++) printf("%1d",i%10);
|
---|
1225 | printf("\n");
|
---|
1226 | printf(" "); {for(int i=il;i<=ih;i++) printf("-"); printf("\n");}
|
---|
1227 |
|
---|
1228 | // imprime histogramme
|
---|
1229 | for(int j=jh;j>=jl;j--) {
|
---|
1230 | printf("%3d: ",j);
|
---|
1231 | for(int i=il;i<=ih;i++) {
|
---|
1232 | int h;
|
---|
1233 | if( 1<=max-min && max-min<=35 ) h = (int)( (*this)(i,j) - min ) - 1;
|
---|
1234 | else h = (int)( ((*this)(i,j)-min)/(max-min) * ns ) - 1;
|
---|
1235 | char c;
|
---|
1236 | if(h<0 && (*this)(i,j)>min) c = '.';
|
---|
1237 | else if(h<0) c = ' ';
|
---|
1238 | else if(h>=ns) c = '*';
|
---|
1239 | else c = s[h];
|
---|
1240 | printf("%c",c);
|
---|
1241 | }
|
---|
1242 | printf("\n");
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | // imprime numero de bin en colonne
|
---|
1246 | printf(" "); {for(int i=il;i<=ih;i++) printf("-"); printf("\n");}
|
---|
1247 | if( nx-1 >= 100 ) {
|
---|
1248 | printf(" ");
|
---|
1249 | for(int i=il;i<=ih;i++) printf("%1d",(int) (i%1000)/100);
|
---|
1250 | printf("\n");
|
---|
1251 | }
|
---|
1252 | if( nx-1 >= 10 ) {
|
---|
1253 | printf(" ");
|
---|
1254 | for(int i=il;i<=ih;i++) printf("%1d",(int) (i%100)/10);
|
---|
1255 | printf("\n");
|
---|
1256 | }
|
---|
1257 | printf(" ");
|
---|
1258 | {for(int i=il;i<=ih;i++) printf("%1d",i%10);}
|
---|
1259 | printf("\n");
|
---|
1260 |
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 | // Rappel des inline functions pour commentaires
|
---|
1264 | //++
|
---|
1265 | // inline float XMin()
|
---|
1266 | // Retourne l'abscisse minimum.
|
---|
1267 | //--
|
---|
1268 | //++
|
---|
1269 | // inline float XMax()
|
---|
1270 | // Retourne l'abscisse maximum.
|
---|
1271 | //--
|
---|
1272 | //++
|
---|
1273 | // inline float YMin()
|
---|
1274 | // Retourne l'ordonnee minimum.
|
---|
1275 | //--
|
---|
1276 | //++
|
---|
1277 | // inline float YMax()
|
---|
1278 | // Retourne l'ordonnee maximum.
|
---|
1279 | //--
|
---|
1280 | //++
|
---|
1281 | // inline int NBinX()
|
---|
1282 | // Retourne le nombre de bins selon X.
|
---|
1283 | //--
|
---|
1284 | //++
|
---|
1285 | // inline int NBinY()
|
---|
1286 | // Retourne le nombre de bins selon Y.
|
---|
1287 | //--
|
---|
1288 | //++
|
---|
1289 | // inline float WBinX()
|
---|
1290 | // Retourne la largeur du bin selon X.
|
---|
1291 | //--
|
---|
1292 | //++
|
---|
1293 | // inline float WBinY()
|
---|
1294 | // Retourne la largeur du bin selon Y.
|
---|
1295 | //--
|
---|
1296 | //++
|
---|
1297 | // inline float* Bins() const
|
---|
1298 | // Retourne le pointeur sur le tableaux des contenus.
|
---|
1299 | //--
|
---|
1300 | //++
|
---|
1301 | // inline float operator()(int i,int j) const
|
---|
1302 | // Retourne le contenu du bin i,j.
|
---|
1303 | //--
|
---|
1304 | //++
|
---|
1305 | // inline float& operator()(int i,int j)
|
---|
1306 | // Remplit le contenu du bin i,j.
|
---|
1307 | //--
|
---|
1308 | //++
|
---|
1309 | // inline float Error(int i,int j) const
|
---|
1310 | // Retourne l'erreur du bin i,j.
|
---|
1311 | //--
|
---|
1312 | //++
|
---|
1313 | // inline double Error2(int i,int j) const
|
---|
1314 | // Retourne l'erreur au carre du bin i,j.
|
---|
1315 | //--
|
---|
1316 | //++
|
---|
1317 | // inline double& Error2(int i,int j)
|
---|
1318 | // Remplit l'erreur au carre du bin i,j.
|
---|
1319 | //--
|
---|
1320 | //++
|
---|
1321 | // inline float NData() const
|
---|
1322 | // Retourne la somme ponderee.
|
---|
1323 | //--
|
---|
1324 | //++
|
---|
1325 | // inline int NEntries() const
|
---|
1326 | // Retourne le nombre d'entrees.
|
---|
1327 | //--
|
---|
1328 | //++
|
---|
1329 | // inline void BinLowEdge(int i,int j,float& x,float& y)
|
---|
1330 | // Retourne l'abscisse et l'ordonnee du coin inferieur du bin i,j.
|
---|
1331 | //--
|
---|
1332 | //++
|
---|
1333 | // inline void BinCenter(int i,int j,float& x,float& y)
|
---|
1334 | // Retourne l'abscisse et l'ordonnee du centre du bin i,j.
|
---|
1335 | //--
|
---|
1336 | //++
|
---|
1337 | // inline void BinHighEdge(int i,int j,float& x,float& y)
|
---|
1338 | // Retourne l'abscisse et l'ordonnee du coin superieur du bin i,j.
|
---|
1339 | //--
|
---|
1340 | //++
|
---|
1341 | // inline void FindBin(float x,float y,int& i,int& j)
|
---|
1342 | // Retourne les numeros du bin contenant l'abscisse et l'ordonnee x,y.
|
---|
1343 | //--
|
---|
1344 |
|
---|
1345 | ///////////////////////////////////////////////////////////////////
|
---|
1346 | //++
|
---|
1347 | // Titre Methodes pour gerer les projections
|
---|
1348 | //--
|
---|
1349 |
|
---|
1350 | //++
|
---|
1351 | void Histo2D::SetProjX()
|
---|
1352 | //
|
---|
1353 | // Pour creer la projection X.
|
---|
1354 | //--
|
---|
1355 | {
|
---|
1356 | if( hprojx != NULL ) DelProjX();
|
---|
1357 | hprojx = new Histo(xmin,xmax,nx);
|
---|
1358 | if( err2 != NULL && hprojx != NULL ) hprojx->Errors();
|
---|
1359 | }
|
---|
1360 |
|
---|
1361 | //++
|
---|
1362 | void Histo2D::SetProjY()
|
---|
1363 | //
|
---|
1364 | // Pour creer la projection Y.
|
---|
1365 | //--
|
---|
1366 | {
|
---|
1367 | if( hprojy != NULL ) DelProjY();
|
---|
1368 | hprojy = new Histo(ymin,ymax,ny);
|
---|
1369 | if( err2 != NULL && hprojy != NULL ) hprojy->Errors();
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | //++
|
---|
1373 | void Histo2D::SetProj()
|
---|
1374 | //
|
---|
1375 | // Pour creer les projections X et Y.
|
---|
1376 | //--
|
---|
1377 | {
|
---|
1378 | SetProjX();
|
---|
1379 | SetProjY();
|
---|
1380 | }
|
---|
1381 |
|
---|
1382 | //++
|
---|
1383 | void Histo2D::ShowProj()
|
---|
1384 | //
|
---|
1385 | // Informations sur les projections.
|
---|
1386 | //--
|
---|
1387 | {
|
---|
1388 | if( hprojx != NULL ) cout << ">>>> Projection X set : "<< hprojx <<endl;
|
---|
1389 | else cout << ">>>> NO Projection X set"<<endl;
|
---|
1390 | if( hprojy != NULL ) cout << ">>>> Projection Y set : "<< hprojy <<endl;
|
---|
1391 | else cout << ">>>> NO Projection Y set"<<endl;
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 | //++
|
---|
1395 | void Histo2D::DelProjX()
|
---|
1396 | //
|
---|
1397 | // Destruction de l'histogramme de la projection selon X.
|
---|
1398 | //--
|
---|
1399 | {
|
---|
1400 | if( hprojx == NULL ) return;
|
---|
1401 | delete hprojx;
|
---|
1402 | hprojx = NULL;
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 | //++
|
---|
1406 | void Histo2D::DelProjY()
|
---|
1407 | //
|
---|
1408 | // Destruction de l'histogramme de la projection selon X.
|
---|
1409 | //--
|
---|
1410 | {
|
---|
1411 | if( hprojy == NULL ) return;
|
---|
1412 | delete hprojy;
|
---|
1413 | hprojy = NULL;
|
---|
1414 | }
|
---|
1415 |
|
---|
1416 | //++
|
---|
1417 | void Histo2D::DelProj()
|
---|
1418 | //
|
---|
1419 | // Destruction des histogrammes des projections selon X et Y.
|
---|
1420 | //--
|
---|
1421 | {
|
---|
1422 | DelProjX();
|
---|
1423 | DelProjY();
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | //++
|
---|
1427 | void Histo2D::ZeroProjX()
|
---|
1428 | //
|
---|
1429 | // Remise a zero de la projection selon X.
|
---|
1430 | //--
|
---|
1431 | {
|
---|
1432 | if( hprojx == NULL ) return;
|
---|
1433 | hprojx->Zero();
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | //++
|
---|
1437 | void Histo2D::ZeroProjY()
|
---|
1438 | //
|
---|
1439 | // Remise a zero de la projection selon Y.
|
---|
1440 | //--
|
---|
1441 | {
|
---|
1442 | if( hprojy == NULL ) return;
|
---|
1443 | hprojy->Zero();
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | //++
|
---|
1447 | void Histo2D::ZeroProj()
|
---|
1448 | //
|
---|
1449 | // Remise a zero des projections selon X et Y.
|
---|
1450 | //--
|
---|
1451 | {
|
---|
1452 | ZeroProjX();
|
---|
1453 | ZeroProjY();
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | // Rappel des inline functions pour commentaires
|
---|
1457 | //++
|
---|
1458 | // inline Histo* HProjX()
|
---|
1459 | // Retourne le pointeur sur l'histo 1D de la projection selon X.
|
---|
1460 | //--
|
---|
1461 | //++
|
---|
1462 | // inline Histo* HProjY()
|
---|
1463 | // Retourne le pointeur sur l'histo 1D de la projection selon Y.
|
---|
1464 | //--
|
---|
1465 |
|
---|
1466 | ///////////////////////////////////////////////////////////////////
|
---|
1467 | //++
|
---|
1468 | // Titre Methodes pour gerer les bandes
|
---|
1469 | //--
|
---|
1470 |
|
---|
1471 | //++
|
---|
1472 | int Histo2D::SetBandX(float ybmin,float ybmax)
|
---|
1473 | //
|
---|
1474 | // Pour creer une bande en X entre ybmin et ybmax.
|
---|
1475 | //--
|
---|
1476 | {
|
---|
1477 | b_s.num = lbandx.size();
|
---|
1478 | b_s.min = ybmin;
|
---|
1479 | b_s.max = ybmax;
|
---|
1480 | b_s.H = new Histo(xmin,xmax,nx);
|
---|
1481 | lbandx.push_back(b_s);
|
---|
1482 | b_s.H = NULL;
|
---|
1483 | return lbandx.size()-1;
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | //++
|
---|
1487 | int Histo2D::SetBandY(float xbmin,float xbmax)
|
---|
1488 | //
|
---|
1489 | // Pour creer une bande en Y entre xbmin et xbmax.
|
---|
1490 | //--
|
---|
1491 | {
|
---|
1492 | b_s.num = lbandy.size();
|
---|
1493 | b_s.min = xbmin;
|
---|
1494 | b_s.max = xbmax;
|
---|
1495 | b_s.H = new Histo(ymin,ymax,ny);
|
---|
1496 | lbandy.push_back(b_s);
|
---|
1497 | b_s.H = NULL;
|
---|
1498 | return lbandy.size()-1;
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | //++
|
---|
1502 | void Histo2D::DelBandX()
|
---|
1503 | //
|
---|
1504 | // Destruction des histogrammes des bandes selon X.
|
---|
1505 | //--
|
---|
1506 | {
|
---|
1507 | if( lbandx.size() <= 0 ) return;
|
---|
1508 | for(list<bande_slice>::iterator i = lbandx.begin(); i != lbandx.end(); i++)
|
---|
1509 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
1510 | lbandx.erase(lbandx.begin(),lbandx.end());
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | //++
|
---|
1514 | void Histo2D::DelBandY()
|
---|
1515 | //
|
---|
1516 | // Destruction des histogrammes des bandes selon Y.
|
---|
1517 | //--
|
---|
1518 | {
|
---|
1519 | if( lbandy.size() <= 0 ) return;
|
---|
1520 | for(list<bande_slice>::iterator i = lbandy.begin(); i != lbandy.end(); i++)
|
---|
1521 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
1522 | lbandy.erase(lbandy.begin(),lbandy.end());
|
---|
1523 | }
|
---|
1524 |
|
---|
1525 | //++
|
---|
1526 | void Histo2D::ZeroBandX()
|
---|
1527 | //
|
---|
1528 | // Remise a zero des bandes selon X.
|
---|
1529 | //--
|
---|
1530 | {
|
---|
1531 | if( lbandx.size() <= 0 ) return;
|
---|
1532 | list<bande_slice>::iterator i;
|
---|
1533 | for(i = lbandx.begin(); i != lbandx.end(); i++)
|
---|
1534 | (*i).H->Zero();
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 | //++
|
---|
1538 | void Histo2D::ZeroBandY()
|
---|
1539 | //
|
---|
1540 | // Remise a zero des bandes selon Y.
|
---|
1541 | //--
|
---|
1542 | {
|
---|
1543 | if( lbandy.size() <= 0 ) return;
|
---|
1544 | list<bande_slice>::iterator i;
|
---|
1545 | for(i = lbandy.begin(); i != lbandy.end(); i++)
|
---|
1546 | (*i).H->Zero();
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | //++
|
---|
1550 | Histo* Histo2D::HBandX(int n) const
|
---|
1551 | //
|
---|
1552 | // Retourne un pointeur sur la bande numero `n' selon X.
|
---|
1553 | //--
|
---|
1554 | {
|
---|
1555 | if( lbandx.size() <= 0 || n < 0 || n >= (int) lbandx.size() ) return NULL;
|
---|
1556 | for(list<bande_slice>::const_iterator i = lbandx.begin(); i != lbandx.end(); i++)
|
---|
1557 | if( (*i).num == n ) return (*i).H;
|
---|
1558 | return NULL;
|
---|
1559 | }
|
---|
1560 |
|
---|
1561 | //++
|
---|
1562 | Histo* Histo2D::HBandY(int n) const
|
---|
1563 | //
|
---|
1564 | // Retourne un pointeur sur la bande numero `n' selon Y.
|
---|
1565 | //--
|
---|
1566 | {
|
---|
1567 | if( lbandy.size() <= 0 || n < 0 || n >= (int) lbandy.size() ) return NULL;
|
---|
1568 | for(list<bande_slice>::const_iterator i = lbandy.begin(); i != lbandy.end(); i++)
|
---|
1569 | if( (*i).num == n ) return (*i).H;
|
---|
1570 | return NULL;
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | //++
|
---|
1574 | void Histo2D::GetBandX(int n,float& ybmin,float& ybmax) const
|
---|
1575 | //
|
---|
1576 | // Retourne les limites de la bande numero `n' selon X.
|
---|
1577 | //--
|
---|
1578 | {
|
---|
1579 | ybmin = 0.; ybmax = 0.;
|
---|
1580 | if( lbandx.size() <= 0 || n < 0 || n >= (int) lbandx.size() ) return;
|
---|
1581 | for(list<bande_slice>::const_iterator i = lbandx.begin(); i != lbandx.end(); i++)
|
---|
1582 | if( (*i).num == n ) { ybmin = (*i).min; ybmax = (*i).max; return;}
|
---|
1583 | return;
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | //++
|
---|
1587 | void Histo2D::GetBandY(int n,float& xbmin,float& xbmax) const
|
---|
1588 | //
|
---|
1589 | // Retourne les limites de la bande numero `n' selon Y.
|
---|
1590 | //--
|
---|
1591 | {
|
---|
1592 | xbmin = 0.; xbmax = 0.;
|
---|
1593 | if( lbandy.size() <= 0 || n < 0 || n >= (int) lbandy.size() ) return;
|
---|
1594 | for(list<bande_slice>::const_iterator i = lbandy.begin(); i != lbandy.end(); i++)
|
---|
1595 | if( (*i).num == n ) { xbmin = (*i).min; xbmax = (*i).max; return;}
|
---|
1596 | return;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | //++
|
---|
1600 | void Histo2D::ShowBand(int lp)
|
---|
1601 | //
|
---|
1602 | // Informations sur les bandes.
|
---|
1603 | //--
|
---|
1604 | {
|
---|
1605 | cout << ">>>> Nombre de bande X : " << lbandx.size() << endl;
|
---|
1606 | if( lp>0 && lbandx.size()>0 ) {
|
---|
1607 | list<bande_slice>::iterator i;
|
---|
1608 | for(i = lbandx.begin(); i != lbandx.end(); i++) {
|
---|
1609 | cout<<" "<<(*i).num<<" de ymin="<<(*i).min<<" a ymax="<<(*i).max;
|
---|
1610 | if(lp>1) cout << " H=" << (*i).H;
|
---|
1611 | cout << endl;
|
---|
1612 | }
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | cout << ">>>> Nombre de bande Y : " << lbandy.size() << endl;
|
---|
1616 | if( lp>0 && lbandy.size()>0 ) {
|
---|
1617 | list<bande_slice>::iterator i;
|
---|
1618 | for(i = lbandy.begin(); i != lbandy.end(); i++) {
|
---|
1619 | cout<<" "<<(*i).num<<" de xmin="<<(*i).min<<" a xmax="<<(*i).max;
|
---|
1620 | if(lp>1) cout << " H=" << (*i).H;
|
---|
1621 | cout << endl;
|
---|
1622 | }
|
---|
1623 | }
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | // Rappel des inline functions pour commentaires
|
---|
1627 | //++
|
---|
1628 | // inline int NBandX()
|
---|
1629 | // Retourne le nombre de bandes selon X
|
---|
1630 | //--
|
---|
1631 | //++
|
---|
1632 | // inline int NBandY()
|
---|
1633 | // Retourne le nombre de bandes selon Y
|
---|
1634 | //--
|
---|
1635 |
|
---|
1636 | ///////////////////////////////////////////////////////////////////
|
---|
1637 | //++
|
---|
1638 | // Titre Methodes pour gerer les bandes equidistantes
|
---|
1639 | //--
|
---|
1640 |
|
---|
1641 | //++
|
---|
1642 | int Histo2D::SetSliX(int nsli)
|
---|
1643 | //
|
---|
1644 | // Pour creer `nsli' bandes equidistantes selon X.
|
---|
1645 | //--
|
---|
1646 | {
|
---|
1647 | if( nsli <= 0 ) return -1;
|
---|
1648 | if( nsli > ny ) nsli = ny;
|
---|
1649 | if( lslix.size() > 0 ) DelSliX();
|
---|
1650 | float w = (ymax-ymin)/nsli;
|
---|
1651 |
|
---|
1652 | for(int i=0; i<nsli; i++ ) {
|
---|
1653 | b_s.num = i;
|
---|
1654 | b_s.min = ymin + i*w;
|
---|
1655 | b_s.max = b_s.min + w;
|
---|
1656 | b_s.H = new Histo(xmin,xmax,nx);
|
---|
1657 | lslix.push_back(b_s);
|
---|
1658 | b_s.H = NULL;
|
---|
1659 | }
|
---|
1660 | return (int) lslix.size();
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 | //++
|
---|
1664 | int Histo2D::SetSliY(int nsli)
|
---|
1665 | //
|
---|
1666 | // Pour creer `nsli' bandes equidistantes selon Y.
|
---|
1667 | //--
|
---|
1668 | {
|
---|
1669 | if( nsli <= 0 ) return -1;
|
---|
1670 | if( nsli > nx ) nsli = nx;
|
---|
1671 | if( lsliy.size() > 0 ) DelSliY();
|
---|
1672 | float w = (xmax-xmin)/nsli;
|
---|
1673 |
|
---|
1674 | for(int i=0; i<nsli; i++ ) {
|
---|
1675 | b_s.num = i;
|
---|
1676 | b_s.min = xmin + i*w;
|
---|
1677 | b_s.max = b_s.min + w;
|
---|
1678 | b_s.H = new Histo(ymin,ymax,ny);
|
---|
1679 | lsliy.push_back(b_s);
|
---|
1680 | b_s.H = NULL;
|
---|
1681 | }
|
---|
1682 | return (int) lsliy.size();
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 | //++
|
---|
1686 | void Histo2D::DelSliX()
|
---|
1687 | //
|
---|
1688 | // Destruction des bandes equidistantes selon X.
|
---|
1689 | //--
|
---|
1690 | {
|
---|
1691 | if( lslix.size() <= 0 ) return;
|
---|
1692 | for(list<bande_slice>::iterator i = lslix.begin(); i != lslix.end(); i++)
|
---|
1693 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
1694 | lslix.erase(lslix.begin(),lslix.end());
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 | //++
|
---|
1698 | void Histo2D::DelSliY()
|
---|
1699 | //
|
---|
1700 | // Destruction des bandes equidistantes selon Y.
|
---|
1701 | //--
|
---|
1702 | {
|
---|
1703 | if( lsliy.size() <= 0 ) return;
|
---|
1704 | for(list<bande_slice>::iterator i = lsliy.begin(); i != lsliy.end(); i++)
|
---|
1705 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
1706 | lsliy.erase(lsliy.begin(),lsliy.end());
|
---|
1707 | }
|
---|
1708 |
|
---|
1709 | //++
|
---|
1710 | void Histo2D::ZeroSliX()
|
---|
1711 | //
|
---|
1712 | // Remise a zero des bandes equidistantes selon X.
|
---|
1713 | //--
|
---|
1714 | {
|
---|
1715 | if( lslix.size() <= 0 ) return;
|
---|
1716 | list<bande_slice>::iterator i;
|
---|
1717 | for(i = lslix.begin(); i != lslix.end(); i++)
|
---|
1718 | (*i).H->Zero();
|
---|
1719 | }
|
---|
1720 |
|
---|
1721 | //++
|
---|
1722 | void Histo2D::ZeroSliY()
|
---|
1723 | //
|
---|
1724 | // Remise a zero des bandes equidistantes selon Y.
|
---|
1725 | //--
|
---|
1726 | {
|
---|
1727 | if( lsliy.size() <= 0 ) return;
|
---|
1728 | list<bande_slice>::iterator i;
|
---|
1729 | for(i = lsliy.begin(); i != lsliy.end(); i++)
|
---|
1730 | (*i).H->Zero();
|
---|
1731 | }
|
---|
1732 |
|
---|
1733 | //++
|
---|
1734 | Histo* Histo2D::HSliX(int n) const
|
---|
1735 | //
|
---|
1736 | // Retourne un pointeur sur la bande equidistante numero `n'
|
---|
1737 | // selon X.
|
---|
1738 | //--
|
---|
1739 | {
|
---|
1740 | if( lslix.size() <= 0 || n < 0 || n >= (int) lslix.size() ) return NULL;
|
---|
1741 | for(list<bande_slice>::const_iterator i = lslix.begin(); i != lslix.end(); i++)
|
---|
1742 | if( (*i).num == n ) return (*i).H;
|
---|
1743 | return NULL;
|
---|
1744 | }
|
---|
1745 |
|
---|
1746 | //++
|
---|
1747 | Histo* Histo2D::HSliY(int n) const
|
---|
1748 | //
|
---|
1749 | // Retourne un pointeur sur la bande equidistante numero `n'
|
---|
1750 | // selon Y.
|
---|
1751 | //--
|
---|
1752 | {
|
---|
1753 | if( lsliy.size() <= 0 || n < 0 || n >= (int) lsliy.size() ) return NULL;
|
---|
1754 | for(list<bande_slice>::const_iterator i = lsliy.begin(); i != lsliy.end(); i++)
|
---|
1755 | if( (*i).num == n ) return (*i).H;
|
---|
1756 | return NULL;
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | //++
|
---|
1760 | void Histo2D::ShowSli(int lp)
|
---|
1761 | //
|
---|
1762 | // Informations sur les bandes equidistantes.
|
---|
1763 | //--
|
---|
1764 | {
|
---|
1765 | list<bande_slice>::iterator i;
|
---|
1766 | cout << ">>>> Nombre de slice X : " << lslix.size() << endl;
|
---|
1767 | if( lp>0 && lslix.size() > 0 )
|
---|
1768 | for(i = lslix.begin(); i != lslix.end(); i++) {
|
---|
1769 | cout<<" "<<(*i).num<<" de ymin="<<(*i).min<<" a ymax="<<(*i).max;
|
---|
1770 | if(lp>1) cout << " H=" << (*i).H;
|
---|
1771 | cout << endl;
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | cout << ">>>> Nombre de slice Y : " << lsliy.size() << endl;
|
---|
1775 | if( lp>0 && lsliy.size()>0 )
|
---|
1776 | for(i = lsliy.begin(); i != lsliy.end(); i++) {
|
---|
1777 | cout<<" "<<(*i).num<<" de xmin="<<(*i).min<<" a xmax="<<(*i).max;
|
---|
1778 | if(lp>1) cout << " H=" << (*i).H;
|
---|
1779 | cout << endl;
|
---|
1780 | }
|
---|
1781 | }
|
---|
1782 |
|
---|
1783 | // Rappel des inline functions pour commentaires
|
---|
1784 | //++
|
---|
1785 | // inline int NSliX()
|
---|
1786 | // Retourne le nombre de slices selon X
|
---|
1787 | //--
|
---|
1788 | //++
|
---|
1789 | // inline int NSliY()
|
---|
1790 | // Retourne le nombre de slices selon Y
|
---|
1791 | //--
|
---|
1792 |
|
---|
1793 |
|
---|
1794 | ///////////////////////////////////////////////////////////////////
|
---|
1795 | //++
|
---|
1796 | // Titre Methodes pour ecriture ppersist
|
---|
1797 | //--
|
---|
1798 |
|
---|
1799 | //++
|
---|
1800 | void Histo2D::WriteSelf(POutPersist& s) const
|
---|
1801 | //
|
---|
1802 | // Ecriture fichier de type ppersist.
|
---|
1803 | //--
|
---|
1804 | {
|
---|
1805 | char strg[256];
|
---|
1806 | int j;
|
---|
1807 | float min,max;
|
---|
1808 | Histo* h;
|
---|
1809 |
|
---|
1810 | // Que faut-il ecrire?
|
---|
1811 | int_4 errok = (err2) ? 1 : 0;
|
---|
1812 | int_4 projx = (hprojx) ? 1 : 0;
|
---|
1813 | int_4 projy = (hprojy) ? 1 : 0;
|
---|
1814 | int_4 nslix = NSliX();
|
---|
1815 | int_4 nsliy = NSliY();
|
---|
1816 | int_4 nbanx = NBandX();
|
---|
1817 | int_4 nbany = NBandY();
|
---|
1818 |
|
---|
1819 | // Ecriture entete pour identifier facilement
|
---|
1820 | sprintf(strg,"nx=%d ny=%d nxy=%d errok=%1d",nx,ny,nxy,errok);
|
---|
1821 | s.PutLine(strg);
|
---|
1822 | sprintf(strg,"nHist=%g nEntries=%d",nHist,nEntries);
|
---|
1823 | s.PutLine(strg);
|
---|
1824 | sprintf(strg,"wbinx=%g wbiny=%g",wbinx,wbiny);
|
---|
1825 | s.PutLine(strg);
|
---|
1826 | sprintf(strg,"xmin=%g xmax=%g ymin=%g ymax=%g",xmin,xmax,ymin,ymax);
|
---|
1827 | s.PutLine(strg);
|
---|
1828 | sprintf(strg,"projx/y=%d %d nbandx/y=%d %d nbslix/y=%d %d"
|
---|
1829 | ,projx,projy,nbanx,nbany,nslix,nsliy);
|
---|
1830 | s.PutLine(strg);
|
---|
1831 | sprintf(strg,"over %g %g %g %g %g %g %g %g %g"
|
---|
1832 | ,over[0][0],over[0][1],over[0][2]
|
---|
1833 | ,over[1][0],over[1][1],over[1][2]
|
---|
1834 | ,over[2][0],over[2][1],over[2][2]);
|
---|
1835 | s.PutLine(strg);
|
---|
1836 |
|
---|
1837 | // Ecriture variables de definitions
|
---|
1838 | s.PutI4(nx);
|
---|
1839 | s.PutI4(ny);
|
---|
1840 | s.PutI4(nxy);
|
---|
1841 | s.PutI4(errok);
|
---|
1842 | s.PutI4(nEntries);
|
---|
1843 | s.PutR8(nHist);
|
---|
1844 |
|
---|
1845 | s.PutR4(xmin);
|
---|
1846 | s.PutR4(xmax);
|
---|
1847 | s.PutR4(ymin);
|
---|
1848 | s.PutR4(ymax);
|
---|
1849 | s.PutR4(wbinx);
|
---|
1850 | s.PutR4(wbiny);
|
---|
1851 |
|
---|
1852 | s.PutR4s(&over[0][0],9);
|
---|
1853 |
|
---|
1854 | s.PutI4(projx);
|
---|
1855 | s.PutI4(projy);
|
---|
1856 | s.PutI4(nslix);
|
---|
1857 | s.PutI4(nsliy);
|
---|
1858 | s.PutI4(nbanx);
|
---|
1859 | s.PutI4(nbany);
|
---|
1860 |
|
---|
1861 | // Ecriture histo2D
|
---|
1862 | sprintf(strg,"Histo2D: Tableau des donnees %d = %d * %d",nxy,nx,ny);
|
---|
1863 | s.PutLine(strg);
|
---|
1864 | for(j=0;j<ny;j++) s.PutR4s(data+j*nx,nx);
|
---|
1865 |
|
---|
1866 |
|
---|
1867 | // Ecriture erreurs
|
---|
1868 | if(errok) {
|
---|
1869 | sprintf(strg,"Histo2D: Tableau des erreurs %d = %d * %d",nxy,nx,ny);
|
---|
1870 | s.PutLine(strg);
|
---|
1871 | for(j=0;j<ny;j++) s.PutR8s(err2+j*nx,nx);
|
---|
1872 | }
|
---|
1873 |
|
---|
1874 | // Ecriture des projections
|
---|
1875 | if(projx) {
|
---|
1876 | sprintf(strg,"Histo2D: Projection X");
|
---|
1877 | s.PutLine(strg);
|
---|
1878 | hprojx->Write(s);
|
---|
1879 | }
|
---|
1880 | if(projy) {
|
---|
1881 | sprintf(strg,"Histo2D: Projection Y");
|
---|
1882 | s.PutLine(strg);
|
---|
1883 | hprojy->Write(s);
|
---|
1884 | }
|
---|
1885 |
|
---|
1886 | // Ecriture des slices
|
---|
1887 | if(nslix>0) {
|
---|
1888 | sprintf(strg,"Histo2D: Slices X %d",nslix);
|
---|
1889 | s.PutLine(strg);
|
---|
1890 | for(j=0;j<nslix;j++) {
|
---|
1891 | h = HSliX(j);
|
---|
1892 | h->Write(s);
|
---|
1893 | }
|
---|
1894 | }
|
---|
1895 | if(nsliy>0) {
|
---|
1896 | sprintf(strg,"Histo2D: Slices Y %d",nsliy);
|
---|
1897 | s.PutLine(strg);
|
---|
1898 | for(j=0;j<nsliy;j++) {
|
---|
1899 | h = HSliY(j);
|
---|
1900 | h->Write(s);
|
---|
1901 | }
|
---|
1902 | }
|
---|
1903 |
|
---|
1904 | // Ecriture des bandes
|
---|
1905 | if( nbanx>0 ) {
|
---|
1906 | sprintf(strg,"Histo2D: Bandes X %d",nbanx);
|
---|
1907 | s.PutLine(strg);
|
---|
1908 | list<bande_slice>::const_iterator it;
|
---|
1909 | for(it = lbandx.begin(); it != lbandx.end(); it++) {
|
---|
1910 | min = (*it).min;
|
---|
1911 | max = (*it).max;
|
---|
1912 | s.PutR4(min);
|
---|
1913 | s.PutR4(max);
|
---|
1914 | }
|
---|
1915 | for(it = lbandx.begin(); it != lbandx.end(); it++) {
|
---|
1916 | h = (*it).H;
|
---|
1917 | h->Write(s);
|
---|
1918 | }
|
---|
1919 | }
|
---|
1920 | if( nbany>0 ) {
|
---|
1921 | sprintf(strg,"Histo2D: Bandes Y %d",nbany);
|
---|
1922 | s.PutLine(strg);
|
---|
1923 | list<bande_slice>::const_iterator it;
|
---|
1924 | for(it = lbandy.begin(); it != lbandy.end(); it++) {
|
---|
1925 | min = (*it).min;
|
---|
1926 | max = (*it).max;
|
---|
1927 | s.PutR4(min);
|
---|
1928 | s.PutR4(max);
|
---|
1929 | }
|
---|
1930 | for(it = lbandy.begin(); it != lbandy.end(); it++) {
|
---|
1931 | h = (*it).H;
|
---|
1932 | h->Write(s);
|
---|
1933 | }
|
---|
1934 | }
|
---|
1935 |
|
---|
1936 | return;
|
---|
1937 | }
|
---|
1938 |
|
---|
1939 | //++
|
---|
1940 | void Histo2D::ReadSelf(PInPersist& s)
|
---|
1941 | //
|
---|
1942 | // Lecture fichier de type ppersist.
|
---|
1943 | //--
|
---|
1944 | {
|
---|
1945 | Delete();
|
---|
1946 |
|
---|
1947 | int j;
|
---|
1948 | float min,max;
|
---|
1949 | Histo* h;
|
---|
1950 | char strg[256];
|
---|
1951 | int_4 errok, projx, projy, nslix, nsliy, nbanx, nbany;
|
---|
1952 |
|
---|
1953 | // Lecture entete
|
---|
1954 | s.GetLine(strg, 255);
|
---|
1955 | s.GetLine(strg, 255);
|
---|
1956 | s.GetLine(strg, 255);
|
---|
1957 | s.GetLine(strg, 255);
|
---|
1958 | s.GetLine(strg, 255);
|
---|
1959 | s.GetLine(strg, 255);
|
---|
1960 |
|
---|
1961 |
|
---|
1962 | // Lecture variables de definitions
|
---|
1963 | s.GetI4(nx);
|
---|
1964 | s.GetI4(ny);
|
---|
1965 | s.GetI4(nxy);
|
---|
1966 | s.GetI4(errok);
|
---|
1967 | s.GetI4(nEntries);
|
---|
1968 | s.GetR8(nHist);
|
---|
1969 |
|
---|
1970 | s.GetR4(xmin);
|
---|
1971 | s.GetR4(xmax);
|
---|
1972 | s.GetR4(ymin);
|
---|
1973 | s.GetR4(ymax);
|
---|
1974 | s.GetR4(wbinx);
|
---|
1975 | s.GetR4(wbiny);
|
---|
1976 |
|
---|
1977 | s.GetR4s(&over[0][0],9);
|
---|
1978 |
|
---|
1979 | s.GetI4(projx);
|
---|
1980 | s.GetI4(projy);
|
---|
1981 | s.GetI4(nslix);
|
---|
1982 | s.GetI4(nsliy);
|
---|
1983 | s.GetI4(nbanx);
|
---|
1984 | s.GetI4(nbany);
|
---|
1985 |
|
---|
1986 | // Lecture histo2D
|
---|
1987 | data = new float[nxy];
|
---|
1988 | s.GetLine(strg, 255);
|
---|
1989 | for(j=0;j<ny;j++) s.GetR4s(data+j*nx,nx);
|
---|
1990 |
|
---|
1991 | // Lecture erreurs
|
---|
1992 | if(errok) {
|
---|
1993 | s.GetLine(strg, 255);
|
---|
1994 | err2 = new double[nxy];
|
---|
1995 | for(j=0;j<ny;j++) s.GetR8s(err2+j*nx,nx);
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 | // Lecture des projections
|
---|
1999 | if(projx) {
|
---|
2000 | s.GetLine(strg, 255);
|
---|
2001 | SetProjX();
|
---|
2002 | hprojx->Read(s);
|
---|
2003 | }
|
---|
2004 | if(projy) {
|
---|
2005 | s.GetLine(strg, 255);
|
---|
2006 | SetProjY();
|
---|
2007 | hprojy->Read(s);
|
---|
2008 | }
|
---|
2009 |
|
---|
2010 | // Lecture des slices
|
---|
2011 | if(nslix>0) {
|
---|
2012 | s.GetLine(strg, 255);
|
---|
2013 | SetSliX(nslix);
|
---|
2014 | DBASSERT (nslix==NSliX());
|
---|
2015 | for(j=0;j<NSliX();j++) HSliX(j)->Read(s);
|
---|
2016 | }
|
---|
2017 | if(nsliy>0) {
|
---|
2018 | s.GetLine(strg, 255);
|
---|
2019 | SetSliY(nsliy);
|
---|
2020 | DBASSERT (nsliy==NSliY());
|
---|
2021 | for(j=0;j<NSliY();j++) HSliY(j)->Read(s);
|
---|
2022 | }
|
---|
2023 |
|
---|
2024 | // Lecture des bandes
|
---|
2025 | if( nbanx>0 ) {
|
---|
2026 | s.GetLine(strg, 255);
|
---|
2027 | for( j=0; j<nbanx; j++) {
|
---|
2028 | s.GetR4(min);
|
---|
2029 | s.GetR4(max);
|
---|
2030 | SetBandX(min,max);
|
---|
2031 | }
|
---|
2032 | DBASSERT (nbanx==NBandX());
|
---|
2033 | for( j=0; j<NBandX(); j++) {
|
---|
2034 | h = HBandX(j);
|
---|
2035 | h->Read(s);
|
---|
2036 | }
|
---|
2037 | }
|
---|
2038 | if( nbany>0 ) {
|
---|
2039 | s.GetLine(strg, 255);
|
---|
2040 | for( j=0; j<nbany; j++) {
|
---|
2041 | s.GetR4(min);
|
---|
2042 | s.GetR4(max);
|
---|
2043 | SetBandY(min,max);
|
---|
2044 | }
|
---|
2045 | DBASSERT (nbany==NBandY());
|
---|
2046 | for( j=0; j<NBandY(); j++) {
|
---|
2047 | h = HBandY(j);
|
---|
2048 | h->Read(s);
|
---|
2049 | }
|
---|
2050 | }
|
---|
2051 |
|
---|
2052 | return;
|
---|
2053 | }
|
---|