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 )
68 bool yes =
m_fcn -> hasFunction ();
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 ++ ) {
147 setLimits (
unsigned int i,
double lower,
double upper )
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 );
Structure to hold limit values, if any.
void add(const char *, double, double)
StatedFCN * m_fcn
The objective function.
void initialize()
The Minuit Migrad minimizer.
hippodraw::StatedFCN class interface
std::string m_name
The name of the fitter.
virtual void setStepSize(unsigned int i, double size)
Sets the step size used by MnMigrad.
std::vector< limit > m_limits
The limit parameters.
virtual int calcCovariance(std::vector< std::vector< double > > &cov)
Calculates the covariance matrix.
MinuitMigrad(const MinuitMigrad &)
Private copy constructor to prevent user copying.
bool set
true if limit has been set
intp size(numeric::array arr)
string convert(int i)
Converts an integer to a string.
virtual Fitter * clone() const
Makes a copy of the receiving object.
virtual const std::vector< int > & getFixedFlags() const
Sets the limits of the model function parameter values.
virtual void setLimits(unsigned int i, double lower, double upper)
Sets the upper and lower limits of the parameter.
The namespace for conversion to string.
virtual bool calcBestFit()
Calculates the best fit.
void checkIndex(unsigned int index)
Checks the index and throws exception if out of range.
The base class for fitters.
unsigned int nrow() const
void initLimits()
Initializes the limits.
const std::string & name() const
Returns the name of the fitter.
hippodraw::MinuitMigrad class interface