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