As any GEANT4 introduction will earnestly tell you, GEANT4 is a toolkit. In practice, this means there are a great many methods of design and implementation such that when you start learning about all the options, you feel as though you’re using a wrecking ball where a screwdriver might do (to belabour the metaphor).
A GEANT4 installation comes with a number of example simulations, which are very useful, cover a wide range of situations, and may be modified to fit your purpose. The README.txt file in the basic/, advanced/, and extended/ directories give a summary of the purposes of the simulations in each directory. Going further into the directories B1/, B2/, B3/, and so forth, a further README.txt file gives more in-depth information about each simulation (for example, the source, geometries, and physics used).
Different things are defined in different sections of the code. Using the basic B1 simulation as an example, I will describe what these different sections are doing.
Geometries, materials, fields, sensitive detectors – DetectorConstruction()
In the DetectorConstruction() class, geometries, materials, fields and sensitive detectors are defined.
Since materials are the simplest to explain, I shall start with them.
Some materials are predefined in GEANT4, a list of these can be found here. If you wish to make use of these, the relevant header file must be included with the other headers:
Within the G4VPhysicalVolume constructor, to get the NIST materials manager and choose one of the predefined materials in this manner :
G4NistManager* nist = G4NistManager::Instance(); G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
The NIST manager can also be used to define materials made of a single element, in a similar manner.
You can also define your own materials. This is not shown in example B1, but can be done like this:
G4Element* Cd = new G4Element("Cadmium","Cd",48., 112.41*g/mole); G4Element* Zn = new G4Element("Zinc","Zn", 30., 65.38*g/mole); G4Element* Te = new G4Element("Tellurium","Te", 52., 127.60*g/mole); G4Material* CZT = new G4Material("CZT", 5.8*g/cm3, ncomponents=3); CZT->AddElement(Cd, 48*perCent); CZT->AddElement(Zn, 02*perCent); CZT->AddElement(Te, 50*perCent);
More to follow.