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