That “Aha!” moment in C++

One of my responsibilities as a CMS physicist is developing C++ and python code using the framework, CMSSW. The coding standards are very high for CMSSW, with strict checking and treating warnings as errors, so even the slightest lapse in safety causes compile errors. I just came across a build error because I tried to pass a const instance of class as an argument to a method and using a non const method of that class, giving the error message:

error: passing ‘const PixelMatchSParameters’ as ‘this’ argument of ‘float PixelMatchSParameters::sPhi1B()’ discards qualifiers

It had been a while since I’d seen this error, so I had to look it up and when it did, and I realised the problem a smile spread across my face. There’s something beautiful about how strongly cast C is, and how strict C++ forces you to be when passing around objects. When the code is clean and safe it’s something I can be proud of, and that’s one of the reasons I love C++. (On the other hand there are times when C++ makes me want to pull my hair out, but they are often the result of poorly documented code, or working with someone else’s perverse design choices.)

I’ve been developing in C and C++ for about a decade now, but so far I have not created my own standalone project from scratch before without building upon some other framework. Perhaps it’s time I did.

Accelerator future prospects plot

This project was written as part of the content for a talk presented at the International Workshop on Future Linear Colliders to compare the future prospects of the LHC and lepton colliders. It is shared here in case it is of use for other physicists.

Links

GitHub repository

Overview

This project simply plots a series of graphs.

Challenges

Challenge: Using a TMultigraph in pyroot is not easy.
Solution: In order to make this work I had to use the array module, a step I usually forget! This macro should save me a few headaches in the future. (Resolved.)

Output

Future prospects of various accelerators
Future prospects of various accelerators