26 #include <Minuit2/FunctionMinimum.h>
27 #include <Minuit2/MinuitParameter.h>
28 #include <Minuit2/MnMigrad.h>
29 #include <Minuit2/MnUserParameters.h>
30 using namespace ROOT::Minuit2;
38 using namespace hippodraw;
41 MinuitMigrad (
const char * name )
70 const vector < double > & parms =
m_fcn -> getParameters ();
72 assert ( fixes.size() == parms.size() );
73 unsigned int size = parms.size ();
78 for (
unsigned int i = 0;
i <
size;
i++ ) {
80 double value = parms [
i ];
82 mn_parms.
add ( name.c_str(), value, 0.1 );
84 mn_parms.Add ( name.c_str(), value, 0.1 );
87 if ( fixes [
i ] != 0 ) {
99 for (
unsigned int i = 0;
i <
m_limits.size ();
i++ ) {
119 if ( m_minimizer == 0 ) {
121 what +=
": model function no yet set";
122 throw std::runtime_error ( what );
124 const vector < double > & parms =
m_fcn -> getParameters ();
125 unsigned int size = parms.size();
126 if ( i < size ==
false ) {
128 what +=
": index to parameter out of range";
129 throw std::runtime_error ( what );
137 const vector < double > & parms =
m_fcn -> getParameters ();
138 for (
unsigned int i = 0;
i < parms.size();
i ++ ) {
166 m_minimizer -> SetError ( i, size );
168 m_minimizer -> setError ( i, size );
187 bool yes = fun_min.IsValid ();
195 std::vector < double > cur_parms = m_minimizer -> Params();
197 std::vector < double > cur_parms = m_minimizer -> params();
199 m_fcn -> setParameters ( cur_parms );
212 unsigned int size = covar_m.Nrow ();
215 unsigned int size = covar_m.
nrow ();
217 covar.resize ( size );
218 for (
unsigned int i = 0;
i <
size;
i++ ) {
219 covar[
i].resize ( size, 0.0 );
222 for (
unsigned int i = 0;
i <
size;
i++ ) {
223 for (
unsigned int j = 0; j <
size; j++ ) {
224 covar[
i][j] = covar_m (
i, j );
void add(const char *, double, double)
virtual void setStepSize(unsigned int i, double size)
Sets the step size used by MnMigrad.
void initLimits()
Initializes the limits.
std::string m_name
The name of the fitter.
void initialize()
The Minuit Migrad minimizer.
The namespace for conversion to string.
The base class for fitters.
virtual int calcCovariance(std::vector< std::vector< double > > &cov)
Calculates the covariance matrix.
intp size(numeric::array arr)
virtual void setLimits(unsigned int i, double lower, double upper)
Sets the upper and lower limits of the parameter.
string convert(int i)
Converts an integer to a string.
virtual bool calcBestFit()
Calculates the best fit.
Structure to hold limit values, if any.
const std::string & name() const
Returns the name of the fitter.
hippodraw::MinuitMigrad class interface
bool set
true if limit has been set
std::vector< limit > m_limits
The limit parameters.
void checkIndex(unsigned int index)
Checks the index and throws exception if out of range.
unsigned int nrow() const
MinuitMigrad(const MinuitMigrad &)
Private copy constructor to prevent user copying.
hippodraw::StatedFCN class interface
virtual const std::vector< int > & getFixedFlags() const
Sets the limits of the model function parameter values.
virtual Fitter * clone() const
Makes a copy of the receiving object.
StatedFCN * m_fcn
The objective function.