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:

  1. Its default behavior is to produce hideous plots, and
  2. 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

  1. I’m particular when it comes to aesthetics, and
  2. 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.

Histograms plotted with the default (left) and "Plain" (right) styles

Histograms plotted with the default (left) and "Plain" (right) styles

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

  1. The backgrounds of my plots are not just a stupid mistake on my part;
  2. I can fix this with five lines of boilerplate code at the top of all my programs;
  3. I can put this code in a configuration file that appears in every directory where I run;
  4. I can set a ROOT path and put this code in a single configuration file for my entire login session; and finally,
  5. 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?

2D histograms plotted with the default palette (left) and SetPalette(1) (right)

2D histograms plotted with the default palette (left) and gStyle->SetPalette(1) (right)