Fitting a TH3F with a 3D linear fit

Dear ROOTers,
While working on my latest program, I ran into some issues that I hope you can help me fix. This program is designed to fit a 4x4 grid of “pixels” (represented by the points) using a set of weights for each point based on data collected in our experiment. First, when running the problem with some very simple test data (all points weighted=0 and only the 4 center points weighted =1), the fitter gives me a fit where x0,y0 seems to be in the right place (near the origin), but with huge errors (see below). Is there any way I can minimize these errors? Secondly, when I try to draw the TGraph2D, suddenly all these min-max scope errors come up (also see below). I have traced the issue to the fact that all the points that are to be fitted now lie on the xy-plane (z=0), how does this affect the plotter? Thanks for your help.

Alexander

FCN=5.76 FROM MIGRAD STATUS=CONVERGED 123 CALLS 124 TOTAL
EDM=7.83694e-07 STRATEGY= 1 ERR MATRIX NOT POS-DEF
EXT PARAMETER APPROXIMATE PHYSICAL LIMITS
NO. NAME VALUE ERROR NEGATIVE POSITIVE
1 x0 4.02588e-08 2.87778e+00 -3.60000e+00 3.60000e+00
2 Ax 1.28092e+03 1.65362e+07
3 y0 4.02588e-08 2.87778e+00 -3.60000e+00 3.60000e+00
4 Ay 1.28092e+03 1.65362e+07
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
Error in TView3D::ResetView: Error in min-max scope
Error in TView3D::ResetView: Error in min-max scope
Error in TView3D::ResetView: Error in min-max scope
Error in TView3D::SetRange: problem setting view
Error in TView3D::ResetView: Error in min-max scope
Warning in TCanvas::ResizePad: c1 width changed from 64000 to 10

Warning in TCanvas::ResizePad: c1 height changed from 64000 to 10

root [1] Warning in TCanvas::ResizePad: c1 width changed from 64000 to 10

Warning in TCanvas::ResizePad: c1 height changed from 64000 to 10

Warning in TCanvas::ResizePad: c1 width changed from 64000 to 10

Warning in TCanvas::ResizePad: c1 height changed from 64000 to 10
line3Dfitwithweight.C (3.6 KB)