Fitting gaussian curve for a billion events

Hi guys.

Just wanted to find out if there is a limit to the number of events one can generate with the rf101_basics.C code. I tried generating a billion events and this is the plot I get.

As you can see, the generator fails near the peak. The RooGaussian uses uniform random numbers from TRandom3 to generate gaussian deviates. The algorithm used in TRandom3, Mersenne Twister, has a period of 2^19937−1. Does this not mean that it should be able to generate 1 billion events without repetition?
I was wondering if someone could help me interpret this.

Hi,
The regenerator has no problem to generate a lots of events. We would need an enormous time to generate events for exhausting the period.
There is something else happening there, maybe an overflow of a 32 bit integer ?

Lorenzo

Hi @moneta

So I changed the type of the counter “evt” in RooAbsGenContext line 235 from Int_t to long long because I assumed that the overflow might be occurring there. But I also found that the maximum value for a 32-bit is 2,147,483,647 while I am using 1,000,000,000. Could the problem be linked to the RooDataSet that I am trying to store the values in using addFast()?

I don’t know where the problem could be. Can you please post your macro so I can reproduce it and investigate it ?
Thanks
Lorenzo

Hi @moneta

Here is my macro.

gaus.C (13.0 KB)

HI,
Your script does not compile and the genration part seems to be very complex and in addition it cannot be compiled by cling or c++.
I would suggest to simplify the generation part and test if you see still this effect.

Lorenzo

Hi @moneta.

It is actually a modified version of the rf101_basics.C code in the tutorial directory. I think it only compiles with the project I have on my machine. Otherwise they give the same results. You can use the code I just uploaded. It should work

rf101_basics.C (2.3 KB).

Thank you!
I can reproduce it now and I will investigate it

As I though is an overflow problem. It is caused by using a TH1F internally in RooFit instead of a TH1D.
The bin content of TH1F is limited to something like 1.6E6, the single precision value.
I think RooFit should use double precision histogram by default.
Anyway in your case the workaround is also very simple, increase the number of bins. For example setting 1000 bins, with x.setBins(1000) fixes the issue

Lorenzo

Thank you so much.This worked!

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