From ff6649cb8971dcd7047771ddb864b5ef3139c26b Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 24 Sep 2024 14:24:25 +0200 Subject: [PATCH] [RF] Support scalar categorical inputs in RooFit::Evaluator Closes #16419. Should be backported also to 6.32. --- roofit/roofitcore/src/RooFit/Evaluator.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roofit/roofitcore/src/RooFit/Evaluator.cxx b/roofit/roofitcore/src/RooFit/Evaluator.cxx index 7c199f7747efb..67f637a99b5a1 100644 --- a/roofit/roofitcore/src/RooFit/Evaluator.cxx +++ b/roofit/roofitcore/src/RooFit/Evaluator.cxx @@ -332,7 +332,7 @@ void Evaluator::updateOutputSizes() Evaluator::~Evaluator() { for (auto &info : _nodes) { - if(!info.isVariable) { + if (!info.isVariable) { info.absArg->resetDataToken(); } } @@ -342,8 +342,6 @@ void Evaluator::computeCPUNode(const RooAbsArg *node, NodeInfo &info) { using namespace Detail; - auto nodeAbsReal = static_cast(node); - const std::size_t nOut = info.outputSize; double *buffer = nullptr; @@ -372,7 +370,17 @@ void Evaluator::computeCPUNode(const RooAbsArg *node, NodeInfo &info) if (nOut > 1) { _evalContextCPU.enableVectorBuffers(true); } - nodeAbsReal->doEval(_evalContextCPU); + if (info.isCategory) { + auto nodeAbsCategory = static_cast(node); + if (nOut == 1) { + buffer[0] = nodeAbsCategory->getCurrentIndex(); + } else { + throw std::runtime_error("RooFit::Evaluator - non-scalar category values are not supported!"); + } + } else { + auto nodeAbsReal = static_cast(node); + nodeAbsReal->doEval(_evalContextCPU); + } _evalContextCPU.resetVectorBuffers(); _evalContextCPU.enableVectorBuffers(false); if (info.copyAfterEvaluation) {