|
|
Go to the documentation of this file. 1 #ifndef PhisycsTools_Utilities_RootMinuit_h
2 #define PhisycsTools_Utilities_RootMinuit_h
12 #include "Math/SMatrix.h"
20 template <
class Function>
29 <<
"RootMinuit: can't add parameter " <<
name <<
" after minuit initialization\n";
68 template <
unsigned int N>
73 <<
"RootMinuit: can't call getErrorMatrix passing an SMatrix of dimension " <<
N
75 double *
e =
new double[
N *
N];
77 for (
size_t i = 0;
i <
N; ++
i) {
78 for (
size_t j = 0;
j <=
i; ++
j) {
108 <<
"RootMinuit: error in setting parameter " <<
i <<
" value = " << par.
val <<
" error = " << par.
err
109 <<
" range = [" << par.
min <<
", " << par.
max <<
"]\n";
115 for (;
i !=
end; ++
i) {
127 return minuit_->GetNumFreePars();
137 std::cerr <<
"ERROR in minimize!!" << std::endl;
154 std::cerr <<
"ERROR in migrad!!" << std::endl;
173 for (;
i !=
end; ++
i) {
188 std::vector<std::shared_ptr<double> >
pars_;
189 static std::vector<std::shared_ptr<double> > *
fPars_;
192 static void fcn_(
int &,
double *,
double &
f,
double *par,
int) {
194 for (
size_t i = 0;
i <
size; ++
i)
199 typename std::map<std::string, size_t>::const_iterator
p =
parIndices_.find(
name);
223 for (;
p !=
end; ++
p, ++
i) {
229 <<
"RootMinuit: error in setting parameter " <<
i <<
" value = " << par.
val <<
" error = " << par.
err
230 <<
" range = [" << par.
min <<
", " << par.
max <<
"]\n";
241 template <
class Function>
244 template <
class Function>
void setParameter(const std::string &name, double val)
const std::string & name() const
void addParameter(const std::string &name, std::shared_ptr< double > val, double err, double min, double max)
size_t parameterIndex(const std::string &name) const
double getParameterError(const std::string &name, double &val)
void getErrorMatrix(ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > &err)
void printParameters(std::ostream &cout=std::cout)
std::vector< std::shared_ptr< double > > pars_
std::map< std::string, size_t > parIndices_
void fixParameter(const std::string &name)
RootMinuit(const Function &f, bool verbose=false)
static constexpr int verbose
std::unique_ptr< TMinuit > minuit_
int numberOfFreeParameters()
double getParameter(const std::string &name)
static double evaluate(const Function &f)
void addParameter(const funct::Parameter &par, double err, double min, double max)
static void print(double amin, unsigned int numberOfFreeParameters, const Function &f)
static std::vector< std::shared_ptr< double > > * fPars_
double getParameter(const std::string &name, double &err)
double getParameterError(const std::string &name)
std::vector< std::pair< std::string, parameter_t > > parameterVector_t
void releaseParameter(const std::string &name)
static void fcn_(int &, double *, double &f, double *par, int)
void printFitResults(std::ostream &cout=std::cout)
parameterVector_t parMap_