RooFit: convolution of 2 Gaussians of mean 0 has MPV less than 0

Hello everyone,

I’m new to RooFit. I’m trying to create a convolution of 2 Gaussian function of variable x by using RooFFTConvPdf. In principle, the convolution should return a Gaussian whose mean is the sum of the means of the initial Gaussians.

To make the case simple, I just set the means of the initial Gaussians to 0, so the expected mean should also be 0.

In my code, I also try to generate a histogram that obey the distribution of the convolution using TRandom to compare with the function it self. When I plot the histogram and the function together, the result shows the shape of the histogram and the function is almost identical, the only difference is the mean of the histogram is at 0, but the mean of the function is less than 0. I also found that the distance from the mean of the function to 0 is about 0.5% the range of x variable (for example, if I define x to be in the range of [-20, 20], then the mean of the convolution is -0.2)

I attach my code below, and also a plot that shows the difference between the function and the histogram.

I cannot figure out what is causing the problem, is it caused by an error in my code or is it a limitation of RooFit? Please give me your suggestions, thanks a lot.

Hoa.

TestRooFit_Model.h (2.4 KB)

xAna_TestRoofit_Gaussian.C (3.8 KB)

Hi,
I cannot reproduce this problem with both master and root 6.16 version. Maybe you are using an older version of ROOT, which had a bug in the FFT convolution

Lorenzo

Hi,

Thanks a lot for your reply. Since I’m working on lxplus to do my analysis, I use root provided by CMS Software.

The current version of root is 6.12/07, corresponding to CMSSW_10_5_0 (It seem to be one of the latest version of CMS Software) and I can still encounter the problem (the mean is around -1.0 for x from -100 to 100)

So I think I will try to install the standalone version of root on lxplus and rerun the code. I will let you know when I have the new result.

Thanks again for your suggestion.

Hoa.

Hi Lorenzo,

I was able to use root 6.16, which is installed as default on lxplus. However I ran into the Segmentation violation error.

Error in TVirtualFFT::FFT: plugin not found
Error in TVirtualFFT::FFT: plugin not found
Error in TVirtualFFT::FFT: plugin not found

*** Break *** segmentation violation

The error occurred when I extracted my RooAbsPdf into a TF1 object:

TF1 *function = model_Gaus -> asTF (RooArgList(var_x));

and also when I plotted it:

model_Gaus -> plotOn (frame);

The version of ROOT is 6.16/00. How can I fix it?

Hoa.

HI,
This means that version of ROOT is not installed with FFTW support.
How did you setup up ROOT ? Did you use the cvmfs installation, for example from
/cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.16.00/x86_64-centos7-gcc48-opt

Lorenzo

Hi,

I didn’t do any setup, the version 6.16 of ROOT I used is the default installation on lxplus. I mean I just simply login to lxplus and run my code without doing any setup.

As you recommended, I try to set up with:
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.16.00/x86_64-centos7-gcc48-opt/bin/thisroot.sh

The problem with segmentation error is gone. However, the mean of the convoluted pdf is still less than 0. For x in the range of -100 to 100, 6.12 returns the mean at -0.9999999993…, 6.16 returns the mean at -0.107527.

Is the result of 6.16 expected?

Hoa

Hi,

The FFT convolution is discrete and works by binning the function in the range. When doing it is recommended to increase the number of bins in the variable. I think the default number of bins in 6.12 was too small and this has causd the effect that you observe.
For the latest version is larger but probably not sufficient for you.
One should add then this line in the code after creating the convoluted ODF,

x->setBins(10000,"cache")

where x is your observable object (called var+x in your example)

Lorenzo

1 Like

Hi,

Increasing the number of bins works well! Thank you very much!

Hoa.