Public Member Functions | Private Attributes | List of all members
RootParFormula Class Reference

#include <RootParFormula.h>

Inheritance diagram for RootParFormula:
ParFormula

Public Member Functions

 RootParFormula (Name snam, Name sform)
 
Name name () const override
 
Name formulaString () const override
 
Index nvar () const override
 
Index npar () const override
 
Names pars () const override
 
Names setPars () const override
 
Names unsetPars () const override
 
Names resetPars () const override
 
bool isPar (Name parnam) const override
 
bool ready () const override
 
Value defaultEval () const override
 
double eval (const Values &vars) const override
 
double eval (Value var) const override
 
double eval () const override
 
int setParValue (Name parnam, Value parval) override
 
int setDefaultEval (Value val) override
 
int unsetParValues () override
 
- Public Member Functions inherited from ParFormula
virtual ~ParFormula ()
 

Private Attributes

Name m_nam
 
TFormula * m_ptf
 
Name m_sform
 
Names m_parNames
 
Values m_parValues
 
std::vector< Indexm_setCounts
 
Value m_defval
 

Additional Inherited Members

- Public Types inherited from ParFormula
using Value = double
 
using Values = std::vector< Value >
 
using Index = unsigned int
 
using Name = std::string
 
using Names = std::vector< Name >
 

Detailed Description

Definition at line 14 of file RootParFormula.h.

Constructor & Destructor Documentation

RootParFormula::RootParFormula ( Name  snam,
Name  sform 
)

Definition at line 9 of file RootParFormula.cxx.

9  :
10 m_nam(snam),
11 m_ptf(sform.size() ? new TFormula(snam.c_str(), sform.c_str()) : nullptr),
12 m_sform(sform),
13 m_defval(0.0) {
14  for ( int ipar=0; ipar<m_ptf->GetNpar(); ++ipar ) {
15  m_parNames.push_back(m_ptf->GetParName(ipar));
16  }
17  m_setCounts.resize(npar(), 0);
18  m_parValues.resize(npar(), 0.0);
19 }
std::vector< Index > m_setCounts
Index npar() const override
TFormula * m_ptf

Member Function Documentation

Value RootParFormula::defaultEval ( ) const
inlineoverridevirtual

Reimplemented from ParFormula.

Definition at line 44 of file RootParFormula.h.

44 { return m_defval; }
double RootParFormula::eval ( const Values vars) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 47 of file RootParFormula.h.

47  {
48  return ready() && nvar() <= vars.size() ? m_ptf->EvalPar(&vars[0], &m_parValues[0]) : m_defval;
49  }
Index nvar() const override
TFormula * m_ptf
bool ready() const override
double RootParFormula::eval ( Value  var) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 50 of file RootParFormula.h.

50  {
51  return ready() && nvar() <= 1 ? m_ptf->Eval(var) : m_defval;
52  }
Index nvar() const override
TFormula * m_ptf
bool ready() const override
int var
Definition: 018_def.c:9
double RootParFormula::eval ( ) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 53 of file RootParFormula.h.

53  {
54  return ready() && nvar() == 0 ? m_ptf->Eval(0.0) : m_defval;
55  }
Index nvar() const override
TFormula * m_ptf
bool ready() const override
Name RootParFormula::formulaString ( ) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 25 of file RootParFormula.h.

25 { return m_sform; }
bool RootParFormula::isPar ( Name  parnam) const
overridevirtual

Implements ParFormula.

Definition at line 23 of file RootParFormula.cxx.

23  {
24  return std::find(m_parNames.begin(), m_parNames.end(), parnam) != m_parNames.end();
25 }
Name RootParFormula::name ( ) const
inlineoverridevirtual

Reimplemented from ParFormula.

Definition at line 22 of file RootParFormula.h.

22 { return m_nam; }
Index RootParFormula::npar ( ) const
inlineoverridevirtual

Reimplemented from ParFormula.

Definition at line 31 of file RootParFormula.h.

31 { return m_parNames.size(); }
Index RootParFormula::nvar ( ) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 28 of file RootParFormula.h.

