Mysterious disappearing histogram titles

I have a reproduceable bug in Root version 4.X. If you run the attached macro in batch mode (-b), you should find that in one of the output files (pads2x3.ps), the histogram is missing its title. The title is there if run in interactive mode, and is there for Root versions 3.X and 5.X, from what I can tell from the numerous versions of Root that I’ve tried.

The 2x1, 2x2, and 2x4 plots look fine. It only happens to occur for 2x3. And the title text really is absent from the postscript file (I have looked at the postscript code and a 0 exists where the text should be), and is absent from pdf files if I choose to save to pdf instead.

The only technique I’ve found for reliably making the problem not happen for THIS histogram is to change the histogram title in ANY way (add a character, remove a character, replace a character). However, this is an unsatisfactory option, as there are other histogram titles which fail/don’t fail at other pad sizes (i.e. I might fix this for all the current histograms I have when displaying 2x3 by editing the titles, but I cannot then guarantee the titles will appear if I instead use 2x2 or 2x4, etc.). So, I do not see this as a viable solution.

I have not found what change in Root between versions 4 and 5 fixed the issue, and honestly I’m not quite sure how to figure it out. I have no idea what piece of code would be responsible for this bug! I’ve searched the CVS histories of TPad and TVirtualPad for “batch” for relevant changes, but nothing obvious appears.

I am hoping someone here knows what changes to Root might have affected this so that perhaps we can patch the Root vers. 4.04.02 that we currently use in our experiment. Anyone?

Thanks for any help,
-Gene
bad_titles.C (432 Bytes)

I just had a quick look and I think I found the fix. I think it is the revision 1.20 of TPaveText:

root.cern.ch/viewcvs/graf/src/TPaveText.cxx

it says:

This correspond to the symptom you see.
You will find the differences here:

root.cern.ch/viewcvs/graf/src/TP … 19&r2=1.20

Thanks for the suggestion! TPaveText seems an obvious place to look, in hindsight. However, we are in fact using TPaveText.cxx version 1.20 in Root version 4.04.02 where we are experiencing the problem.

-Gene

Ok, I have the exact version number now. I will investigate a more.

Olivier, if it’s any further help…

In the versions of Root that I’ve tested, the problem appears between Root versions 3.10.01 and 4.00.04. It then disappears between 4.04.02 and somewhere in the 5.X range. I’m sorry that I don’t know that version number more specifically as all I’ve got from the 5.X series is the latest.

-Gene

I have scanned all the obvious places. And I could not find nothing as good as the suggestion I sent you. Seems to me that is the only explanation. I will have a closer look tomorrow with the new versions ranges you gave me.

Olivier, I’m a bit curious about your patch for TPaveText.cxx 1.19 -> 1.20. Your restriction that the text be a maximum of 0.92 times the box widith instead of 0.96 seems a little bit ad hoc: 0.96 should already not draw outside the pave frame. Perhaps whatever deeper bug was causing text to draw outside the frame with 0.96 could still occur when using 0.92, but under fewer circumstances…some fortuitous string of characters that adds up to a specific number of pixels perhaps?

Also, interestingly, my bug only occurs in batch mode (root -b). Run the exact same code interactively and the text will appear in the postscript file. Did you see that symptom before?

I’m additionally beginning to wonder if this is a bug which is actually there in Root versions 3.X and 5.X, but that small changes to the sizes/margins/colors/something between those versions were enough to cause my particular bad titles to appear (while perhaps other titles might disappear). I do know that in Root 4.04.02 the histogram title of my example macro reappears at smaller pad sizes (see the pads2x4.ps file), but that other histogram titles disappear. So it really is some particular combination of sizes and text strings.

Thanks,
-Gene

Gene,

In the latest ROOT version, I have undone the famous Revision 1.20 in TPaveText. I went back to 1.19, and the bug reapeared ! So, clearly, this fix is the explanation of what you observe. (I am running on Linux).

Olivier

OK. I believe you that it is the same bug…

But I’m still experiencing the problem even with vers. 1.20 in Root 4.04.02.

-Gene

I believe you too, but the only way I could reproduce your problem was to roll back that one.
:frowning:

Olivier:

I confirmed your finding that modifying TPaveText.cxx’s 0.92 value back to 0.96 in the latest Root 5 does make the titles disappear again. Now I’m wondering how you were able to determine that this maximum width was the problem in the first place way back when you provided that fix. Was the 0.96 -> 0.92 modification simply an educated guess that worked for you? I’m not sure I’m going in the right direction if I modify this value in Root 4.04.02 until my titles begin appearing again there.

I think it’s somewhat humorous that we’ve learned how to make the problem occur again, but not how to prevent it :slight_smile:

Thanks,
-Gene

When a text is clipped in a PS file the all text is dropped. When the title is close to the pad border and when the title goes out of the frame you are in that case. When a string is long and the PS text legnth might be a bit different from the Pad text lengh. Plus, a margins in need inside the box. that is how we found .92 (in some caes .96 was not enough). But that changes is more than one year old and I must admit I do not remember all the details.
Like you I find a bit strange that you we found how to reproduce the problem but not the way to fix it.

I’ve figured out a temporary patch that seems to work: set the alignment of the text to “left”. Doing this seems to show how the text is running past the edge of the box under these mysterious problem conditions.

gPad->Draw(); TList* list = gPad->GetListOfPrimitives(); TPaveText* pp=0; int li = 0; while (!pp) { if (li == list->GetSize()) { printf("ERROR!!!\n"); return; } TObject* lobj = list->At(li++); if ((lobj->IsA() == TPaveText::Class()) && (!strcmp(lobj->GetName(),"title"))) pp = (TPaveText*) lobj; } pp->SetTextAlign(12);

To recap, part of the problem goes away with left alignment:

  • titles re-appear…
  • but titles run past the edge of the box

I’ve found in my own code that I only need to do this for histogram titles which are longer than 38 characters for 3 columns of histograms, and longer than 60 characters for 2 columns.

-Gene

Hi Gene,
Ok, may be that is the best solution until to switch to version 5.

Olivier