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