Delete RooObject in RooWorkspace

Hi Root Experts,

I need to delete something from a RooWorkspace, but it is difficult to remove it permanently.

Following this support thread[1], I thought that I would be able to do this [2]. After doing [2], I can “.ls” and myRooObject is gone. However, when I close and open the file, myRooObject has returned.

How can I delete something in the workspace?

Cheers,
Chris

[1]

[2]
root

root [0] TFile f = TFile(“myfile.root”, “UPDATE”)
root [1] myws->cd()
root [2] gDirectory->Delete("myRooObject)

Try: gDirectory->Delete(“myRooObject;*”);
If it helps, see http://root.cern.ch/root/html/TDirectoryFile.html#TDirectoryFile:Delete and/or http://root.cern.ch/root/html/TFile.html#TFile:Delete