Roofit: generation of events from histogram shape?

Hi all,

(sorry for multi post but Rene suggested me to post it to this forum.)

I have a question about Roofit.
Can I generate events from Histogram, that is,
in the next example, I want to generate toyMC based on the shape of “hdata”.

TFile f1 = new TFile(“t.root”);
TH1D * h1 = new TH1D(
((TH1D*) gDirectory->Get(“Mass_higgscand”)));
RooDataHist hdata(“hdata”,“binned data”,x,h1);

Actually, I can find examples to generate toyMC from pdf
but cannot find it from a binned histogram.

Junichi

Hi Junichi,

The missing step is that you need to make a p.d.f from your
histogram first: a RooHistPdf. See tutorial macro #706 for an example.

root.cern.ch/root/html/tutorials … pdf.C.html

The corresponding macro file is also in $ROOTSYS/tutorials/roofit.
Once you have the RooHistPdf you can simply call RooAbsPdf::generate()
on it.

Wouter