EDIT:
I just saw that we already were at this step. In dealing with other questions, I forgot that we already tried this. I will give it another try tomorrow.
Hi @andychin912,
I ran your script again and found this:
[#0] WARNING:Plotting -- RooHist::getFitRangeNEvt() WARNING: Number of normalization events associated to histogram is not equal to number of events in histogram
due cut made in RooAbsData::plotOn() call. Automatic normalization over sub-range of plot variable assumes
that the effect of that cut is uniform across the plot, which may be an incorrect assumption. To be sure of
correct normalization explicit pass normalization information to RooAbsPdf::plotOn() call using Normalization()
As the warning says, the automatic computation of normalisation cannot work out the number of data events. Like this I got it to work:
// Plot the results
RooPlot* frame01 = x.frame(Title("x"));
modelData->plotOn(frame01,CutRange("SB1"));
const double nData = modelData->sumEntries("", "SB1");
// Make clear that the target normalisation is nData. The enumerator NumEvent
// is needed to switch between relative and absolute scaling.
model.plotOn(frame01,LineColor(1),LineWidth(2), Normalization(nData, RooAbsReal::NumEvent),
ProjectionRange("SB1"));
RooPlot* frame02 = y.frame(Title("y"));
modelData->plotOn(frame02);
// Here, all data are plotted. It is therefore not necessary to adapt the normalisation
model.plotOn(frame02,LineColor(1),LineWidth(2),Range("SB1"), NormRange("SB1"));