Hello,
I’d like to understand if this behaviour is correct. What I’m trying to do is importing a TH1D in a RooDataHist (the TH1D has a variable binning but this problem should have been already solved [0]) but if I plot the original histogram on top of the RooDataHist plot I get different shapes and different bin content.
Here is the code which show the problem: all OK for the constant binning while I get something wierd with variable binning:
void mytest() {
const int nBin=100;
double xbins[nBin+1];
const float left_Val = 150;
const float rightVal = 1150;
const float logxmin = TMath::Log10(left_Val);
const float logxmax = TMath::Log10(rightVal);
const double dxLog = (logxmax-logxmin)/nBin;
for (int i=0;i<=nBin;i++) xbins[i] = TMath::Power(10., logxmin + i * dxLog);
TF1 *f1 = new TF1("f1","expo(0)",left_Val,rightVal);
f1->SetParameters(1e2,-1e-2);
TH1D *h1 = new TH1D("h1","",nBin,xbins);
h1->FillRandom("f1",10000000);
RooRealVar mInv("mInv","m [GeV]",150,1150);
RooDataHist hist_test1("hist_test1","hist_test1",mInv,Import(*h1,false));
TCanvas *cExpo1 = new TCanvas();
gPad->SetLogx();
gPad->SetLogy();
auto plot_test1 = mInv.frame();
hist_test1.plotOn(plot_test1,DataError(RooAbsData::SumW2));
plot_test1->Draw();
h1->Draw("same");
TH1D *h2 = new TH1D("h2","",nBin,left_Val,rightVal);
h2->FillRandom("f1",10000000);
RooDataHist hist_test2("hist_test2","hist_test2",mInv,Import(*h2,false));
TCanvas *cExpo2 = new TCanvas();
gPad->SetLogx();
gPad->SetLogy();
auto plot_test2 = mInv.frame();
hist_test2.plotOn(plot_test2,DataError(RooAbsData::SumW2));
plot_test2->Draw();
h2->Draw("same");
}
As suggested in [0], I use the false option when importing the histogram but it looks the problem is still there…
ROOT VERSION 6.28/04
Best
Attilio