12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Detector Definition and Response4.2.2.4. Final ConsiderationsThe classes will automatically decide if the total of the mass fractions is correct, and per<strong>for</strong>m the necessary checks.The main reason why a fixed index is kept as a data member is that many cross section and energy tables willbe built in the physics processes "by rows of materials (or elements, or even isotopes)". The tracking gives thephysics process the address of a material object (the material of the current volume). If the material has an indexaccording to which the cross section table has been built, then direct access is available when a number in such atable must be accessed. We get directly to the correct row, and the energy of the particle will tell us the column.Without such an index, every access to the cross section or energy tables would imply a search to get to the correctmaterial's row. More details will be given in the section on processes.Isotopes, elements and materials must be instantiated dynamically in the user application; they are automaticallyregistered in internal stores and the system takes care to free the memory allocated at the end of the job.4.2.3. Recipes <strong>for</strong> Building Elements and MaterialsExample 4.10 illustrates the different ways to define materials.Example 4.10. A program which illustrates the different ways to define materials.#include "G4Isotope.hh"#include "G4Element.hh"#include "G4Material.hh"#include "G4UnitsTable.hh"int main() {G4String name, symbol;G4double a, z, density;G4int iz, n;G4int ncomponents, natoms;G4double abundance, fractionmass;G4double temperature, pressure;// a=mass of a mole;// z=mean number of protons;// iz=nb of protons in an isotope;// n=nb of nucleons in an isotope;G4UnitDefinition::BuildUnitsTable();// define Elementsa = 1.01*g/mole;G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);a = 12.01*g/mole;G4Element* elC = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);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);a = 28.09*g/mole;G4Element* elSi = new G4Element(name="Silicon", symbol="Si", z=14., a);a = 55.85*g/mole;G4Element* elFe = new G4Element(name="Iron",symbol="Fe", z=26., a);a = 183.84*g/mole;G4Element* elW = new G4Element(name="Tungsten" ,symbol="W", z=74., a);a = 207.20*g/mole;G4Element* elPb = new G4Element(name="Lead",symbol="Pb", z=82., a);// define an Element from isotopes, by relative abundanceG4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);G4Element* elU = new G4Element(name="enriched Uranium", symbol="U", ncomponents=2);elU->AddIsotope(U5, abundance= 90.*perCent);elU->AddIsotope(U8, abundance= 10.*perCent);cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!