RooFit Landau-Gaussian and goodness of fit

Dear RooFitters,

I have a TH1F that I would simply like to fit a convoluted Landau-Gaussian against. Also I would like to get the goodness of fit in the form of a chi^2 probability. So, using various examples in the tutorials, I tried the following, but it doesn’t seem to work.

// CREATE LANDAU GAUSSIAN MODEL
RooRealVar x("x","x",0,20);
RooRealVar mpv("mpv","mpv",1,0.1,4);
RooRealVar width("width","width",1,0.1,10);
RooLandau ld("ld","ld",x,mpv,width);
RooRealVar mean("mean","mean",0.1,0.1,4);
RooRealVar sigma("sigma","sigma",0.5,0.1,10);
RooGaussian gs("gs","gs",x,mean,sigma);
RooFFTConvPdf lxg("lxg","lxg",x,ld,gs);

// IMPORT DATA FROM HISTOGRAM
RooDataHist dh("dh","dh",RooArgList(x),Import(*myHistogram));

// FIT AND GET GOODNESS OF FIT
RooFitResult* fitresult = ld.fitTo(dh,Save(),Range(0.2,1.8));
RooChi2Var Chi2("Chi2","Chi2",ld,dh,true);
RooMinuit m2(Chi2);
m2.migrad();
RooPlot* xframe = mpv.frame();
dh.plotOn(xframe, RooFit::Name("data"));
ld.plotOn(xframe,RooFit::Name("model"));
double chi2 = xframe->chiSquare("model","data",3);
double ndoff = xframe->GetNbinsX();
double chi2prob = TMath::Prob(chi2,ndoff);

In this file I upload the output I get from trying one specific fit on the TH1F myHistogram. Any help on finding what is wrong with my code is very much welcomed.

Kind regards,
Marco
output.txt (13.4 KB)