Global variable

I think there are a few ways to do this, but I am not sure of the best way.

I would like to have a variable amount of pixels in my simulation. I only would change this number between application builds, not during a run. Currently I have a variable in my detector construction and can easily change. However, as I move to data processing, I would like to do some summations and initialize arrays with this number of pixels, so I need to access it in run manager, steppingmanager, etc. I can make a getter for the detector construction class and call the variables, but only if I instantiate the detector construction, which seems wasteful to do many times.

What would be the correct way to have a global variable like this that I can easily access from any of my .cc files?

I have solved this problem by:
Making pixel # a static variable of the class
Making getPixels a static function of the class
Defining the pixel number in the top namespace of Detectorconstruction.cc via
int DetectorConstruction::pixels = ;