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