I am performing a fit of a blinded dataset using a RooChebychev.
I have already posted this issue on the ROOT forum in June, but I didn't get any reply. Now we are a little stuck with our analysis because we need to be able to perform this kind of fit.
I did lots of checks try to debug the problem, but I didn't manage to find any good solution.
In attachment you can find a macro that shows the problem. The macro is divided into "TEST1" and "TEST2".
– TEST1 generates a dataset using a 1st order Chebychev in the mass region [4700,5900] and a "blinded" dataset reducing the full dataset to the two sub-regions [4700,5100] and [5500,4900]. Then, it performs two fits:
1) fit the "full" dataset and plot the results (lines 75-79 )
2) fit the "blinded" dataset and plots the results (lines 86-90).
– TEST2, similar to TEST1, but with a different PDF (1st order Chebychev + Gaussian)
Now, if I do this test using a RooExponential, the fit is OK on both full and blinded dataset (you can try that commenting RooChebychev and de-commenting RooExponential), whereas if I do the test using RooChebychev, when I do the fit on the two sub-ranges, ROOT crashes and exits due to the assert() present in the RooChebychev.cxx (lines 141-142). In attachment you can find the bt obtained running lldb on my laptop.
I added some prints to RooChebychev.cxx
Now, looking at RooChebychev.h, if I understood correctly, "_x" should correspond to the variable "mass" (in my case) and so xminfull = _x.min() should always be equal to 4700, and xmaxfull = _x.max() should always be equal to 5900.
When I try to do the fit in the two sub-ranges I got this print (before ROOT crashes)
_x.min(rangeName) = 4700
_x.max(rangeName) = 5900
xminfull = 4700
xmaxfull = 5100
As you can see, it seems that the ranges are swapped, and so the assert() fails and exits ROOT. "rangeName" should be "SB1" or "SB2" (defined in lines 54-55).
I have tried to investigate the problem in more detail, but I din't find any proper solution. Maybe there is some problem in dealing with the ranges in the RooChebychev.cxx (maybe some problem in RooProxy?).
Looking at RooAbsOptTestStatistic.cxx, in lines 286-365 RooFit make adjustments for the fit ranges, I saw that, commenting line 311, ROOT does not crash, the fit with the Chebychev only seems to be OK (but not the normalisation, that is wrong), whereas the fit Chebychev+Gaussian converges but the chi2 is huge (so the fitted curve does not fit the data and the normalisation is wrong).
I hope these tests can help in figure out where the problem is. Let me know if I can help with some other tests and if you need more information.
Thanks a lot in advance!