Skip to content

Commit

Permalink
[RF] Support scalar categorical inputs in RooFit::Evaluator
Browse files Browse the repository at this point in the history
Closes #16419.

Should be backported also to 6.32.
  • Loading branch information
guitargeek committed Sep 24, 2024
1 parent 5369b4c commit ff6649c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions roofit/roofitcore/src/RooFit/Evaluator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void Evaluator::updateOutputSizes()
Evaluator::~Evaluator()
{
for (auto &info : _nodes) {
if(!info.isVariable) {
if (!info.isVariable) {
info.absArg->resetDataToken();
}
}
Expand All @@ -342,8 +342,6 @@ void Evaluator::computeCPUNode(const RooAbsArg *node, NodeInfo &info)
{
using namespace Detail;

auto nodeAbsReal = static_cast<RooAbsReal const *>(node);

const std::size_t nOut = info.outputSize;

double *buffer = nullptr;
Expand Down Expand Up @@ -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<RooAbsCategory const *>(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<RooAbsReal const *>(node);
nodeAbsReal->doEval(_evalContextCPU);
}
_evalContextCPU.resetVectorBuffers();
_evalContextCPU.enableVectorBuffers(false);
if (info.copyAfterEvaluation) {
Expand Down

0 comments on commit ff6649c

Please sign in to comment.