#include "objfitter.h" //=========================================================================== //=========================================================================== //=========================== ObjectFitter ================================== //=========================================================================== //=========================================================================== TMatrix ObjectFitter::FitResidus(TMatrix const & mtx, GeneralFit& gfit, double xorg, double yorg, double dx, double dy) { return( ArrayFitter::FitResidus(mtx, gfit, xorg, yorg, dx, dy) ); } TMatrix ObjectFitter::FitResidus(TMatrix const & mtx, GeneralFit& gfit, double xorg, double yorg, double dx, double dy) { return( ArrayFitter::FitResidus(mtx, gfit, xorg, yorg, dx, dy) ); } TMatrix ObjectFitter::FitFunction(TMatrix const & mtx, GeneralFit& gfit, double xorg, double yorg, double dx, double dy) { return( ArrayFitter::FitFunction(mtx, gfit, xorg, yorg, dx, dy) ); } TMatrix ObjectFitter::FitFunction(TMatrix const & mtx, GeneralFit& gfit, double xorg, double yorg, double dx, double dy) { return( ArrayFitter::FitFunction(mtx, gfit, xorg, yorg, dx, dy) ); } TVector ObjectFitter::FitResidus(TVector const & vec, GeneralFit& gfit, double xorg, double dx) { return( ArrayFitter::FitResidus(vec, gfit, xorg, dx) ); } TVector ObjectFitter::FitResidus(TVector const & vec, GeneralFit& gfit, double xorg, double dx) { return( ArrayFitter::FitResidus(vec, gfit, xorg, dx) ); } TVector ObjectFitter::FitFunction(TVector const & vec, GeneralFit& gfit, double xorg, double dx) { return( ArrayFitter::FitFunction(vec, gfit, xorg, dx) ); } TVector ObjectFitter::FitFunction(TVector const & vec, GeneralFit& gfit, double xorg, double dx) { return( ArrayFitter::FitFunction(vec, gfit, xorg, dx) ); } //=============================== Histo ===================================== /*! Retourne une classe contenant les residus du fit ``gfit''. */ Histo ObjectFitter::FitResidus(Histo const& hh, GeneralFit& gfit) { Histo h(hh); if(h.NBins()<=0) throw(SzMismatchError("Histo::FitResidus: size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("Histo::FitResidus: NULL pointer\n")); TVector par = gfit.GetParm(); for(int_4 i=0;iValue(&x,par.Data()); } return h; } /*! Retourne une classe contenant la fonction du fit ``gfit''. */ Histo ObjectFitter::FitFunction(Histo const& hh, GeneralFit& gfit) { Histo h(hh); if(h.NBins()<=0) throw(SzMismatchError("Histo::FitFunction: size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("Histo::FitFunction: NULL pointer\n")); TVector par = gfit.GetParm(); for(int_4 i=0;iValue(&x,par.Data()); } return h; } /*! Fit de l'histogramme par ``gfit''. \verbatim typ_err = 0 : - erreur attachee au bin si elle existe - sinon 1 typ_err = 1 : - erreur attachee au bin si elle existe - sinon max( sqrt(abs(bin) ,1 ) typ_err = 2 : - erreur forcee a 1 typ_err = 3 : - erreur forcee a max( sqrt(abs(bin) ,1 ) typ_err = 4 : - erreur forcee a 1, nulle si bin a zero. typ_err = 5 : - erreur forcee a max( sqrt(abs(bin) ,1 ), nulle si bin a zero. \endverbatim */ int_4 ObjectFitter::Fit(Histo const& h, GeneralFit& gfit,unsigned short typ_err) { if(h.NBins()<=0) return -1000; if(typ_err>5) typ_err=0; GeneralFitData mydata(1,h.NBins()); for(int_4 i=0;i par = gfit.GetParm(); for(int_4 i=0;iValue(x,par.Data()); } return h; } /*! Retourne une classe contenant la fonction du fit ``gfit''. */ Histo2D ObjectFitter::FitFunction(Histo2D const& hh, GeneralFit& gfit) { Histo2D h(hh); if(h.NBinX()<=0 || h.NBinY()<=0) throw(SzMismatchError("Histo2D::FitFunction: size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("Histo2D::FitFunction: NULL pointer\n")); TVector par = gfit.GetParm(); for(int_4 i=0;iValue(x,par.Data()); } return h; } /*! Fit de l'histogramme par ``gfit''. \verbatim typ_err = 0 : - erreur attachee au bin si elle existe - sinon 1 typ_err = 1 : - erreur attachee au bin si elle existe - sinon max( sqrt(abs(bin) ,1 ) typ_err = 2 : - erreur forcee a 1 typ_err = 3 : - erreur forcee a max( sqrt(abs(bin) ,1 ) typ_err = 4 : - erreur forcee a 1, nulle si bin a zero. typ_err = 5 : - erreur forcee a max( sqrt(abs(bin) ,1 ), nulle si bin a zero. \endverbatim */ int_4 ObjectFitter::Fit(Histo2D const & h, GeneralFit& gfit,unsigned short typ_err) { if(h.NBinX()*h.NBinY()<=0) return -1000; if(typ_err>5) typ_err=0; GeneralFitData mydata(2,h.NBinX()*h.NBinY()); for(int_4 i=0;i ================================= //=========================================================================== //=========================================================================== template TMatrix ArrayFitter::FitResidus(TMatrix const & mtx, GeneralFit& gfit, double xorg,double yorg,double dx,double dy) // Retourne une classe contenant les residus du fit ``gfit''. // On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j). // Les coordonnees de l'element (i,j) sont : // (i,j) -> x = xorg+j*dx , y = yorg+i*dy { if(mtx.NCols()<=0||mtx.NRows()<=0) throw(SzMismatchError("ArrayFitter::FitResidus(TMatrix...) size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("ArrayFitter::FitResidus(TMatrix...) GeneraFit==NULL\n")); int npar = gfit.GetNPar(); if(npar==0) throw(SzMismatchError("ArrayFitter::FitResidus(TMatrix...) GeneraFit 0 parametre\n")); double* par = new double[npar]; {for(int i=0;i m(mtx); m.SetTemp(true); for(uint_4 i=0;iValue(x,par); } delete [] par; return m; } template TMatrix ArrayFitter::FitFunction(TMatrix const & mtx, GeneralFit& gfit, double xorg,double yorg,double dx,double dy) // Retourne une classe contenant la fonction du fit ``gfit''. // On suppose que x=j (colonnes) et y=i (lignes) pour m(i,j). // Les coordonnees de l'element (i,j) sont : // (i,j) -> x = xorg + j*dx , y = yorg + i*dy { if(mtx.NCols()<=0||mtx.NRows()<=0) throw(SzMismatchError("ArrayFitter::FitFunction(TMatrix...) size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("ArrayFitter::FitFunction(TMatrix...) GeneraFit==NULL\n")); int npar = gfit.GetNPar(); if(npar==0) throw(SzMismatchError("ArrayFitter::FitFunction(TMatrix...) GeneraFit 0 parametre\n")); double* par = new double[npar]; {for(int i=0;i m(mtx.NRows(), mtx.NCols()); m.SetTemp(true); for(uint_4 i=0;iValue(x,par); } delete [] par; return m; } template TVector ArrayFitter::FitResidus(TVector const & vec, GeneralFit& gfit, double xorg,double dx) // Retourne une classe contenant les residus du fit ``gfit''. // La coordonnee de l'element (i) est -> x = xorg + i*dx { if(vec.NElts()<=0) throw(SzMismatchError("ArrayFitter::FitResidus(TVector...) size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("ArrayFitter::FitResidus(TVector...) GeneraFit==NULL\n")); int npar = gfit.GetNPar(); if(npar==0) throw(SzMismatchError("ArrayFitter::FitResidus(TVector...) GeneraFit 0 parametre\n")); double* par = new double[npar]; {for(int i=0;i v(vec); v.SetTemp(true); for(uint_4 i=0;iValue(&x,par); } delete [] par; return v; } template TVector ArrayFitter::FitFunction(TVector const & vec, GeneralFit& gfit, double xorg,double dx) // Retourne une classe contenant les residus du fit ``gfit''. // La coordonnee de l'element (i) est -> x = xorg + i*dx { if(vec.NElts()<=0) throw(SzMismatchError("ArrayFitter::FitResidus(TVector...) size mismatch\n")); GeneralFunction* f = gfit.GetFunction(); if(f==NULL) throw(NullPtrError("ArrayFitter::FitResidus(TVector...) GeneraFit==NULL\n")); int npar = gfit.GetNPar(); if(npar==0) throw(SzMismatchError("ArrayFitter::FitResidus(TVector...) GeneraFit 0 parametre\n")); double* par = new double[npar]; {for(int i=0;i v(vec.NElts()); v.SetTemp(true); for(uint_4 i=0;iValue(&x,par); } delete [] par; return v; } /////////////////////////////////////////////////////////////// #ifdef __CXX_PRAGMA_TEMPLATES__ #pragma define_template ArrayFitter #pragma define_template ArrayFitter #endif #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) template class ArrayFitter; template class ArrayFitter; #endif