Overview Contents Previous Next Geant4 User's Guide
For Application Developers
Getting Started with Geant4

2.3 How to Specify Materials in the Detector

2.3.1 General Considerations

In nature, general materials (chemical compounds, mixtures) are made of elements, and elements are made of isotopes. Therefore, these are the three main classes designed in Geant4. Each of these classes has a table as a static data member, which is for keeping track of the instances created of the respective classes.

The G4Element class describes the properties of the atoms:

The G4Material class describes the macroscopic properties of matter:

The G4Material class is the one which is visible to the rest of the toolkit, and is used by the tracking, the geometry, and the physics. It contains all the information relative to the eventual elements and isotopes of which it is made, at the same time hiding the implementation details.

2.3.2 Define a Simple Material

In the example below, liquid argon is created, by specifying its name, density, mass per mole, and atomic number.

  G4double density = 1.390*g/cm3;
  G4double a = 39.95*g/mole;
  G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density);
Source listing 2.3.1
Creating liquid argon.

The pointer to the material, lAr, will be used to specify the matter of which a given logical volume is made:

  G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,"Lbox",0,0,0);

2.3.3 Define a Molecule

In the example below, the water, H2O, is built from its components, by specifying the number of atoms in the molecule.

  a = 1.01*g/mole;
  G4Element* elH  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);

  a = 16.00*g/mole;
  G4Element* elO  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);

  density = 1.000*g/cm3;
  G4Material* H2O = new G4Material(name="Water",density,ncomponents=2);
  H2O->AddElement(elH, natoms=2);
  H2O->AddElement(elO, natoms=1);
Source listing 2.3.2
Creating water by defining its molecular components.

2.3.4 Define a Mixture by Fractional Mass

In the example below, air is built from nitrogen and oxygen, by giving the fractional mass of each component.

  a = 14.01*g/mole;
  G4Element* elN  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);

  a = 16.00*g/mole;
  G4Element* elO  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);

  density = 1.290*mg/cm3;
  G4Material* Air = new G4Material(name="Air  ",density,ncomponents=2);
  Air->AddElement(elN, fractionmass=70*perCent);
  Air->AddElement(elO, fractionmass=30*perCent);
Source listing 2.3.3
Creating air by defining the fractional mass of its components.

2.3.5 Define a Material from the Geant4 Material Database

In the example below, air and water are accessed via the Geant4 material database.

  G4NistManager* man = G4NistManager::Instance();

  G4Material* H2O  = man->FindOrBuildMaterial("G4_WATER");
  G4Material* Air  = man->FindOrBuildMaterial("G4_AIR");

Source listing 2.3.4
Defining air and water from the internal Geant4 database.

2.3.6 Print Material Information

  G4cout << H2O;                                \\ print a given material
  G4cout << *(G4Material::GetMaterialTable());  \\ print the list of materials
Source listing 2.3.5
Printing information about materials.

In examples/novice/N03/N03DetectorConstruction.cc, you will find examples of all possible ways to build a material.

About the authors