RootParFormula.cxx
Go to the documentation of this file.
1 // RootParFormula.h
2 
4 
6 
7 //**********************************************************************
8 
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 }
20 
21 //**********************************************************************
22 
23 bool RootParFormula::isPar(Name parnam) const {
24  return std::find(m_parNames.begin(), m_parNames.end(), parnam) != m_parNames.end();
25 }
26 
27 //**********************************************************************
28 
29 bool RootParFormula::ready() const {
30  if ( m_ptf == nullptr ) return false;
31  for ( Index nset : m_setCounts ) {
32  if ( nset == 0 ) return false;
33  }
34  return true;
35 }
36 
37 //**********************************************************************
38 
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 }
46 
47 //**********************************************************************
48 
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 }
56 
57 //**********************************************************************
58 
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 }
66 
67 //**********************************************************************
68 
69 int RootParFormula::setParValue(Name parnam, Value parval) {
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 }
80 
81 //**********************************************************************
82 
84  for ( Index ipar=0; ipar<npar(); ++ipar ) {
85  m_setCounts[ipar] = 0;
86  }
87  return 0;
88 }
89 
90 //**********************************************************************
std::string Name
Definition: ParFormula.h:23
std::vector< Index > m_setCounts
unsigned int Index
Definition: ParFormula.h:22
int setParValue(Name parnam, Value parval) override
Names setPars() const override
Index npar() const override
RootParFormula(Name snam, Name sform)
double Value
Definition: ParFormula.h:20
TFormula * m_ptf
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
ParFormula::Names Names
std::vector< Name > Names
Definition: ParFormula.h:24
int unsetParValues() override
Names unsetPars() const override
bool ready() const override
Names resetPars() const override
bool isPar(Name parnam) const override