1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.3. How to Specify Materials in the Detector</title><link rel="stylesheet" href="../xml/XSLCustomizationLayer/G4HTMLStylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="Geant4 User's Guide for Application Developers"><link rel="up" href="ch02.html" title="Chapter 2. Getting Started with Geant4 - Running a Simple Example"><link rel="prev" href="ch02s02.html" title="2.2. How to Define a Detector Geometry"><link rel="next" href="ch02s04.html" title="2.4. How to Specify Particles"><script language="JavaScript"> |
---|
2 | function remote_win(fName) |
---|
3 | { |
---|
4 | var url = "AllResources/Detector/geometry.src/" + fName; |
---|
5 | RemoteWin=window.open(url,"","resizable=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,copyhistory=0,width=520,height=520") |
---|
6 | RemoteWin.creator=self |
---|
7 | } |
---|
8 | </script></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">2.3. |
---|
9 | How to Specify Materials in the Detector |
---|
10 | </th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter 2. |
---|
11 | Getting Started with Geant4 - Running a Simple Example |
---|
12 | </th><td width="20%" align="right"> <a accesskey="n" href="ch02s04.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sect.HowToSpecMate"></a>2.3. |
---|
13 | How to Specify Materials in the Detector |
---|
14 | </h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.GeneCons"></a>2.3.1. |
---|
15 | General Considerations |
---|
16 | </h3></div></div></div><p> |
---|
17 | In nature, general materials (chemical compounds, mixtures) are |
---|
18 | made of elements, and elements are made of isotopes. Therefore, |
---|
19 | these are the three main classes designed in Geant4. Each of these |
---|
20 | classes has a table as a static data member, which is for keeping |
---|
21 | track of the instances created of the respective classes. |
---|
22 | </p><p> |
---|
23 | The <span class="emphasis"><em>G4Element</em></span> class describes the properties of the |
---|
24 | atoms: |
---|
25 | </p><div class="itemizedlist"><ul type="disc" compact><li><p> |
---|
26 | atomic number, |
---|
27 | </p></li><li><p> |
---|
28 | number of nucleons, |
---|
29 | </p></li><li><p> |
---|
30 | atomic mass, |
---|
31 | </p></li><li><p> |
---|
32 | shell energy, |
---|
33 | </p></li><li><p> |
---|
34 | as well as quantities such as cross sections per atom, etc. |
---|
35 | </p></li></ul></div><p> |
---|
36 | </p><p> |
---|
37 | The <span class="emphasis"><em>G4Material</em></span> class describes the macroscopic properties |
---|
38 | of matter: |
---|
39 | </p><div class="itemizedlist"><ul type="disc" compact><li><p> |
---|
40 | density, |
---|
41 | </p></li><li><p> |
---|
42 | state, |
---|
43 | </p></li><li><p> |
---|
44 | temperature, |
---|
45 | </p></li><li><p> |
---|
46 | pressure, |
---|
47 | </p></li><li><p> |
---|
48 | as well as macroscopic quantities like radiation length, mean |
---|
49 | free path, dE/dx, etc. |
---|
50 | </p></li></ul></div><p> |
---|
51 | </p><p> |
---|
52 | The <span class="emphasis"><em>G4Material</em></span> class is the one which is visible to the |
---|
53 | rest of the toolkit, and is used by the tracking, the geometry, and |
---|
54 | the physics. It contains all the information relative to the |
---|
55 | eventual elements and isotopes of which it is made, at the same |
---|
56 | time hiding the implementation details. |
---|
57 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.DefSimpleMate"></a>2.3.2. |
---|
58 | Define a Simple Material |
---|
59 | </h3></div></div></div><p> |
---|
60 | In the example below, liquid argon is created, by specifying its |
---|
61 | name, density, mass per mole, and atomic number. |
---|
62 | </p><div class="example"><a name="programlist_HowToSpecMate_1"></a><p class="title"><b>Example 2.7. |
---|
63 | Creating liquid argon. |
---|
64 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
65 | G4double density = 1.390*g/cm3; |
---|
66 | G4double a = 39.95*g/mole; |
---|
67 | G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density); |
---|
68 | </pre></div></div><p><br class="example-break"> |
---|
69 | </p><p> |
---|
70 | The pointer to the material, <span class="emphasis"><em>lAr</em></span>, will be used to specify |
---|
71 | the matter of which a given logical volume is made: |
---|
72 | </p><div class="informalexample"><pre class="programlisting"> |
---|
73 | G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,"Lbox",0,0,0); |
---|
74 | </pre></div><p> |
---|
75 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.DefineMolecule"></a>2.3.3. |
---|
76 | Define a Molecule |
---|
77 | </h3></div></div></div><p> |
---|
78 | In the example below, the water, <span class="emphasis"><em>H2O</em></span>, is built from its |
---|
79 | components, by specifying the number of atoms in the molecule. |
---|
80 | </p><div class="example"><a name="programlist_HowToSpecMate_2"></a><p class="title"><b>Example 2.8. |
---|
81 | Creating water by defining its molecular components. |
---|
82 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
83 | a = 1.01*g/mole; |
---|
84 | G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); |
---|
85 | |
---|
86 | a = 16.00*g/mole; |
---|
87 | G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); |
---|
88 | |
---|
89 | density = 1.000*g/cm3; |
---|
90 | G4Material* H2O = new G4Material(name="Water",density,ncomponents=2); |
---|
91 | H2O->AddElement(elH, natoms=2); |
---|
92 | H2O->AddElement(elO, natoms=1); |
---|
93 | </pre></div></div><p><br class="example-break"> |
---|
94 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.DefMixtureByFractionalMass"></a>2.3.4. |
---|
95 | Define a Mixture by Fractional Mass |
---|
96 | </h3></div></div></div><p> |
---|
97 | In the example below, air is built from nitrogen and oxygen, by |
---|
98 | giving the fractional mass of each component. |
---|
99 | |
---|
100 | </p><div class="example"><a name="programlist_HowToSpecMate_3"></a><p class="title"><b>Example 2.9. |
---|
101 | Creating air by defining the fractional mass of its components. |
---|
102 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
103 | a = 14.01*g/mole; |
---|
104 | G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); |
---|
105 | |
---|
106 | a = 16.00*g/mole; |
---|
107 | G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); |
---|
108 | |
---|
109 | density = 1.290*mg/cm3; |
---|
110 | G4Material* Air = new G4Material(name="Air ",density,ncomponents=2); |
---|
111 | Air->AddElement(elN, fractionmass=70*perCent); |
---|
112 | Air->AddElement(elO, fractionmass=30*perCent); |
---|
113 | </pre></div></div><p><br class="example-break"> |
---|
114 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.DefMateFromDatabase"></a>2.3.5. |
---|
115 | Define a Material from the Geant4 Material Database |
---|
116 | </h3></div></div></div><p> |
---|
117 | In the example below, air and water are accessed via the Geant4 |
---|
118 | material database. |
---|
119 | </p><div class="example"><a name="programlist_HowToSpecMate_4"></a><p class="title"><b>Example 2.10. |
---|
120 | Defining air and water from the internal Geant4 database. |
---|
121 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
122 | G4NistManager* man = G4NistManager::Instance(); |
---|
123 | |
---|
124 | G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); |
---|
125 | G4Material* Air = man->FindOrBuildMaterial("G4_AIR"); |
---|
126 | </pre></div></div><p><br class="example-break"> |
---|
127 | </p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToSpecMate.PrintMateInfo"></a>2.3.6. |
---|
128 | Print Material Information |
---|
129 | </h3></div></div></div><p> |
---|
130 | </p><div class="example"><a name="programlist_HowToSpecMate_5"></a><p class="title"><b>Example 2.11. |
---|
131 | Printing information about materials. |
---|
132 | </b></p><div class="example-contents"><pre class="programlisting"> |
---|
133 | G4cout << H2O; \\ print a given material |
---|
134 | G4cout << *(G4Material::GetMaterialTable()); \\ print the list of materials |
---|
135 | </pre></div></div><p><br class="example-break"> |
---|
136 | |
---|
137 | In <code class="literal">examples/novice/N03/N03DetectorConstruction.cc</code>, you |
---|
138 | will find examples of all possible ways to build a material. |
---|
139 | </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch02.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch02s04.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">2.2. |
---|
140 | How to Define a Detector Geometry |
---|
141 | </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="AllResources/IconsGIF/home.gif" alt="Home"></a></td><td width="40%" align="right" valign="top"> 2.4. |
---|
142 | How to Specify Particles |
---|
143 | </td></tr></table></div></body></html> |
---|