Changeset 1109 in Sophya for trunk/SophyaLib/HiStats/histos.cc


Ignore:
Timestamp:
Jul 28, 2000, 6:29:55 PM (25 years ago)
Author:
ansari
Message:

on vire FitResidus/Function -> cf objfitter cmv 28/7/00

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/HiStats/histos.cc

    r1092 r1109  
    11//
    2 // $Id: histos.cc,v 1.10 2000-07-26 13:15:15 ansari Exp $
     2// $Id: histos.cc,v 1.11 2000-07-28 16:29:54 ansari Exp $
    33//
    44
     
    1111#include "poly.h"
    1212#include "strutil.h"
    13 #include "generalfit.h"
    1413
    1514/*!
     
    295294  Remplissage d'un tableau avec la valeur des abscisses
    296295*/
    297 void Histo::GetAbsc(TVector<r_8> &v)
     296void Histo::GetAbsc(TVector<r_8> &v) const
    298297{
    299298v.Realloc(mBins);
     
    305304  Remplissage d'un tableau avec la valeur du contenu
    306305*/
    307 void Histo::GetValue(TVector<r_8> &v)
     306void Histo::GetValue(TVector<r_8> &v) const
    308307{
    309308v.Realloc(mBins);
     
    315314  Remplissage d'un tableau avec la valeur des erreurs au carre
    316315*/
    317 void Histo::GetError2(TVector<r_8> &v)
     316void Histo::GetError2(TVector<r_8> &v) const
    318317{
    319318v.Realloc(mBins);
     
    326325  Remplissage d'un tableau avec la valeur des erreurs
    327326*/
    328 void Histo::GetError(TVector<r_8> &v)
     327void Histo::GetError(TVector<r_8> &v) const
    329328{
    330329v.Realloc(mBins);
     
    764763  \endverbatim
    765764*/
    766 int_4 Histo::BinPercent(r_8 x,r_8 per,int& imin,int& imax)
     765int_4 Histo::BinPercent(r_8 x,r_8 per,int& imin,int& imax) const
    767766{
    768767imin = imax = -1;
     
    792791  Idem precedent mais renvoie xmin et xmax
    793792*/
    794 int_4 Histo::BinPercent(r_8 x,r_8 per,r_8& xmin,r_8& xmax)
     793int_4 Histo::BinPercent(r_8 x,r_8 per,r_8& xmin,r_8& xmax) const
    795794{
    796795xmin = xmax = 0.;
     
    901900  consecutifs, le bin le plus a droite est pris.
    902901*/
    903 int_4 Histo::MaxiLocal(r_8& maxi,int& imax,r_8& maxn,int& imaxn)
     902int_4 Histo::MaxiLocal(r_8& maxi,int& imax,r_8& maxn,int& imaxn) const
    904903{
    905904int_4 nml = 0;
     
    11621161  Cf suivant mais im est le bin du maximum de l'histo
    11631162*/
    1164 int_4 Histo::EstimeMax(r_8& xm,int_4 SzPav)
     1163int_4 Histo::EstimeMax(r_8& xm,int_4 SzPav) const
    11651164{
    11661165int_4 im = IMax();
     
    11801179  \endverbatim
    11811180*/
    1182 int_4 Histo::EstimeMax(int& im,r_8& xm,int_4 SzPav)
     1181int_4 Histo::EstimeMax(int& im,r_8& xm,int_4 SzPav) const
    11831182{
    11841183xm = 0;
     
    12121211  et a droite (widthD)
    12131212*/
    1214 void Histo::EstimeWidthS(r_8 frac,r_8& widthG,r_8& widthD)
     1213void Histo::EstimeWidthS(r_8 frac,r_8& widthG,r_8& widthD) const
    12151214{
    12161215int_4 i;
     
    12481247}
    12491248
    1250 }
    1251 
    1252 //////////////////////////////////////////////////////////
    1253 /*!
    1254   Fit de l'histogramme par ``gfit''.
    1255   \verbatim
    1256     typ_err = 0 :
    1257        - erreur attachee au bin si elle existe
    1258        - sinon 1
    1259     typ_err = 1 :
    1260        - erreur attachee au bin si elle existe
    1261        - sinon max( sqrt(abs(bin) ,1 )
    1262     typ_err = 2 :
    1263        - erreur forcee a 1
    1264     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   \endverbatim
    1272 */
    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;
    13351249}
    13361250
     
    13541268*/
    13551269void 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
    13571271{
    13581272 
     
    15121426*/
    15131427void 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
    15151429{
    15161430 Histo::PrintF(stdout, hdyn, hmin, hmax, pflag, il, ih);
Note: See TracChangeset for help on using the changeset viewer.