Roofit: Toy MC of correlated variables

Hi all,

I need to produce toy MC events for two variables that are totally correlated. Something like A=2B. So for each entry with value B in a histogram, I need another entry with value 2B in another histogram.

I thought that I would be able to extract a TTree from the PDF with the toy events and then Draw histograms like tree->Draw(“B”) and tree->Draw(“2*B”), but this doesn’t seem to work (no TTree is stored).

I could, of course, generate a histogram very fine binned and extract the events from it as if they were unbinned, but I thought there might be another less dirty way.

It would be enough with having a histogram for each of the variables, I don’t need the TTree. How could I do this? I can provide more details if my question is too vague!



Well, since I didn’t find any other way, I solved it by putting my generated toy MC into a TH1 with a million bins and then filling a TTree with the bin central value and the “weights” (how many entries in each bin)…

If somebody has a better (faster) solution, it is still welcome :slight_smile: