RooFit:saving RooWorkspace and RooSimultaneous in file fails

Hi,
I’m using Root 5.22, with RooFit 2.95.
I’ve been trying to use what is explained in the tutorials/roofit/rf504_simwstool.C to have a simultaneous fit of 5 categories. The fit works well, as the lines I use are the following :

  m_total_pdf = new RooAddPdf("Total pdf","Total pdf",
                              RooArgList(*m_sig_pdf,*m_bkg_pdf),
                              *m_f_S);

  m_workspace = new RooWorkspace("ws","ws");
  m_workspace->import(RooArgSet(*m_total_pdf,*m_tagCat));
  m_simTool = new RooSimWSTool(*m_workspace);
  m_simPdf = m_simTool->build("model_sim","Total pdf", RooFit::SplitParam("#omega_{sig}^{OS},#omega_{B2},#omega_{B3},f_{B2},f_{S},slope_{B2},slope_{B3},#tau_{B2},#tau_{B3}","tagCat"));[/code]
tagCat (m_tagCat) is a roocategory that takes 5 states. 

At the end of my code I'd like to save all objects in a root file using the following :
[code]  fout2 = new TFile("fout_roofit.root","RECREATE");
  m_fullPdfResults->Write();
  m_workspace->Write();
  m_simPdf->Write();
  fout2->Close();

but the code fails with a seg fault at m_workspace->Write(); or m_simPdf->Write();

Is there something specific to do before doing the write ?
What is strange is the fact if I don’t call the fitting using

RooNLLVar*m_sig_fit = new RooNLLVar("Sig fit","Sig fit", *m_simPdf,*m_data,RooFit::NumCPU(nbcpu));
  RooMinuit minuit_Sig(*m_sig_fit);
  minuit_Sig.setStrategy(1);
  minuit_Sig.optimizeConst(kTRUE);
  minuit_Sig.setProfile(kTRUE);
  minuit_Sig.setVerbose(kFALSE);
  minuit_Sig.setEps(1e-20);
  minuit_Sig.migrad();
  minuit_Sig.hesse();
  m_fullPdfResults = minuit_Sig.save();

it works !

The attached code shows this.

Cheers.

P.S : I found this problem because I wanted to be able to plot the mixing asymmetry for all five categories, but it fails with the Slice() option. What should be used ?
test.C (3.47 KB)

Hi,

Thanks for reporting that. I suspect something might be broken in RooSimultaneous in persistency (I do run a simple test in stressRooFit with RooSim, but that does apparently not catch this problem). I’ll run your example, see what needs fixing and get back to you

Wouter