where physics and life collide
The ROOT of all my frustrations
If you work in high energy physics (HEP) you almost certainly come in contact with some software called ROOT on a very regular basis. ROOT is a collection of tools and a framework of C++ classes developed at CERN specifically for the data collection and processing that many physicists perform. It defines a “Tree” format designed specifically for HEP data (the name is a play on the name ROOT and not much of a tree in the classic algorithms-and-data-structures sense), it produces nearly all the plots that we show each other at meetings, and it provides a C++ environment that can be used both interactively and compiled. (There is also a Python interface which I actually use more often these days.) If you use something every day you are bound to become frustrated with it in some way or another. Unfortunately, ROOT’s annoyances are very pernicious:
- Its default behavior is to produce hideous plots, and
- Every now and then you can come up with the simplest of goals (something such as “set the color of these histograms to red”) that teases you with the prospect of an easy solution but instead sucks you into a whirlwind of failure that invariably transports you to the colorful land of the ROOT source code where you search for a way home skipping from function call to function call until you find the solution didn’t make any sense at all but was right in front of you the whole time. If you are luck enough to reach this point it is probably 4am.
These issues frustrate my personality especially because
- I’m particular when it comes to aesthetics, and
- I’m a stubborn optimist always willing to stay up just a little bit longer.
This post will feature a couple examples of item 1, but the infinitely long scroll of bits that this blog could fill is just barely long enough for the further rants I may produce.
Below is an example of two fitted histograms. The left is a plot drawn with the default style and the right is using the “Plain” style. There are two main issues with the default style: the uniform gray background makes it an eyesore on almost any white page or white presentation background, and the last time the chamfering and shadow effects were cool was back in 1995. I have seen no circumstance in which the “Plain” style on the right wasn’t a clearly better choice.
What’s madding is the Plain style can be enabled with one simple line of code, and yet after I started using ROOT every day and was immediately struck by these offensive plots I went months between the stages of realizing
- The backgrounds of my plots are not just a stupid mistake on my part;
- I can fix this with five lines of boilerplate code at the top of all my programs;
- I can put this code in a configuration file that appears in every directory where I run;
- I can set a ROOT path and put this code in a single configuration file for my entire login session; and finally,
- That there are perfectly good styles build into the code called “Plain” and “Pub” that setup every as you wanted it to begin with using a single line of code.
These days when I see a presentation with these ugly gray backgrounds I presume the presenter has either not been using ROOT for very long (at least not long enough to produce a publication, since no publication would accept such plots), or they are still on stages 2 or 3 and the plots where made in a hurry. Both of these scenarios are common.
What’s even more maddening is that I didn’t reach stage 5 by reading the documentation, which really needs to begin with
In order for your ROOT plots to not suck be sure to set a Unix.*.Root.MacroPath: in your ~/.rootrc file and then add gROOT->SetStyle(“Plain”); to a rootlogon.C file somewhere in this path.
Admittedly, this style setting stuff is in the documentation, but a section called “Create or Modify a Style” is not one you would read too carefully when you are rushing to make plots for your next presentation. Instead, I came upon the “Plain” and “Pub” styles by finding them in the source code while on one of those lovely journeys mentioned in item 2 of my opening.
Finally, here is another example of crap that ROOT gives you by default. It’s possible the default plot offers some advantages to those who are color blind or to those who are 13 years old and are really trying to piss me off, but otherwise why? Why?
| Print article | This entry was posted by lots-o-love on 16 October 2009 at 08:00, and is filed under Science's cutting edge. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |










