I have an issue when trying to generate a distribution from a binned pdf. You will find an example of minimal code attached to this entry, as well as the necessary input files.
In a nutshell, I want to generate events from a pdf stored in a TH1 and save the results back to a TH1. Here’s how I am attempting to do this:
1- Build a distribution in a TH1D to be used as a pdf for the generation
2- Create a RooDataHist out of this TH1D
3- Create a RooHistPdf out of this RooDataHist (to be able to use the generate methods)
4- call generateBinned() on the resulting RooHistPdf
5- Create a TH1D out of the resulting RooDataHist (requesting there to have the same binning as for the TH1D in step 1)
I would naively expect from this to obtain a rather smooth distribution using the original binning. Turns out something goes wrong at step 4, where I am outputting the resulting RooDataHist to the RooFrame in the code and one can clearly see that roughly one bin out of 2 (sometimes 3) have 0 content. I am not sure to understand why that is. Can someone point me to what I am doing wrong?
I have a similar problem, as already been discussed in this thread.
I am performing a chi2 fit using RooFit. However, I face an issue while trying to generate a distribution from a binned pdf.
What I am doing is as follows:
Obtain a distribution in a TH1D to be used as a pdf for the generation
Create a RooDataHist out of this TH1D using RooRealVar
Create a RooHistPdf out of this RooDataHist
Create a RooAddPdf using RooHistPdf and RooRealVar
Create a TH1D out of the resulting RooAddPdf using the method createHistograms() (requesting it to have the same binning as for the TH1D in step 1)
No matter what I do, I always get number of bins = (original number - 1) in the last step. Clearly, there is something which I am not doing correctly. Can someone please help me to solve this problem?