Make a RooPlot survive after TFile::Close()

In the following code:

int myfunc()
{
  TFile * fw = TFile::Open("workspace.root");
  RooWorkspace *w = (RooWorkspace *) fw -> Get("w");
  RooRealVar * x = w -> var("x");
  RooPlot * frame = x -> frame();
  RooAbsData *dataw = w -> data("data_obs");                                                                                                                        
  fw -> Close();
  x -> Print();
  dataw -> Print();
  frame -> Print();
  return 0;
}

the object frame (unlike x and dataw) does not survive after fw -> Close(). How to fix?

Can you check in tutorial https://root.cern.ch/root/html/tutorials/roofit/rf106_plotdecoration.C.html
seems to be discussed similar situation?

Cheers,
Oksana.

@oshadura, it is not the same. I am looking for something similar to SetDirectory(nullptr) on a RooPlot.

@moneta, probably you can help here please?

Cheers,
Oksana.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.