source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch02s03.html @ 901

Last change on this file since 901 was 901, checked in by garnier, 16 years ago

Add Geant4 Documentation at 8.12.2008

File size: 8.6 KB
Line 
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">
2function 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. 
9How 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. 
11Getting 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. 
13How 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. 
15General Considerations
16</h3></div></div></div><p>
17In nature, general materials (chemical compounds, mixtures) are
18made of elements, and elements are made of isotopes. Therefore,
19these are the three main classes designed in Geant4. Each of these
20classes has a table as a static data member, which is for keeping
21track of the instances created of the respective classes.
22</p><p>
23The <span class="emphasis"><em>G4Element</em></span> class describes the properties of the
24atoms:
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>
37The <span class="emphasis"><em>G4Material</em></span> class describes the macroscopic properties
38of 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>
52The <span class="emphasis"><em>G4Material</em></span> class is the one which is visible to the
53rest of the toolkit, and is used by the tracking, the geometry, and
54the physics. It contains all the information relative to the
55eventual elements and isotopes of which it is made, at the same
56time 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. 
58Define a Simple Material
59</h3></div></div></div><p>
60In the example below, liquid argon is created, by specifying its
61name, 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. 
63Creating 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>
70The pointer to the material, <span class="emphasis"><em>lAr</em></span>, will be used to specify
71the 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. 
76Define a Molecule
77</h3></div></div></div><p>
78In the example below, the water, <span class="emphasis"><em>H2O</em></span>, is built from its
79components, 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. 
81Creating 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-&gt;AddElement(elH, natoms=2);
92  H2O-&gt;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. 
95Define a Mixture by Fractional Mass
96</h3></div></div></div><p>
97In the example below, air is built from nitrogen and oxygen, by
98giving 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. 
101Creating 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-&gt;AddElement(elN, fractionmass=70*perCent);
112  Air-&gt;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. 
115Define a Material from the Geant4 Material Database
116</h3></div></div></div><p>
117In the example below, air and water are accessed via the Geant4
118material database.
119</p><div class="example"><a name="programlist_HowToSpecMate_4"></a><p class="title"><b>Example 2.10. 
120Defining 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-&gt;FindOrBuildMaterial("G4_WATER");
125  G4Material* Air  = man-&gt;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. 
128Print 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. 
131Printing information about materials.
132</b></p><div class="example-contents"><pre class="programlisting">
133  G4cout &lt;&lt; H2O;                                \\ print a given material
134  G4cout &lt;&lt; *(G4Material::GetMaterialTable());  \\ print the list of materials
135</pre></div></div><p><br class="example-break">
136
137In <code class="literal">examples/novice/N03/N03DetectorConstruction.cc</code>, you
138will 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. 
140How 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. 
142How to Specify Particles
143</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.