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