TProfile2D errors

Is there a way to fill a TH2 with the errors from a TProfile2D, without having to get and fill each bin? I am looking for something like (TH2*) TProfile2D::GetErrors()

see TProfile2D::ProjectionXY
use version 4.04/02 or newer

Rene

Actually, I wanted to get the errors to a new histogram, not the bin content. The idea is to avoid loops like:

    for i in xrange(hist.GetNbinsX()):
        for j in xrange(hist.GetNbinsY()):
            h.Fill(i, j, hist.GetBinError(h.GetBin(i+1, j+1)))

Hi!
So if I understand it correctly, with the ProjectionXY and the plot option “e” I am able to plot the histgrom WITH the errors. (I tried it out with some Th2D in the tutorial and that is what seems to happen).
But one will agree that it’s not very easy to see the value of errors in these kinds of plots, so as the previous poster mentioned, it’s sometimes also interesting to only have a histogram/plot with only the errors of a histogram.
Is that possible without the above mentioned loop or should I still use these loops to read out the errors manually and fill them into a new histogram?
Cheers,
Michael

Michael,

Your question is not clear. You need to plot the errors on top
of something! in your case what?

Rene

Hi René,
of course the errors belong to my first histogram, but in the case of 2D histos for the reason of visibility I would like to have them plotted in their own pad, not on top of the values they have been calculated from.
Of course not as a default or something, it would just nice to have the above written loops as a built-in method (especially b/c i always make an error with the bin countings :slight_smile:).
As I tried to describe before but maybe a bit more exemplary:
if one has a 2d histogram with one million bins, it’s not easy to see where the biggest errors are only by looking at the little black crosses on top of the 3d-plot using the option “e”. So I guess the best option is to get the errors out of the histogram and put them in another one to have their own pad, just for displaying reasons. Or are there other possibilities I have overlooked?
Have a nice weekend everyone! :slight_smile:
Michael

You did not answer my question. How would you like to see the errors displayed in the other pad? how to of what?

Rene

I’m sorry, maybe I just don’t understand your question correctly? What do you mean with “how to of what”?
Here is what I do:
The TProfile2D had been filled before with 10 flatfields of a CCD image, 1054x1092 bins.
Part of checking the flatfield image is checking the errors from filling 10 equal flatfields, i.e. I want to check if the errors show any anomaly, e.g. not being evenly distributed.

TFile f(“flats.root”);
TProfile2D prof = (TProfile2D) f.Get(“F430nm”);
TCanvas c1(“c1”);
c1.Divide(1,2);
c1.cd(1);
prof.Draw(“colz”);
TH2D* h2 = prof.ProjectionXY();
c1.cd(2);
for (int i = 0 ; i < prof.GetNbinsX(); i++)
{
for (int j = 0; j < prof.GetNbinsY(); j++)
h2.SetBinContent(i+1,j+1,prof.GetBinError(i+1,j+1));
}
h2.SetName(“F430nmErr”);
h2.SetTitle(“430 nm Errors”);
h2.Draw(“colz”);
c1.Update();

The root file is a bit big (8 MB), so I didn’t want to upload it, but it should be clear now what I meant.
As soon as the number of bins in a 2d histogram becomes very large, for me this way of displaying the errors is more efficient than the 3d plot with “e”. Unless I overlooked other possibilites?
Regards,
Michael

In the CVS version, I have implemented a new optiion to do what you request:

// if option "E" is specified, the errors are computed. (default) // if option "B" is specified, the content of bin of the returned histogram // will be equal to the GetBinEntries(bin) of the profile, // if option "C=E" the bin contents of the projection are set to the // bin errors of the profile

Rene

Very nice, thanks Rene!
:laughing: