Louis Bianchini
CERN Physicist ∶ Software Engineer


Programming Humanity is overrated.

To give a bit of motivation, when running a particle physics analysis one needs to consider different systematic effects.
The correct way to do this involves applying one systematic effect at a time to the analysis procedure. Thus, in order to produce the analysis with systematics requires looping over all possible systematic effects. One could handle these systematics as a string and loop over a container of all strings, or store these in a JSON/XML file and parse it. Of course in C++, this is describing a single particular value among a list of pre-defined values which is perhaps best handled by an enum. Still, when faced with an enum type how does one loop over all possible values?

Recently at an interview I was given a small coding question to write a function which would return values with differing probability. The setup was this:

If we follow the ROOT user’s guide, then code like the following ends up being fairly common: