Problem with roofit ranges

I’m working with a 2d dataset & fit, and am trying to add a range to the (pre-defined) dataset and fit model. The dataset & model are loaded from a file, but then additional ranges do not get recognised in the plotting.

I’ve attached an example of the problem based on RooFit tutorial macro #310. There are two versions - one which works, and one which does not. The difference between the two is just where I define the RooRealVar for the variables being fitted. Simply try:
root TestApp_works.cpp
root TestApp_doesntwork.cpp

I’m using root v5.34.

So, is it possible to load a dataset & fit model from a file, then define ranges for them using setRange ?

TestApp_doesntwork.cpp (3.89 KB)
TestApp_works.cpp (3.89 KB)


I have exacstly the same problem.
If dataset is loaded from the file Cutrange() option doesn’t work in plotOn() options. I can use reduce() and save subset of orginal in new RooDataSet, but Cutrange() option would be more convenient.
Are there any fixes to this problem?

RooFit verison is v3.60.