Question about ConfInterval

Hi everybody,
I am RooFit/RooStats beginners.
I am trying to get a confidence interval from FeldmanCousins class.
In attachment there is the script I use.
It is very slow since it takes 5 days to process 20 steps over 100.
I would like to know if this is normal or is in the script something wrong.
And I would like to know if there is some way to make it faster.

Thank you a lot,
BuildInterval.cpp (56.6 KB)


Your model pdf is quite CPU intensive, since it is made from an integral (in theta) and then another integral in Enu. So having to perform numerical integral of integrals is very inefficient. If you could do analytically, it would be much faster. In addition you are also using a Formula var which needs to be processed by CINT and this is also slow.
However, making a fit of your model at the end is not too slow. Another problem is in generating the toys needed for Feldman-Cousins. The problem is that the default generator (Foam) is not adapted for your discrete observable (Nobs). It would be much faster (factor of 100-1000) to make an histogram with your pdf and generate nobs from the histogram. I think for doing this you might need to make your own generator.
I have tried also by switching to Accept/Reject and it is about 10 faster. For example by doing:

RooAbsPdf::defaultGeneratorConfig()->getConfigSection(“RooAcceptReject”).setRealValue(“nTrial1D”,100) ;

Best Regards