How to obtain fit goodness in ROOFIT?

None of these methods work for me, I’m unable do get the chi2.

I do exactly the

Double_t chi2 = frame->chiSquare(“model”,“data”,3);

but I keep getting a

[#0] ERROR:InputArguments – RooPlot::findObject(frame_Dimuon Mass_36331e0) cannot find object data
[#0] ERROR:InputArguments – RooPlot::chiSquare(frame_Dimuon Mass_36331e0) cannot find histogram

I have also tried the solutions from this thread: Roofit: failing to find object in frame

but they didn’t work either.