From 46924045143943dd0740ae0d4a81892e897a07e1 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sat, 16 Dec 2023 21:02:49 +0100 Subject: [PATCH] [RF] Fix ownership problem in `RooGenProdProj` At some point in `RooGenProdProj::createIntegral()`, an intermediate integral object that should only live during the scope of the function is accidentally put in the `saveSet` output parameter. This needs to be fixed. Thanks to the following forum post for noticing this: https://root-forum.cern.ch/t/error-inputarguments-rooargset-error-argument-with-name-is-already-in-this-set-in-roomcstudy/57571 --- roofit/roofitcore/src/RooGenProdProj.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roofit/roofitcore/src/RooGenProdProj.cxx b/roofit/roofitcore/src/RooGenProdProj.cxx index 7ee3b7d86286d..6d9b712d54152 100644 --- a/roofit/roofitcore/src/RooGenProdProj.cxx +++ b/roofit/roofitcore/src/RooGenProdProj.cxx @@ -166,6 +166,8 @@ RooAbsReal* RooGenProdProj::makeIntegral(const char* name, const RooArgSet& comp // normalization. RooArgSet emptyNormSet{}; + RooArgSet keepAlive; + for (const auto pdfAsArg : compSet) { auto pdf = static_cast(pdfAsArg); @@ -183,8 +185,8 @@ RooAbsReal* RooGenProdProj::makeIntegral(const char* name, const RooArgSet& comp // Remove analytically integratable observables from numeric integration list numIntSet.remove(anaSet) ; - // Declare ownership of integral - saveSet.addOwned(std::move(pai)); + // Keep integral alive until the prodSet is cloned later + keepAlive.addOwned(std::move(pai)); } else { // Analytic integration of factorizable observable not possible, add straight pdf to product prodSet.add(*pdf) ;