Problem with plotting projections of simultaneous fit in python

Dear Experts,

My name is Giorgos. I am trying to do a simultaneous fit using python.

First of all I am trying to do the simultaneous fit in lxplus.
The python version is Python 2.7.5 and the root version is 6.24/08.

In the beginning of my code I import Root as “import ROOT”, which I assume that imports the same root version as when I run ‘root’.

My simultaneous fit is for 15 samples. In most of the samples I have similar fit components, e.g. exponential for background, double sided crystal balls for partially reconstructed background and double sided crystal ball + gaussian for signal. Each sample has its own components, so I have 15 exponentials for background, 15 double sided crystal balls for partially reconstructed background etc etc.

For most of the fit components I have a module in order to fix the shape from MC. For example, in order to fix the shape for the partially reconstructed background, I have defined a function as “def background_partially(tree,…):” which returns a dictionary of the parameters for the specific sample and I call this function 15 times. For each fit component, I store the dictionaries in a list and when I want to defice the components for the simultaneous fit I am using indices for the lists in order to use a dictionary for a specific component for a specific sample. In order not to define each parameter by hand (I have more than 400 parameters), I have used “for loops” to define and to initialize the parameters inside a RooWorkSpace. When I try to do the simultaneous fit, the fit seems to work fine, since it is printing the RooFitResult, the covariance matrix, I can print parameters, the normalizations that are calculated by the simultaneous fit etc etc. So I guess that whatever it is trying to use in order to do the fit is defined.

Some days before I had managed to plot the projections to the various samples and everything seemed fined. I needed to edit my code and then came the problems. The fit is still performed but when I try to plot the projections of the simultaneous fit to the different samples it returns a *** Break *** segmentation violation and crashes.

In the beginning I couldn’t understand what was happening, it was not complaining about a specific line, so I tried to isolate the line that causes the crash, by deactivating the last few parts of the code. I noticed that each time the output was different and while I was deactivating more parts of the code, the crash was moving to previous lines, I noticed that by adding prints in various lines along the code. Now, I try to plot a projection and I see something different: I have deactivated some parts and the code is running. When I try to add the next line it crashes but the only difference between the two lines is the RooFit Component I am projecting.

After a lot of prints, I guess that the problem is somewhere here:
line 747: simPdf.plotOn(xframe,RooFit.Slice(sample,“sample_q1”),RooFit.ProjWData(ROOT.RooArgSet(sample),data_comb),RooFit.Components(“pimumu_dscb_q1”),RooFit.LineStyle(2),RooFit.LineColor(6),RooFit.Name(“pimumu1”),RooFit.LineWidth(3)); line 748: simPdf.plotOn(xframe,RooFit.Slice(sample,“sample_q1”),RooFit.ProjWData(ROOT.RooArgSet(sample),data_comb),RooFit.Components(“comb_exp_q1”),RooFit.LineStyle(2),RooFit.LineColor(6),RooFit.Name(“comb_exp_q1”),RooFit.LineWidth(3));

When the second line is out, the projection is plotted, but when the second line is in, it returns the attached segmentation_violation.txt.
I also tried to have activated only the second line and not the first one and I saw again the same segmentation violation.

I am complitely confused with this bug(?), how is it possible the line 747 be ok if line 748 and after are not included in the code and the same line not be ok if line 748 and after are included in the code?

Furthermore, I was following this tutorial ROOT: tutorials/roofit/ File Reference and had also a lot of problems in order to run it in the same environment. So I am not sure that it is a bug in myside or it is a bug in ROOT or in python or something.

Please let me know if you need any other information from myside or if anything is not clear. Any kind of help is appreciated!

Best regards,

segmentantion_violation.txt (8.3 KB)

Make sure you always use “${ROOTSYS}/tutorials” which come with your ROOT version, e.g., ROOT 6.24 → ${ROOTSYS}/tutorials/roofit/


thank you very much, I modified my code according to the tutorial for root version 6.24 and it is working again.


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