Hating ROOT

ROOT, produced at CERN, seems to be pretty much the standard software package for data visualization, and often also storage, in experimental particle physics and in particle astrophysics. Which means that I'm expected to use it at my job, as I was also at my previous job. The only problem is that I hate ROOT. SOme other time I'll compose an entire rant about why I hate ROOT, but today I have an example. For the past day I have been trying to fix a bug in a macro I wrote to generate some plots. Here's the error message I was getting:

Syntax Error: %6] compare2.C:162:
*** Interpreter error recovered ***

And here's the line of code to which it was referring, which, it is worth noting, is not line 162, but 192:

lineDiffHists[(j+tallest)%6]->SetLineStyle(doubleStyles[(j+tallest)%6]);

There is nothing fundamentally wrong with that line of code. lineDiffHists is an array of size of pointers to histogram objects, and doubleStyles is an array of size 6 of line styles with which to style the aforementioned histograms. Thanks to one of ROOT's many stupidities, in order to make all of the histograms fit comfortably on the same plot without any of them being clipped, the tallest one must be drawn first. Earlier in the code tallest is computed to be the index of the histogram with the highest peak. Then, a simple loop of the index j from 0 to 5 will do every operation starting with the tallest histogram if every array access uses the expression (j+tallest)%6 for the index. Nothing special.

Seeing the above error message, I was confused, so i tried writing the line more explicitly as:

lineDiffHists[((j+tallest)%6)]->SetLineStyle(doubleStyles[((j+tallest)%6)]);

This should have the exact same meaning, but I was hoping that maybe the problem was just CINT's1parser failing to handle this dense pile of symbols correctly, and that I could help it out with some extra clarity. Nope! After that I got this message:

Error: Symbol ] is not defined in current scope compare2.C:162:
*** Interpreter error recovered ***

That's clearly so much better, since the meaning of the ']' character is defined by the language, rather than by me. As it happens, there was a tiny, literally single character typing error in my macro, which did cause this line to fail. The thing is, strictly speaking, it's not on this line. What actually happened was that a hundred lines before I had entered this:

const int doubleSTyles[6] = {1,1,1,2,2,2};

A quick glance shows that I accidentally capitalized the 'T' in the variable name. Now to a compiler, the name with the capital 'T' is acceptable and the rest of the program must conform to it. But this means we would surely expect to see this, right?

Error: Symbol doubleStyles is not defined in current scope compare2.C:192:
*** Interpreter error recovered ***

If I'd seen this error message, it would have been immediately clear that the problem had to do with the interpreter recognizing that variable, and I'm certain I would have found the bug in about 30 seconds. As it was, it took me the first ten minutes just to find out what line the error was really on, thanks to the wrong line number that CINT reported. The only way I did narrow it down was by inserting print statements and rerunning the macro, because I have several dozen appearances of %6] in the code. This took some time becaue the macro takes about 3 minutes to run to the point where CINT would notice and report the error.

Thanks for wasting several hours of my life, ROOT, especially on Saturday.


  1. CINT is the C Interpreter used by ROOT, which actually doesn't quite adhere to the rules of either C or C++, but comes close to both. 

No Comments

Comment on this post