Drawing errors on a TH2 in the colz style?


My question seems simple, but I can’t quite find a satisfactory answer. If I have a TH2D h that has been filled, potentially with fractional weights (and certainly with Sumw2() called before filling), how can I draw the Sumw2 errors for each bin in the “colz” style? I would like to do something like the following:

// TH2D *h has already been declared and filled by here.
TCanvas *c = new TCanvas("c","c",1000,1000);

h->Draw("colz"); // gives a display of the contents of h

h->DrawSumw2Error("colz"); // THIS IS WHAT I WANT TO DO, IS THIS POSSIBLE? 

I am aware that h can be drawn with the various E options but this gives a 3D view and is not what I want. I want a 2D colour-coded map of the Sumw2 errors, so that each bin value in the drawn histogram of errors is the square root of the Sumw2 value for that bin in h.

I can create a whole new histogram hErr with the same size as h and loop over the bins, using SetBinContent() to assign values of sqrt( h->GetBinError(the_bin) ) to the same bin in hErr, and then draw hErr with the colz option. But I feel like this functionality might already be provided in the TH2 class and I just can’t find it. Any suggestions?

Thank you.

The available drawing options are described in: THistPainter

Thank you for the reply. Yes I have already seen the options in THistPainter, but all of the various “E” options don’t draw what I’ve described above. Does this mean that a simple 2D histogram of the errors in a TH2 cannot be drawn without first manually filling a new TH2 using GetBinError?

Yes the option E for 2D histogram produces 3D errors bars. If you want to Draw only the errors as a COL plot like a normal 2D histogram you will need to create a such histogram. The combination of “COL” and “E” options is not implemented.

Thank you @couet, that makes it clear. This might be an attractive drawing option for future implementation.