[763] | 1 | //
|
---|
| 2 | // cmv 05/08/96
|
---|
| 3 | //
|
---|
| 4 |
|
---|
[2615] | 5 | #include "sopnamsp.h"
|
---|
[763] | 6 | #include "machdefs.h"
|
---|
| 7 |
|
---|
| 8 | #include <string.h>
|
---|
[2741] | 9 | #include <new>
|
---|
[763] | 10 | #include <stdlib.h>
|
---|
| 11 | #include <stdio.h>
|
---|
[1783] | 12 | #ifndef NO_VALUES_H
|
---|
[763] | 13 | #include <values.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "histos2.h"
|
---|
| 17 |
|
---|
[926] | 18 | /*!
|
---|
| 19 | \class SOPHYA::Histo2D
|
---|
| 20 | \ingroup HiStats
|
---|
| 21 | Classe d'histogrammes 2D
|
---|
| 22 | \verbatim
|
---|
| 23 | Remarque sur les indices:
|
---|
| 24 | H(i,j) -> i = coord x (0<i<nx), j = coord y (0<j<ny)
|
---|
| 25 | v(ii,jj) -> ii = ligne (0<i<NRows()), jj = colonne (0<i<NCol())
|
---|
| 26 | On fait une correspondance directe i<->ii et j<->jj
|
---|
| 27 | ce qui, en representation classique des histos2D et des matrices
|
---|
| 28 | entraine une inversion x<->y cad une symetrie / diagonale principale
|
---|
| 29 | H(0,...) represente ^ mais v(0,...) represente
|
---|
| 30 | |x....... |xxxxxxxx|
|
---|
| 31 | |x....... |........|
|
---|
| 32 | |x....... |........|
|
---|
| 33 | |x....... |........|
|
---|
| 34 | |x....... |........|
|
---|
| 35 | --------->
|
---|
| 36 | colonne no 1 ligne no 1
|
---|
| 37 | \endverbatim
|
---|
| 38 | */
|
---|
| 39 |
|
---|
[763] | 40 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 41 | /*!
|
---|
| 42 | Createur d'un histogramme 2D ayant nxBin,nyBin bins
|
---|
| 43 | entre xMin,xMax et yMin,yMax.
|
---|
| 44 | */
|
---|
[1092] | 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)
|
---|
[763] | 47 | , nHist(0), nEntries(0)
|
---|
[1092] | 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)
|
---|
[763] | 52 | {
|
---|
| 53 | ASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax);
|
---|
[1092] | 54 | for(int_4 i=0;i<3;i++) for(int_4 j=0;j<3;j++) mOver[i][j]=0.;
|
---|
[763] | 55 | Zero();
|
---|
[1092] | 56 | mB_s.H = NULL;
|
---|
[763] | 57 | }
|
---|
| 58 |
|
---|
[914] | 59 | /*!
|
---|
[1092] | 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 | /*!
|
---|
[914] | 78 | Constructeur par copie.
|
---|
| 79 | */
|
---|
[763] | 80 | Histo2D::Histo2D(const Histo2D& h)
|
---|
| 81 | {
|
---|
[1092] | 82 | int_4 i,j;
|
---|
| 83 | mData = new r_8[h.mNxy];
|
---|
| 84 | memcpy(mData, h.mData, h.mNxy*sizeof(r_8));
|
---|
[763] | 85 |
|
---|
[1092] | 86 | mErr2 = NULL;
|
---|
| 87 | if(h.mErr2) {
|
---|
| 88 | mErr2 = new r_8[h.mNxy];
|
---|
| 89 | memcpy(mErr2, h.mErr2, h.mNxy*sizeof(r_8));
|
---|
[763] | 90 | }
|
---|
| 91 |
|
---|
| 92 | nHist = h.nHist; nEntries = h.nEntries;
|
---|
[1092] | 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;
|
---|
[763] | 98 |
|
---|
[1092] | 99 | mHprojx = mHprojy = NULL;
|
---|
| 100 | if(h.mHprojx) {
|
---|
[763] | 101 | SetProjX();
|
---|
[1092] | 102 | *mHprojx = *(h.mHprojx);
|
---|
[763] | 103 | }
|
---|
[1092] | 104 | if(h.mHprojy) {
|
---|
[763] | 105 | SetProjY();
|
---|
[1092] | 106 | *mHprojy = *(h.mHprojy);
|
---|
[763] | 107 | }
|
---|
| 108 |
|
---|
[1092] | 109 | int_4 nb;
|
---|
| 110 | r_8 min,max;
|
---|
[763] | 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 |
|
---|
[914] | 143 | /*!
|
---|
| 144 | Constructeur par defaut.
|
---|
| 145 | */
|
---|
[763] | 146 | Histo2D::Histo2D()
|
---|
[1092] | 147 | : mData(NULL), mErr2(NULL)
|
---|
[763] | 148 | , nHist(0), nEntries(0)
|
---|
[1092] | 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)
|
---|
[763] | 153 | {
|
---|
[1092] | 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;
|
---|
[763] | 156 | }
|
---|
| 157 |
|
---|
| 158 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 159 | /*!
|
---|
| 160 | Desallocation de la place de l'histogramme (fct privee).
|
---|
| 161 | */
|
---|
[763] | 162 | void Histo2D::Delete()
|
---|
| 163 | {
|
---|
[1092] | 164 | if( mData != NULL ) { delete[] mData; mData = NULL;}
|
---|
[763] | 165 |
|
---|
[1092] | 166 | if( mErr2 != NULL ) { delete[] mErr2; mErr2 = NULL;}
|
---|
[763] | 167 |
|
---|
| 168 | DelProj();
|
---|
| 169 |
|
---|
| 170 | DelBandX();
|
---|
| 171 | DelBandY();
|
---|
| 172 |
|
---|
| 173 | DelSliX();
|
---|
| 174 | DelSliY();
|
---|
| 175 |
|
---|
| 176 | nHist = 0;
|
---|
| 177 | nEntries = 0;
|
---|
[1092] | 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;
|
---|
[763] | 183 | }
|
---|
| 184 |
|
---|
[914] | 185 | /*!
|
---|
| 186 | Destructeur.
|
---|
| 187 | */
|
---|
[763] | 188 | Histo2D::~Histo2D()
|
---|
| 189 | {
|
---|
| 190 | Delete();
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 194 | /*!
|
---|
| 195 | Remise a zero du contenu, des erreurs et des valeurs.
|
---|
| 196 | */
|
---|
[763] | 197 | void Histo2D::Zero()
|
---|
| 198 | {
|
---|
| 199 | nHist = nEntries = 0;
|
---|
[1092] | 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));
|
---|
[763] | 203 |
|
---|
[1092] | 204 | if( mErr2 != NULL ) memset(mErr2, 0, mNxy*sizeof(r_8));
|
---|
[763] | 205 |
|
---|
| 206 | ZeroProj();
|
---|
| 207 |
|
---|
| 208 | ZeroBandX();
|
---|
| 209 | ZeroBandY();
|
---|
| 210 |
|
---|
| 211 | ZeroSliX();
|
---|
| 212 | ZeroSliY();
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 216 | /*!
|
---|
| 217 | Pour avoir le calcul des erreurs.
|
---|
| 218 | */
|
---|
[763] | 219 | void Histo2D::Errors()
|
---|
| 220 | {
|
---|
[1092] | 221 | if( mNxy > 0 ) {
|
---|
| 222 | if(mErr2==NULL) mErr2 = new r_8[mNxy];
|
---|
| 223 | memset(mErr2, 0, mNxy*sizeof(r_8));
|
---|
[763] | 224 | }
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 228 | /*!
|
---|
| 229 | Operateur H2 = H1
|
---|
| 230 | */
|
---|
[763] | 231 | Histo2D& Histo2D::operator = (const Histo2D& h)
|
---|
| 232 | {
|
---|
[1092] | 233 | int_4 i,j,nb;
|
---|
| 234 | r_8 min,max;
|
---|
[763] | 235 |
|
---|
| 236 | if(this == &h) return *this;
|
---|
[1092] | 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];
|
---|
[763] | 241 |
|
---|
[1092] | 242 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] = h.mOver[i][j];
|
---|
[763] | 243 | nHist = h.nHist;
|
---|
| 244 | nEntries = h.nEntries;
|
---|
[1092] | 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;
|
---|
[763] | 248 |
|
---|
[1092] | 249 | memcpy(mData, h.mData, mNxy*sizeof(r_8));
|
---|
| 250 | if(mErr2) memcpy(mErr2, h.mErr2, mNxy*sizeof(r_8));
|
---|
[763] | 251 |
|
---|
| 252 | DelProjX();
|
---|
[1092] | 253 | if(h.mHprojx) {
|
---|
[763] | 254 | SetProjX();
|
---|
[1092] | 255 | *mHprojx = *(h.mHprojx);
|
---|
[763] | 256 | }
|
---|
| 257 | DelProjY();
|
---|
[1092] | 258 | if(h.mHprojy) {
|
---|
[763] | 259 | SetProjY();
|
---|
[1092] | 260 | *mHprojy = *(h.mHprojy);
|
---|
[763] | 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 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 301 | /*!
|
---|
| 302 | Operateur H *= b
|
---|
| 303 | */
|
---|
[1092] | 304 | Histo2D& Histo2D::operator *= (r_8 b)
|
---|
[763] | 305 | {
|
---|
[1092] | 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;
|
---|
[763] | 311 | }
|
---|
[1092] | 312 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] *= b;
|
---|
[763] | 313 | nHist *= b;
|
---|
| 314 |
|
---|
[1092] | 315 | if(mHprojx) *mHprojx *= b;
|
---|
| 316 | if(mHprojy) *mHprojy *= b;
|
---|
[763] | 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 |
|
---|
[914] | 325 | /*!
|
---|
| 326 | Operateur H /= b
|
---|
| 327 | */
|
---|
[1092] | 328 | Histo2D& Histo2D::operator /= (r_8 b)
|
---|
[763] | 329 | {
|
---|
[1092] | 330 | int_4 i,j;
|
---|
[2507] | 331 | if (b==0.) throw ParmError("Histo2D::operator / (0) ");
|
---|
[1092] | 332 | r_8 b2 = b*b;
|
---|
| 333 | for(i=0;i<mNxy;i++) {
|
---|
| 334 | mData[i] /= b;
|
---|
| 335 | if(mErr2) mErr2[i] /= b2;
|
---|
[763] | 336 | }
|
---|
[1092] | 337 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] /= b;
|
---|
[763] | 338 | nHist /= b;
|
---|
| 339 |
|
---|
[1092] | 340 | if(mHprojx) *mHprojx /= b;
|
---|
| 341 | if(mHprojy) *mHprojy /= b;
|
---|
[763] | 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 |
|
---|
[914] | 350 | /*!
|
---|
| 351 | Operateur H += b
|
---|
| 352 | */
|
---|
[1092] | 353 | Histo2D& Histo2D::operator += (r_8 b)
|
---|
[763] | 354 | {
|
---|
[1092] | 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;
|
---|
[763] | 360 |
|
---|
[1092] | 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();
|
---|
[763] | 365 | if(NBandX()>0) for(i=0; i<NBandX();i++) {
|
---|
| 366 | GetBandX(i,min,max);
|
---|
[1092] | 367 | *HBandX(i) += b*(max-min)/(mYmax-mYmin)*mNy;
|
---|
[763] | 368 | }
|
---|
| 369 | if(NBandY()>0) for(i=0; i<NBandY();i++) {
|
---|
| 370 | GetBandY(i,min,max);
|
---|
[1092] | 371 | *HBandY(i) += b*(max-min)/(mXmax-mXmin)*mNx;
|
---|
[763] | 372 | }
|
---|
| 373 |
|
---|
| 374 | return *this;
|
---|
| 375 | }
|
---|
| 376 |
|
---|
[914] | 377 | /*!
|
---|
| 378 | Operateur H -= b
|
---|
| 379 | */
|
---|
[1092] | 380 | Histo2D& Histo2D::operator -= (r_8 b)
|
---|
[763] | 381 | {
|
---|
[1092] | 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;
|
---|
[763] | 387 |
|
---|
[1092] | 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();
|
---|
[763] | 392 | if(NBandX()>0) for(i=0; i<NBandX();i++) {
|
---|
| 393 | GetBandX(i,min,max);
|
---|
[1092] | 394 | *HBandX(i) -= b*(max-min)/(mYmax-mYmin)*mNy;
|
---|
[763] | 395 | }
|
---|
| 396 | if(NBandY()>0) for(i=0; i<NBandY();i++) {
|
---|
| 397 | GetBandY(i,min,max);
|
---|
[1092] | 398 | *HBandY(i) -= b*(max-min)/(mXmax-mXmin)*mNx;
|
---|
[763] | 399 | }
|
---|
| 400 |
|
---|
| 401 | return *this;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 405 | /*!
|
---|
| 406 | Operateur H += H1
|
---|
| 407 | */
|
---|
[763] | 408 | Histo2D& Histo2D::operator += (const Histo2D& a)
|
---|
| 409 | {
|
---|
[1092] | 410 | int_4 i,j;
|
---|
[2507] | 411 | if(mNx!=a.mNx || mNy!=a.mNy) throw SzMismatchError("Histo2D::operator += ");
|
---|
[1092] | 412 | for(i=0;i<mNxy;i++) {
|
---|
| 413 | mData[i] += a.mData[i];
|
---|
| 414 | if(mErr2 && a.mErr2) mErr2[i] += a.mErr2[i];
|
---|
[763] | 415 | }
|
---|
[1092] | 416 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] += a.mOver[i][j];
|
---|
[763] | 417 | nHist += a.nHist;
|
---|
| 418 | nEntries += a.nEntries;
|
---|
| 419 |
|
---|
[1092] | 420 | if(mHprojx && a.mHprojx) *mHprojx += *(a.mHprojx);
|
---|
| 421 | if(mHprojy && a.mHprojy) *mHprojy += *(a.mHprojy);
|
---|
[763] | 422 | ZeroSliX(); ZeroSliY();
|
---|
| 423 | ZeroBandX(); ZeroBandY();
|
---|
| 424 |
|
---|
| 425 | return *this;
|
---|
| 426 | }
|
---|
| 427 |
|
---|
[914] | 428 | /*!
|
---|
| 429 | Operateur H -= H1
|
---|
| 430 | */
|
---|
[763] | 431 | Histo2D& Histo2D::operator -= (const Histo2D& a)
|
---|
| 432 | {
|
---|
[1092] | 433 | int_4 i,j;
|
---|
[2507] | 434 | if(mNx!=a.mNx || mNy!=a.mNy) throw SzMismatchError("Histo2D::operator -= ");
|
---|
[1092] | 435 | for(i=0;i<mNxy;i++) {
|
---|
| 436 | mData[i] -= a.mData[i];
|
---|
| 437 | if(mErr2 && a.mErr2) mErr2[i] += a.mErr2[i];
|
---|
[763] | 438 | }
|
---|
[1092] | 439 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] += a.mOver[i][j];
|
---|
[763] | 440 | nHist -= a.nHist;
|
---|
| 441 | nEntries += a.nEntries;
|
---|
| 442 |
|
---|
[1092] | 443 | if(mHprojx && a.mHprojx) *mHprojx -= *(a.mHprojx);
|
---|
| 444 | if(mHprojy && a.mHprojy) *mHprojy -= *(a.mHprojy);
|
---|
[763] | 445 | ZeroSliX(); ZeroSliY();
|
---|
| 446 | ZeroBandX(); ZeroBandY();
|
---|
| 447 |
|
---|
| 448 | return *this;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
[914] | 451 | /*!
|
---|
| 452 | Operateur H *= H1
|
---|
| 453 | */
|
---|
[763] | 454 | Histo2D& Histo2D::operator *= (const Histo2D& a)
|
---|
| 455 | {
|
---|
[1092] | 456 | int_4 i,j;
|
---|
[2507] | 457 | if(mNx!=a.mNx || mNy!=a.mNy) throw SzMismatchError("Histo2D::operator *= ");
|
---|
[763] | 458 | nHist = 0.;
|
---|
[1092] | 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];
|
---|
[763] | 464 | }
|
---|
[1092] | 465 | for(i=0;i<3;i++) for(j=0;j<3;j++) mOver[i][j] *= a.mOver[i][j];
|
---|
[763] | 466 | nEntries += a.nEntries;
|
---|
| 467 |
|
---|
[1092] | 468 | if(mHprojx && a.mHprojx) *mHprojx *= *(a.mHprojx);
|
---|
| 469 | if(mHprojy && a.mHprojy) *mHprojy *= *(a.mHprojy);
|
---|
[763] | 470 | ZeroSliX(); ZeroSliY();
|
---|
| 471 | ZeroBandX(); ZeroBandY();
|
---|
| 472 |
|
---|
| 473 | return *this;
|
---|
| 474 | }
|
---|
| 475 |
|
---|
[914] | 476 | /*!
|
---|
| 477 | Operateur H /= H1
|
---|
| 478 | */
|
---|
[763] | 479 | Histo2D& Histo2D::operator /= (const Histo2D& a)
|
---|
| 480 | {
|
---|
[1092] | 481 | int_4 i,j;
|
---|
[2507] | 482 | if(mNx!=a.mNx || mNy!=a.mNy) throw SzMismatchError("Histo2D::operator /= ");
|
---|
[763] | 483 | nHist = 0.;
|
---|
[1092] | 484 | for(i=0;i<mNxy;i++) {
|
---|
| 485 | if(a.mData[i]==0.) {
|
---|
| 486 | mData[i]=0.;
|
---|
| 487 | if(mErr2) mErr2[i]=0.;
|
---|
[763] | 488 | continue;
|
---|
| 489 | }
|
---|
[1092] | 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];
|
---|
[763] | 495 | }
|
---|
| 496 | for(i=0;i<3;i++) for(j=0;j<3;j++)
|
---|
[1092] | 497 | if(a.mOver[i][j]!=0.) mOver[i][j] *= a.mOver[i][j]; else mOver[i][j] = 0.;
|
---|
[763] | 498 | nEntries += a.nEntries;
|
---|
| 499 |
|
---|
[1092] | 500 | if(mHprojx && a.mHprojx) *mHprojx /= *(a.mHprojx);
|
---|
| 501 | if(mHprojy && a.mHprojy) *mHprojy /= *(a.mHprojy);
|
---|
[763] | 502 | ZeroSliX(); ZeroSliY();
|
---|
| 503 | ZeroBandX(); ZeroBandY();
|
---|
| 504 |
|
---|
| 505 | return *this;
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 509 | /*!
|
---|
| 510 | Remplissage d'un tableau avec les valeurs des abscisses.
|
---|
| 511 | */
|
---|
[1109] | 512 | void Histo2D::GetXCoor(TVector<r_8> &v) const
|
---|
[763] | 513 | {
|
---|
[1092] | 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;}
|
---|
[763] | 517 | return;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
[914] | 520 | /*!
|
---|
| 521 | Remplissage d'un tableau avec les valeurs des ordonnees.
|
---|
| 522 | */
|
---|
[1109] | 523 | void Histo2D::GetYCoor(TVector<r_8> &v) const
|
---|
[763] | 524 | {
|
---|
[1092] | 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;}
|
---|
[763] | 528 | return;
|
---|
| 529 | }
|
---|
| 530 |
|
---|
[914] | 531 | /*!
|
---|
| 532 | Remplissage d'un tableau avec les valeurs du contenu.
|
---|
| 533 | */
|
---|
[1109] | 534 | void Histo2D::GetValue(TMatrix<r_8> &v) const
|
---|
[763] | 535 | {
|
---|
[1092] | 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);
|
---|
[763] | 539 | return;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[914] | 542 | /*!
|
---|
| 543 | Remplissage d'un tableau avec les valeurs du carre des erreurs.
|
---|
| 544 | */
|
---|
[1109] | 545 | void Histo2D::GetError2(TMatrix<r_8> &v) const
|
---|
[763] | 546 | {
|
---|
[1092] | 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);
|
---|
[763] | 552 | return;
|
---|
| 553 | }
|
---|
| 554 |
|
---|
[914] | 555 | /*!
|
---|
| 556 | Remplissage d'un tableau avec les valeurs des erreurs.
|
---|
| 557 | */
|
---|
[1109] | 558 | void Histo2D::GetError(TMatrix<r_8> &v) const
|
---|
[763] | 559 | {
|
---|
[1092] | 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);
|
---|
[763] | 565 | return;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 569 | /*!
|
---|
| 570 | Remplissage du contenu de l'histo avec les valeurs d'un tableau.
|
---|
| 571 | */
|
---|
[1092] | 572 | void Histo2D::PutValue(TMatrix<r_8> &v, int_4 ierr)
|
---|
[763] | 573 | {
|
---|
[2507] | 574 | //if(v.NRows()!=(uint_4)mNx || v.NCol()!=(uint_4)mNy) throw SzMismatchError("Histo2D::PutValue()");
|
---|
[1092] | 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++) {
|
---|
[763] | 578 | (*this)(i,j) = v(i,j);
|
---|
[1092] | 579 | if(mErr2 && ierr) Error2(i,j) = fabs(v(i,j));
|
---|
[763] | 580 | }
|
---|
| 581 | return;
|
---|
| 582 | }
|
---|
| 583 |
|
---|
[914] | 584 | /*!
|
---|
| 585 | Addition du contenu de l'histo avec les valeurs d'un tableau.
|
---|
| 586 | */
|
---|
[1092] | 587 | void Histo2D::PutValueAdd(TMatrix<r_8> &v, int_4 ierr)
|
---|
[763] | 588 | {
|
---|
[2507] | 589 | //if(v.NRows()!=(uint_4)mNx || v.NCol()!=(uint_4)mNy) throw SzMismatchError("Histo2D::PutValueAdd ");
|
---|
[1092] | 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++) {
|
---|
[763] | 593 | (*this)(i,j) += v(i,j);
|
---|
[1092] | 594 | if(mErr2 && ierr) Error2(i,j) += fabs(v(i,j));
|
---|
[763] | 595 | }
|
---|
| 596 | return;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
[914] | 599 | /*!
|
---|
| 600 | Remplissage des erreurs au carre de l'histo
|
---|
| 601 | avec les valeurs d'un tableau.
|
---|
| 602 | */
|
---|
[943] | 603 | void Histo2D::PutError2(TMatrix<r_8> &v)
|
---|
[763] | 604 | {
|
---|
[2507] | 605 | //if(v.NRows()!=(uint_4)mNx || v.NCol()!=(uint_4)mNy) throw SzMismatchError("Histo2D::PutError2 ");
|
---|
[1092] | 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;
|
---|
[1064] | 608 | if(nnx>0 && nny>0) {
|
---|
[1092] | 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);
|
---|
[1064] | 611 | }
|
---|
[763] | 612 | return;
|
---|
| 613 | }
|
---|
| 614 |
|
---|
[914] | 615 | /*!
|
---|
| 616 | Addition des erreurs au carre de l'histo
|
---|
| 617 | avec les valeurs d'un tableau.
|
---|
| 618 | */
|
---|
[943] | 619 | void Histo2D::PutError2Add(TMatrix<r_8> &v)
|
---|
[763] | 620 | {
|
---|
[2507] | 621 | //if(v.NRows()!=(uint_4)mNx || v.NCol()!=(uint_4)mNy) throw SzMismatchError("Histo2D::PutError2Add ");
|
---|
[1092] | 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;
|
---|
[1064] | 624 | if(nnx>0 && nny>0) {
|
---|
[1092] | 625 | if(!mErr2) Errors();
|
---|
| 626 | for(uint_4 i=0;i<nnx;i++) for(uint_4 j=0;j<nny;j++)
|
---|
[763] | 627 | if(v(i,j)>0.) Error2(i,j) += v(i,j);
|
---|
[1064] | 628 | }
|
---|
[763] | 629 | return;
|
---|
| 630 | }
|
---|
| 631 |
|
---|
[914] | 632 | /*!
|
---|
| 633 | Remplissage des erreurs de l'histo avec les valeurs d'un tableau.
|
---|
| 634 | */
|
---|
[943] | 635 | void Histo2D::PutError(TMatrix<r_8> &v)
|
---|
[763] | 636 | {
|
---|
[2507] | 637 | //if(v.NRows()!=(uint_4)mNx || v.NCol()!=(uint_4)mNy) throw SzMismatchError("Histo2D::PutError ");
|
---|
[1092] | 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;
|
---|
[1064] | 640 | if(nnx>0 && nny>0) {
|
---|
[1092] | 641 | if(!mErr2) Errors();
|
---|
| 642 | for(uint_4 i=0;i<nnx;i++) for(uint_4 j=0;j<nny;j++)
|
---|
[1064] | 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 | }
|
---|
[763] | 645 | return;
|
---|
| 646 | }
|
---|
| 647 |
|
---|
| 648 | ///////////////////////////////////////////////////////////////////
|
---|
| 649 | /********* Methode *********/
|
---|
[914] | 650 | /*!
|
---|
| 651 | Addition du contenu de l'histo pour x,y poids w.
|
---|
| 652 | */
|
---|
[1092] | 653 | void Histo2D::Add(r_8 x, r_8 y, r_8 w)
|
---|
[763] | 654 | {
|
---|
| 655 | list<bande_slice>::iterator it;
|
---|
[1092] | 656 | int_4 i,j;
|
---|
[763] | 657 | FindBin(x,y,i,j);
|
---|
| 658 |
|
---|
[1092] | 659 | if( mHprojx != NULL ) mHprojx->Add(x,w);
|
---|
| 660 | if( mHprojy != NULL ) mHprojy->Add(y,w);
|
---|
[763] | 661 |
|
---|
[1092] | 662 | if(mLBandx.size()>0)
|
---|
| 663 | for( it = mLBandx.begin(); it != mLBandx.end(); it++)
|
---|
[763] | 664 | if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
|
---|
| 665 |
|
---|
[1092] | 666 | if(mLBandy.size()>0)
|
---|
| 667 | for( it = mLBandy.begin(); it != mLBandy.end(); it++)
|
---|
[763] | 668 | if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
|
---|
| 669 |
|
---|
[1092] | 670 | if(mLSlix.size()>0)
|
---|
| 671 | for( it = mLSlix.begin(); it != mLSlix.end(); it++)
|
---|
[763] | 672 | if( (*it).min <= y && y < (*it).max ) (*it).H->Add(x,w);
|
---|
| 673 |
|
---|
[1092] | 674 | if(mLSliy.size()>0)
|
---|
| 675 | for( it = mLSliy.begin(); it != mLSliy.end(); it++)
|
---|
[763] | 676 | if( (*it).min <= x && x < (*it).max ) (*it).H->Add(y,w);
|
---|
| 677 |
|
---|
[1092] | 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;
|
---|
[763] | 683 | return;
|
---|
| 684 | }
|
---|
| 685 |
|
---|
[1092] | 686 | mData[j*mNx+i] += w;
|
---|
| 687 | if(mErr2!=NULL) mErr2[j*mNx+i] += w*w;
|
---|
[763] | 688 | nHist += w;
|
---|
| 689 | nEntries++;
|
---|
| 690 | }
|
---|
| 691 |
|
---|
| 692 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 693 | /*!
|
---|
| 694 | Recherche du bin du maximum dans le pave [il,ih][jl,jh].
|
---|
| 695 | */
|
---|
[1109] | 696 | void Histo2D::IJMax(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 697 | {
|
---|
[1092] | 698 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 699 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 700 | if( il < 0 ) il = 0;
|
---|
| 701 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 702 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 703 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 704 |
|
---|
| 705 | imax = jmax = 0;
|
---|
[1092] | 706 | if(mNxy==1) return;
|
---|
[763] | 707 |
|
---|
[1092] | 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++)
|
---|
[763] | 711 | if ((*this)(i,j)>mx) {imax = i; jmax = j; mx=(*this)(i,j);}
|
---|
| 712 | }
|
---|
| 713 |
|
---|
[914] | 714 | /*!
|
---|
| 715 | Recherche du bin du minimum dans le pave [il,ih][jl,jh].
|
---|
| 716 | */
|
---|
[1109] | 717 | void Histo2D::IJMin(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 718 | {
|
---|
[1092] | 719 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 720 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 721 | if( il < 0 ) il = 0;
|
---|
| 722 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 723 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 724 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 725 |
|
---|
| 726 | imax = jmax = 0;
|
---|
[1092] | 727 | if(mNxy==1) return;
|
---|
[763] | 728 |
|
---|
[1092] | 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++)
|
---|
[763] | 732 | if ((*this)(i,j)<mx) {imax = i; jmax = j; mx=(*this)(i,j);}
|
---|
| 733 | }
|
---|
| 734 |
|
---|
| 735 |
|
---|
[914] | 736 | /*!
|
---|
| 737 | Recherche du maximum dans le pave [il,ih][jl,jh].
|
---|
| 738 | */
|
---|
[1092] | 739 | r_8 Histo2D::VMax(int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 740 | {
|
---|
[1092] | 741 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 742 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 743 | if( il < 0 ) il = 0;
|
---|
| 744 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 745 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 746 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 747 |
|
---|
[1092] | 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++)
|
---|
[763] | 752 | if ((*this)(i,j)>mx) mx=(*this)(i,j);
|
---|
| 753 | return mx;
|
---|
| 754 | }
|
---|
| 755 |
|
---|
[914] | 756 | /*!
|
---|
| 757 | Recherche du minimum dans le pave [il,ih][jl,jh].
|
---|
| 758 | */
|
---|
[1092] | 759 | r_8 Histo2D::VMin(int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 760 | {
|
---|
[1092] | 761 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 762 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 763 | if( il < 0 ) il = 0;
|
---|
| 764 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 765 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 766 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 767 |
|
---|
[1092] | 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++)
|
---|
[763] | 772 | if ((*this)(i,j)<mx) mx=(*this)(i,j);
|
---|
| 773 | return mx;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 777 | /*!
|
---|
| 778 | Renvoie les under.overflow dans les 8 quadrants.
|
---|
| 779 | \verbatim
|
---|
[1092] | 780 | mOver[3][3]: 20 | 21 | 22
|
---|
[914] | 781 | | |
|
---|
| 782 | --------------
|
---|
| 783 | | |
|
---|
| 784 | 10 | 11 | 12 11 = all overflow+underflow
|
---|
| 785 | | |
|
---|
| 786 | --------------
|
---|
| 787 | | |
|
---|
| 788 | 00 | 01 | 02
|
---|
| 789 | \endverbatim
|
---|
| 790 | */
|
---|
[1092] | 791 | r_8 Histo2D::NOver(int_4 i,int_4 j) const
|
---|
[763] | 792 | {
|
---|
[1092] | 793 | if( i < 0 || i>=3 || j < 0 || j>=3 ) return mOver[1][1];
|
---|
| 794 | return mOver[i][j];
|
---|
[763] | 795 | }
|
---|
| 796 |
|
---|
| 797 |
|
---|
| 798 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 799 | /*!
|
---|
| 800 | Retourne le nombre de bins non-nuls.
|
---|
| 801 | */
|
---|
[1092] | 802 | int_4 Histo2D::BinNonNul() const
|
---|
[763] | 803 | {
|
---|
[1092] | 804 | int_4 non=0;
|
---|
| 805 | for (int_4 i=0;i<mNxy;i++) if( mData[i] != 0. ) non++;
|
---|
[763] | 806 | return non;
|
---|
| 807 | }
|
---|
| 808 |
|
---|
[914] | 809 | /*!
|
---|
| 810 | Retourne le nombre de bins avec erreurs non-nulles.
|
---|
| 811 | */
|
---|
[1092] | 812 | int_4 Histo2D::ErrNonNul() const
|
---|
[763] | 813 | {
|
---|
[1092] | 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++;
|
---|
[763] | 817 | return non;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 821 | /*!
|
---|
| 822 | Idem EstimeMax(int...) mais retourne x,y.
|
---|
| 823 | */
|
---|
[1092] | 824 | int_4 Histo2D::EstimeMax(r_8& xm,r_8& ym,int_4 SzPav
|
---|
[1109] | 825 | ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 826 | {
|
---|
[1092] | 827 | int_4 im,jm;
|
---|
[763] | 828 | IJMax(im,jm,il,ih,jl,jh);
|
---|
| 829 | return EstimeMax(im,jm,xm,ym,SzPav);
|
---|
| 830 | }
|
---|
| 831 |
|
---|
[914] | 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 | */
|
---|
[1109] | 844 | int_4 Histo2D::EstimeMax(int_4 im,int_4 jm,r_8& xm,r_8& ym,int_4 SzPav) const
|
---|
[763] | 845 | {
|
---|
| 846 | xm = ym = 0;
|
---|
| 847 | if( SzPav <= 0 ) return -1;
|
---|
[1092] | 848 | if( im < 0 || im >= mNx ) return -1;
|
---|
| 849 | if( jm < 0 || jm >= mNy ) return -1;
|
---|
[763] | 850 |
|
---|
| 851 | if( SzPav%2 == 0 ) SzPav++;
|
---|
| 852 | SzPav = (SzPav-1)/2;
|
---|
| 853 |
|
---|
[1092] | 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;
|
---|
[763] | 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 |
|
---|
[914] | 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 | */
|
---|
[1092] | 899 | int_4 Histo2D::FindMax(int_4& im,int_4& jm,int_4 SzPav,r_8 Dz
|
---|
[1109] | 900 | ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 901 | {
|
---|
[1092] | 902 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 903 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 904 | if( il < 0 ) il = 0;
|
---|
| 905 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 906 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 907 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 908 | if( SzPav < 0 ) SzPav = 0;
|
---|
| 909 | else { if( SzPav%2 == 0 ) SzPav++; SzPav = (SzPav-1)/2;}
|
---|
| 910 | if( Dz < 0 ) Dz = 0.;
|
---|
[1092] | 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++) {
|
---|
[763] | 915 | if( (*this)(i,j) < max) continue;
|
---|
| 916 | nmax++;
|
---|
[1092] | 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;
|
---|
[763] | 922 | sum += (*this)(ii,jj);
|
---|
| 923 | }
|
---|
| 924 | }
|
---|
[1092] | 925 | if(nmax==1 || sum>sumx) {im=i; jm=j; sumx=sum;}
|
---|
[763] | 926 | }
|
---|
| 927 | if( nmax <= 0 ) { IJMax(im,jm,il,ih,jl,jh); return 1;}
|
---|
| 928 | return nmax;
|
---|
| 929 | }
|
---|
| 930 |
|
---|
| 931 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 932 | /*!
|
---|
| 933 | Impression des informations sur l'histogramme.
|
---|
| 934 | */
|
---|
[1413] | 935 | void Histo2D::Show(ostream & os) const
|
---|
[763] | 936 | {
|
---|
[1413] | 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);
|
---|
[763] | 957 | }
|
---|
| 958 |
|
---|
| 959 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 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 | */
|
---|
[1092] | 969 | void Histo2D::Print(r_8 min,r_8 max
|
---|
[1109] | 970 | ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const
|
---|
[763] | 971 | {
|
---|
[1092] | 972 | int_4 ns = 35;
|
---|
[763] | 973 | const char *s = "+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
---|
| 974 |
|
---|
[1092] | 975 | if( il > ih ) { il = 0; ih = mNx-1; }
|
---|
| 976 | if( jl > jh ) { jl = 0; jh = mNy-1; }
|
---|
[763] | 977 | if( il < 0 ) il = 0;
|
---|
| 978 | if( jl < 0 ) jl = 0;
|
---|
[1092] | 979 | if( ih >= mNx ) ih = mNx-1;
|
---|
| 980 | if( jh >= mNy ) jh = mNy-1;
|
---|
[763] | 981 |
|
---|
| 982 | PrintStatus();
|
---|
| 983 |
|
---|
[1092] | 984 | if( il != 0 || ih != mNx-1 || jl != 0 || jh != mNy-1 ) {
|
---|
| 985 | r_8 xl,xh,yl,yh;
|
---|
[763] | 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");
|
---|
[1092] | 1003 | if( mNx-1 >= 100 ) {
|
---|
[763] | 1004 | printf(" ");
|
---|
[1092] | 1005 | for(int_4 i=il;i<=ih;i++) printf("%1d",(int_4) (i%1000)/100);
|
---|
[763] | 1006 | printf("\n");
|
---|
| 1007 | }
|
---|
[1092] | 1008 | if( mNx-1 >= 10 ) {
|
---|
[763] | 1009 | printf(" ");
|
---|
[1092] | 1010 | for(int_4 i=il;i<=ih;i++) printf("%1d",(int_4) (i%100)/10);
|
---|
[763] | 1011 | printf("\n");
|
---|
| 1012 | }
|
---|
| 1013 | printf(" ");
|
---|
[1092] | 1014 | for(int_4 i=il;i<=ih;i++) printf("%1d",i%10);
|
---|
[763] | 1015 | printf("\n");
|
---|
[1092] | 1016 | printf(" "); {for(int_4 i=il;i<=ih;i++) printf("-"); printf("\n");}
|
---|
[763] | 1017 |
|
---|
| 1018 | // imprime histogramme
|
---|
[1092] | 1019 | for(int_4 j=jh;j>=jl;j--) {
|
---|
[763] | 1020 | printf("%3d: ",j);
|
---|
[1092] | 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;
|
---|
[763] | 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
|
---|
[1092] | 1036 | printf(" "); {for(int_4 i=il;i<=ih;i++) printf("-"); printf("\n");}
|
---|
| 1037 | if( mNx-1 >= 100 ) {
|
---|
[763] | 1038 | printf(" ");
|
---|
[1092] | 1039 | for(int_4 i=il;i<=ih;i++) printf("%1d",(int_4) (i%1000)/100);
|
---|
[763] | 1040 | printf("\n");
|
---|
| 1041 | }
|
---|
[1092] | 1042 | if( mNx-1 >= 10 ) {
|
---|
[763] | 1043 | printf(" ");
|
---|
[1092] | 1044 | for(int_4 i=il;i<=ih;i++) printf("%1d",(int_4) (i%100)/10);
|
---|
[763] | 1045 | printf("\n");
|
---|
| 1046 | }
|
---|
| 1047 | printf(" ");
|
---|
[1092] | 1048 | {for(int_4 i=il;i<=ih;i++) printf("%1d",i%10);}
|
---|
[763] | 1049 | printf("\n");
|
---|
| 1050 |
|
---|
| 1051 | }
|
---|
| 1052 |
|
---|
| 1053 | ///////////////////////////////////////////////////////////////////
|
---|
| 1054 | // Titre Methodes pour gerer les projections
|
---|
| 1055 |
|
---|
[914] | 1056 | /*!
|
---|
| 1057 | Pour creer la projection X.
|
---|
| 1058 | */
|
---|
[763] | 1059 | void Histo2D::SetProjX()
|
---|
| 1060 | {
|
---|
[1092] | 1061 | if( mHprojx != NULL ) DelProjX();
|
---|
| 1062 | mHprojx = new Histo(mXmin,mXmax,mNx);
|
---|
| 1063 | if( mErr2 != NULL && mHprojx != NULL ) mHprojx->Errors();
|
---|
[763] | 1064 | }
|
---|
| 1065 |
|
---|
[914] | 1066 | /*!
|
---|
| 1067 | Pour creer la projection Y.
|
---|
| 1068 | */
|
---|
[763] | 1069 | void Histo2D::SetProjY()
|
---|
| 1070 | {
|
---|
[1092] | 1071 | if( mHprojy != NULL ) DelProjY();
|
---|
| 1072 | mHprojy = new Histo(mYmin,mYmax,mNy);
|
---|
| 1073 | if( mErr2 != NULL && mHprojy != NULL ) mHprojy->Errors();
|
---|
[763] | 1074 | }
|
---|
| 1075 |
|
---|
[914] | 1076 | /*!
|
---|
| 1077 | Pour creer les projections X et Y.
|
---|
| 1078 | */
|
---|
[763] | 1079 | void Histo2D::SetProj()
|
---|
| 1080 | {
|
---|
| 1081 | SetProjX();
|
---|
| 1082 | SetProjY();
|
---|
| 1083 | }
|
---|
| 1084 |
|
---|
[914] | 1085 | /*!
|
---|
| 1086 | Informations sur les projections.
|
---|
| 1087 | */
|
---|
[1109] | 1088 | void Histo2D::ShowProj() const
|
---|
[763] | 1089 | {
|
---|
[1092] | 1090 | if( mHprojx != NULL ) cout << ">>>> Projection X set : "<< mHprojx <<endl;
|
---|
[763] | 1091 | else cout << ">>>> NO Projection X set"<<endl;
|
---|
[1092] | 1092 | if( mHprojy != NULL ) cout << ">>>> Projection Y set : "<< mHprojy <<endl;
|
---|
[763] | 1093 | else cout << ">>>> NO Projection Y set"<<endl;
|
---|
| 1094 | }
|
---|
| 1095 |
|
---|
[914] | 1096 | /*!
|
---|
| 1097 | Destruction de l'histogramme de la projection selon X.
|
---|
| 1098 | */
|
---|
[763] | 1099 | void Histo2D::DelProjX()
|
---|
| 1100 | {
|
---|
[1092] | 1101 | if( mHprojx == NULL ) return;
|
---|
| 1102 | delete mHprojx;
|
---|
| 1103 | mHprojx = NULL;
|
---|
[763] | 1104 | }
|
---|
| 1105 |
|
---|
[914] | 1106 | /*!
|
---|
| 1107 | Destruction de l'histogramme de la projection selon X.
|
---|
| 1108 | */
|
---|
[763] | 1109 | void Histo2D::DelProjY()
|
---|
| 1110 | {
|
---|
[1092] | 1111 | if( mHprojy == NULL ) return;
|
---|
| 1112 | delete mHprojy;
|
---|
| 1113 | mHprojy = NULL;
|
---|
[763] | 1114 | }
|
---|
| 1115 |
|
---|
[914] | 1116 | /*!
|
---|
| 1117 | Destruction des histogrammes des projections selon X et Y.
|
---|
| 1118 | */
|
---|
[763] | 1119 | void Histo2D::DelProj()
|
---|
| 1120 | {
|
---|
| 1121 | DelProjX();
|
---|
| 1122 | DelProjY();
|
---|
| 1123 | }
|
---|
| 1124 |
|
---|
[914] | 1125 | /*!
|
---|
| 1126 | Remise a zero de la projection selon X.
|
---|
| 1127 | */
|
---|
[763] | 1128 | void Histo2D::ZeroProjX()
|
---|
| 1129 | {
|
---|
[1092] | 1130 | if( mHprojx == NULL ) return;
|
---|
| 1131 | mHprojx->Zero();
|
---|
[763] | 1132 | }
|
---|
| 1133 |
|
---|
[914] | 1134 | /*!
|
---|
| 1135 | Remise a zero de la projection selon Y.
|
---|
| 1136 | */
|
---|
[763] | 1137 | void Histo2D::ZeroProjY()
|
---|
| 1138 | {
|
---|
[1092] | 1139 | if( mHprojy == NULL ) return;
|
---|
| 1140 | mHprojy->Zero();
|
---|
[763] | 1141 | }
|
---|
| 1142 |
|
---|
[914] | 1143 | /*!
|
---|
| 1144 | Remise a zero des projections selon X et Y.
|
---|
| 1145 | */
|
---|
[763] | 1146 | void Histo2D::ZeroProj()
|
---|
| 1147 | {
|
---|
| 1148 | ZeroProjX();
|
---|
| 1149 | ZeroProjY();
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | ///////////////////////////////////////////////////////////////////
|
---|
| 1153 | // Titre Methodes pour gerer les bandes
|
---|
| 1154 |
|
---|
[914] | 1155 | /*!
|
---|
| 1156 | Pour creer une bande en X entre ybmin et ybmax.
|
---|
| 1157 | */
|
---|
[1092] | 1158 | int_4 Histo2D::SetBandX(r_8 ybmin,r_8 ybmax)
|
---|
[763] | 1159 | {
|
---|
[1092] | 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;
|
---|
[763] | 1167 | }
|
---|
| 1168 |
|
---|
[914] | 1169 | /*!
|
---|
| 1170 | Pour creer une bande en Y entre xbmin et xbmax.
|
---|
| 1171 | */
|
---|
[1092] | 1172 | int_4 Histo2D::SetBandY(r_8 xbmin,r_8 xbmax)
|
---|
[763] | 1173 | {
|
---|
[1092] | 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;
|
---|
[763] | 1181 | }
|
---|
| 1182 |
|
---|
[914] | 1183 | /*!
|
---|
| 1184 | Destruction des histogrammes des bandes selon X.
|
---|
| 1185 | */
|
---|
[763] | 1186 | void Histo2D::DelBandX()
|
---|
| 1187 | {
|
---|
[1092] | 1188 | if( mLBandx.size() <= 0 ) return;
|
---|
| 1189 | for(list<bande_slice>::iterator i = mLBandx.begin(); i != mLBandx.end(); i++)
|
---|
[763] | 1190 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
[1092] | 1191 | mLBandx.erase(mLBandx.begin(),mLBandx.end());
|
---|
[763] | 1192 | }
|
---|
| 1193 |
|
---|
[914] | 1194 | /*!
|
---|
| 1195 | Destruction des histogrammes des bandes selon Y.
|
---|
| 1196 | */
|
---|
[763] | 1197 | void Histo2D::DelBandY()
|
---|
| 1198 | {
|
---|
[1092] | 1199 | if( mLBandy.size() <= 0 ) return;
|
---|
| 1200 | for(list<bande_slice>::iterator i = mLBandy.begin(); i != mLBandy.end(); i++)
|
---|
[763] | 1201 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
[1092] | 1202 | mLBandy.erase(mLBandy.begin(),mLBandy.end());
|
---|
[763] | 1203 | }
|
---|
| 1204 |
|
---|
[914] | 1205 | /*!
|
---|
| 1206 | Remise a zero des bandes selon X.
|
---|
| 1207 | */
|
---|
[763] | 1208 | void Histo2D::ZeroBandX()
|
---|
| 1209 | {
|
---|
[1092] | 1210 | if( mLBandx.size() <= 0 ) return;
|
---|
[763] | 1211 | list<bande_slice>::iterator i;
|
---|
[1092] | 1212 | for(i = mLBandx.begin(); i != mLBandx.end(); i++)
|
---|
[763] | 1213 | (*i).H->Zero();
|
---|
| 1214 | }
|
---|
| 1215 |
|
---|
[914] | 1216 | /*!
|
---|
| 1217 | Remise a zero des bandes selon Y.
|
---|
| 1218 | */
|
---|
[763] | 1219 | void Histo2D::ZeroBandY()
|
---|
| 1220 | {
|
---|
[1092] | 1221 | if( mLBandy.size() <= 0 ) return;
|
---|
[763] | 1222 | list<bande_slice>::iterator i;
|
---|
[1092] | 1223 | for(i = mLBandy.begin(); i != mLBandy.end(); i++)
|
---|
[763] | 1224 | (*i).H->Zero();
|
---|
| 1225 | }
|
---|
| 1226 |
|
---|
[914] | 1227 | /*!
|
---|
| 1228 | Retourne un pointeur sur la bande numero `n' selon X.
|
---|
| 1229 | */
|
---|
[1092] | 1230 | Histo* Histo2D::HBandX(int_4 n) const
|
---|
[763] | 1231 | {
|
---|
[1092] | 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++)
|
---|
[763] | 1234 | if( (*i).num == n ) return (*i).H;
|
---|
| 1235 | return NULL;
|
---|
| 1236 | }
|
---|
| 1237 |
|
---|
[914] | 1238 | /*!
|
---|
| 1239 | Retourne un pointeur sur la bande numero `n' selon Y.
|
---|
| 1240 | */
|
---|
[1092] | 1241 | Histo* Histo2D::HBandY(int_4 n) const
|
---|
[763] | 1242 | {
|
---|
[1092] | 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++)
|
---|
[763] | 1245 | if( (*i).num == n ) return (*i).H;
|
---|
| 1246 | return NULL;
|
---|
| 1247 | }
|
---|
| 1248 |
|
---|
[914] | 1249 | /*!
|
---|
| 1250 | Retourne les limites de la bande numero `n' selon X.
|
---|
| 1251 | */
|
---|
[1092] | 1252 | void Histo2D::GetBandX(int_4 n,r_8& ybmin,r_8& ybmax) const
|
---|
[763] | 1253 | {
|
---|
| 1254 | ybmin = 0.; ybmax = 0.;
|
---|
[1092] | 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++)
|
---|
[763] | 1257 | if( (*i).num == n ) { ybmin = (*i).min; ybmax = (*i).max; return;}
|
---|
| 1258 | return;
|
---|
| 1259 | }
|
---|
| 1260 |
|
---|
[914] | 1261 | /*!
|
---|
| 1262 | Retourne les limites de la bande numero `n' selon Y.
|
---|
| 1263 | */
|
---|
[1092] | 1264 | void Histo2D::GetBandY(int_4 n,r_8& xbmin,r_8& xbmax) const
|
---|
[763] | 1265 | {
|
---|
| 1266 | xbmin = 0.; xbmax = 0.;
|
---|
[1092] | 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++)
|
---|
[763] | 1269 | if( (*i).num == n ) { xbmin = (*i).min; xbmax = (*i).max; return;}
|
---|
| 1270 | return;
|
---|
| 1271 | }
|
---|
| 1272 |
|
---|
[914] | 1273 | /*!
|
---|
| 1274 | Informations sur les bandes.
|
---|
| 1275 | */
|
---|
[1109] | 1276 | void Histo2D::ShowBand(int_4 lp) const
|
---|
[763] | 1277 | {
|
---|
[1092] | 1278 | cout << ">>>> Nombre de bande X : " << mLBandx.size() << endl;
|
---|
| 1279 | if( lp>0 && mLBandx.size()>0 ) {
|
---|
[1109] | 1280 | list<bande_slice>::const_iterator i;
|
---|
[1092] | 1281 | for(i = mLBandx.begin(); i != mLBandx.end(); i++) {
|
---|
[763] | 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 |
|
---|
[1092] | 1288 | cout << ">>>> Nombre de bande Y : " << mLBandy.size() << endl;
|
---|
| 1289 | if( lp>0 && mLBandy.size()>0 ) {
|
---|
[1109] | 1290 | list<bande_slice>::const_iterator i;
|
---|
[1092] | 1291 | for(i = mLBandy.begin(); i != mLBandy.end(); i++) {
|
---|
[763] | 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 | ///////////////////////////////////////////////////////////////////
|
---|
[914] | 1300 | // Titre Methodes pour gerer les bandes equidistantes ou slices
|
---|
[763] | 1301 |
|
---|
[914] | 1302 | /*!
|
---|
| 1303 | Pour creer `nsli' bandes equidistantes selon X.
|
---|
| 1304 | */
|
---|
[1092] | 1305 | int_4 Histo2D::SetSliX(int_4 nsli)
|
---|
[763] | 1306 | {
|
---|
| 1307 | if( nsli <= 0 ) return -1;
|
---|
[1092] | 1308 | if( nsli > mNy ) nsli = mNy;
|
---|
| 1309 | if( mLSlix.size() > 0 ) DelSliX();
|
---|
| 1310 | r_8 w = (mYmax-mYmin)/nsli;
|
---|
[763] | 1311 |
|
---|
[1092] | 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;
|
---|
[763] | 1319 | }
|
---|
[1092] | 1320 | return (int_4) mLSlix.size();
|
---|
[763] | 1321 | }
|
---|
| 1322 |
|
---|
[914] | 1323 | /*!
|
---|
| 1324 | Pour creer `nsli' bandes equidistantes selon Y.
|
---|
| 1325 | */
|
---|
[1092] | 1326 | int_4 Histo2D::SetSliY(int_4 nsli)
|
---|
[763] | 1327 | {
|
---|
| 1328 | if( nsli <= 0 ) return -1;
|
---|
[1092] | 1329 | if( nsli > mNx ) nsli = mNx;
|
---|
| 1330 | if( mLSliy.size() > 0 ) DelSliY();
|
---|
| 1331 | r_8 w = (mXmax-mXmin)/nsli;
|
---|
[763] | 1332 |
|
---|
[1092] | 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;
|
---|
[763] | 1340 | }
|
---|
[1092] | 1341 | return (int_4) mLSliy.size();
|
---|
[763] | 1342 | }
|
---|
| 1343 |
|
---|
[914] | 1344 | /*!
|
---|
| 1345 | Destruction des bandes equidistantes selon X.
|
---|
| 1346 | */
|
---|
[763] | 1347 | void Histo2D::DelSliX()
|
---|
| 1348 | {
|
---|
[1092] | 1349 | if( mLSlix.size() <= 0 ) return;
|
---|
| 1350 | for(list<bande_slice>::iterator i = mLSlix.begin(); i != mLSlix.end(); i++)
|
---|
[763] | 1351 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
[1092] | 1352 | mLSlix.erase(mLSlix.begin(),mLSlix.end());
|
---|
[763] | 1353 | }
|
---|
| 1354 |
|
---|
[914] | 1355 | /*!
|
---|
| 1356 | Destruction des bandes equidistantes selon Y.
|
---|
| 1357 | */
|
---|
[763] | 1358 | void Histo2D::DelSliY()
|
---|
| 1359 | {
|
---|
[1092] | 1360 | if( mLSliy.size() <= 0 ) return;
|
---|
| 1361 | for(list<bande_slice>::iterator i = mLSliy.begin(); i != mLSliy.end(); i++)
|
---|
[763] | 1362 | if( (*i).H != NULL ) {delete (*i).H; (*i).H=NULL;}
|
---|
[1092] | 1363 | mLSliy.erase(mLSliy.begin(),mLSliy.end());
|
---|
[763] | 1364 | }
|
---|
| 1365 |
|
---|
[914] | 1366 | /*!
|
---|
| 1367 | Remise a zero des bandes equidistantes selon X.
|
---|
| 1368 | */
|
---|
[763] | 1369 | void Histo2D::ZeroSliX()
|
---|
| 1370 | {
|
---|
[1092] | 1371 | if( mLSlix.size() <= 0 ) return;
|
---|
[763] | 1372 | list<bande_slice>::iterator i;
|
---|
[1092] | 1373 | for(i = mLSlix.begin(); i != mLSlix.end(); i++)
|
---|
[763] | 1374 | (*i).H->Zero();
|
---|
| 1375 | }
|
---|
| 1376 |
|
---|
[914] | 1377 | /*!
|
---|
| 1378 | Remise a zero des bandes equidistantes selon Y.
|
---|
| 1379 | */
|
---|
[763] | 1380 | void Histo2D::ZeroSliY()
|
---|
| 1381 | {
|
---|
[1092] | 1382 | if( mLSliy.size() <= 0 ) return;
|
---|
[763] | 1383 | list<bande_slice>::iterator i;
|
---|
[1092] | 1384 | for(i = mLSliy.begin(); i != mLSliy.end(); i++)
|
---|
[763] | 1385 | (*i).H->Zero();
|
---|
| 1386 | }
|
---|
| 1387 |
|
---|
[914] | 1388 | /*!
|
---|
| 1389 | Retourne un pointeur sur la bande equidistante numero `n'
|
---|
| 1390 | selon X.
|
---|
| 1391 | */
|
---|
[1092] | 1392 | Histo* Histo2D::HSliX(int_4 n) const
|
---|
[763] | 1393 | {
|
---|
[1092] | 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++)
|
---|
[763] | 1396 | if( (*i).num == n ) return (*i).H;
|
---|
| 1397 | return NULL;
|
---|
| 1398 | }
|
---|
| 1399 |
|
---|
[914] | 1400 | /*!
|
---|
| 1401 | Retourne un pointeur sur la bande equidistante numero `n'
|
---|
| 1402 | selon Y.
|
---|
| 1403 | */
|
---|
[1092] | 1404 | Histo* Histo2D::HSliY(int_4 n) const
|
---|
[763] | 1405 | {
|
---|
[1092] | 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++)
|
---|
[763] | 1408 | if( (*i).num == n ) return (*i).H;
|
---|
| 1409 | return NULL;
|
---|
| 1410 | }
|
---|
| 1411 |
|
---|
[914] | 1412 | /*!
|
---|
| 1413 | Informations sur les bandes equidistantes.
|
---|
| 1414 | */
|
---|
[1109] | 1415 | void Histo2D::ShowSli(int_4 lp) const
|
---|
[763] | 1416 | {
|
---|
[1109] | 1417 | list<bande_slice>::const_iterator i;
|
---|
[1092] | 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++) {
|
---|
[763] | 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 |
|
---|
[1092] | 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++) {
|
---|
[763] | 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 |
|
---|
[2341] | 1442 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[763] | 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 |
|
---|
[1092] | 1450 | r_8 min,max;
|
---|
[763] | 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
|
---|
[1092] | 1462 | is.Get(dobj->mNx);
|
---|
| 1463 | is.Get(dobj->mNy);
|
---|
| 1464 | is.Get(dobj->mNxy);
|
---|
[763] | 1465 | is.Get(errok);
|
---|
| 1466 | is.Get(dobj->nEntries);
|
---|
| 1467 | is.Get(dobj->nHist);
|
---|
| 1468 |
|
---|
[1092] | 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);
|
---|
[763] | 1475 |
|
---|
[1092] | 1476 | is.Get(&(dobj->mOver[0][0]),9);
|
---|
[763] | 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
|
---|
[1092] | 1486 | dobj->mData = new r_8[dobj->mNxy];
|
---|
[763] | 1487 | is.GetLine(strg, 255);
|
---|
[1092] | 1488 | {for(int_4 j=0;j<dobj->mNy;j++) is.Get(dobj->mData+j*dobj->mNx,dobj->mNx);}
|
---|
[763] | 1489 |
|
---|
| 1490 | // Lecture erreurs
|
---|
| 1491 | if(errok) {
|
---|
| 1492 | is.GetLine(strg, 255);
|
---|
[1092] | 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);
|
---|
[763] | 1495 | }
|
---|
| 1496 |
|
---|
| 1497 | // Lecture des projections
|
---|
| 1498 | if(projx) {
|
---|
| 1499 | is.GetLine(strg, 255);
|
---|
| 1500 | dobj->SetProjX();
|
---|
[1092] | 1501 | ObjFileIO<Histo> fio_h(dobj->mHprojx);
|
---|
[763] | 1502 | fio_h.Read(is);
|
---|
| 1503 | }
|
---|
| 1504 | if(projy) {
|
---|
| 1505 | is.GetLine(strg, 255);
|
---|
| 1506 | dobj->SetProjY();
|
---|
[1092] | 1507 | ObjFileIO<Histo> fio_h(dobj->mHprojy);
|
---|
[763] | 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());
|
---|
[1092] | 1516 | for(int_4 j=0;j<dobj->NSliX();j++)
|
---|
[763] | 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());
|
---|
[1092] | 1523 | for(int_4 j=0;j<dobj->NSliY();j++)
|
---|
[763] | 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);
|
---|
[1092] | 1530 | {for(int_4 j=0; j<nbanx; j++) {
|
---|
[763] | 1531 | is.Get(min); is.Get(max);
|
---|
| 1532 | dobj->SetBandX(min,max);
|
---|
| 1533 | }}
|
---|
| 1534 | ASSERT (nbanx==dobj->NBandX());
|
---|
[1092] | 1535 | {for(int_4 j=0; j<dobj->NBandX(); j++) {
|
---|
[763] | 1536 | ObjFileIO<Histo> fio_h(dobj->HBandX(j));
|
---|
| 1537 | fio_h.Read(is);
|
---|
| 1538 | }}
|
---|
| 1539 | }
|
---|
| 1540 | if( nbany>0 ) {
|
---|
| 1541 | is.GetLine(strg, 255);
|
---|
[1092] | 1542 | {for(int_4 j=0; j<nbany; j++) {
|
---|
[763] | 1543 | is.Get(min); is.Get(max);
|
---|
| 1544 | dobj->SetBandY(min,max);
|
---|
| 1545 | }}
|
---|
| 1546 | ASSERT (nbany==dobj->NBandY());
|
---|
[1092] | 1547 | {for(int_4 j=0; j<dobj->NBandY(); j++) {
|
---|
[763] | 1548 | ObjFileIO<Histo> fio_h(dobj->HBandY(j));
|
---|
| 1549 | fio_h.Read(is);
|
---|
| 1550 | }}
|
---|
| 1551 | }
|
---|
| 1552 |
|
---|
| 1553 | return;
|
---|
| 1554 | }
|
---|
| 1555 |
|
---|
[2341] | 1556 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[763] | 1557 | void ObjFileIO<Histo2D>::WriteSelf(POutPersist& os) const
|
---|
| 1558 | {
|
---|
| 1559 | if (dobj == NULL) return;
|
---|
| 1560 | char strg[256];
|
---|
| 1561 |
|
---|
| 1562 | // Que faut-il ecrire?
|
---|
[1092] | 1563 | int_4 errok = (dobj->mErr2) ? 1 : 0;
|
---|
| 1564 | int_4 projx = (dobj->mHprojx) ? 1 : 0;
|
---|
| 1565 | int_4 projy = (dobj->mHprojy) ? 1 : 0;
|
---|
[763] | 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"
|
---|
[1092] | 1573 | ,dobj->mNx,dobj->mNy,dobj->mNxy,errok);
|
---|
[763] | 1574 | os.PutLine(strg);
|
---|
| 1575 | sprintf(strg,"nHist=%g nEntries=%d",dobj->nHist,dobj->nEntries);
|
---|
| 1576 | os.PutLine(strg);
|
---|
[1092] | 1577 | sprintf(strg,"wbinx=%g wbiny=%g",dobj->mWBinx,dobj->mWBiny);
|
---|
[763] | 1578 | os.PutLine(strg);
|
---|
| 1579 | sprintf(strg,"xmin=%g xmax=%g ymin=%g ymax=%g"
|
---|
[1092] | 1580 | ,dobj->mXmin,dobj->mXmax,dobj->mYmin,dobj->mYmax);
|
---|
[763] | 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);
|
---|
[1092] | 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]);
|
---|
[763] | 1589 | os.PutLine(strg);
|
---|
| 1590 |
|
---|
| 1591 | // Ecriture variables de definitions
|
---|
[1092] | 1592 | os.Put(dobj->mNx);
|
---|
| 1593 | os.Put(dobj->mNy);
|
---|
| 1594 | os.Put(dobj->mNxy);
|
---|
[763] | 1595 | os.Put(errok);
|
---|
| 1596 | os.Put(dobj->nEntries);
|
---|
| 1597 | os.Put(dobj->nHist);
|
---|
| 1598 |
|
---|
[1092] | 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);
|
---|
[763] | 1605 |
|
---|
[1092] | 1606 | os.Put(&(dobj->mOver[0][0]),9);
|
---|
[763] | 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"
|
---|
[1092] | 1617 | ,dobj->mNxy,dobj->mNx,dobj->mNy);
|
---|
[763] | 1618 | os.PutLine(strg);
|
---|
[1092] | 1619 | {for(int_4 j=0;j<dobj->mNy;j++) os.Put(dobj->mData+j*dobj->mNx,dobj->mNx);}
|
---|
[763] | 1620 |
|
---|
| 1621 | // Ecriture erreurs
|
---|
| 1622 | if(errok) {
|
---|
| 1623 | sprintf(strg,"Histo2D: Tableau des erreurs %d = %d * %d"
|
---|
[1092] | 1624 | ,dobj->mNxy,dobj->mNx,dobj->mNy);
|
---|
[763] | 1625 | os.PutLine(strg);
|
---|
[1092] | 1626 | for(int_4 j=0;j<dobj->mNy;j++) os.Put(dobj->mErr2+j*dobj->mNx,dobj->mNx);
|
---|
[763] | 1627 | }
|
---|
| 1628 |
|
---|
| 1629 | // Ecriture des projections
|
---|
| 1630 | if(projx) {
|
---|
| 1631 | sprintf(strg,"Histo2D: Projection X");
|
---|
| 1632 | os.PutLine(strg);
|
---|
[1092] | 1633 | ObjFileIO<Histo> fio_h(dobj->mHprojx); fio_h.Write(os);
|
---|
[763] | 1634 | }
|
---|
| 1635 | if(projy) {
|
---|
| 1636 | sprintf(strg,"Histo2D: Projection Y");
|
---|
| 1637 | os.PutLine(strg);
|
---|
[1092] | 1638 | ObjFileIO<Histo> fio_h(dobj->mHprojy); fio_h.Write(os);
|
---|
[763] | 1639 | }
|
---|
| 1640 |
|
---|
| 1641 | // Ecriture des slices
|
---|
| 1642 | if(nslix>0) {
|
---|
| 1643 | sprintf(strg,"Histo2D: Slices X %d",nslix);
|
---|
| 1644 | os.PutLine(strg);
|
---|
[1092] | 1645 | for(int_4 j=0;j<nslix;j++) {
|
---|
[763] | 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);
|
---|
[1092] | 1653 | for(int_4 j=0;j<nsliy;j++) {
|
---|
[763] | 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;
|
---|
[1092] | 1664 | for(it = dobj->mLBandx.begin(); it != dobj->mLBandx.end(); it++) {
|
---|
| 1665 | r_8 min = (*it).min; r_8 max = (*it).max;
|
---|
[763] | 1666 | os.Put(min); os.Put(max);
|
---|
| 1667 | }
|
---|
[1092] | 1668 | for(it = dobj->mLBandx.begin(); it != dobj->mLBandx.end(); it++) {
|
---|
[763] | 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;
|
---|
[1092] | 1677 | for(it = dobj->mLBandy.begin(); it != dobj->mLBandy.end(); it++) {
|
---|
| 1678 | r_8 min = (*it).min; r_8 max = (*it).max;
|
---|
[763] | 1679 | os.Put(min); os.Put(max);
|
---|
| 1680 | }
|
---|
[1092] | 1681 | for(it = dobj->mLBandy.begin(); it != dobj->mLBandy.end(); it++) {
|
---|
[763] | 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
|
---|