# Day 2 - Exercise Geant4 Materials

## OBJECTIVE

Learn how to create and use a materials

## HOW

• unpack the code for this exercise into your working directory
```	% cd ~/g4course2011
% wget http://www.ifh.de/geant4/g4course2011/day2b.tgz
% tar xzf day2b.tgz
% cd day2b
```

• compile and generate an executable:
```	% gmake clean
% gmake -j2
```

• execute 'calorimeter' in interactive mode
```        % \$G4WORKDIR/bin/\$G4SYSTEM/calorimeter
....
Idle> # type your commands. example:

Idle> /run/beamOn 1
....
Idle> exit
```

In this exercise you will be asked to create the material used for the electromagnetic calorimeter of the exercise. The relevant method to look at is in DetectorConstruction::DefineMaterials()

Look at the code there in file src/DetectorConstruction.cc , the line

```G4cout<<*(G4Material::GetMaterialTable()) <<G4endl;
```

added at the end of the function prints the list of known materials.

## PRACTICE

### Hint - Deactivate Qt UI

Activate the vanilla Geant4 interface for this exercise.
```	% unset G4UI_USE_QT
% unset G4UI_USE_XM
```
as we are mainly looking to the text output.

### Exercise 2.2.1 - Simple Elements

• Define the Element Nitrogen with a variable name "N" and z=7 a= 14.01 g/mole
• Define the Element Hydrogen with a variable name "H" and z=1 and a molar mass 1.01 g/mole
• Compile, run your code, check the output

### Exercise 2.2.2 - Element with Isotopes

• Define the Isotope O_16 with a variable name "O16", z=8, N=16 and a= 15.99 g/mole
• Define the Isotope O_17 with a variable name "O17", z=8, N=17 and a= 17.00 g/mole
• Define the Isotope O_18 with a variable name "O18", z=8, N=18 and a= 18.00 g/mole
• Define the Element O with a variable name "O", sybole "O" and give the number of components of this new element.
• Add the three isotopes O16, O17 and O18 to the Element O with the correct abundances in percent (see above)
• Compile, run your code and check if your new Element O is registered. (use the command /material/g4/printElement in the UI terminal)

### Exercise 2.2.3 - Materials I

• Define Lead as a pure material with a variable name Pb, atomic number 82, molar mass 207.19 g/mole and a density of 11.35 g/cm3

• Define the air material with a variable name "Air", density = 1.29 mg/cm3 and number of element 2, State=Gas, temperature = 300. kelvin, pressure = 1 atm
• Use the method "AddElement" and give the the percentage of each used element. 70% Element Nitrogen (N) and 30% Element Oxygen (O)
• Compile, run your code and check if your material is registered. (it should be printed out)

### Exercise 2.2.4 - Materials II (optional)

Define Water as a material made of 2 atoms of Element Hydrogen (H) and 1 atom of Element Oxygen (O)
• Define the material with a variable name "Water", density = 1.0 mg/cm3 and number of element 2
• use the method "AddElement" and give the number of each used element. (2 atoms of Element Hydrogen (H) and 1 atom of Element Oxygen (O))
• Compile, run your code and check if your material is registered. (it should be printed out)

### Exercise 2.2.5 - Nist Materials

Defining Materials using Geant4 NIST DataBase
• Define a Nist manager with a variable name Nistman (or as you want!) :-)
• find or build (I mean define) the following materials: Tungsten, Aluminium, plastic-scintillator and glass.
• Compile, run your code and check if your material is registered. (it should be printed out)
• Is the difference with the material defined by hand, or provided via Nist?

### Exercise 2.2.6 - Materials III (optional)

Assign now the implemented materials to the corresponding logical volumes.

Generated on Wed May 11 15:39:24 2011