Seg fault when adding RooTFnPdfBinding into a RooWorkspace

Dear experts,

I am trying to create a RooWorkspace with my data and my model:

RooWorkspace* wspace = new RooWorkspace(“wspace”,“wspace”);
wspace->import(*data);
wspace->import(model);
std::string path_output = “blabla.root”
wspace->writeToFile(path_output.c_str());

Where data is a RooDataSet (this is fine, the workspace works fine if I just add data) and my model is:

TKDE *kde_photon = new TKDE(4000, array_mc_unweighted, xdown, xup,
“KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning”,1.5);
TF1 *f_photon = kde_photon->GetFunction((xup-xdown)*100, xdown, xup);
f_photon->SetName(“f_photon”);
RooTFnPdfBinding pdf_photonMC_unweighted(“pdf_photonMC_unweighted”, “”, f_photon, topoIso);

RooGaussian gauss(“gauss”,"",topoIso,shift,res);
RooFFTConvPdf pdf_photon(“pdf_photon”,"",topoIso,pdf_photonMC_unweighted,gauss) ;

(pdf_jet is also defined and directly of type RooTFnPdfBinding)

RooExtendPdf extPdf_photon(“extPdf_photon”,"",pdf_photon,Ng);
RooExtendPdf extPdf_jet(“extPdf_jet” ,"",pdf_jet ,Nj);
RooAddPdf model(“model”,"",RooArgList(extPdf_photon,extPdf_jet));

Everything executes fine but when I try to Print() my workspace, I get a segfault (log attached) with ROOTDict::delete_TF1(void*) mentioned. I tried to import(*f_photon) and *f_jet into the workspace, write them as TF1 outside the workspace but in the same file but nothing works. I tried to build a workspace with a modified model without RooTFnPdfBinding and it works well.

Any ideas?

Here is the log during the execution of the script, the crash log when printing is attached:

[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing dataset data
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooRealVar::topoIso
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooAddPdf::model
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooExtendPdf::extPdf_photon
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooFFTConvPdf::pdf_photon
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooTFnPdfBinding::pdf_photonMC_unweighted
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooGaussian::gauss
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooRealVar::shift
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooRealVar::res
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooRealVar::Ng
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooExtendPdf::extPdf_jet
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooTFnPdfBinding::pdf_jet
[#1] INFO:ObjectHandling – RooWorkspace::import(wspace) importing RooRealVar::Nj

Looking forward to hearing from you
Best wishes
Matthias
log.txt (38.5 KB)

HI Matthias,

Can you please attached the code to create the workspace and the data set you use for creating the TKDE, so I can reproduce it and investigate it

Thank you

Lorenzo

Dear Lorenzo,

Thank you for your message. Everything you need should be in /afs/cern.ch/user/m/msaimper/public/Lorenzo_files

There a simplified code adapted to reproduce the problem and some inputs required to build the model. I tested it and it should work, please let me know if you have any problems. You might need to change the location of the “tmp” file to a directory you have writing access, same for output.root.

Cheers
Matthias

Thank you for the files. I could reproduce the crash but only when using version 6.o2 or master of ROOT. Not in version 5.34.
This is strange and we need to understand. Which version of ROOT are you using ?

Lorenzo

Hi Lorenzo,

I am using: ROOT version 5.34.25-x86_64-slc6-gcc48-opt, RooFit v3.60. This strange indeed …

Cheers
Matthias

Hi,

Sorry, the crash I was referring was at the end when writing the workspace. Now in 5.34 I see also a crash, but afterwards, when reading the workspace

Cheers

Lorenzo

Hi Lorenzo,

Ok it makes more sense then. Did you have time to further identify the problem and have an idea of the timescale for a fix?

Thank you for your help!
Best wishes
Matthias

Hi,

I did not have yet the time to investigate this issue, caused when streaming these classes.
As a workaround I would save the TF1 in the workspace and re-build later in memory the RooTFnBinding class. You can write the model without the RooTfn and then use the RoOWorkspace EDIT function to insert the RooTfnBinding class

Best Regards

Lorenzo

Hi Lorenzo,

No problem, please let me know once you have something to test, it would make things easier to have everything in a workspace already since the fit will be pretty heavy :slight_smile:

Regards
Matthias

Hi Matthias,

This is now fixed in both master, 6 and 5.34 versions of ROOT.

Lorenzo

Hi Lorenzo,

Thanks a lot for this I will test it as soon as possible.

Cheers
Matthias