Operation on RooDataSet and RooDataHist

I created a PDF as a sum of two gaussians and an exponential and using this PDF generated a dataset, I don’t understand:

  1. How to generate the binned dataset, here [ROOT: RooDataHist Class Reference] I saw that there’s a constructor for RooDataHist which takes as argument the RooDataSet object I have but I don’t understand how to pass to said constructor either the number of bins or their dimension.
  2. How do I downscale the RooDataSet or RooDataHist object so that it has the same height as the PDF instead of being proportional to the number of entries?

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22/06
Platform: Ubuntu 20.10
Compiler: g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0


Hello,

  1. For generating a binned dataset you need to call the RooAbsPdf::generateBinned function, see
    ROOT: RooAbsPdf Class Reference
    The number of bins can be set in the ROoRealVar representing the observable you want to bin. By default is 100, but you can change using RooRealVar::setBins (ROOT: RooRealVar Class Reference).

  2. Normally when plotting a pdf on top of the data you have the pdf that is scaled and normalized such that the integral of the pdf corresponds to the one of the data. I think you would like instead to scale the data to the integral of the pdf, i.e. to be equal to 1.
    You can however rescale the RooDataHist when plotting using the Rescale(factor) option, see ROOT: RooAbsData Class Reference.
    The factor should be 1./( Integral of data * binWidth)

Lorenzo