28 { return m_ptf == nullptr ? 0 : m_ptf->GetNdim(); }
TFormula * m_ptf
Names RootParFormula::pars ( ) const
inlineoverridevirtual

Implements ParFormula.

Definition at line 32 of file RootParFormula.h.

32 { return m_parNames; }
bool RootParFormula::ready ( ) const
overridevirtual

Reimplemented from ParFormula.

Definition at line 29 of file RootParFormula.cxx.

29  {
30  if ( m_ptf == nullptr ) return false;
31  for ( Index nset : m_setCounts ) {
32  if ( nset == 0 ) return false;
33  }
34  return true;
35 }
std::vector< Index > m_setCounts
unsigned int Index
TFormula * m_ptf
Names RootParFormula::resetPars ( ) const
overridevirtual

Implements ParFormula.

Definition at line 59 of file RootParFormula.cxx.

59  {
60  Names nams;
61  for ( Index ipar=0; ipar<npar(); ++ipar ) {
62  if ( m_setCounts[ipar] > 1 ) nams.push_back(m_parNames[ipar]);
63  }
64  return nams;
65 }
std::vector< Index > m_setCounts
unsigned int Index
Index npar() const override
ParFormula::Names Names
int RootParFormula::setDefaultEval ( Value  val)
inlineoverridevirtual

Reimplemented from ParFormula.

Definition at line 61 of file RootParFormula.h.

61 { m_defval = val; return 0; }
Names RootParFormula::setPars ( ) const
overridevirtual

Implements ParFormula.

Definition at line 39 of file RootParFormula.cxx.

39  {
40  Names nams;
41  for ( Index ipar=0; ipar<npar(); ++ipar ) {
42  if ( m_setCounts[ipar] ) nams.push_back(m_parNames[ipar]);
43  }
44  return nams;
45 }
std::vector< Index > m_setCounts
unsigned int Index
Index npar() const override
ParFormula::Names Names
int RootParFormula::setParValue ( Name  parnam,
Value  parval 
)
overridevirtual

Implements ParFormula.

Definition at line 69 of file RootParFormula.cxx.

69  {
70  Index ipar = 0;
71  for ( ; ipar<npar(); ++ipar ) {
72  if ( m_parNames[ipar] == parnam ) break;
73  }
74  if ( ipar >= npar() ) return 1;
75  m_parValues[ipar] = parval;
76  ++m_setCounts[ipar];
77  m_ptf->SetParameter(parnam.c_str(), parval);
78  return 0;
79 }
std::vector< Index > m_setCounts
unsigned int Index
Index npar() const override
TFormula * m_ptf
Names RootParFormula::unsetPars ( ) const
overridevirtual

Implements ParFormula.

Definition at line 49 of file RootParFormula.cxx.

49  {
50  Names nams;
51  for ( Index ipar=0; ipar<npar(); ++ipar ) {
52  if ( m_setCounts[ipar] == 0 ) nams.push_back(m_parNames[ipar]);
53  }
54  return nams;
55 }
std::vector< Index > m_setCounts
unsigned int Index
Index npar() const override
ParFormula::Names Names
int RootParFormula::unsetParValues ( )
overridevirtual

Implements ParFormula.

Definition at line 83 of file RootParFormula.cxx.

83  {
84  for ( Index ipar=0; ipar<npar(); ++ipar ) {
85  m_setCounts[ipar] = 0;
86  }
87  return 0;
88 }
std::vector< Index > m_setCounts
unsigned int Index
Index npar() const override

Member Data Documentation

Value RootParFormula::m_defval
private

Definition at line 74 of file RootParFormula.h.

Name RootParFormula::m_nam
private

Definition at line 68 of file RootParFormula.h.

Names RootParFormula::m_parNames
private

Definition at line 71 of file RootParFormula.h.

Values RootParFormula::m_parValues
private

Definition at line 72 of file RootParFormula.h.

TFormula* RootParFormula::m_ptf
private

Definition at line 69 of file RootParFormula.h.

std::vector<Index> RootParFormula::m_setCounts
private

Definition at line 73 of file RootParFormula.h.

Name RootParFormula::m_sform
private

Definition at line 70 of file RootParFormula.h.


The documentation for this class was generated from the following files: