Visualising a 2d histogram with errors

Hi,

I note that the THistPainter class includes a function, Paint2DErrors(), which presumably draws error bars on a two dimentional histogram. Can someone tell me how to activate this option? I’ve tried the obvious “hist e”, “p e”, “lego e”, etc. I’m using v4.02.04 and am actually trying to paint a TProfile2D.

mike kordosky

Just use option E on a 2d histogram. For instance:

root [0] TFile f(“hsimple.root”)
root [1] hpxpy->Draw(“e”)

[quote=“couet”]Just use option E on a 2d histogram. For instance:
root [0] TFile f(“hsimple.root”)
root [1] hpxpy->Draw(“e”)
[/quote]

This is strange. I find that when I run hsimple.C, then draw as you do, I get error bars. However, for my particular histogram, the Draw(“e”) command produces a scatter plot. I’ve tried doing this inside the tutorials area to decouple my logon file, but still no error bars.

The histogram is here.

As I said before, it’s a TProfile2D but I’ve also tried doing ProjectionXY()->Draw(“e”) and the result is the same.

A slight error in my post above: I use root v4.02.00. I don’t think there is a v4.02.04.

Any ideas?

mike kordosky

this painting option is for true 2d histos only

Uhh, when I do TProfile2D::ProjectionXY(), don’t I create a true 2d histo??? It certainly gives me a pointer to a TH2D, and looking under the hood it’s definitely doing “new TH2D(…”

mike kordosky

yes … but it is a profile histo … they are not handled the same way at drawing time

I fail to understand this. If I have a pointer “h” to a TProfile2D, and then I call:

TH2D* hh = h->ProjectionXY();
hh->Draw("e");

then, I am drawing a TH2D, not a TProfile2D. So, it must be something to do with how the TH2D is created. However, when I do Print(“all”) for both the TProfile2D and the derived TH2D, I see output like this:

.
.
.
fSumw[13][24]=0.454137, x=-1.5, y=0.94, error=0.885482
.
.
.

I compare the output from TProfile2D::Print(“all”) and TH2D::Print(“all”) and it’s exacly the same, including the error field which is what I assume it will try to draw. Certainly then, there is some other variable in the histogram objects that is used by Paint2DErrors(), and that variable is not being (or cannot be) set correctly. But, what varible is it?

mike kordosky

send me an example (histogram in a root file and a small macro).

Ok. Here you go:
root file
macro

Thanks!

mike kordosky

This problem is now fixed in the CVS head. Thanks to have reported it.