Changeset 3053 in Sophya for trunk/SophyaLib/HiStats
- Timestamp:
- Aug 12, 2006, 7:29:29 PM (19 years ago)
- Location:
- trunk/SophyaLib/HiStats
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/hisprof.cc
r2868 r3053 18 18 */ 19 19 HProf::HProf() 20 : Histo() 21 , SumY(NULL), SumY2(NULL), SumW(NULL),Ok(false), YMin(1.), YMax(-1.), Opt(0)20 : Histo(), mSumY(NULL), mSumY2(NULL), mSumW(NULL) 21 , Ok(false), YMin(1.), YMax(-1.), Opt(0) 22 22 { 23 23 } … … 32 32 */ 33 33 HProf::HProf(r_8 xMin, r_8 xMax, int_4 nBin, r_8 yMin, r_8 yMax) 34 : Histo(xMin,xMax,nBin) 35 , SumY( (nBin>0) ? new r_8[nBin] : NULL) 36 , SumY2((nBin>0) ? new r_8[nBin] : NULL) 37 , SumW( (nBin>0) ? new r_8[nBin] : NULL) 38 , Ok(false), YMin(yMin), YMax(yMax), Opt(0) 39 { 40 Histo::Errors(); 41 Zero(); 34 : Histo(), mSumY(NULL), mSumY2(NULL), mSumW(NULL) 35 { 36 CreateOrResize(xMin,xMax,nBin,yMin,yMax); 42 37 } 43 38 … … 47 42 */ 48 43 HProf::HProf(r_4 xMin, r_4 xMax, int_4 nBin, r_4 yMin, r_4 yMax) 49 : Histo((r_8)xMin,(r_8)xMax,nBin) 50 , SumY( (nBin>0) ? new r_8[nBin] : NULL) 51 , SumY2((nBin>0) ? new r_8[nBin] : NULL) 52 , SumW( (nBin>0) ? new r_8[nBin] : NULL) 53 , Ok(false), YMin((r_8)yMin), YMax((r_8)yMax), Opt(0) 54 { 55 Histo::Errors(); 56 Zero(); 44 : Histo(), mSumY(NULL), mSumY2(NULL), mSumW(NULL) 45 { 46 CreateOrResize((r_8)xMin,(r_8)xMax,nBin,(r_8)yMin,(r_8)yMax); 57 47 } 58 48 … … 63 53 HProf::HProf(const HProf& H) 64 54 : Histo(H) 65 , SumY((H.mBins>0) ? new r_8[H.mBins] : NULL)66 , SumY2((H.mBins>0) ? new r_8[H.mBins] : NULL)67 , SumW((H.mBins>0) ? new r_8[H.mBins] : NULL)55 , mSumY((H.mBins>0) ? new r_8[H.mBins] : NULL) 56 , mSumY2((H.mBins>0) ? new r_8[H.mBins] : NULL) 57 , mSumW((H.mBins>0) ? new r_8[H.mBins] : NULL) 68 58 , Ok(H.Ok), YMin(H.YMin), YMax(H.YMax), Opt(H.Opt) 69 59 { 70 60 if(mBins>0) { 71 memcpy( SumY, H.SumY, mBins*sizeof(r_8));72 memcpy( SumY2, H.SumY2, mBins*sizeof(r_8));73 memcpy( SumW, H.SumW, mBins*sizeof(r_8));61 memcpy(mSumY, H.mSumY, mBins*sizeof(r_8)); 62 memcpy(mSumY2, H.mSumY2, mBins*sizeof(r_8)); 63 memcpy(mSumW, H.mSumW, mBins*sizeof(r_8)); 74 64 } 75 65 UpdateHisto(); … … 78 68 /********* Methode *********/ 79 69 /*! 70 allocation 71 */ 72 void HProf::CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin, r_8 yMin, r_8 yMax) 73 { 74 //cout<<"HProf::CreateOrResize()"<<endl; 75 Histo::CreateOrResize(xMin,xMax,nBin); 76 Histo::Errors(); 77 if(mSumY !=NULL) {delete[] mSumY; mSumY = NULL;} 78 if(mSumY2!=NULL) {delete[] mSumY2; mSumY2= NULL;} 79 if(mSumW !=NULL) {delete[] mSumW; mSumW = NULL;} 80 if(nBin>0) { 81 mSumY = new r_8[nBin]; memset(mSumY, 0, nBin*sizeof(r_8)); 82 mSumY2 = new r_8[nBin]; memset(mSumY2,0, nBin*sizeof(r_8)); 83 mSumW = new r_8[nBin]; memset(mSumW, 0, nBin*sizeof(r_8)); 84 } 85 YMin = yMin; YMax = yMax; 86 Ok = false; 87 Opt = 0; 88 } 89 90 /********* Methode *********/ 91 /*! 80 92 Des-allocation 81 93 */ 82 94 void HProf::Delete() 83 95 { 84 if( SumY != NULL ) { delete[] SumY; SumY = NULL;} 85 if( SumY2 != NULL ) { delete[] SumY2; SumY2 = NULL;} 86 if( SumW != NULL ) { delete[] SumW; SumW = NULL;} 96 //cout<<"HProf::Delete()"<<endl; 97 Histo::Delete(); 98 if(mSumY != NULL) {delete[] mSumY; mSumY = NULL;} 99 if(mSumY2!= NULL) {delete[] mSumY2; mSumY2 = NULL;} 100 if(mSumW != NULL) {delete[] mSumW; mSumW = NULL;} 87 101 Ok = false; 88 102 } … … 94 108 HProf::~HProf() 95 109 { 96 Delete();110 Delete(); 97 111 } 98 112 … … 112 126 void HProf::Zero() 113 127 { 114 memset(SumY, 0, mBins*sizeof(r_8)); 115 memset(SumY2, 0, mBins*sizeof(r_8)); 116 memset(SumW, 0, mBins*sizeof(r_8)); 128 Histo::Zero(); 129 memset(mSumY, 0, mBins*sizeof(r_8)); 130 memset(mSumY2, 0, mBins*sizeof(r_8)); 131 memset(mSumW, 0, mBins*sizeof(r_8)); 117 132 Ok = false; 118 Histo::Zero();119 133 } 120 134 … … 158 172 r_8 m,e2; 159 173 if(mBins>0) for(int_4 i=0;i<mBins;i++) { 160 if( SumW[i]<=0.) {174 if(mSumW[i]<=0.) { 161 175 m = e2 = 0.; 162 176 } else { 163 m = SumY[i]/SumW[i];164 e2 = SumY2[i]/SumW[i] - m*m;165 if(Opt) e2 /= SumW[i];177 m = mSumY[i]/mSumW[i]; 178 e2 = mSumY2[i]/mSumW[i] - m*m; 179 if(Opt) e2 /= mSumW[i]; 166 180 } 167 181 mData[i] = m; … … 187 201 else { 188 202 Ok = false; 189 SumY[numBin] += y*w;190 SumY2[numBin] += y*y*w;191 SumW[numBin] += w;203 mSumY[numBin] += y*w; 204 mSumY2[numBin] += y*y*w; 205 mSumW[numBin] += w; 192 206 nHist += w; 193 207 nEntries++; … … 206 220 else { 207 221 Ok = false; 208 SumY[numBin] += y*w;209 SumY2[numBin] += y*y*w;210 SumW[numBin] += w;222 mSumY[numBin] += y*w; 223 mSumY2[numBin] += y*y*w; 224 mSumW[numBin] += w; 211 225 nHist += w; 212 226 nEntries++; … … 224 238 Histo *hthis = (Histo *) this; 225 239 *hthis = (Histo) h; 226 if(! SumY)SumY = new r_8[mBins];227 if(! SumY2)SumY2 = new r_8[mBins];228 if(! SumW)SumW = new r_8[mBins];229 memcpy( SumY, h.SumY, mBins*sizeof(r_8));230 memcpy( SumY2, h.SumY2, mBins*sizeof(r_8));231 memcpy( SumW, h.SumW, mBins*sizeof(r_8));240 if(!mSumY) mSumY = new r_8[mBins]; 241 if(!mSumY2) mSumY2 = new r_8[mBins]; 242 if(!mSumW) mSumW = new r_8[mBins]; 243 memcpy(mSumY, h.mSumY, mBins*sizeof(r_8)); 244 memcpy(mSumY2, h.mSumY2, mBins*sizeof(r_8)); 245 memcpy(mSumW, h.mSumW, mBins*sizeof(r_8)); 232 246 Ok = h.Ok; 233 247 YMin = h.YMin; … … 252 266 *hthis += (Histo) a; 253 267 if(mBins>0) for(int_4 i=0;i<mBins;i++) { 254 SumY[i] += a.SumY[i];255 SumY2[i] += a.SumY2[i];256 SumW[i] += a.SumW[i];268 mSumY[i] += a.mSumY[i]; 269 mSumY2[i] += a.mSumY2[i]; 270 mSumW[i] += a.mSumW[i]; 257 271 } 258 272 updatehisto(); … … 279 293 // Le nombre de bins est il plus grand ?? 280 294 if( mBins > binold ) { 281 delete [] SumY; SumY = new r_8[nbinew]; memset(SumY, 0,mBins*sizeof(r_8));282 delete [] SumY2; SumY2 = new r_8[nbinew]; memset(SumY2,0,mBins*sizeof(r_8));283 delete [] SumW; SumW = new r_8[nbinew]; memset(SumW, 0,mBins*sizeof(r_8));295 delete [] mSumY; mSumY = new r_8[nbinew]; memset(mSumY, 0,mBins*sizeof(r_8)); 296 delete [] mSumY2; mSumY2 = new r_8[nbinew]; memset(mSumY2,0,mBins*sizeof(r_8)); 297 delete [] mSumW; mSumW = new r_8[nbinew]; memset(mSumW, 0,mBins*sizeof(r_8)); 284 298 } 285 299 … … 294 308 r_8 wY = 0., wY2 = 0., wW = 0.; 295 309 if( ima == imi ) { 296 wY = H. SumY[imi] * binWidth/H.binWidth;297 wY2 = H. SumY2[imi] * binWidth/H.binWidth;298 wW = H. SumW[imi] * binWidth/H.binWidth;310 wY = H.mSumY[imi] * binWidth/H.binWidth; 311 wY2 = H.mSumY2[imi] * binWidth/H.binWidth; 312 wW = H.mSumW[imi] * binWidth/H.binWidth; 299 313 } else { 300 wY += H. SumY[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth;301 wY += H. SumY[ima] * (xma -H.BinLowEdge(ima))/H.binWidth;302 wY2 += H. SumY2[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth;303 wY2 += H. SumY2[ima] * (xma -H.BinLowEdge(ima))/H.binWidth;304 wW += H. SumW[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth;305 wW += H. SumW[ima] * (xma -H.BinLowEdge(ima))/H.binWidth;314 wY += H.mSumY[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth; 315 wY += H.mSumY[ima] * (xma -H.BinLowEdge(ima))/H.binWidth; 316 wY2 += H.mSumY2[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth; 317 wY2 += H.mSumY2[ima] * (xma -H.BinLowEdge(ima))/H.binWidth; 318 wW += H.mSumW[imi] * (H.BinHighEdge(imi)-xmi)/H.binWidth; 319 wW += H.mSumW[ima] * (xma -H.BinLowEdge(ima))/H.binWidth; 306 320 if(ima>imi+1) for(int_4 ii=imi+1;ii<ima;ii++) 307 {wY += H. SumY[ii]; wY2 += H.SumY2[ii]; wW += H.SumW[ii];}321 {wY += H.mSumY[ii]; wY2 += H.mSumY2[ii]; wW += H.mSumW[ii];} 308 322 } 309 SumY[i] += wY; SumY2[i] += wY2;SumW[i] += wW;310 } 311 // On synchronise les tableaux Sum?? et l'Histogramme323 mSumY[i] += wY; mSumY2[i] += wY2; mSumW[i] += wW; 324 } 325 // On synchronise les tableaux mSum?? et l'Histogramme 312 326 updatehisto(); 313 327 } … … 317 331 UpdateHisto(); 318 332 Histo::Show(os); 333 os <<" ymin="<<YMin<<" ymax="<<YMax<<" opt="<<Opt<< endl; 319 334 } 320 335 … … 346 361 // Lecture des donnees propres a l'histogramme de profil. 347 362 is.GetLine(strg,255); 348 dobj-> SumY = new r_8[dobj->mBins];349 dobj-> SumY2 = new r_8[dobj->mBins];350 dobj-> SumW = new r_8[dobj->mBins];351 is.Get(dobj-> SumY, dobj->mBins);352 is.Get(dobj-> SumY2, dobj->mBins);353 is.Get(dobj-> SumW, dobj->mBins);363 dobj->mSumY = new r_8[dobj->mBins]; 364 dobj->mSumY2 = new r_8[dobj->mBins]; 365 dobj->mSumW = new r_8[dobj->mBins]; 366 is.Get(dobj->mSumY, dobj->mBins); 367 is.Get(dobj->mSumY2, dobj->mBins); 368 is.Get(dobj->mSumW, dobj->mBins); 354 369 355 370 // Lecture de l'histogramme 356 371 is >> (Histo&)(*dobj); 372 357 373 return; 358 374 } … … 379 395 sprintf(strg,"HProf: SumY SumY2 SumW"); 380 396 os.PutLine(strg); 381 os.Put(dobj-> SumY, dobj->mBins);382 os.Put(dobj-> SumY2, dobj->mBins);383 os.Put(dobj-> SumW, dobj->mBins);397 os.Put(dobj->mSumY, dobj->mBins); 398 os.Put(dobj->mSumY2, dobj->mBins); 399 os.Put(dobj->mSumW, dobj->mBins); 384 400 385 401 // Ecriture de l'histogramme 386 // FIO_Histo fio_h((Histo&)*dobj);387 // fio_h.Write(os);388 402 os << (Histo&)(*dobj); 389 403 -
trunk/SophyaLib/HiStats/hisprof.h
r3049 r3053 56 56 {UpdateHisto(); 57 57 return (mErr2[i]>0.) ? sqrt(mErr2[i]) : 0.;} 58 //! Retourne le carre de la dispersion/erreur du bin i 59 inline r_8 SumW(int_4 i) const {return mSumW[i];} 58 60 59 61 // Operators … … 65 67 66 68 virtual void Show(ostream& os) const; 69 inline void Show() const { Show(cout); } 67 70 //! Print, voir detail dans Histo::Print 68 71 inline void Print(int_4 dyn=100,r_8 hmin=1.,r_8 hmax=-1. … … 71 74 72 75 protected: 76 void CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin, r_8 yMin=1., r_8 yMax=-1.); 73 77 void Delete(); 74 78 void updatehisto() const; 75 79 76 r_8* SumY; //!< somme77 r_8* SumY2; //!< somme des carres78 r_8* SumW; //!< somme des poids80 r_8* mSumY; //!< somme 81 r_8* mSumY2; //!< somme des carres 82 r_8* mSumW; //!< somme des poids 79 83 mutable bool Ok; //!< true if update fait 80 84 r_8 YMin; //!< limite minimum Y pour somme … … 83 87 }; 84 88 89 /*! Prints histogram information on stream \b s (h.Show(s)) */ 90 inline ostream& operator << (ostream& s, HProf const & h) 91 { h.Show(s); return(s); } 85 92 86 93 /*! \ingroup HiStats \fn operator<<(POuttPersist&, HProf) -
trunk/SophyaLib/HiStats/histerr.cc
r3049 r3053 17 17 /*! Constructeur par defaut */ 18 18 HistoErr::HistoErr(void) 19 19 : Histo(), mNData(NULL), mCorrel(0) 20 20 { 21 21 } … … 24 24 /*! Constructeur d'un histo de nBin bins allant de xMin a xMax */ 25 25 HistoErr::HistoErr(r_8 xMin, r_8 xMax, int_4 nBin) 26 : Histo(xMin,xMax,nBin), mNData(NULL), mCorrel(0) 27 { 28 this->Errors(); 29 allocate_mNData(nBin); 30 Zero(); 26 : Histo(), mNData(NULL) 27 { 28 CreateOrResize(xMin,xMax,nBin); 31 29 } 32 30 … … 34 32 /*! Constructeur par copie */ 35 33 HistoErr::HistoErr(const HistoErr& H) 36 : Histo(H), mNData(NULL), mCorrel(H.mCorrel) 37 { 38 allocate_mNData(H.mBins); 39 if(mBins>0) memcpy(mNData,H.mNData,mBins*sizeof(r_8)); 34 : Histo(H), mNData((H.mBins>0)? new r_8[H.mBins] : NULL), mCorrel(H.mCorrel) 35 { 36 if(mNData>0) memcpy(mNData,H.mNData,mBins*sizeof(r_8)); 40 37 } 41 38 … … 48 45 49 46 /********* Methode *********/ 47 /*! Gestion de l'allocation */ 48 void HistoErr::CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin) 49 { 50 //cout<<"HistoErr::CreateOrResize()"<<endl; 51 Histo::CreateOrResize(xMin,xMax,nBin); 52 Histo::Errors(); 53 allocate_mNData(nBin); 54 mCorrel = 0; 55 } 56 57 /********* Methode *********/ 50 58 /*! Allocation du tableau mNData */ 51 59 void HistoErr::allocate_mNData(int nbin) 52 60 { 53 if(nbin<=0) return; 54 if(mNData) {delete [] mNData; mNData=NULL;} 55 mNData = new r_8[nbin]; 61 if(mNData) {delete [] mNData; mNData=NULL;} 62 if(nbin<=0) return; 63 mNData = new r_8[nbin]; 64 memset(mNData,0,nbin*sizeof(r_8)); 56 65 } 57 66 … … 60 69 void HistoErr::Delete(void) 61 70 { 62 Histo::Delete(); 63 if(mNData) {delete [] mNData; mNData=NULL;} 71 //cout<<"HistoErr::Delete()"<<endl; 72 Histo::Delete(); 73 if(mNData) {delete [] mNData; mNData=NULL;} 74 mCorrel = 0; 64 75 } 65 76 … … 70 81 void HistoErr::Zero(void) 71 82 { 72 Histo::Zero();73 if(mNData) memset(mNData,0,mBins*sizeof(r_8));74 mCorrel = 0;83 Histo::Zero(); 84 if(mNData) memset(mNData,0,mBins*sizeof(r_8)); 85 mCorrel = 0; 75 86 } 76 87 … … 201 212 } 202 213 214 /********* Methode *********/ 215 /*! 216 Print info 217 */ 218 void HistoErr::Show(ostream & os) const 219 { 220 Histo::Show(os); 221 os <<" ncorrel="<<mCorrel<< endl; 222 } 223 203 224 /////////////////////////////////////////////////////////// 204 225 // -------------------------------------------------------- -
trunk/SophyaLib/HiStats/histerr.h
r3049 r3053 78 78 HistoErr& operator = (const HistoErr& h); 79 79 80 // Print 81 virtual void Show(ostream& os) const; 82 inline void Show() const { Show(cout); } 83 80 84 protected: 81 85 void allocate_mNData(int nbin); 86 void CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin); 82 87 void Delete(void); 83 88 … … 85 90 int_4 mCorrel; //!< Nombre d'appels a ToCorrel(+1) ou FromCorrel(-1) 86 91 }; 92 93 /*! Prints histogram information on stream \b s (h.Show(s)) */ 94 inline ostream& operator << (ostream& s, HistoErr const & h) 95 { h.Show(s); return(s); } 87 96 88 97 /*! \ingroup HiStats \fn operator<<(POuttPersist&,HistoErr) -
trunk/SophyaLib/HiStats/histos.cc
r3044 r3053 1 1 // 2 // $Id: histos.cc,v 1.2 2 2006-08-07 17:38:47cmv Exp $2 // $Id: histos.cc,v 1.23 2006-08-12 17:29:29 cmv Exp $ 3 3 // 4 4 … … 22 22 /*! Constructeur par defaut */ 23 23 Histo::Histo() 24 : mData(NULL), mErr2(NULL), 25 mUnder(0), mOver(0), nHist(0), nEntries(0), 26 mBins(0), mMin(0), mMax(0), 27 binWidth(0) 24 : mData(NULL), mErr2(NULL) 25 , mUnder(0.), mOver(0.), nHist(0.), nEntries(0) 26 , mBins(0), mMin(0.), mMax(0.), binWidth(0.) 28 27 { 29 28 } … … 32 31 /*! Constructeur d'un histo de nBin bins allant de xMin a xMax */ 33 32 Histo::Histo(r_8 xMin, r_8 xMax, int_4 nBin) 34 : mData((nBin>0) ? new r_8[nBin] : NULL), 35 mErr2(NULL), 36 mUnder(0), mOver(0), nHist(0), nEntries(0), 37 mBins(nBin), mMin(xMin), mMax(xMax), 38 binWidth((nBin>0) ? (mMax-mMin)/nBin : 0) 39 { 40 Zero(); 33 : mData(NULL), mErr2(NULL) 34 { 35 CreateOrResize(xMin,xMax,nBin); 41 36 } 42 37 … … 44 39 /*! Constructeur d'un histo de nBin bins allant de xMin a xMax */ 45 40 Histo::Histo(r_4 xMin, r_4 xMax, int_4 nBin) 46 : mData((nBin>0) ? new r_8[nBin] : NULL), 47 mErr2(NULL), 48 mUnder(0), mOver(0), nHist(0), nEntries(0), 49 mBins(nBin), mMin((r_8)xMin), mMax((r_8)xMax), 50 binWidth((nBin>0) ? (mMax-mMin)/nBin : 0) 51 { 52 Zero(); 41 : mData(NULL), mErr2(NULL) 42 { 43 CreateOrResize((r_8)xMin,(r_8)xMax,nBin); 53 44 } 54 45 … … 68 59 69 60 /********* Methode *********/ 61 /*! Destructeur */ 62 Histo::~Histo() 63 { 64 Delete(); 65 } 66 67 /********* Methode *********/ 68 /*! Gestion de l'allocation */ 69 void Histo::CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin) 70 { 71 //cout<<"Histo::CreateOrResize()"<<endl; 72 if(mData != NULL) {delete[] mData; mData = NULL;} 73 if(mErr2 != NULL) {delete[] mErr2; mErr2 = NULL;} 74 if(nBin>0) {mData = new r_8[nBin]; memset(mData,0,nBin*sizeof(r_8));} 75 mBins = nBin; 76 mMin = xMin; mMax = xMax; 77 binWidth = (nBin>0) ? (mMax-mMin)/nBin : 0.; 78 mUnder = mOver = nHist = 0.; 79 nEntries = 0; 80 } 81 82 /********* Methode *********/ 70 83 /*! Gestion de la des-allocation */ 71 84 void Histo::Delete() 72 85 { 73 if( mData != NULL ) { delete[] mData; mData = NULL;} 74 if( mErr2 != NULL ) { delete[] mErr2; mErr2 = NULL;} 75 mUnder = mOver = mMin = mMax = binWidth= 0.; 76 nHist = 0.; 77 mBins = 0; 78 nEntries = 0; 79 } 80 81 /********* Methode *********/ 82 /*! Destructeur */ 83 Histo::~Histo() 84 { 85 Delete(); 86 //cout<<"Histo::Delete()"<<endl; 87 if(mData != NULL) {delete[] mData; mData = NULL;} 88 if(mErr2 != NULL) {delete[] mErr2; mErr2 = NULL;} 89 mUnder = mOver = mMin = mMax = binWidth = nHist = 0.; 90 mBins = 0; 91 nEntries = 0; 86 92 } 87 93 … … 94 100 if(mBins<=0 || mData==NULL) return; 95 101 memset(mData,0,mBins*sizeof(r_8)); 96 mUnder = mOver = 0;97 nHist = 0;102 if(mErr2) memset(mErr2,0, mBins*sizeof(r_8)); 103 mUnder = mOver = nHist = 0; 98 104 nEntries = 0; 99 if(mErr2) memset(mErr2, 0, mBins*sizeof(r_8));100 105 } 101 106 … … 106 111 void Histo::Errors() 107 112 { 113 if(mErr2 != NULL) {delete[] mErr2; mErr2 = NULL;} 108 114 if(mBins<=0) return; 109 if(mErr2==NULL)mErr2 = new r_8[mBins];115 mErr2 = new r_8[mBins]; 110 116 memset(mErr2,0,mBins*sizeof(r_8)); 111 117 } … … 141 147 mData = new r_8[h.mBins]; 142 148 if(h.mErr2) mErr2 = new r_8[h.mBins]; 143 mUnder = h.mUnder; 144 mOver = h.mOver; 149 mUnder = h.mUnder; mOver = h.mOver; 145 150 nHist = h.nHist; 146 151 nEntries = h.nEntries; 147 152 mBins = h.mBins; 148 mMin = h.mMin; 149 mMax = h.mMax; 153 mMin = h.mMin; mMax = h.mMax; 150 154 binWidth = h.binWidth; 151 155 -
trunk/SophyaLib/HiStats/histos.h
r3049 r3053 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: histos.h,v 1.2 2 2006-08-11 16:10:13cmv Exp $3 // $Id: histos.h,v 1.23 2006-08-12 17:29:29 cmv Exp $ 4 4 // 5 5 … … 158 158 159 159 protected: 160 void Delete(); 160 void CreateOrResize(r_8 xMin, r_8 xMax, int_4 nBin); 161 void Delete(void); // Ne pas passer en "virtual" 161 162 162 163 r_8* mData; //!< donnees -
trunk/SophyaLib/HiStats/histos2.cc
r2868 r3053 39 39 40 40 /////////////////////////////////////////////////////////////////// 41 42 /*! 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 41 55 /*! 42 56 Createur d'un histogramme 2D ayant nxBin,nyBin bins … … 44 58 */ 45 59 Histo2D::Histo2D(r_8 xMin,r_8 xMax,int_4 nxBin,r_8 yMin,r_8 yMax,int_4 nyBin) 46 : mData(new r_8[nxBin*nyBin]), mErr2(NULL) 47 , nHist(0), nEntries(0) 48 , mNx(nxBin), mNy(nyBin), mNxy(nxBin*nyBin) 49 , mXmin(xMin), mXmax(xMax), mYmin(yMin), mYmax(yMax) 50 , mWBinx((xMax - xMin)/nxBin), mWBiny((yMax - yMin)/nyBin) 51 , mHprojx(NULL), mHprojy(NULL) 52 { 53 ASSERT(nxBin>0 && nyBin>0 && xMin<xMax && yMin<yMax); 54 for(int_4 i=0;i<3;i++) for(int_4 j=0;j<3;j++) mOver[i][j]=0.; 55 Zero(); 56 mB_s.H = NULL; 60 : mData(NULL), mErr2(NULL), mHprojx(NULL), mHprojy(NULL) 61 { 62 CreateOrResize(xMin,xMax,nxBin,yMin,yMax,nyBin); 57 63 } 58 64 … … 62 68 */ 63 69 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; 70 : mData(NULL), mErr2(NULL), mHprojx(NULL), mHprojy(NULL) 71 { 72 CreateOrResize((r_8)xMin,(r_8)xMax,nxBin,(r_8)yMin,(r_8)yMax,nyBin); 75 73 } 76 74 … … 142 140 143 141 /*! 144 Constructeur par defaut. 145 */ 146 Histo2D::Histo2D() 147 : mData(NULL), mErr2(NULL) 148 , nHist(0), nEntries(0) 149 , mNx(0), mNy(0), mNxy(0) 150 , mXmin(0), mXmax(0), mYmin(0), mYmax(0) 151 , mWBinx(0), mWBiny(0) 152 , mHprojx(NULL), mHprojy(NULL) 153 { 154 for(int_4 i=0;i<3;i++) for(int_4 j=0;j<3;j++) mOver[i][j]=0.; 155 mB_s.H = NULL; 156 } 157 158 /////////////////////////////////////////////////////////////////// 142 Destructeur. 143 */ 144 Histo2D::~Histo2D() 145 { 146 Delete(); 147 } 148 149 /////////////////////////////////////////////////////////////////// 150 /*! 151 allocation de la place de l'histogramme (fct privee). 152 */ 153 void Histo2D::CreateOrResize(r_8 xMin,r_8 xMax,int_4 nxBin,r_8 yMin,r_8 yMax,int_4 nyBin) 154 { 155 int_8 n = nxBin*nyBin; 156 if(mData!=NULL) {delete[] mData; mData = NULL;} 157 if(n>0) {mData = new r_8[n]; memset(mData, 0, n*sizeof(r_8));} 158 mNx = nxBin; mNy = nyBin; mNxy = nxBin*nyBin; 159 mXmin = xMin; mXmax = xMax; mYmin = yMin; mYmax = yMax; 160 mWBinx = (nxBin>0) ? (xMax - xMin)/nxBin: 0.; 161 mWBiny = (nyBin>0) ? (yMax - yMin)/nyBin: 0.; 162 nHist = 0; nEntries = 0; 163 for(int_4 i=0;i<3;i++) for(int_4 j=0;j<3;j++) mOver[i][j]=0.; 164 mB_s.H = NULL; 165 } 166 159 167 /*! 160 168 Desallocation de la place de l'histogramme (fct privee). … … 163 171 { 164 172 if( mData != NULL ) { delete[] mData; mData = NULL;} 165 166 173 if( mErr2 != NULL ) { delete[] mErr2; mErr2 = NULL;} 167 174 … … 180 187 mWBinx = 0; mWBiny = 0; 181 188 for(int_4 i=0;i<3;i++) for(int_4 j=0;j<3;j++) mOver[i][j]=0.; 182 mB_s.H = NULL; 183 } 184 185 /*! 186 Destructeur. 187 */ 188 Histo2D::~Histo2D() 189 { 190 Delete(); 189 mB_s.H = NULL; // Ne pas faire de delete! 191 190 } 192 191 … … 219 218 void Histo2D::Errors() 220 219 { 221 if( mNxy > 0 ) {222 if(mErr2==NULL) mErr2 = new r_8[mNxy];223 memset(mErr2, 0, mNxy*sizeof(r_8));224 }220 if(mErr2!=NULL) {delete[] mErr2; mErr2 = NULL;} 221 if(mNxy <= 0) return; 222 mErr2 = new r_8[mNxy]; 223 memset(mErr2,0,mNxy*sizeof(r_8)); 225 224 } 226 225 -
trunk/SophyaLib/HiStats/histos2.h
r3049 r3053 143 143 // Print et Display ASCII 144 144 virtual void Show(ostream& os) const; 145 inline void Show() const { Show(cout); } 145 146 inline void PrintStatus() const { Show(cout); } 146 147 … … 211 212 #endif 212 213 213 void Delete(); 214 void CreateOrResize(r_8 xMin,r_8 xMax,int_4 nxBin,r_8 yMin,r_8 yMax,int_4 nyBin); 215 void Delete(void); 214 216 215 217 r_8* mData; //!< donnees -
trunk/SophyaLib/HiStats/smakefile
r3007 r3053 12 12 13 13 $(SOPHYAOBJP)basedtable.o: basedtable.cc basedtable.h \ 14 $(SOPHYAINCP)machdefs.h ntupintf.h\15 $(SOPHYAINCP)dvlist.h \14 $(SOPHYAINCP)machdefs.h \ 15 ntupintf.h $(SOPHYAINCP)dvlist.h \ 16 16 $(SOPHYAINCP)objfio.h \ 17 17 $(SOPHYAINCP)machdefs.h \ … … 40 40 41 41 $(SOPHYAOBJP)datatable.o: datatable.cc datatable.h basedtable.h \ 42 $(SOPHYAINCP)machdefs.h ntupintf.h\43 $(SOPHYAINCP)dvlist.h \42 $(SOPHYAINCP)machdefs.h \ 43 ntupintf.h $(SOPHYAINCP)dvlist.h \ 44 44 $(SOPHYAINCP)objfio.h \ 45 45 $(SOPHYAINCP)machdefs.h \ … … 73 73 74 74 $(SOPHYAOBJP)fio_dtable.o: fio_dtable.cc datatable.h basedtable.h \ 75 $(SOPHYAINCP)machdefs.h ntupintf.h \ 76 $(SOPHYAINCP)dvlist.h \ 77 $(SOPHYAINCP)objfio.h \ 78 $(SOPHYAINCP)machdefs.h \ 79 $(SOPHYAINCP)anydataobj.h \ 80 $(SOPHYAINCP)ppersist.h \ 81 $(SOPHYAINCP)pexceptions.h \ 82 $(SOPHYAINCP)gnumd5.h \ 83 $(SOPHYAINCP)ppfbinstream.h \ 84 $(SOPHYAINCP)rawstream.h \ 85 $(SOPHYAINCP)ppfnametag.h \ 86 $(SOPHYAINCP)mutyv.h \ 87 $(SOPHYAINCP)timestamp.h \ 88 $(SOPHYAINCP)segdatablock.h \ 89 $(SOPHYAINCP)tvector.h \ 90 $(SOPHYAINCP)tmatrix.h \ 91 $(SOPHYAINCP)tarray.h \ 92 $(SOPHYAINCP)basarr.h \ 93 $(SOPHYAINCP)dvlist.h \ 94 $(SOPHYAINCP)ndatablock.h \ 95 $(SOPHYAINCP)utilarr.h \ 96 $(SOPHYAINCP)tmatrix_tsnl.h \ 97 $(SOPHYAINCP)tvector_tsnl.h \ 98 $(SOPHYAINCP)objfio.h swppfdtable.h \ 75 $(SOPHYAINCP)machdefs.h \ 76 ntupintf.h $(SOPHYAINCP)dvlist.h \ 77 $(SOPHYAINCP)objfio.h \ 78 $(SOPHYAINCP)machdefs.h \ 79 $(SOPHYAINCP)anydataobj.h \ 80 $(SOPHYAINCP)ppersist.h \ 81 $(SOPHYAINCP)pexceptions.h \ 82 $(SOPHYAINCP)gnumd5.h \ 83 $(SOPHYAINCP)ppfbinstream.h \ 84 $(SOPHYAINCP)rawstream.h \ 85 $(SOPHYAINCP)ppfnametag.h \ 86 $(SOPHYAINCP)mutyv.h \ 87 $(SOPHYAINCP)timestamp.h \ 88 $(SOPHYAINCP)segdatablock.h \ 89 $(SOPHYAINCP)tvector.h \ 90 $(SOPHYAINCP)tmatrix.h \ 91 $(SOPHYAINCP)tarray.h \ 92 $(SOPHYAINCP)basarr.h \ 93 $(SOPHYAINCP)dvlist.h \ 94 $(SOPHYAINCP)ndatablock.h \ 95 $(SOPHYAINCP)utilarr.h \ 96 $(SOPHYAINCP)tmatrix_tsnl.h \ 97 $(SOPHYAINCP)tvector_tsnl.h \ 98 $(SOPHYAINCP)objfio.h \ 99 swppfdtable.h \ 99 100 $(SOPHYAINCP)swsegdb.h \ 100 101 $(SOPHYAINCP)segdatablock.h \ … … 109 110 $(SOPHYAOBJP)hisprof.o: hisprof.cc \ 110 111 $(SOPHYAINCP)sopnamsp.h \ 111 $(SOPHYAINCP)machdefs.h hisprof.h\112 $(SOPHYAINCP)peida.h \112 $(SOPHYAINCP)machdefs.h \ 113 hisprof.h $(SOPHYAINCP)peida.h \ 113 114 $(SOPHYAINCP)machdefs.h \ 114 115 $(SOPHYAINCP)utils.h \ … … 142 143 $(SOPHYAOBJP)histerr.o: histerr.cc \ 143 144 $(SOPHYAINCP)sopnamsp.h \ 144 $(SOPHYAINCP)machdefs.h histinit.h \ 145 $(SOPHYAINCP)machdefs.h \ 146 histinit.h \ 145 147 $(SOPHYAINCP)ntoolsinit.h \ 146 148 $(SOPHYAINCP)tarrinit.h \ 147 149 $(SOPHYAINCP)sophyainit.h \ 148 $(SOPHYAINCP)machdefs.h histerr.h\149 $(SOPHYAINCP)objfio.h \150 $(SOPHYAINCP)anydataobj.h \ 151 $(SOPHYAINCP)ppersist.h \ 152 $(SOPHYAINCP)pexceptions.h \ 153 $(SOPHYAINCP)gnumd5.h \ 154 $(SOPHYAINCP)ppfbinstream.h \ 155 $(SOPHYAINCP)rawstream.h \ 156 $(SOPHYAINCP)ppfnametag.h histos.h\157 $(SOPHYAINCP)peida.h \150 $(SOPHYAINCP)machdefs.h \ 151 histerr.h $(SOPHYAINCP)objfio.h \ 152 $(SOPHYAINCP)anydataobj.h \ 153 $(SOPHYAINCP)ppersist.h \ 154 $(SOPHYAINCP)pexceptions.h \ 155 $(SOPHYAINCP)gnumd5.h \ 156 $(SOPHYAINCP)ppfbinstream.h \ 157 $(SOPHYAINCP)rawstream.h \ 158 $(SOPHYAINCP)ppfnametag.h \ 159 histos.h $(SOPHYAINCP)peida.h \ 158 160 $(SOPHYAINCP)utils.h \ 159 161 $(SOPHYAINCP)perrors.h \ … … 178 180 $(SOPHYAOBJP)histinit.o: histinit.cc \ 179 181 $(SOPHYAINCP)sopnamsp.h \ 180 $(SOPHYAINCP)machdefs.h histinit.h \ 182 $(SOPHYAINCP)machdefs.h \ 183 histinit.h \ 181 184 $(SOPHYAINCP)ntoolsinit.h \ 182 185 $(SOPHYAINCP)tarrinit.h \ … … 208 211 $(SOPHYAINCP)tvector_tsnl.h \ 209 212 $(SOPHYAINCP)ppersist.h \ 210 $(SOPHYAINCP)anydataobj.h histos2.h \ 211 $(SOPHYAINCP)utils.h hisprof.h histerr.h \ 212 ntuple.h ntupintf.h $(SOPHYAINCP)dvlist.h \ 213 xntuple.h datatable.h basedtable.h \ 214 $(SOPHYAINCP)segdatablock.h swppfdtable.h \ 213 $(SOPHYAINCP)anydataobj.h \ 214 histos2.h $(SOPHYAINCP)utils.h \ 215 hisprof.h histerr.h ntuple.h ntupintf.h \ 216 $(SOPHYAINCP)dvlist.h xntuple.h \ 217 datatable.h basedtable.h \ 218 $(SOPHYAINCP)segdatablock.h \ 219 swppfdtable.h \ 215 220 $(SOPHYAINCP)swsegdb.h \ 216 221 $(SOPHYAINCP)segdatablock.h \ … … 222 227 $(SOPHYAOBJP)histos2.o: histos2.cc \ 223 228 $(SOPHYAINCP)sopnamsp.h \ 224 $(SOPHYAINCP)machdefs.h histos2.h\225 $(SOPHYAINCP)peida.h \229 $(SOPHYAINCP)machdefs.h \ 230 histos2.h $(SOPHYAINCP)peida.h \ 226 231 $(SOPHYAINCP)machdefs.h \ 227 232 $(SOPHYAINCP)utils.h \ … … 253 258 $(CXXCOMPILE) $(CXXTEMPFLG) -o $@ histos2.cc 254 259 255 $(SOPHYAOBJP)histos.o: histos.cc $(SOPHYAINCP)sopnamsp.h \ 260 $(SOPHYAOBJP)histos.o: histos.cc \ 261 $(SOPHYAINCP)sopnamsp.h \ 256 262 $(SOPHYAINCP)machdefs.h histos.h \ 257 263 $(SOPHYAINCP)objfio.h \ … … 290 296 291 297 $(SOPHYAOBJP)ntupintf.o: ntupintf.cc \ 292 $(SOPHYAINCP)sopnamsp.h ntupintf.h \ 298 $(SOPHYAINCP)sopnamsp.h \ 299 ntupintf.h \ 293 300 $(SOPHYAINCP)machdefs.h \ 294 301 $(SOPHYAINCP)pexceptions.h \ … … 296 303 $(CXXCOMPILE) $(CXXTEMPFLG) -o $@ ntupintf.cc 297 304 298 $(SOPHYAOBJP)ntuple.o: ntuple.cc $(SOPHYAINCP)sopnamsp.h \ 305 $(SOPHYAOBJP)ntuple.o: ntuple.cc \ 306 $(SOPHYAINCP)sopnamsp.h \ 299 307 $(SOPHYAINCP)strutil.h \ 300 308 $(SOPHYAINCP)perrors.h \ … … 307 315 $(SOPHYAINCP)ppfbinstream.h \ 308 316 $(SOPHYAINCP)rawstream.h \ 309 $(SOPHYAINCP)ppfnametag.h ntupintf.h \ 317 $(SOPHYAINCP)ppfnametag.h \ 318 ntupintf.h \ 310 319 $(SOPHYAINCP)machdefs.h \ 311 320 $(SOPHYAINCP)ppersist.h \ … … 317 326 318 327 $(SOPHYAOBJP)proxtuple.o: proxtuple.cc \ 319 $(SOPHYAINCP)sopnamsp.h proxtuple.h \ 320 ntuple.h $(SOPHYAINCP)objfio.h \ 321 $(SOPHYAINCP)machdefs.h \ 322 $(SOPHYAINCP)anydataobj.h \ 323 $(SOPHYAINCP)ppersist.h \ 324 $(SOPHYAINCP)pexceptions.h \ 325 $(SOPHYAINCP)gnumd5.h \ 326 $(SOPHYAINCP)ppfbinstream.h \ 327 $(SOPHYAINCP)rawstream.h \ 328 $(SOPHYAINCP)ppfnametag.h ntupintf.h \ 328 $(SOPHYAINCP)sopnamsp.h \ 329 proxtuple.h ntuple.h \ 330 $(SOPHYAINCP)objfio.h \ 331 $(SOPHYAINCP)machdefs.h \ 332 $(SOPHYAINCP)anydataobj.h \ 333 $(SOPHYAINCP)ppersist.h \ 334 $(SOPHYAINCP)pexceptions.h \ 335 $(SOPHYAINCP)gnumd5.h \ 336 $(SOPHYAINCP)ppfbinstream.h \ 337 $(SOPHYAINCP)rawstream.h \ 338 $(SOPHYAINCP)ppfnametag.h \ 339 ntupintf.h \ 329 340 $(SOPHYAINCP)machdefs.h \ 330 341 $(SOPHYAINCP)ppersist.h \ … … 336 347 337 348 $(SOPHYAOBJP)swppfdtable.o: swppfdtable.cc swppfdtable.h basedtable.h \ 338 $(SOPHYAINCP)machdefs.h ntupintf.h\339 $(SOPHYAINCP)dvlist.h \349 $(SOPHYAINCP)machdefs.h \ 350 ntupintf.h $(SOPHYAINCP)dvlist.h \ 340 351 $(SOPHYAINCP)objfio.h \ 341 352 $(SOPHYAINCP)machdefs.h \ … … 380 391 $(SOPHYAINCP)ppersist.h \ 381 392 $(SOPHYAINCP)perrors.h xntuple.h \ 382 $(SOPHYAINCP)machdefs.h ntupintf.h\383 $(SOPHYAINCP)dvlist.h \393 $(SOPHYAINCP)machdefs.h \ 394 ntupintf.h $(SOPHYAINCP)dvlist.h \ 384 395 $(SOPHYAINCP)objfio.h \ 385 396 $(SOPHYAINCP)anydataobj.h \
Note:
See TracChangeset
for help on using the changeset viewer.