source: trunk/Documentation/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch02s02.html @ 902

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

Add Geant4 Documentation at 8.12.2008

File size: 11.7 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.2.  How to Define a Detector Geometry</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="ch02.html" title="Chapter 2.  Getting Started with Geant4 - Running a Simple Example"><link rel="next" href="ch02s03.html" title="2.3.  How to Specify Materials in the Detector"><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.2. 
9How to Define a Detector Geometry
10</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02.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="ch02s03.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.HowToDefDetectorGeom"></a>2.2. 
13How to Define a Detector Geometry
14</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.BasicConcepts"></a>2.2.1. 
15Basic Concepts
16</h3></div></div></div><p>
17A detector geometry in Geant4 is made of a number of volumes. The
18largest volume is called the <span class="bold"><strong>World</strong></span> 
19volume. It must contain, with some margin, all other volumes
20in the detector geometry. The other volumes are created and placed
21inside previous volumes, included in the World volume.
22The most simple (and efficient) shape to describe the World is a box.
23</p><p>
24Each volume is created by describing its shape and its physical
25characteristics, and then placing it inside a containing
26volume.
27</p><p>
28When a volume is placed within another volume, we call the
29former volume the daughter volume and the latter the mother volume.
30The coordinate system used to specify where the daughter volume is
31placed, is the coordinate system of the mother volume.
32</p><p>
33To describe a volume's shape, we use the concept of a solid. A
34solid is a geometrical object that has a shape and specific values
35for each of that shape's dimensions. A cube with a side of 10
36centimeters and a cylinder of radius 30 cm and length 75 cm are
37examples of solids.
38</p><p>
39To describe a volume's full properties, we use a logical volume.
40It includes the geometrical properties of the solid, and adds
41physical characteristics: the material of the volume; whether it
42contains any sensitive detector elements; the magnetic field;
43etc.
44</p><p>
45We have yet to describe how to position the volume. To do this
46you create a physical volume, which places a copy of the logical
47volume inside a larger, containing, volume.
48</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.CreateSimpleVol"></a>2.2.2. 
49Create a Simple Volume
50</h3></div></div></div><p>
51What do you need to do to create a volume?
52</p><div class="itemizedlist"><ul type="disc" compact><li><p>
53  Create a solid.
54  </p></li><li><p>
55  Create a logical volume, using this solid, and adding other
56  attributes.
57  </p></li></ul></div><p>
58</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.ChooseSolid"></a>2.2.3. Choose a Solid
59</h3></div></div></div><p>
60To create a simple box, you only need to define its name and its
61extent along each of the Cartesian axes. You can find an example
62how to do this in Novice Example N01.
63</p><p>
64In the detector description in the source file
65<code class="literal">ExN01DetectorConstruction.cc</code>, you will find the following
66box definition:
67
68</p><div class="example"><a name="programlist_HowToDefDetectorGeom_1"></a><p class="title"><b>Example 2.3. 
69Creating a box.
70</b></p><div class="example-contents"><pre class="programlisting">
71  G4double expHall_x = 3.0*m;
72  G4double expHall_y = 1.0*m;
73  G4double expHall_z = 1.0*m;
74
75  G4Box* experimentalHall_box
76     = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z);
77</pre></div></div><p><br class="example-break">
78
79This creates a box named "expHall_box" with extent from -3.0
80meters to +3.0 meters along the X axis, from -1.0 to 1.0 meters in
81Y, and from -1.0 to 1.0 meters in Z.
82</p><p>
83It is also very simple to create a cylinder. To do this, you can
84use the <span class="emphasis"><em>G4Tubs</em></span> class.
85
86</p><div class="example"><a name="programlist_HowToDefDetectorGeom_2"></a><p class="title"><b>Example 2.4. 
87Creating a cylinder.
88</b></p><div class="example-contents"><pre class="programlisting">
89  G4double innerRadiusOfTheTube = 0.*cm;
90  G4double outerRadiusOfTheTube = 60.*cm;
91  G4double hightOfTheTube = 25.*cm;
92  G4double startAngleOfTheTube = 0.*deg;
93  G4double spanningAngleOfTheTube = 360.*deg;
94
95  G4Tubs* tracker_tube
96    = new G4Tubs("tracker_tube",
97                 innerRadiusOfTheTube,
98                 outerRadiusOfTheTube,
99                 hightOfTheTube,
100                 startAngleOfTheTube,
101                 spanningAngleOfTheTube);
102</pre></div></div><p><br class="example-break">
103
104This creates a full cylinder, named "tracker_tube", of radius 60
105centimeters and length 50 cm.
106</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.CreateLogicalVol"></a>2.2.4. 
107Create a Logical Volume
108</h3></div></div></div><p>
109To create a logical volume, you must start with a solid and a
110material. So, using the box created above, you can create a simple
111logical volume filled with argon gas (see materials) by entering:
112
113</p><div class="informalexample"><pre class="programlisting">
114 G4LogicalVolume* experimentalHall_log
115    = new G4LogicalVolume(experimentalHall_box,Ar,"expHall_log");
116</pre></div><p>
117
118This logical volume is named "expHall_log".
119</p><p>
120Similarly we create a logical volume with the cylindrical solid
121filled with aluminium
122
123</p><div class="informalexample"><pre class="programlisting">
124  G4LogicalVolume* tracker_log
125    = new G4LogicalVolume(tracker_tube,Al,"tracker_log");
126</pre></div><p>
127
128
129and named "tracker_log"
130</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.PlaceVolume"></a>2.2.5. 
131Place a Volume
132</h3></div></div></div><p>
133How do you place a volume? You start with a logical volume, and
134then you decide the already existing volume inside of which to
135place it. Then you decide where to place its center within that
136volume, and how to rotate it. Once you have made these decisions,
137you can create a physical volume, which is the placed instance of
138the volume, and embodies all of these atributes.
139</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.CreatePhysicalVol"></a>2.2.6. Create a Physical Volume</h3></div></div></div><p>
140You create a physical volume starting with your logical volume.
141A physical volume is simply a placed instance of the logical
142volume. This instance must be placed inside a mother logical
143volume. For simplicity it is unrotated:
144</p><div class="example"><a name="programlist_HowToDefDetectorGeom_3"></a><p class="title"><b>Example 2.5. 
145A simple physical volume.
146</b></p><div class="example-contents"><pre class="programlisting">
147  G4double trackerPos_x = -1.0*meter;
148  G4double trackerPos_y =  0.0*meter;
149  G4double trackerPos_z =  0.0*meter;
150
151  G4VPhysicalVolume* tracker_phys
152    = new G4PVPlacement(0,                       // no rotation
153                        G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z),
154                                                 // translation position
155                        tracker_log,             // its logical volume
156                        "tracker",               // its name
157                        experimentalHall_log,    // its mother (logical) volume
158                        false,                   // no boolean operations
159                        0);                      // its copy number
160</pre></div></div><br class="example-break"><p>
161This places the logical volume <code class="literal">tracker_log</code> at the
162origin of the mother volume <code class="literal">experimentalHall_log</code>, shifted
163by one meter along X and unrotated. The resulting physical volume
164is named "tracker" and has a copy number of 0.
165</p><p>
166An exception exists to the rule that a physical volume must be
167placed inside a mother volume. That exception is for the World
168volume, which is the largest volume created, and which contains all
169other volumes. This volume obviously cannot be contained in any
170other. Instead, it must be created as a <span class="emphasis"><em>G4PVPlacement</em></span> 
171with a null mother pointer. It also must be unrotated, and it must be
172placed at the origin of the global coordinate system.
173</p><p>
174Generally, it is best to choose a simple solid as the World
175volume, and in Example N01, we use the experimental hall:
176
177</p><div class="example"><a name="programlist_HowToDefDetectorGeom_4"></a><p class="title"><b>Example 2.6. 
178The World volume from Example N01.
179</b></p><div class="example-contents"><pre class="programlisting">
180  G4VPhysicalVolume* experimentalHall_phys
181      = new G4PVPlacement(0,                       // no rotation
182                          G4ThreeVector(0.,0.,0.), // translation position
183                          experimentalHall_log,    // its logical volume
184                          "expHall",               // its name
185                          0,                       // its mother volume
186                          false,                   // no boolean operations
187                          0);                      // its copy number
188</pre></div></div><p><br class="example-break">
189</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sect.HowToDefDetectorGeom.CoordinateRotations"></a>2.2.7. 
190Coordinate Systems and Rotations
191</h3></div></div></div><p>
192In Geant4, the rotation matrix associated to a placed physical
193volume represents the rotation of the reference system of this
194volume with respect to its mother.
195</p><p>
196A rotation matrix is normally constructed as in CLHEP, by
197instantiating the identity matrix and then applying a rotation to
198it. This is also demonstrated in Example N04.
199</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02.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="ch02s03.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. 
200Getting Started with Geant4 - Running a Simple Example
201 </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.3. 
202How to Specify Materials in the Detector
203</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.