CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

RooMinimizerFcnOpt Class Reference

#include <RooMinimizerOpt.h>

List of all members.

Public Member Functions

virtual
ROOT::Math::IBaseFunctionMultiDim * 
Clone () const
 RooMinimizerFcnOpt (RooAbsReal *funct, RooMinimizer *context, bool verbose=false)

Protected Member Functions

virtual double DoEval (const double *x) const

Protected Attributes

std::vector< RooRealVar * > _vars

Detailed Description

Definition at line 18 of file RooMinimizerOpt.h.


Constructor & Destructor Documentation

RooMinimizerFcnOpt::RooMinimizerFcnOpt ( RooAbsReal *  funct,
RooMinimizer *  context,
bool  verbose = false 
)

Definition at line 28 of file RooMinimizerOpt.cc.

References _vars, and a.

Referenced by Clone().

                                                                                              :
    RooMinimizerFcn(funct, context, verbose)
{
    _vars.resize(_floatParamList->getSize());
    std::vector<RooRealVar *>::iterator itv = _vars.begin();
    RooLinkedListIter iter = _floatParamList->iterator();
    for (TObject *a = iter.Next(); a != 0; a = iter.Next(), ++itv) {
        RooRealVar *rrv = dynamic_cast<RooRealVar *>(a);
        if (rrv == 0) throw std::logic_error(Form("Float param not a RooRealVar but a %s", a->ClassName()));
        *itv = rrv; 
    }
}

Member Function Documentation

ROOT::Math::IBaseFunctionMultiDim * RooMinimizerFcnOpt::Clone ( ) const [virtual]

Definition at line 42 of file RooMinimizerOpt.cc.

References RooMinimizerFcnOpt().

{
      return new RooMinimizerFcnOpt(_funct,_context,_verbose);
}
double RooMinimizerFcnOpt::DoEval ( const double *  x) const [protected, virtual]

Definition at line 48 of file RooMinimizerOpt.cc.

References _vars, gather_cfg::cout, first, and getHLTprescales::index.

{
  // Set the parameter values for this iteration
  for (int index = 0; index < _nDim; index++) {
      if (_logfile) (*_logfile) << x[index] << " " ;
      RooRealVar* par = _vars[index];
      if (par->getVal()!=x[index]) {
          if (_verbose) cout << par->GetName() << "=" << x[index] << ", " ;
          par->setVal(x[index]);
      }
  }

  // Calculate the function for these parameters
  double fvalue = _funct->getVal();
  if (RooAbsPdf::evalError() || RooAbsReal::numEvalErrors()>0) {

    if (_printEvalErrors>=0) {

      if (_doEvalErrorWall) {
        oocoutW(_context,Minimization) << "RooMinimizerFcn: Minimized function has error status." << endl 
                                       << "Returning maximum FCN so far (" << _maxFCN 
                                       << ") to force MIGRAD to back out of this region. Error log follows" << endl ;
      } else {
        oocoutW(_context,Minimization) << "RooMinimizerFcn: Minimized function has error status but is ignored" << endl ;
      } 

      TIterator* iter = _floatParamList->createIterator() ;
      RooRealVar* var ;
      Bool_t first(kTRUE) ;
      ooccoutW(_context,Minimization) << "Parameter values: " ;
      while((var=(RooRealVar*)iter->Next())) {
        if (first) { first = kFALSE ; } else ooccoutW(_context,Minimization) << ", " ;
        ooccoutW(_context,Minimization) << var->GetName() << "=" << var->getVal() ;
      }
      delete iter ;
      ooccoutW(_context,Minimization) << endl ;
      
      RooAbsReal::printEvalErrors(ooccoutW(_context,Minimization),_printEvalErrors) ;
      ooccoutW(_context,Minimization) << endl ;
    } 

    if (_doEvalErrorWall) {
      fvalue = _maxFCN ;
    }

    RooAbsPdf::clearEvalError() ;
    RooAbsReal::clearEvalErrorLog() ;
    _numBadNLL++ ;
  } else if (fvalue>_maxFCN) {
    _maxFCN = fvalue ;
  }
      
  // Optional logging
  if (_logfile) 
    (*_logfile) << setprecision(15) << fvalue << setprecision(4) << endl;
  if (_verbose) {
    cout << "\nprevFCN = " << setprecision(10) 
         << fvalue << setprecision(4) << "  " ;
    cout.flush() ;
  }

  return fvalue;
}

Member Data Documentation

std::vector<RooRealVar *> RooMinimizerFcnOpt::_vars [mutable, protected]

Definition at line 24 of file RooMinimizerOpt.h.

Referenced by DoEval(), and RooMinimizerFcnOpt().