Tag Archives: c++

Using GEANT4 (Still for Dummies) Part 1: Some notes on C++

While in the process of diving straight into a GEANT4 example (the subject of part 2), it occurred to me that a note on programming in C++ would be of use.

Making a model in GEANT4 requires the use of C++ to build the model. A model therefore requires a main(), source files, and header files, as a minimum. It is useful to at least be aware of some general programming concepts, and their application to C++ in particular.

The C++ features that GEANT4 uses are:

  • Inheritance.
  • Singletons.
  • Templates.
  • Classes.
    • Constructors/destructors, methods and arguments, constant initialisation and operator overloading.

I am not going to go into detail on these, because more comprehensive explanations are available in textbooks and online, and I consider the purpose of this series of posts to be a collection of information that is not necessarily as readily available. Here is a useful link, which gives an overview of C++ programming.