Skip to content

Commit

Permalink
Don't use Clone() when importing a Workspace
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ajgilbert committed Sep 1, 2015
1 parent 7260465 commit aea666d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions CombineHarvester/CombineTools/src/CombineHarvester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,12 @@ std::shared_ptr<RooWorkspace> CombineHarvester::SetupWorkspace(
// 2) No: Ok will clone it in. Is the ws name already in use?
if (!name_in_use) {
// - No: clone with same name and return
wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
reinterpret_cast<RooWorkspace*>(ws.Clone()));
// IMPORTANT: Don't used RooWorkspace::Clone(), it seems to introduce
// bugs
// wspaces_[std::string(ws.GetName())] = std::shared_ptr<RooWorkspace>(
// reinterpret_cast<RooWorkspace*>(ws.Clone()));
wspaces_[std::string(ws.GetName())] =
std::make_shared<RooWorkspace>(RooWorkspace(ws));
return wspaces_.at(ws.GetName());
}

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

wspaces_[new_name] = std::shared_ptr<RooWorkspace>(
reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
// wspaces_[new_name] = std::shared_ptr<RooWorkspace>(
// reinterpret_cast<RooWorkspace*>(ws.Clone(new_name.c_str())));
std::shared_ptr<RooWorkspace> new_wsp =
std::make_shared<RooWorkspace>(RooWorkspace(ws));
new_wsp->SetName(new_name.c_str());
wspaces_[new_name] = new_wsp;
return wspaces_.at(new_name);
}

Expand Down

0 comments on commit aea666d

Please sign in to comment.