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