TGraph2DErrors

Martin Woudstra (Martin.Woudstra@cern.ch)
Tue, 02 Dec 1997 18:49:11 +0100


Dear Root Developers,

I would like to make a 3D fit (e.g. plane) to a set of 3D
points (x,y,z) with their errors. Both the points and the errors
come from another calculation and I want to set directly the
points with their errors, like in TGraphErrors, but then in 3D.

So, something like TGraph2DErrors class could do the job.
Would it be useful to add this to ROOT?
I was surprised you didn't put it in yet (at least I didn't find it).

Currently I am using TH2F, but each bin has one entry (with
weight=z), and the assumed error on this in a Fit is
certainly wrong (1.0 I guess), so the fit is wrong.

So I am thinking of making a new class like
class TH2FErrors : public TH2F {
void Fill(Axis_t x, Axis_t y, Stat_t w, Stat_t e)
}

void TH2FErrors::Fill(Axis_t x, Axis_t y, Stat_t w, Stat_t e)
{
Int_t binx, biny, bin;
TH2F::Fill(x,y,w);// ensure bookkeeping

binx = fXaxis.FindBin(x);
biny = fYaxis.FindBin(y);
bin = biny*(fXaxis.GetNbins()+2) + binx;
// overwrite bin contents + bin error
SetBinContent(bin,w);
SetBinError(bin,e);
}

But I'm not sure this is a good idea, and it might even be
dangerous. Maybe you can help me here.

Thanks!

Martin.