about 10 months ago
I am still on stage 2 and I am using root for 5 years
about 10 months ago
Hi, I’m a ROOT developer, and yes you are right in many of the things you say. I have also had many frustrations with ROOT, probably many more than you could ever expect.
I don’t want to justify anything or pretend I’m selling a product. I just want to give you a friendly advice that might help you ‘feel better’ when anything like this happens to you again. Whenever you think something in ROOT is very odd, think twice, there is always a reason, for good or for bad….
Consider that ROOT is a software that is more than 15 years old! Not only that, but at the beginning it was an almost direct implementation of PAW, that is even older. Between the physics community there are plenty of people that need (for whatever the reason, I could give you many) backward compatibility. That means you have to keep things sort of ‘stable’ in the design. Just this thought might give you the answer to many of the questions you just mentioned. For example, the default colors on the 2D histogram… are the palette of 16 colors computers used about 20 years ago!
I really hope this helps!
about 9 months ago
Wow David,
For example, the default colors on the 2D histogram… are the palette of 16 colors computers used about 20 years ago!
Thanks for that comment. That’s amazing. I personally think the default style is okay for a computer screen. Terrible for presentation or document. For you developers it’s very difficult just to find the part about the plain style.
I think ROOTs great all in all, but I bet there are a few things like things this that seem very common but are very difficult to find in the docs or on the webpage.
Elliott
about 9 months ago
David,
If I was aiming for a longer post I certainly would have mentioned ROOT’s PAW roots (hey, a pun, what a way to start!), but I don’t see how the history sheds any positive light. I’m sure there are reasons for most of the design choices in ROOT, but I really hope they are better than “this is the way PAW did it.” I can’t imagine a worse reason (well, beyond egregious ones like “I don’t know” or “we want to make this painful for you”). The age of ROOT might excuse it for some quirks like not using the STL, but regarding the issues I mentioned in this post I see no excuses. Switching the default background of pads to flat white will not break any code, in fact it could do nothing but spread goodness through the HEP community. Elliot says the default style is “okay for a computer screen” and I agree, but I don’t know anyone who actually prefers it to white in any output media. And, once you go to print the default style is absolutely terrible.
The issue of the default palette is similar. First of all, I don’t see how the default palette could be “the palette of 16 colors computers used about 20 years ago”. The default palette has 50 colors! Maybe this 16 color palette is some subset? For reference here are some 8-bit computer palettes In ROOT’s palette the first 8 colors are grays and at least the next 8 are reddish browns. The last 8 are fully saturated colors, but here the color red is repeated twice! (Note: the first 16 colors by color index makes a more plausible palette, they are mostly grays or saturated colors; but even here there are quirks, like the two whites, (1.0,1.0,1.0) and (0.999, 0.999, 0.999).) It’s certainly a mystery how this evolved out of a simpler primitive palette. Obviously the larger palette was chosen at some point, in which case the question remains, why these colors? A hint comes from the ROOT documentation where it says “the colors defined in [the default] palette are good for coloring pads, labels, and other graphic objects.” Does anyone actually use the palette for coloring pads? I’ve only been working in HEP for 5 years, but still, in all that time I have never seen any work that seemed to use the color palette as-is except in the case of a 2D histogram (and maybe for an array of stacked histograms, but usually this could just be a set of consecutive color indices). Notice also that the description of TColor::SetPalette() only mentions the 2D histogram example. The description even makes some erroneous claims about the palette colors; for example, palette colors 19 and 20 are distinctly green, not “brown” or “blueish.”
In addition, I hinted at a serious practical problem when making 2D histograms with the default palette. Even if you ignore the ugliness (maybe you even think it is beautiful), you can’t ignore the fact that colors are repeated, but in a an irregular way. You can see for yourself in the code, the red (index 2) is repeated near the end of the palette. Also, there are some brown colors which are very similar but occur in disjoint groups. This certainly aggravates the interpretation of the plots when using this palette. Finally, while I was poking around just now I noticed that the issue of repeated reds is not present in older versions of TStyle::SetPalette(), which is a really strange thing.
All of this goes to show that the default palette in ROOT is truly a mess. Thus, I’d be amazed if it is used for anything but offending our eyes. So why not change the default and save future users a little aggravation that spread over thousands of users becomes a lot of aggravation? In the rare case of an application expecting the old palette but needing to use a new version of ROOT one need add only a single line: gStyle->SetPalette(0). And as for changing the default TPad background, I could imagine even fewer unpleasant consequences for old code. Such changes are only cosmetic, with no change in the interfaces needed. There is no substantial issue of backwards compatibility.
about 6 months ago
Thanks for useful hints there – step 5 should save me a lot of time!
Another example of ROOT pain – a ridiculous amount of code to set label size in pixels, and this has to be done for every label!
http://root.cern.ch/root/roottalk/roottalk97/1194.html
about 5 months ago
There is much better doc about the color palettes in ROOT:
http://root.cern.ch/root/html/TColor.html
http://root.cern.ch/drupal/content/how-define-smooth-color-palette
about 2 months ago
I think they’ve made good default’s choices. Thanks to that terrible style, I can easily ID newbies, in presentations.