#include <RootMinuit.h>
Public Member Functions | |
void | addParameter (const std::string &name, boost::shared_ptr< double > val, double err, double min, double max) |
void | addParameter (const funct::Parameter &par, double err, double min, double max) |
void | fixParameter (const std::string &name) |
template<unsigned int N> | |
void | getErrorMatrix (ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > &err) |
double | getParameter (const std::string &name, double &err) |
double | getParameter (const std::string &name) |
double | getParameterError (const std::string &name, double &val) |
double | getParameterError (const std::string &name) |
double | migrad () |
double | minimize () |
double | minValue () |
int | numberOfFreeParameters () |
int | numberOfParameters () |
void | printFitResults (std::ostream &cout=std::cout) |
void | printParameters (std::ostream &cout=std::cout) |
void | releaseParameter (const std::string &name) |
RootMinuit (Function f, bool verbose=false) | |
void | setParameter (const std::string &name, double val) |
void | setParameters () |
Private Member Functions | |
void | init () |
size_t | parameterIndex (const std::string &name) const |
Static Private Member Functions | |
static void | fcn_ (int &, double *, double &f, double *par, int) |
Private Attributes | |
bool | initialized_ |
std::auto_ptr< TMinuit > | minuit_ |
double | minValue_ |
std::map< std::string, size_t > | parIndices_ |
parameterVector_t | parMap_ |
std::vector< boost::shared_ptr < double > > | pars_ |
bool | verbose_ |
Static Private Attributes | |
static Function | f_ |
static std::vector < boost::shared_ptr< double > > * | fPars_ = 0 |
Definition at line 21 of file RootMinuit.h.
fit::RootMinuit< Function >::RootMinuit | ( | Function | f, |
bool | verbose = false |
||
) | [inline] |
Definition at line 23 of file RootMinuit.h.
References f, and fit::RootMinuit< Function >::f_.
void fit::RootMinuit< Function >::addParameter | ( | const std::string & | name, |
boost::shared_ptr< double > | val, | ||
double | err, | ||
double | min, | ||
double | max | ||
) | [inline] |
Definition at line 27 of file RootMinuit.h.
References edm::errors::Configuration, fit::parameter_t::err, Exception, fit::parameter_t::fixed, fit::RootMinuit< Function >::initialized_, fit::parameter_t::max, max(), fit::parameter_t::min, min, mergeVDriftHistosByStation::name, fit::RootMinuit< Function >::parIndices_, fit::RootMinuit< Function >::parMap_, fit::RootMinuit< Function >::pars_, alignCSCRings::s, and fit::parameter_t::val.
Referenced by fit::RootMinuitCommands< Function >::add(), and fit::RootMinuit< Function >::addParameter().
{ if(initialized_) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: can't add parameter " << name << " after minuit initialization\n"; pars_.push_back(val); parameter_t par; par.val = *val; par.err = err; par.min = min; par.max = max; par.fixed = false; parMap_.push_back(std::make_pair(name, par)); size_t s = parIndices_.size(); parIndices_[name] = s; }
void DropBoxMetadata::Parameters::addParameter | ( | const funct::Parameter & | par, |
double | err, | ||
double | min, | ||
double | max | ||
) | [inline] |
Definition at line 43 of file RootMinuit.h.
References fit::RootMinuit< Function >::addParameter(), max(), min, and funct::Parameter::name().
{ return addParameter(par.name(), par, err, min, max); }
static void fit::RootMinuit< Function >::fcn_ | ( | int & | , |
double * | , | ||
double & | f, | ||
double * | par, | ||
int | |||
) | [inline, static, private] |
Definition at line 189 of file RootMinuit.h.
References fit::RootMinuit< Function >::f_, fit::RootMinuit< Function >::fPars_, i, and findQualityFiles::size.
Referenced by fit::RootMinuit< Function >::init().
void fit::RootMinuit< Function >::fixParameter | ( | const std::string & | name | ) | [inline] |
Definition at line 87 of file RootMinuit.h.
References i, fit::RootMinuit< Function >::initialized_, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::parameterIndex(), and fit::RootMinuit< Function >::parMap_.
Referenced by fit::RootMinuitCommands< Function >::add(), and fit::RootMinuitCommands< Function >::run().
{ size_t i = parameterIndex(name); parMap_[i].second.fixed = true; if(initialized_) { minuit_->FixParameter(i); } }
void fit::RootMinuit< Function >::getErrorMatrix | ( | ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > & | err | ) | [inline] |
Definition at line 71 of file RootMinuit.h.
References edm::errors::Configuration, alignCSCRings::e, Exception, i, fit::RootMinuit< Function >::init(), j, fit::RootMinuit< Function >::minuit_, N, fit::RootMinuit< Function >::numberOfParameters(), and fit::RootMinuit< Function >::setParameters().
{ init(); if(N != numberOfParameters()) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: can't call getErrorMatrix passing an SMatrix of dimension " << N << " while the number of parameters is " << numberOfParameters() << "\n"; double * e = new double[N*N]; minuit_->mnemat(e, numberOfParameters()); for(size_t i = 0; i < N; ++i) { for(size_t j = 0; j <= i; ++j) { err(i, j) = e[i + N*j]; } } delete [] e; setParameters(); }
string DropBoxMetadata::Parameters::getParameter | ( | const std::string & | name | ) | [inline] |
Definition at line 52 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::minuit_, and fit::RootMinuit< Function >::parameterIndex().
{ double val, err; init(); minuit_->GetParameter(parameterIndex(name), val, err); return val; }
double fit::RootMinuit< Function >::getParameter | ( | const std::string & | name, |
double & | err | ||
) | [inline] |
Definition at line 46 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::minuit_, and fit::RootMinuit< Function >::parameterIndex().
{ double val; init(); minuit_->GetParameter(parameterIndex(name), val, err); return val; }
double fit::RootMinuit< Function >::getParameterError | ( | const std::string & | name, |
double & | val | ||
) | [inline] |
Definition at line 58 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::minuit_, and fit::RootMinuit< Function >::parameterIndex().
Referenced by fit::RootMinuit< Function >::printParameters().
{ double err; init(); minuit_->GetParameter(parameterIndex(name), val, err); return err; }
double fit::RootMinuit< Function >::getParameterError | ( | const std::string & | name | ) | [inline] |
Definition at line 64 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::minuit_, and fit::RootMinuit< Function >::parameterIndex().
{ double val, err; init(); minuit_->GetParameter(parameterIndex(name), val, err); return err; }
void fit::RootMinuit< Function >::init | ( | void | ) | [inline, private] |
Definition at line 202 of file RootMinuit.h.
References fitWZ::arglist, edm::errors::Configuration, end, fit::parameter_t::err, Exception, fit::RootMinuit< Function >::fcn_(), fit::RootMinuit< Function >::fPars_, i, fit::RootMinuit< Function >::initialized_, fit::parameter_t::max, fit::parameter_t::min, fit::RootMinuit< Function >::minuit_, mergeVDriftHistosByStation::name, AlCaHLTBitMon_ParallelJobs::p, fit::RootMinuit< Function >::parMap_, fit::RootMinuit< Function >::pars_, AlCaHLTBitMon_QueryRunRegistry::string, fit::parameter_t::val, and fit::RootMinuit< Function >::verbose_.
Referenced by fit::RootMinuit< Function >::getErrorMatrix(), fit::RootMinuit< Function >::getParameter(), fit::RootMinuit< Function >::getParameterError(), fit::RootMinuit< Function >::migrad(), fit::RootMinuit< Function >::minimize(), fit::RootMinuit< Function >::minValue(), fit::RootMinuit< Function >::numberOfFreeParameters(), and fit::RootMinuit< Function >::numberOfParameters().
{ if(initialized_) return; minuit_.reset(new TMinuit(parMap_.size())); double arglist[10]; int ierflg = 0; if (! verbose_) { arglist[0] = -1; minuit_->mnexcm("SET PRINT", arglist, 1, ierflg); if (ierflg != 0) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: error in calling SET PRINT\n"; } arglist[0] = 1; minuit_->mnexcm("SET ERR", arglist, 1, ierflg); if (ierflg != 0) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: error in calling SET ERR\n"; size_t i = 0; typename parameterVector_t::const_iterator p = parMap_.begin(), end = parMap_.end(); for(; p != end; ++p, ++i) { const std::string & name = p->first; const parameter_t & par = p->second; minuit_->mnparm(i, name, par.val, par.err, par.min, par.max, ierflg); if(ierflg != 0) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: error in setting parameter " << i << " value = " << par.val << " error = " << par.err << " range = [" << par.min << ", " << par.max << "]\n"; } initialized_ = true; for(i = 0, p = parMap_.begin(); p != end; ++p, ++i) if(p->second.fixed) minuit_->FixParameter(i); fPars_= & pars_; minuit_->SetFCN(fcn_); }
double fit::RootMinuit< Function >::migrad | ( | ) | [inline] |
Definition at line 146 of file RootMinuit.h.
References fitWZ::arglist, dtNoiseDBValidation_cfg::cerr, fit::RootMinuit< Function >::init(), m, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::minValue(), fit::RootMinuit< Function >::setParameters(), and fit::RootMinuit< Function >::verbose_.
Referenced by fit::RootMinuitCommands< Function >::run().
{ init(); double arglist[10]; arglist[0] = 5000; arglist[1] = 0.1; int ierflag; minuit_->mnexcm("MIGRAD", arglist, 2, ierflag); if ( ierflag != 0 ) std::cerr << "ERROR in migrad!!" << std::endl; if(verbose_) minuit_->mnmatu(1); //Prints the covariance matrix double m = minValue(); if(verbose_) minuit_->mnprin(3, m); setParameters(); return m; }
double fit::RootMinuit< Function >::minimize | ( | ) | [inline] |
Definition at line 132 of file RootMinuit.h.
References fitWZ::arglist, dtNoiseDBValidation_cfg::cerr, fit::RootMinuit< Function >::init(), m, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::minValue(), fit::RootMinuit< Function >::setParameters(), and fit::RootMinuit< Function >::verbose_.
Referenced by fit::RootMinuitCommands< Function >::run().
{ init(); double arglist[10]; arglist[0] = 5000; arglist[1] = 0.1; int ierflag; minuit_->mnexcm("MINIMIZE", arglist, 2, ierflag); if ( ierflag != 0 ) std::cerr << "ERROR in minimize!!" << std::endl; if(verbose_) minuit_->mnmatu(1); //Prints the covariance matrix double m = minValue(); if(verbose_) minuit_->mnprin(3, m); setParameters(); return m; }
double fit::RootMinuit< Function >::minValue | ( | ) | [inline] |
Definition at line 160 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::minuit_, and fit::RootMinuit< Function >::minValue_.
Referenced by fit::RootMinuit< Function >::migrad(), fit::RootMinuit< Function >::minimize(), and fit::RootMinuit< Function >::printFitResults().
int fit::RootMinuit< Function >::numberOfFreeParameters | ( | ) | [inline] |
Definition at line 128 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), and fit::RootMinuit< Function >::minuit_.
Referenced by fit::RootMinuit< Function >::printFitResults().
int fit::RootMinuit< Function >::numberOfParameters | ( | ) | [inline] |
Definition at line 124 of file RootMinuit.h.
References fit::RootMinuit< Function >::init(), and fit::RootMinuit< Function >::minuit_.
Referenced by fit::RootMinuit< Function >::getErrorMatrix().
size_t fit::RootMinuit< Function >::parameterIndex | ( | const std::string & | name | ) | const [inline, private] |
Definition at line 195 of file RootMinuit.h.
References edm::errors::Configuration, AlCaHLTBitMon_ParallelJobs::p, and fit::RootMinuit< Function >::parIndices_.
Referenced by fit::RootMinuit< Function >::fixParameter(), fit::RootMinuit< Function >::getParameter(), fit::RootMinuit< Function >::getParameterError(), fit::RootMinuit< Function >::releaseParameter(), and fit::RootMinuit< Function >::setParameter().
{ typename std::map<std::string, size_t>::const_iterator p = parIndices_.find(name); if(p == parIndices_.end()) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: can't find parameter " << name << "\n"; return p->second; }
void fit::RootMinuit< Function >::printFitResults | ( | std::ostream & | cout = std::cout | ) | [inline] |
Definition at line 175 of file RootMinuit.h.
References gather_cfg::cout, fit::RootMinuit< Function >::f_, fit::RootMinuit< Function >::minValue(), fit::RootMinuit< Function >::numberOfFreeParameters(), reco::print(), and fit::RootMinuit< Function >::printParameters().
Referenced by fit::RootMinuitCommands< Function >::run().
void fit::RootMinuit< Function >::printParameters | ( | std::ostream & | cout = std::cout | ) | [inline] |
Definition at line 168 of file RootMinuit.h.
References gather_cfg::cout, end, fit::RootMinuit< Function >::getParameterError(), i, fit::RootMinuit< Function >::parIndices_, and fit::RootMinuit< Function >::pars_.
Referenced by fit::RootMinuit< Function >::printFitResults().
{ std::map<std::string, size_t>::const_iterator i = parIndices_.begin(), end = parIndices_.end(); for(; i != end; ++i) { cout << i->first << " = " << *pars_[i->second] << " +/- " << getParameterError(i->first) << std::endl; } }
void fit::RootMinuit< Function >::releaseParameter | ( | const std::string & | name | ) | [inline] |
Definition at line 94 of file RootMinuit.h.
References i, fit::RootMinuit< Function >::initialized_, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::parameterIndex(), and fit::RootMinuit< Function >::parMap_.
Referenced by fit::RootMinuitCommands< Function >::run().
{ size_t i = parameterIndex(name); parMap_[i].second.fixed = false; if(initialized_) { minuit_->Release(i); } }
void fit::RootMinuit< Function >::setParameter | ( | const std::string & | name, |
double | val | ||
) | [inline] |
Definition at line 101 of file RootMinuit.h.
References edm::errors::Configuration, fit::parameter_t::err, Exception, i, fit::RootMinuit< Function >::initialized_, fit::parameter_t::max, fit::parameter_t::min, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::parameterIndex(), fit::RootMinuit< Function >::parMap_, and fit::parameter_t::val.
Referenced by fit::RootMinuitCommands< Function >::run().
{ size_t i = parameterIndex(name); parameter_t & par = parMap_[i].second; par.val = val; if(initialized_) { int ierflg = 0; minuit_->mnparm(i, name, par.val, par.err, par.min, par.max, ierflg); if(ierflg != 0) throw edm::Exception(edm::errors::Configuration) << "RootMinuit: error in setting parameter " << i << " value = " << par.val << " error = " << par.err << " range = [" << par.min << ", " << par.max << "]\n"; } }
void fit::RootMinuit< Function >::setParameters | ( | ) | [inline] |
Definition at line 115 of file RootMinuit.h.
References end, i, getHLTprescales::index, fit::RootMinuit< Function >::minuit_, fit::RootMinuit< Function >::parIndices_, and fit::RootMinuit< Function >::pars_.
Referenced by fit::RootMinuit< Function >::getErrorMatrix(), fit::RootMinuit< Function >::migrad(), and fit::RootMinuit< Function >::minimize().
{ std::map<std::string, size_t>::const_iterator i = parIndices_.begin(), end = parIndices_.end(); double val, err; for(; i != end; ++i) { size_t index = i->second; minuit_->GetParameter(index, val, err); *pars_[index] = val; } }
Function fit::RootMinuit< Function >::f_ [static, private] |
Definition at line 188 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::fcn_(), fit::RootMinuit< Function >::printFitResults(), and fit::RootMinuit< Function >::RootMinuit().
std::vector< boost::shared_ptr< double > > * fit::RootMinuit< Function >::fPars_ = 0 [static, private] |
Definition at line 186 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::fcn_(), and fit::RootMinuit< Function >::init().
bool fit::RootMinuit< Function >::initialized_ [private] |
Definition at line 182 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::addParameter(), fit::RootMinuit< Function >::fixParameter(), fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::releaseParameter(), and fit::RootMinuit< Function >::setParameter().
std::auto_ptr<TMinuit> fit::RootMinuit< Function >::minuit_ [private] |
Definition at line 184 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::fixParameter(), fit::RootMinuit< Function >::getErrorMatrix(), fit::RootMinuit< Function >::getParameter(), fit::RootMinuit< Function >::getParameterError(), fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::migrad(), fit::RootMinuit< Function >::minimize(), fit::RootMinuit< Function >::minValue(), fit::RootMinuit< Function >::numberOfFreeParameters(), fit::RootMinuit< Function >::numberOfParameters(), fit::RootMinuit< Function >::releaseParameter(), fit::RootMinuit< Function >::setParameter(), and fit::RootMinuit< Function >::setParameters().
double fit::RootMinuit< Function >::minValue_ [private] |
Definition at line 183 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::minValue().
std::map<std::string, size_t> fit::RootMinuit< Function >::parIndices_ [private] |
Definition at line 181 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::addParameter(), fit::RootMinuit< Function >::parameterIndex(), fit::RootMinuit< Function >::printParameters(), and fit::RootMinuit< Function >::setParameters().
parameterVector_t fit::RootMinuit< Function >::parMap_ [private] |
Definition at line 180 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::addParameter(), fit::RootMinuit< Function >::fixParameter(), fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::releaseParameter(), and fit::RootMinuit< Function >::setParameter().
std::vector<boost::shared_ptr<double> > fit::RootMinuit< Function >::pars_ [private] |
Definition at line 185 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::addParameter(), fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::printParameters(), and fit::RootMinuit< Function >::setParameters().
bool fit::RootMinuit< Function >::verbose_ [private] |
Definition at line 187 of file RootMinuit.h.
Referenced by fit::RootMinuit< Function >::init(), fit::RootMinuit< Function >::migrad(), and fit::RootMinuit< Function >::minimize().