Changeset 3147 in Sophya for trunk/SophyaLib/HiStats/hist2err.cc
- Timestamp:
- Jan 18, 2007, 7:20:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/hist2err.cc
r3136 r3147 19 19 : xmin_(1.), xmax_(-1.), nx_(0), dx_(0.) 20 20 , ymin_(1.), ymax_(-1.), ny_(0), dy_(0.) 21 , m Correl(0)21 , mMean(0) 22 22 { 23 23 } … … 33 33 /*! Constructeur par copie */ 34 34 Histo2DErr::Histo2DErr(const Histo2DErr& H) 35 : m Correl(0)35 : mMean(0) 36 36 { 37 37 if(H.nx_<=0 || H.ny_<=0) return; … … 40 40 err2_ = H.err2_; 41 41 ndata_ = H.ndata_; 42 m Correl = H.mCorrel;42 mMean = H.mMean; 43 43 } 44 44 … … 47 47 Histo2DErr::~Histo2DErr(void) 48 48 { 49 m Correl= 0;49 mMean = 0; 50 50 } 51 51 … … 63 63 dy_ = (ymax_-ymin_)/ny_; 64 64 } 65 m Correl= 0;65 mMean = 0; 66 66 } 67 67 … … 113 113 /********* Methode *********/ 114 114 /*! 115 Compute the correlation histogram.116 Each bin content is divided by the number of entries in th atbin.117 Each squared error is divided by the number of entries in th atbin.118 The number of entries by bin is NOT set to 1 (calling ToCorrel119 120 */ 121 void Histo2DErr::To Correl(void)115 Compute the mean histogram. 116 Each bin content is divided by the number of entries in the bin. 117 Each squared error is divided by the number of entries in the bin. 118 The number of entries by bin is NOT set to 1 119 (calling ToMean many time will change the histogram !) 120 */ 121 void Histo2DErr::ToMean(void) 122 122 { 123 123 if(nx_<1 || ny_<1) return; 124 m Correl++;124 mMean++; 125 125 for(int_4 i=0;i<nx_;i++) { 126 126 for(int_4 j=0;j<ny_;j++) { … … 135 135 /********* Methode *********/ 136 136 /*! 137 Recompute back the original Histo2DErr before ToCorrelaction138 */ 139 void Histo2DErr::From Correl(void)137 Recompute back the original Histo2DErr after ToMean action 138 */ 139 void Histo2DErr::FromMean(void) 140 140 { 141 141 if(nx_<1 || ny_<1) return; 142 m Correl--;142 mMean--; 143 143 for(int_4 i=0;i<nx_;i++) { 144 144 for(int_4 j=0;j<ny_;j++) { … … 146 146 data_(i,j) *= ndata_(i,j); 147 147 err2_(i,j) *= ndata_(i,j); 148 } 149 } 150 return; 151 } 152 153 /********* Methode *********/ 154 /*! 155 Compute the mean histogram and replace the "error table" by the variance. 156 This should be done if Add(x,w,w) has been used. 157 The "value table" is divided by the number of entries to get the mean 158 The "error table" is replace by the variance 159 The number of entries by bin is NOT set to 1 160 (calling ToMean many time will change the histogram !) 161 Mixing ToMean and ToVariance leads to unpredictable results 162 */ 163 void Histo2DErr::ToVariance(void) 164 { 165 if(nx_<1 || ny_<1) return; 166 mMean++; 167 for(int_4 i=0;i<nx_;i++) { 168 for(int_4 j=0;j<ny_;j++) { 169 if(ndata_(i,j)<1.) continue; 170 data_(i,j) /= ndata_(i,j); 171 err2_(i,j) = err2_(i,j)/ndata_(i,j) - data_(i,j)*data_(i,j); 172 } 173 } 174 return; 175 } 176 177 /********* Methode *********/ 178 /*! 179 Recompute back the original HistoErr after ToVariance action 180 Mixing FromMean and FromVariance leads to unpredictable results 181 */ 182 void Histo2DErr::FromVariance(void) 183 { 184 if(nx_<1 || ny_<1) return; 185 mMean--; 186 for(int_4 i=0;i<nx_;i++) { 187 for(int_4 j=0;j<ny_;j++) { 188 if(ndata_(i,j)<1.) continue; 189 err2_(i,j) = ndata_(i,j)*(err2_(i,j) + data_(i,j)*data_(i,j)); 190 data_(i,j) *= ndata_(i,j); 148 191 } 149 192 } … … 172 215 } 173 216 } 174 m Correl = hfrom.mCorrel;217 mMean = hfrom.mMean; 175 218 176 219 } … … 187 230 err2_ = h.err2_; 188 231 ndata_ = h.ndata_; 189 m Correl = h.mCorrel;232 mMean = h.mMean; 190 233 return *this; 191 234 } … … 213 256 void Histo2DErr::Show(ostream & os) const 214 257 { 215 os <<"Histo2DErr(n correl="<<mCorrel<<")"<<endl258 os <<"Histo2DErr(nmean="<<mMean<<")"<<endl 216 259 <<" nx="<<nx_<<" ["<<xmin_<<","<<xmax_<<"] dx="<<dx_<<endl 217 260 <<" ny="<<ny_<<" ["<<ymin_<<","<<ymax_<<"] dy="<<dy_<<endl; … … 234 277 is.GetStr(strg); 235 278 236 // Nombre d'appels a To Correl/FromCorrel237 is.Get(dobj->m Correl);279 // Nombre d'appels a ToMean/FromMean 280 is.Get(dobj->mMean); 238 281 239 282 // Lecture des parametres Histo2DErr … … 267 310 os.PutStr(strg); 268 311 269 // Nombre d'appels a To Correl/FromCorrel270 os.Put(dobj->m Correl);312 // Nombre d'appels a ToMean/FromMean 313 os.Put(dobj->mMean); 271 314 272 315 // Ecriture des parametres Histo2DErr
Note:
See TracChangeset
for help on using the changeset viewer.