Skip to content

Commit 941f3e9

Browse files
committed
[RF] Fix wrong usage of std::ostringstream in RooProdPdf
After getting confused for some time why some fits don't work with the new CPU backend, I found one of the problems: the `std::ostringstream` was used incorrectly since 916a180 (commit from 10 years ago). The `std::ostringstream` constructor arguments do not initialize the stream with that string — the argument sets the open mode, not the contents. This can be seen with this little example in the interpreter. ```txt root [0] const char *pfx = "hello"; root [1] std::ostringstream os(pfx); root [2] os << " world"; root [3] os.str() (std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::__string_type) " world" root [4] .q ``` The result is that the prefix doesn't get added, and hence it can happen that many nodes in the computation graph can have the same name, breaking the assumptions of the new RooFit evaluation backend.
1 parent da1ebd9 commit 941f3e9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

roofit/roofitcore/src/RooProdPdf.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,8 @@ std::string RooProdPdf::makeRGPPName(const char* pfx, const RooArgSet& term, con
14381438
{
14391439
// Make an appropriate automatic name for a RooGenProdProj object in getPartIntList()
14401440

1441-
std::ostringstream os(pfx);
1441+
std::ostringstream os;
1442+
os << pfx;
14421443
os << "[";
14431444

14441445
// Encode component names

0 commit comments

Comments
 (0)