In order to fit my data with an external function (a polynom for exemple), as written in the manual, I tried this :
RooDataHist data("data","dataset with E",E,Import(*hh));
RooPlot* frame = E.frame();
data.plotOn(frame);
frame->Draw();
RooDataHist needs a TH1* whereas hh is a TH2*.
By the way it drew me something, but E (which is between 0 and 2000) is drawn rebinned between 0 and 1217 (or something like that).
Since TH2 inherits from TH1 you can provide a TH2 whereever a TH1 is requested. However if you want a 2D binned dataset to be created you should specify 2 observables in the constructor e.g.
RooDataHist data(“data”,“dataset with E vs F”,RooArgList(E,F),Import(*hh));
Concerning the binning and ranges: The RooDataHist import operation will only import the range of the histogram that fits in the defined range of the RooRealVars E,F. E.g. if you define RooRealVar E to have a range from (0-1000) and your TH2 has a range of (0-2000) it will only import the bins in the range (0-1000). This is probably what happens in your case.