Hi @SAlsum,
1. Weighted vs. Unweighted Events
indeed, that’s unrelated to the first problem. Just for completeness (if somebody else reads this thread):
If you ask for 10 events on a binned dataset, you will get one entry per bin (four in your case), but the sum of weights will be 10. More details can be found in the post you linked.
2. Number of Events in Nested Categories
Could you just add a short answer on how you got around the following problem?
I can at least tell you why it doesn’t work when you just ask the top-level PDF for a specific number of events. The problem is that RooFit cannot know how many events to put in which category if the top-level PDF is not extended. Let’s say you want 5 events, and you have two categories. Should the split be {3,2} or {2.5,2.5}, or something completely different? In your example it’s even a bit more complicated because the categories are nested, so if you join A and B, which each have a category 1 and 2, there are actually four categories (A1 B1, A2 B1, A1 B2, A2 B2).
There’s two options I can see how to solve this:
- The SuperCategory. It creates one category for each combination of sub-categories, so it joins them. With this, you can select each combination of categories in A and B directly. That’s why the generation succeeds, because you can say for each category how many events you want.
- You need to extend the PDFs when making the categories. When you do this, (let’s say the original A1 has 5 events and the original A2 has 10), it’s clear that the ratio of A1 to A2 is 0.5. Then, if you ask the top-level PDF for 9 events from A, there should be 3 in A1 and 6 in A2.