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