ProjectRange doesn't work for RooHistPdf

Dear colleagues,

I’m trying to project multidimensional RooHistPdf while integrating over a specific range of other variable: exactly what is shown at RooFit tutorial macro #310 but with RooHistPdf as a model.
Unfortunately, the model doesn’t catch normalization properly.
See the minimal working example (code and problematic output) attached.

Could you please help me to get normalization properly?
(I’m using RooFit v3.60)

Bad_Fit.pdf (23.0 KB) min_example.C (4.1 KB)


We need our RooFit expert @StephanH to be back to answer your question. He should return from travel next week; please ping here should you not get an answer by end of next week!


Hi @Axel, thanks for the reply. Will do.

Hi @StephanH, sorry for bothering you, but @Axel suggested to ping you to point at this question.
Do you have may be any ideas how to fix RooFit behaviour here?

Hi @11117,

I ran it with debugger etc, but I have no clue why it doesn’t work out the integral correctly. I will try to ask Wouter Verkerke about it.

Thanks Stephan. Let’s wait for Wouter’s response than.

(Sorry for the awkward nickname - I’m Ilya).

+1 so this doesn’t get closed


it looks like there is a bug in computing the relevant integrals, but there’s apparently a way around it:

  1. Create a dataset that only contains events in the signal range (that happens anyway for plotting, so you can create it once, and also use it for plotting).
  2. Ask for a data-weighted projection, i.e. project out the curve only at the locations indicated by the data points in the sample.

It’s done in this tutorial
and the relevant lines should look something like

auto projData = static_cast<RooDataSet*>(mcprojData->reduce(Cut("<signalRegionCuts>"))); //Probably CutRange(const char* name) also works
model.plotOn(frame2, ProjWData(*projData));
auto projData = static_cast<RooDataSet*>(data->reduce(CutRange("sigRegion")));
   model_hist.plotOn(frame2_hist, ProjWData(*projData), LineColor(kRed));

Thanks, @StephanH!
This solution works for the example, but there are some problems when I try to use it in “real” code
(I have big 7D sample and ProjWData doesn’t seem to scale there). But this is another business - let me investigate my own issues in detail and open another topic if needed.

Yeah, it’s slow unfortunately. Maybe Wouter finds the bug that sparked your question in the mean time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.