Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roofit/roofitcore/inc/RooFormula.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RooFormula : public TNamed, public RooPrintable {
return _origList.at(index);
}

Bool_t ok() { return _tFormula != nullptr; }
Bool_t ok() const { return _tFormula != nullptr; }
/// Evalute all parameters/observables, and then evaluate formula.
Double_t eval(const RooArgSet* nset=0) const;

Expand Down
15 changes: 10 additions & 5 deletions roofit/roofitcore/inc/RooFormulaVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class RooFormulaVar : public RooAbsReal {
RooFormulaVar(const RooFormulaVar& other, const char* name=0);
virtual TObject* clone(const char* newname) const { return new RooFormulaVar(*this,newname); }

inline Bool_t ok() const { return formula().ok() ; }
inline Bool_t ok() const { return getFormula().ok() ; }

/// Return pointer to parameter with given name.
inline RooAbsArg* getParameter(const char* name) const {
// Return pointer to parameter with given name
return _actualVars.find(name) ;
}
/// Return pointer to parameter at given index.
inline RooAbsArg* getParameter(Int_t index) const {
// Return pointer to parameter at given index
return _actualVars.at(index) ;
}

Expand All @@ -56,7 +56,12 @@ class RooFormulaVar : public RooAbsReal {
void printMetaArgs(std::ostream& os) const ;

// Debugging
void dumpFormula() { formula().dump() ; }
/// Dump the formula to stdout.
void dumpFormula() { getFormula().dump() ; }
/// Get reference to the internal formula object.
const RooFormula& formula() const {
return getFormula();
}

virtual Double_t defaultErrorLevel() const ;

Expand All @@ -73,7 +78,7 @@ class RooFormulaVar : public RooAbsReal {
virtual Bool_t isValidReal(Double_t /*value*/, Bool_t /*printError*/) const {return true;}

private:
RooFormula& formula() const;
RooFormula& getFormula() const;

RooListProxy _actualVars ; // Actual parameters used by formula engine
std::unique_ptr<RooFormula> _formula{nullptr}; //! Formula engine
Expand Down
11 changes: 6 additions & 5 deletions roofit/roofitcore/src/RooFormulaVar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ RooFormulaVar::RooFormulaVar(const RooFormulaVar& other, const char* name) :

////////////////////////////////////////////////////////////////////////////////
/// Return reference to internal RooFormula object.
RooFormula& RooFormulaVar::formula() const
/// If it doesn't exist, create it on the fly.
RooFormula& RooFormulaVar::getFormula() const
{
if (!_formula) {
// After being read from file, the formula object might not exist, yet:
Expand All @@ -147,7 +148,7 @@ RooFormula& RooFormulaVar::formula() const

Double_t RooFormulaVar::evaluate() const
{
return formula().eval(_lastNSet);
return getFormula().eval(_lastNSet);
}


Expand All @@ -156,9 +157,9 @@ Double_t RooFormulaVar::evaluate() const

Bool_t RooFormulaVar::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t /*isRecursive*/)
{
bool success = formula().changeDependents(newServerList,mustReplaceAll,nameChange);
bool success = getFormula().changeDependents(newServerList,mustReplaceAll,nameChange);

_formExpr = formula().GetTitle();
_formExpr = getFormula().GetTitle();
return success;
}

Expand All @@ -173,7 +174,7 @@ void RooFormulaVar::printMultiline(ostream& os, Int_t contents, Bool_t verbose,
if(verbose) {
indent.Append(" ");
os << indent;
formula().printMultiline(os,contents,verbose,indent);
getFormula().printMultiline(os,contents,verbose,indent);
}
}

Expand Down