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