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