Changeset 1089 in Sophya
- Timestamp:
- Jul 25, 2000, 12:20:43 PM (25 years ago)
- Location:
- trunk/SophyaLib/HiStats
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/hisprof.cc
r1058 r1089 57 57 memcpy(SumW, H.SumW, bins*sizeof(double)); 58 58 } 59 UpdateHisto(); 59 60 END_CONSTRUCTOR 60 61 } … … 127 128 et dispersion/erreur sur la moyenne). 128 129 */ 129 void HProf:: UpdateHisto() const130 void HProf::updatehisto() const 130 131 { 131 132 float m,e2; 132 if(bins<=0) return; 133 for(int i=0;i<bins;i++) { 133 if(bins>0) for(int i=0;i<bins;i++) { 134 134 if(SumW[i]<=0.) { 135 135 m = e2 = 0.; … … 142 142 err2[i] = e2; 143 143 } 144 // Attention, a cause de "WriteSelf const" UpdateHisto doit etre "const". 144 Ok = true; 145 // Attention, a cause de "WriteSelf const" updatehisto doit etre "const". 145 146 // Comme on veut modifier Ok, on est oblige de faire cette entourloupe: 146 147 HProf *buff = (HProf *) this; … … 224 225 Histo *hthis = (Histo *) this; 225 226 *hthis += (Histo) a; 226 for(int i=0;i<bins;i++) {227 if(bins>0) for(int i=0;i<bins;i++) { 227 228 SumY[i] += a.SumY[i]; 228 229 SumY2[i] += a.SumY2[i]; 229 230 SumW[i] += a.SumW[i]; 230 231 } 231 Ok = false;232 updatehisto(); 232 233 233 234 return *this; … … 283 284 } 284 285 // On synchronise les tableaux Sum?? et l'Histogramme 285 UpdateHisto();286 updatehisto(); 286 287 } 287 288 … … 303 304 is.GetLine(strg,255); 304 305 305 // Ecriture des valeurs306 // Lecture des valeurs 306 307 is.Get(dobj->bins); 307 308 is.Get(dobj->YMin); … … 310 311 dobj->Ok = true; 311 312 312 // Ecriture des donnees propres a l'histogramme de profil.313 // Lecture des donnees propres a l'histogramme de profil. 313 314 is.GetLine(strg,255); 314 315 dobj->SumY = new double[dobj->bins]; … … 319 320 is.Get(dobj->SumW, dobj->bins); 320 321 321 // Ecriture de l'histogramme322 // Lecture de l'histogramme 322 323 is >> (Histo&)(*dobj); 323 324 return; … … 329 330 char strg[256]; 330 331 331 if(!(dobj->IsOk()))dobj->UpdateHisto();332 dobj->UpdateHisto(); 332 333 333 334 // Ecriture entete pour identifier facilement -
trunk/SophyaLib/HiStats/hisprof.h
r1058 r1089 22 22 23 23 // UPDATING or SETTING 24 void UpdateHisto() const; 24 //! Calcul la partie histogramme du profile si elle n'est pas a jour. 25 virtual inline void UpdateHisto(bool force=false) const 26 {if(!Ok || force) updatehisto();} 25 27 void SetErrOpt(bool spread = true); 26 28 void Zero(); … … 29 31 30 32 // Acces a l information 31 //! Retourne true si l'histogramme est a jours, false sinon.32 inline bool IsOk() const {return Ok;}33 33 //! Retourne l'histogramme de profil. 34 34 inline Histo GetHisto() 35 { if(!Ok)UpdateHisto(); return (Histo) *this;}35 {UpdateHisto(); return (Histo) *this;} 36 36 //! Retourne le contenu de la moyenne dans le vecteur v 37 37 inline void GetValue(TVector<r_8>& v) 38 { if(!Ok)UpdateHisto(); Histo::GetValue(v);}38 {UpdateHisto(); Histo::GetValue(v);} 39 39 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v 40 40 inline void GetError2(TVector<r_8>& v) 41 { if(!Ok)UpdateHisto(); Histo::GetError2(v);}41 {UpdateHisto(); Histo::GetError2(v);} 42 42 //! Retourne le contenu au carre de la dispersion/erreur dans le vecteur v 43 43 inline void GetError(TVector<r_8>& v) 44 { if(!Ok)UpdateHisto(); Histo::GetError(v);}44 {UpdateHisto(); Histo::GetError(v);} 45 45 //! Retourne le contenu du bin i 46 46 inline float operator()(int i) const 47 { if(!Ok)UpdateHisto(); return data[i];}47 {UpdateHisto(); return data[i];} 48 48 //! Retourne le carre de la dispersion/erreur du bin i 49 49 inline double Error2(int i) const 50 {if(!Ok)UpdateHisto(); return (float) err2[i];}50 {UpdateHisto(); return (float) err2[i];} 51 51 //! Retourne la dispersion/erreur du bin i 52 52 inline float Error(int i) const 53 {if(!Ok)UpdateHisto();54 return (err2[i]>0.) ? (float) sqrt(err2[i]) : 0.f;}53 {UpdateHisto(); 54 return (err2[i]>0.) ? (float) sqrt(err2[i]) : 0.f;} 55 55 56 56 // Operators … … 64 64 //! Fit du profile par ``gfit''. 65 65 inline int Fit(GeneralFit& gfit) 66 { if(!Ok)UpdateHisto(); return Histo::Fit(gfit,0);}66 {UpdateHisto(); return Histo::Fit(gfit,0);} 67 67 //! Retourne l'Histogramme des residus par ``gfit''. 68 68 inline Histo FitResidus(GeneralFit& gfit) 69 { if(!Ok)UpdateHisto(); return Histo::FitResidus(gfit);}69 {UpdateHisto(); return Histo::FitResidus(gfit);} 70 70 //! Retourne l'Histogramme de la fonction fittee par ``gfit''. 71 71 inline Histo FitFunction(GeneralFit& gfit) 72 { if(!Ok)UpdateHisto(); return Histo::FitFunction(gfit);}72 {UpdateHisto(); return Histo::FitFunction(gfit);} 73 73 74 74 // Print … … 76 76 inline void Print(int dyn=100,float hmin=1.,float hmax=-1. 77 77 ,int pflag=0,int il=1,int ih=-1) 78 { if(!Ok)UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);}78 {UpdateHisto(); Histo::Print(dyn,hmin,hmax,pflag,il,ih);} 79 79 //! PrintF, voir detail dans Histo::PrintF 80 80 inline void PrintF(FILE * fp,int dyn=100,float hmin=1.,float hmax=-1. 81 81 ,int pflag=0,int il=1,int ih=-1) 82 { if(!Ok)UpdateHisto(); Histo::PrintF(fp,dyn,hmin,hmax,pflag,il,ih);}82 {UpdateHisto(); Histo::PrintF(fp,dyn,hmin,hmax,pflag,il,ih);} 83 83 84 84 protected: 85 85 void Delete(); 86 void updatehisto() const; 86 87 87 88 double* SumY; //!< somme 88 89 double* SumY2; //!< somme des carres 89 90 double* SumW; //!< somme des poids 90 boolOk; //!< true if update fait91 mutable bool Ok; //!< true if update fait 91 92 float YMin; //!< limite minimum Y pour somme 92 93 float YMax; //!< limite maximum Y pour somme -
trunk/SophyaLib/HiStats/histos.h
r1058 r1089 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: histos.h,v 1. 9 2000-07-07 09:44:16ansari Exp $3 // $Id: histos.h,v 1.10 2000-07-25 10:20:43 ansari Exp $ 4 4 // 5 5 … … 43 43 void SetErr(float x, float e); 44 44 void SetErr(int numBin, float e); 45 virtual inline void UpdateHisto() const { return;} 45 46 46 47 // Operators
Note:
See TracChangeset
for help on using the changeset viewer.