Bug plotting TStrings in trees


I think I’ve found a bug when plotting strings in a tree using the ‘same’ drawing option. I’ve attached a short macro reproducing the problem.

I create a small tree that has a TObjString and a float parameter. The TObjString only takes one of four values {case1, case2, case3, case4}.

I histogram the TObjString (using the Draw command with .String() )

Next I overlay a second histogram of the same parameter (using the “same” option) but with a cut on my float parameter.

All bin contents should be smaller after the application of the cut, but this is not what I see (the second histogram is colored red).

I believe this is because when I redraw the histogram, root assigns new bin ids to each type of string, and does not respect the existing histogram in the pad.

example.C (1.07 KB)

sorry - forgot to include my system details

I took the root svn trunk from a few weeks ago, the revision ID is 31880. Sorry for not testing on a released version - I needed the trunk as it has a bug fix I needed

I’m on OS X 10.6.2 running gcc 4.2.1

Hi Peter,

Indeed, I can reproduce the problem; we will investigate this issue.


The labels are not ordered the same way for the two histograms (see picture).
The way to order the labels is explained here:


Ie, do:

  TH1F *h2 = (TH1F*)gPad->GetListOfPrimitives()->FindObject("h2");
  if (h2) {
  TH1F *h1 = (TH1F*)gPad->GetListOfPrimitives()->FindObject("h1");
  if (h1) {

Hi Olivier,

thanks for the work around