Changeset 1109 in Sophya for trunk/SophyaLib/HiStats/histos2.cc
- Timestamp:
- Jul 28, 2000, 6:29:55 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/histos2.cc
r1092 r1109 14 14 15 15 #include "histos2.h" 16 #include "generalfit.h"17 16 18 17 /*! … … 514 513 Remplissage d'un tableau avec les valeurs des abscisses. 515 514 */ 516 void Histo2D::GetXCoor(TVector<r_8> &v) 515 void Histo2D::GetXCoor(TVector<r_8> &v) const 517 516 { 518 517 r_8 x,y; … … 525 524 Remplissage d'un tableau avec les valeurs des ordonnees. 526 525 */ 527 void Histo2D::GetYCoor(TVector<r_8> &v) 526 void Histo2D::GetYCoor(TVector<r_8> &v) const 528 527 { 529 528 r_8 x,y; … … 536 535 Remplissage d'un tableau avec les valeurs du contenu. 537 536 */ 538 void Histo2D::GetValue(TMatrix<r_8> &v) 537 void Histo2D::GetValue(TMatrix<r_8> &v) const 539 538 { 540 539 v.Realloc(mNx,mNy); … … 547 546 Remplissage d'un tableau avec les valeurs du carre des erreurs. 548 547 */ 549 void Histo2D::GetError2(TMatrix<r_8> &v) 548 void Histo2D::GetError2(TMatrix<r_8> &v) const 550 549 { 551 550 int_4 i,j; … … 560 559 Remplissage d'un tableau avec les valeurs des erreurs. 561 560 */ 562 void Histo2D::GetError(TMatrix<r_8> &v) 561 void Histo2D::GetError(TMatrix<r_8> &v) const 563 562 { 564 563 int_4 i,j; … … 698 697 Recherche du bin du maximum dans le pave [il,ih][jl,jh]. 699 698 */ 700 void Histo2D::IJMax(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) 699 void Histo2D::IJMax(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) const 701 700 { 702 701 if( il > ih ) { il = 0; ih = mNx-1; } … … 719 718 Recherche du bin du minimum dans le pave [il,ih][jl,jh]. 720 719 */ 721 void Histo2D::IJMin(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) 720 void Histo2D::IJMin(int_4& imax,int_4& jmax,int_4 il,int_4 ih,int_4 jl,int_4 jh) const 722 721 { 723 722 if( il > ih ) { il = 0; ih = mNx-1; } … … 827 826 */ 828 827 int_4 Histo2D::EstimeMax(r_8& xm,r_8& ym,int_4 SzPav 829 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) 828 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const 830 829 { 831 830 int_4 im,jm; … … 846 845 \endverbatim 847 846 */ 848 int_4 Histo2D::EstimeMax(int_4 im,int_4 jm,r_8& xm,r_8& ym,int_4 SzPav) 847 int_4 Histo2D::EstimeMax(int_4 im,int_4 jm,r_8& xm,r_8& ym,int_4 SzPav) const 849 848 { 850 849 xm = ym = 0; … … 902 901 */ 903 902 int_4 Histo2D::FindMax(int_4& im,int_4& jm,int_4 SzPav,r_8 Dz 904 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) 903 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const 905 904 { 906 905 if( il > ih ) { il = 0; ih = mNx-1; } … … 933 932 } 934 933 935 //////////////////////////////////////////////////////////936 937 //////////////////////////////////////////////////////////938 /*!939 Fit de l'histogramme par ``gfit''.940 \verbatim941 typ_err = 0 :942 - erreur attachee au bin si elle existe943 - sinon 1944 typ_err = 1 :945 - erreur attachee au bin si elle existe946 - sinon max( sqrt(abs(bin) ,1 )947 typ_err = 2 :948 - erreur forcee a 1949 typ_err = 3 :950 - erreur forcee a max( sqrt(abs(bin) ,1 )951 typ_err = 4 :952 - erreur forcee a 1, nulle si bin a zero.953 typ_err = 5 :954 - erreur forcee a max( sqrt(abs(bin) ,1 ),955 nulle si bin a zero.956 \endverbatim957 */958 int_4 Histo2D::Fit(GeneralFit& gfit,unsigned short typ_err)959 {960 if(NBinX()*NBinY()<=0) return -1000;961 if(typ_err>5) typ_err=0;962 963 GeneralFitData mydata(2,NBinX()*NBinY());964 965 for(int_4 i=0;i<NBinX();i++) for(int_4 j=0;j<NBinY();j++) {966 r_8 x,y;967 BinCenter(i,j,x,y);968 r_8 f = (*this)(i,j);969 r_8 saf = sqrt(fabs(f)); if(saf<1.) saf=1.;970 r_8 e=0.;971 if(typ_err==0) {if(HasErrors()) e=Error(i,j); else e=1.;}972 else if(typ_err==1) {if(HasErrors()) e=Error(i,j); else e=saf;}973 else if(typ_err==2) e=1.;974 else if(typ_err==3) e=saf;975 else if(typ_err==4) e=(f==0.)?0.:1.;976 else if(typ_err==5) e=(f==0.)?0.:saf;977 mydata.AddData2(x,y,f,e);978 }979 980 gfit.SetData(&mydata);981 982 return gfit.Fit();983 }984 985 /*!986 Retourne une classe contenant les residus du fit ``gfit''.987 */988 Histo2D Histo2D::FitResidus(GeneralFit& gfit)989 {990 if(NBinX()<=0 || NBinY()<=0)991 throw(SzMismatchError("Histo2D::FitResidus: size mismatch\n"));992 GeneralFunction* f = gfit.GetFunction();993 if(f==NULL)994 throw(NullPtrError("Histo2D::FitResidus: NULL pointer\n"));995 TVector<r_8> par = gfit.GetParm();996 Histo2D h2(*this);997 for(int_4 i=0;i<NBinX();i++) for(int_4 j=0;j<NBinY();j++) {998 r_8 xc,yc;999 BinCenter(i,j,xc,yc);1000 r_8 x[2] = {xc,yc};1001 h2(i,j) -= f->Value(x,par.Data());1002 }1003 return h2;1004 }1005 1006 /*!1007 Retourne une classe contenant la fonction du fit ``gfit''.1008 */1009 Histo2D Histo2D::FitFunction(GeneralFit& gfit)1010 {1011 if(NBinX()<=0 || NBinY()<=0)1012 throw(SzMismatchError("Histo2D::FitFunction: size mismatch\n"));1013 GeneralFunction* f = gfit.GetFunction();1014 if(f==NULL)1015 throw(NullPtrError("Histo2D::FitFunction: NULL pointer\n"));1016 TVector<r_8> par = gfit.GetParm();1017 Histo2D h2(*this);1018 for(int_4 i=0;i<NBinX();i++) for(int_4 j=0;j<NBinY();j++) {1019 r_8 xc,yc;1020 BinCenter(i,j,xc,yc);1021 r_8 x[2] = {xc,yc};1022 h2(i,j) = f->Value(x,par.Data());1023 }1024 return h2;1025 }1026 1027 934 /////////////////////////////////////////////////////////////////// 1028 935 /*! 1029 936 Impression des informations sur l'histogramme. 1030 937 */ 1031 void Histo2D::PrintStatus() 938 void Histo2D::PrintStatus() const 1032 939 { 1033 940 printf("~Histo::Print nHist=%g nEntries=%d",nHist,nEntries); … … 1052 959 */ 1053 960 void Histo2D::Print(r_8 min,r_8 max 1054 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) 961 ,int_4 il,int_4 ih,int_4 jl,int_4 jh) const 1055 962 { 1056 963 int_4 ns = 35; … … 1170 1077 Informations sur les projections. 1171 1078 */ 1172 void Histo2D::ShowProj() 1079 void Histo2D::ShowProj() const 1173 1080 { 1174 1081 if( mHprojx != NULL ) cout << ">>>> Projection X set : "<< mHprojx <<endl; … … 1358 1265 Informations sur les bandes. 1359 1266 */ 1360 void Histo2D::ShowBand(int_4 lp) 1267 void Histo2D::ShowBand(int_4 lp) const 1361 1268 { 1362 1269 cout << ">>>> Nombre de bande X : " << mLBandx.size() << endl; 1363 1270 if( lp>0 && mLBandx.size()>0 ) { 1364 list<bande_slice>:: iterator i;1271 list<bande_slice>::const_iterator i; 1365 1272 for(i = mLBandx.begin(); i != mLBandx.end(); i++) { 1366 1273 cout<<" "<<(*i).num<<" de ymin="<<(*i).min<<" a ymax="<<(*i).max; … … 1372 1279 cout << ">>>> Nombre de bande Y : " << mLBandy.size() << endl; 1373 1280 if( lp>0 && mLBandy.size()>0 ) { 1374 list<bande_slice>:: iterator i;1281 list<bande_slice>::const_iterator i; 1375 1282 for(i = mLBandy.begin(); i != mLBandy.end(); i++) { 1376 1283 cout<<" "<<(*i).num<<" de xmin="<<(*i).min<<" a xmax="<<(*i).max; … … 1497 1404 Informations sur les bandes equidistantes. 1498 1405 */ 1499 void Histo2D::ShowSli(int_4 lp) 1500 { 1501 list<bande_slice>:: iterator i;1406 void Histo2D::ShowSli(int_4 lp) const 1407 { 1408 list<bande_slice>::const_iterator i; 1502 1409 cout << ">>>> Nombre de slice X : " << mLSlix.size() << endl; 1503 1410 if( lp>0 && mLSlix.size() > 0 )
Note:
See TracChangeset
for help on using the changeset viewer.