Skip to content

Commit aea666d

Browse files
committed
Don't use Clone() when importing a Workspace
This was found to modify the workspace in some way that affects the values returned from RooHistFuncs. We use the standard copy constructor now instead
1 parent 7260465 commit aea666d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

CombineHarvester/CombineTools/src/CombineHarvester.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,12 @@ std::shared_ptr<RooWorkspace> CombineHarvester::SetupWorkspace(
604604
// 2) No: Ok will clone it in. Is the ws name already in use?
605605
if (!name_in_use) {
606606
// - No: clone with same name and return
607-
wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
608-
reinterpret_cast<RooWorkspace*>(ws.Clone()));
607+
// IMPORTANT: Don't used RooWorkspace::Clone(), it seems to introduce
608+
// bugs
609+
// wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
610+
// reinterpret_cast<RooWorkspace*>(ws.Clone()));
611+
wspaces_[std::string(ws.GetName())] =
612+
std::make_shared<RooWorkspace>(RooWorkspace(ws));
609613
return wspaces_.at(ws.GetName());
610614
}
611615

@@ -637,8 +641,12 @@ std::shared_ptr<RooWorkspace> CombineHarvester::SetupWorkspace(
637641
<< " already defined, renaming to " << new_name
638642
<< "\n";
639643

640-
wspaces_[new_name] = std::shared_ptr<RooWorkspace>(
641-
reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
644+
// wspaces_[new_name] = std::shared_ptr<RooWorkspace>(
645+
// reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
646+
std::shared_ptr<RooWorkspace> new_wsp =
647+
std::make_shared<RooWorkspace>(RooWorkspace(ws));
648+
new_wsp->SetName(new_name.c_str());
649+
wspaces_[new_name] = new_wsp;
642650
return wspaces_.at(new_name);
643651
}
644652

0 commit comments

Comments
 (0)