Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Fitter.cxx

Go to the documentation of this file.
00001 
00012 #include "Fitter.h"
00013 
00014 #include "StatedFCN.h"
00015 
00016 #include "FitterException.h"
00017 
00018 using std::string;
00019 using std::vector;
00020 
00021 Fitter::
00022 Fitter ( const char * name )
00023   : m_name ( name ),
00024     m_fcn ( 0 ),
00025     m_max_iterations ( 100 )
00026 {
00027 }
00028 
00029 Fitter::
00030 Fitter ( const Fitter & fitter )
00031   : m_name ( fitter.m_name ),
00032     m_max_iterations ( fitter.m_max_iterations )
00033 {
00034   if ( fitter.m_fcn != 0 ) m_fcn = fitter.m_fcn -> clone ();
00035 }
00036 
00037 Fitter::
00038 ~Fitter ()
00039 {
00040   if ( m_fcn != 0 ) delete m_fcn;
00041 }
00042 
00043 void
00044 Fitter::
00045 setFCN ( StatedFCN * fcn )
00046 {
00047   if ( m_fcn != 0 ) delete m_fcn;
00048 
00049   m_fcn = fcn;
00050 }
00051 
00052 StatedFCN *
00053 Fitter::
00054 getFCN ()
00055 {
00056   return m_fcn;
00057 }
00058 
00059 const std::string &
00060 Fitter::
00061 name () const
00062 {
00063   return m_name;
00064 }
00065 
00066 void
00067 Fitter::
00068 fillFreeParameters ( std::vector < double > & free_parms) const
00069 {
00070   return m_fcn -> fillFreeParameters ( free_parms );
00071 }
00072 
00073 void
00074 Fitter::
00075 setFixedFlags ( const std::vector < int > & flags )
00076 {
00077   m_fcn -> setFixedFlags ( flags );
00078 }
00079 
00080 const vector < int > &
00081 Fitter::
00082 getFixedFlags ( ) const
00083 {
00084   return m_fcn -> getFixedFlags ();
00085 }
00086 
00087 void
00088 Fitter::
00089 setLimits ( unsigned int i, double lower, double upper )
00090 {
00091   string what ( "This " );
00092   what += m_name;
00093   what += " minimizer does not support limits on parameters";
00094   throw FitterException ( what );
00095 }
00096 
00097 unsigned int
00098 Fitter::
00099 getParameterIndex ( const std::string & name )
00100 {
00101   unsigned int index = UINT_MAX;
00102   const vector < string > & names = m_fcn -> getParmNames ();
00103   unsigned int size = names.size();
00104   for ( unsigned int i = 0; i < size; i++ ) {
00105     const string & pname = names [i];
00106     if ( pname == name ) {
00107       index = i;
00108       break;
00109     }
00110   }
00111   if ( index == UINT_MAX ) {
00112     string what ( "No parameter named `" );
00113     what += name;
00114     what += "' for this function.";
00115     throw FitterException ( what );
00116   }
00117 
00118   return index;
00119 }
00120 
00121 void
00122 Fitter::
00123 setLimits ( const std::string & name, double lower, double upper )
00124 {
00125 //   unsigned int index = UINT_MAX;
00126 //   const vector < string > & names = m_fcn -> getParmNames ();
00127 //   unsigned int size = names.size();
00128 //   for ( unsigned int i = 0; i < size; i++ ) {
00129 //     const string & pname = names [i];
00130 //     if ( pname == name ) {
00131 //       index = i;
00132 //       break;
00133 //     }
00134 //   }
00135   unsigned int index = getParameterIndex ( name );
00136   setLimits ( index, lower, upper );
00137 }
00138 
00139 void
00140 Fitter::
00141 setStepSize ( unsigned int i, double size )
00142 {
00143   string what ( "This " );
00144   what += m_name;
00145   what += " minimizer does not support setting step size.";
00146   throw FitterException ( what );
00147 }
00148 
00149 void
00150 Fitter::
00151 setStepSize ( const std::string & name, double size )
00152 {
00153   unsigned int index = getParameterIndex ( name );
00154   setStepSize ( index, size );
00155 }
00156 
00157 double
00158 Fitter::objectiveValue () const
00159 {
00160   return m_fcn -> objectiveValue ();
00161 }
00162 
00163 int
00164 Fitter::
00165 calcDegreesOfFreedom () const
00166 {
00167   return m_fcn -> degreesOfFreedom();
00168 }
00169 
00170 int
00171 Fitter::
00172 calcCovariance ( std::vector < std::vector < double > > & cov )
00173 {
00174   return EXIT_FAILURE;
00175 }
00176 
00177 void
00178 Fitter::
00179 setFitCut ( TupleCut * cut )
00180 {
00181   m_fcn -> setFitCut ( cut );
00182 }
00183 
00184 void
00185 Fitter::
00186 setFitRange ( bool yes )
00187 {
00188   m_fcn -> setFitRange ( yes );
00189 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3