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