Changeset 1109 in Sophya for trunk/SophyaLib/HiStats/histos.cc
- Timestamp:
- Jul 28, 2000, 6:29:55 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/histos.cc
r1092 r1109 1 1 // 2 // $Id: histos.cc,v 1.1 0 2000-07-26 13:15:15ansari Exp $2 // $Id: histos.cc,v 1.11 2000-07-28 16:29:54 ansari Exp $ 3 3 // 4 4 … … 11 11 #include "poly.h" 12 12 #include "strutil.h" 13 #include "generalfit.h"14 13 15 14 /*! … … 295 294 Remplissage d'un tableau avec la valeur des abscisses 296 295 */ 297 void Histo::GetAbsc(TVector<r_8> &v) 296 void Histo::GetAbsc(TVector<r_8> &v) const 298 297 { 299 298 v.Realloc(mBins); … … 305 304 Remplissage d'un tableau avec la valeur du contenu 306 305 */ 307 void Histo::GetValue(TVector<r_8> &v) 306 void Histo::GetValue(TVector<r_8> &v) const 308 307 { 309 308 v.Realloc(mBins); … … 315 314 Remplissage d'un tableau avec la valeur des erreurs au carre 316 315 */ 317 void Histo::GetError2(TVector<r_8> &v) 316 void Histo::GetError2(TVector<r_8> &v) const 318 317 { 319 318 v.Realloc(mBins); … … 326 325 Remplissage d'un tableau avec la valeur des erreurs 327 326 */ 328 void Histo::GetError(TVector<r_8> &v) 327 void Histo::GetError(TVector<r_8> &v) const 329 328 { 330 329 v.Realloc(mBins); … … 764 763 \endverbatim 765 764 */ 766 int_4 Histo::BinPercent(r_8 x,r_8 per,int& imin,int& imax) 765 int_4 Histo::BinPercent(r_8 x,r_8 per,int& imin,int& imax) const 767 766 { 768 767 imin = imax = -1; … … 792 791 Idem precedent mais renvoie xmin et xmax 793 792 */ 794 int_4 Histo::BinPercent(r_8 x,r_8 per,r_8& xmin,r_8& xmax) 793 int_4 Histo::BinPercent(r_8 x,r_8 per,r_8& xmin,r_8& xmax) const 795 794 { 796 795 xmin = xmax = 0.; … … 901 900 consecutifs, le bin le plus a droite est pris. 902 901 */ 903 int_4 Histo::MaxiLocal(r_8& maxi,int& imax,r_8& maxn,int& imaxn) 902 int_4 Histo::MaxiLocal(r_8& maxi,int& imax,r_8& maxn,int& imaxn) const 904 903 { 905 904 int_4 nml = 0; … … 1162 1161 Cf suivant mais im est le bin du maximum de l'histo 1163 1162 */ 1164 int_4 Histo::EstimeMax(r_8& xm,int_4 SzPav) 1163 int_4 Histo::EstimeMax(r_8& xm,int_4 SzPav) const 1165 1164 { 1166 1165 int_4 im = IMax(); … … 1180 1179 \endverbatim 1181 1180 */ 1182 int_4 Histo::EstimeMax(int& im,r_8& xm,int_4 SzPav) 1181 int_4 Histo::EstimeMax(int& im,r_8& xm,int_4 SzPav) const 1183 1182 { 1184 1183 xm = 0; … … 1212 1211 et a droite (widthD) 1213 1212 */ 1214 void Histo::EstimeWidthS(r_8 frac,r_8& widthG,r_8& widthD) 1213 void Histo::EstimeWidthS(r_8 frac,r_8& widthG,r_8& widthD) const 1215 1214 { 1216 1215 int_4 i; … … 1248 1247 } 1249 1248 1250 }1251 1252 //////////////////////////////////////////////////////////1253 /*!1254 Fit de l'histogramme par ``gfit''.1255 \verbatim1256 typ_err = 0 :1257 - erreur attachee au bin si elle existe1258 - sinon 11259 typ_err = 1 :1260 - erreur attachee au bin si elle existe1261 - sinon max( sqrt(abs(bin) ,1 )1262 typ_err = 2 :1263 - erreur forcee a 11264 typ_err = 3 :1265 - erreur forcee a max( sqrt(abs(bin) ,1 )1266 typ_err = 4 :1267 - erreur forcee a 1, nulle si bin a zero.1268 typ_err = 5 :1269 - erreur forcee a max( sqrt(abs(bin) ,1 ),1270 nulle si bin a zero.1271 \endverbatim1272 */1273 int_4 Histo::Fit(GeneralFit& gfit,unsigned short typ_err)1274 {1275 if(NBins()<=0) return -1000;1276 if(typ_err>5) typ_err=0;1277 1278 GeneralFitData mydata(1,NBins());1279 1280 for(int_4 i=0;i<NBins();i++) {1281 r_8 x = BinCenter(i);1282 r_8 f = (*this)(i);1283 r_8 saf = sqrt(fabs( f)); if(saf<1.) saf=1.;1284 r_8 e=0.;1285 if(typ_err==0) {if(HasErrors()) e=Error(i); else e=1.;}1286 else if(typ_err==1) {if(HasErrors()) e=Error(i); else e=saf;}1287 else if(typ_err==2) e=1.;1288 else if(typ_err==3) e=saf;1289 else if(typ_err==4) e=(f==0.)?0.:1.;1290 else if(typ_err==5) e=(f==0.)?0.:saf;1291 mydata.AddData1(x,f,e);1292 }1293 1294 gfit.SetData(&mydata);1295 1296 return gfit.Fit();1297 }1298 1299 /*!1300 Retourne une classe contenant les residus du fit ``gfit''.1301 */1302 Histo Histo::FitResidus(GeneralFit& gfit)1303 {1304 if(NBins()<=0)1305 throw(SzMismatchError("Histo::FitResidus: size mismatch\n"));1306 GeneralFunction* f = gfit.GetFunction();1307 if(f==NULL)1308 throw(NullPtrError("Histo::FitResidus: NULL pointer\n"));1309 TVector<r_8> par = gfit.GetParm();1310 Histo h(*this);1311 for(int_4 i=0;i<NBins();i++) {1312 r_8 x = BinCenter(i);1313 h(i) -= f->Value(&x,par.Data());1314 }1315 return h;1316 }1317 1318 /*!1319 Retourne une classe contenant la fonction du fit ``gfit''.1320 */1321 Histo Histo::FitFunction(GeneralFit& gfit)1322 {1323 if(NBins()<=0)1324 throw(SzMismatchError("Histo::FitFunction: size mismatch\n"));1325 GeneralFunction* f = gfit.GetFunction();1326 if(f==NULL)1327 throw(NullPtrError("Histo::FitFunction: NULL pointer\n"));1328 TVector<r_8> par = gfit.GetParm();1329 Histo h(*this);1330 for(int_4 i=0;i<NBins();i++) {1331 r_8 x = BinCenter(i);1332 h(i) = f->Value(&x,par.Data());1333 }1334 return h;1335 1249 } 1336 1250 … … 1354 1268 */ 1355 1269 void Histo::PrintF(FILE * fp, int_4 hdyn,r_8 hmin, r_8 hmax,int_4 pflag, 1356 int_4 il, int_4 ih) 1270 int_4 il, int_4 ih) const 1357 1271 { 1358 1272 … … 1512 1426 */ 1513 1427 void Histo::Print(int_4 hdyn,r_8 hmin, r_8 hmax,int_4 pflag, 1514 int_4 il, int_4 ih) 1428 int_4 il, int_4 ih) const 1515 1429 { 1516 1430 Histo::PrintF(stdout, hdyn, hmin, hmax, pflag, il, ih);
Note:
See TracChangeset
for help on using the changeset viewer.