27RooTFormulaEvaluator::RooTFormulaEvaluator(
const char *
name, std::string
const &processedFormula,
28 std::string
const &origFormula,
RooArgList const &varList)
30 auto theFormula = std::make_unique<TFormula>(
name, processedFormula.c_str(),
false);
32 if (!theFormula->IsValid()) {
33 std::stringstream msg;
34 msg <<
"RooFormula '" <<
name <<
"' did not compile or is invalid."
35 <<
"\nInput:\n\t" << origFormula <<
"\nPassed over to TFormula:\n\t" << processedFormula << std::endl;
36 oocoutF(
static_cast<TObject *
>(
nullptr), InputArguments) << msg.str();
37 throw std::runtime_error(msg.str());
40 if (theFormula->GetNdim() != 0) {
43 RooFormulaUtils::reconstructFormula(processedFormula, varList,
"1e-18").c_str(),
45 const auto nullDim = nullFormula.
GetNdim();
51 std::stringstream msg;
52 msg <<
"TFormula interprets the formula " << origFormula <<
" as " << theFormula->GetNdim() + nullDim
53 <<
"-dimensional with undefined variable(s) {";
54 for (
auto i = 0; i < nullDim; ++i) {
55 msg << nullFormula.GetVarName(i) <<
",";
57 msg <<
"}, which could not be supplied by RooFit."
58 <<
"\nThe formula must be modified, or those variables must be supplied in the list of variables."
60 oocoutF(
static_cast<TObject *
>(
nullptr), InputArguments) << msg.str();
61 throw std::invalid_argument(msg.str());
65 _tFormula = std::move(theFormula);
70RooTFormulaEvaluator::RooTFormulaEvaluator(RooTFormulaEvaluator
const &other)
72 if (other._tFormula) {
73 _tFormula = std::make_unique<TFormula>(*other._tFormula);
77RooTFormulaEvaluator::~RooTFormulaEvaluator() =
default;
81double RooTFormulaEvaluator::eval(
const double *vars)
const
83 return _tFormula->EvalPar(vars);
86std::unique_ptr<RooFormulaEvaluator> RooTFormulaEvaluator::clone()
const
88 return std::make_unique<RooTFormulaEvaluator>(*
this);
RooArgList is a container object that can hold multiple RooAbsArg objects.
Mother of all ROOT objects.