test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
reco::FormulaEvaluator Class Reference

#include <FormulaEvaluator.h>

Public Member Functions

template<typename V , typename P >
double evaluate (V const &iVariables, P const &iParameters) const
 
 FormulaEvaluator (std::string const &iFormula)
 
unsigned int numberOfParameters () const
 
unsigned int numberOfVariables () const
 

Private Member Functions

double evaluate (double const *iVariables, double const *iParameters) const
 
void throwWrongNumberOfParameters (size_t) const
 
void throwWrongNumberOfVariables (size_t) const
 

Private Attributes

std::shared_ptr
< formula::EvaluatorBase const > 
m_evaluator
 
unsigned int m_nParameters = 0
 
unsigned int m_nVariables = 0
 

Detailed Description

Definition at line 66 of file FormulaEvaluator.h.

Constructor & Destructor Documentation

FormulaEvaluator::FormulaEvaluator ( std::string const &  iFormula)
explicit

Definition at line 678 of file FormulaEvaluator.cc.

References Exception, m_evaluator, m_nParameters, m_nVariables, eostools::move(), or, and AlCaHLTBitMon_QueryRunRegistry::string.

679 {
680  auto info = s_expressionFinder.createEvaluator(iFormula.begin(), iFormula.end(),std::shared_ptr<reco::formula::BinaryOperatorEvaluatorBase>());
681 
682  if(info.nextParseIndex != static_cast<int>(iFormula.size()) or info.top.get() == nullptr) {
683  throw cms::Exception("FormulaEvaluatorParseError")<<"While parsing '"<<iFormula<<"' could not parse beyond '"<<std::string(iFormula.begin(),iFormula.begin()+info.nextParseIndex) <<"'";
684  }
685  m_evaluator = std::move(info.top);
686  m_nVariables = info.maxNumVariables;
687  m_nParameters = info.maxNumParameters;
688 }
static const TGPicture * info(bool iBackgroundIsBlack)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
def move
Definition: eostools.py:510
std::shared_ptr< formula::EvaluatorBase const > m_evaluator

Member Function Documentation

template<typename V , typename P >
double reco::FormulaEvaluator::evaluate ( V const &  iVariables,
P const &  iParameters 
) const
inline

Definition at line 74 of file FormulaEvaluator.h.

References m_nParameters, m_nVariables, reco::formula::startingAddress(), throwWrongNumberOfParameters(), and throwWrongNumberOfVariables().

Referenced by SimpleJetCorrector::correctionBin(), and SimpleJetCorrector::invert().

74  {
75  if (m_nVariables > iVariables.size()) {
76  throwWrongNumberOfVariables(iVariables.size());
77  }
78  if (m_nParameters > iParameters.size()) {
79  throwWrongNumberOfParameters(iParameters.size());
80  }
81  return evaluate( formula::startingAddress(iVariables),
82  formula::startingAddress(iParameters));
83  }
double evaluate(V const &iVariables, P const &iParameters) const
void throwWrongNumberOfParameters(size_t) const
double const * startingAddress(ArrayAdaptor const &iV)
void throwWrongNumberOfVariables(size_t) const
double FormulaEvaluator::evaluate ( double const *  iVariables,
double const *  iParameters 
) const
private

Definition at line 694 of file FormulaEvaluator.cc.

References m_evaluator.

695 {
696  return m_evaluator->evaluate(iVariables, iParameters);
697 }
std::shared_ptr< formula::EvaluatorBase const > m_evaluator
unsigned int reco::FormulaEvaluator::numberOfParameters ( ) const
inline

Definition at line 85 of file FormulaEvaluator.h.

References m_nParameters.

Referenced by SimpleJetCorrector::invert().

85 { return m_nParameters; }
unsigned int reco::FormulaEvaluator::numberOfVariables ( ) const
inline

Definition at line 86 of file FormulaEvaluator.h.

References m_nVariables.

86 { return m_nVariables; }
void FormulaEvaluator::throwWrongNumberOfParameters ( size_t  iSize) const
private

Definition at line 704 of file FormulaEvaluator.cc.

References Exception, fireworks::iSize, and m_nParameters.

Referenced by evaluate().

704  {
705  throw cms::Exception("WrongNumParameters")<<"FormulaEvaluator expected at least "<<m_nParameters<<" but was passed only "<<iSize;
706 }
void FormulaEvaluator::throwWrongNumberOfVariables ( size_t  iSize) const
private

Definition at line 700 of file FormulaEvaluator.cc.

References Exception, fireworks::iSize, and m_nVariables.

Referenced by evaluate().

700  {
701  throw cms::Exception("WrongNumVariables")<<"FormulaEvaluator expected at least "<<m_nVariables<<" but was passed only "<<iSize;
702 }

Member Data Documentation

std::shared_ptr<formula::EvaluatorBase const> reco::FormulaEvaluator::m_evaluator
private

Definition at line 94 of file FormulaEvaluator.h.

Referenced by evaluate(), and FormulaEvaluator().

unsigned int reco::FormulaEvaluator::m_nParameters = 0
private
unsigned int reco::FormulaEvaluator::m_nVariables = 0
private