1 | <!-- ******************************************************** --> |
---|
2 | <!-- --> |
---|
3 | <!-- [History] --> |
---|
4 | <!-- Changed by: Katsuya Amako, 6-Aug-1998 --> |
---|
5 | <!-- Changed by: Dennis Wright, 28-Nov-2001 --> |
---|
6 | <!-- Proof read by: Joe Chuma, 14-Jun-1999 --> |
---|
7 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
8 | <!-- --> |
---|
9 | <!-- ******************************************************** --> |
---|
10 | |
---|
11 | |
---|
12 | <!-- ******************* Section (Level#1) ****************** --> |
---|
13 | <sect1 id="sect.HowToDefDetectorGeom"> |
---|
14 | <title> |
---|
15 | How to Define a Detector Geometry |
---|
16 | </title> |
---|
17 | |
---|
18 | <!-- ******************* Section (Level#2) ****************** --> |
---|
19 | <sect2 id="sect.HowToDefDetectorGeom.BasicConcepts"> |
---|
20 | <title> |
---|
21 | Basic Concepts |
---|
22 | </title> |
---|
23 | |
---|
24 | <para> |
---|
25 | A detector geometry in Geant4 is made of a number of volumes. The |
---|
26 | largest volume is called the <emphasis role="bold">World</emphasis> |
---|
27 | volume. It must contain, with some margin, all other volumes |
---|
28 | in the detector geometry. The other volumes are created and placed |
---|
29 | inside previous volumes, included in the World volume. |
---|
30 | The most simple (and efficient) shape to describe the World is a box. |
---|
31 | </para> |
---|
32 | |
---|
33 | <para> |
---|
34 | Each volume is created by describing its shape and its physical |
---|
35 | characteristics, and then placing it inside a containing |
---|
36 | volume. |
---|
37 | </para> |
---|
38 | |
---|
39 | <para> |
---|
40 | When a volume is placed within another volume, we call the |
---|
41 | former volume the daughter volume and the latter the mother volume. |
---|
42 | The coordinate system used to specify where the daughter volume is |
---|
43 | placed, is the coordinate system of the mother volume. |
---|
44 | </para> |
---|
45 | |
---|
46 | <para> |
---|
47 | To describe a volume's shape, we use the concept of a solid. A |
---|
48 | solid is a geometrical object that has a shape and specific values |
---|
49 | for each of that shape's dimensions. A cube with a side of 10 |
---|
50 | centimeters and a cylinder of radius 30 cm and length 75 cm are |
---|
51 | examples of solids. |
---|
52 | </para> |
---|
53 | |
---|
54 | <para> |
---|
55 | To describe a volume's full properties, we use a logical volume. |
---|
56 | It includes the geometrical properties of the solid, and adds |
---|
57 | physical characteristics: the material of the volume; whether it |
---|
58 | contains any sensitive detector elements; the magnetic field; |
---|
59 | etc. |
---|
60 | </para> |
---|
61 | |
---|
62 | <para> |
---|
63 | We have yet to describe how to position the volume. To do this |
---|
64 | you create a physical volume, which places a copy of the logical |
---|
65 | volume inside a larger, containing, volume. |
---|
66 | </para> |
---|
67 | |
---|
68 | </sect2> |
---|
69 | |
---|
70 | <!-- ******************* Section (Level#2) ****************** --> |
---|
71 | <sect2 id="sect.HowToDefDetectorGeom.CreateSimpleVol"> |
---|
72 | <title> |
---|
73 | Create a Simple Volume |
---|
74 | </title> |
---|
75 | |
---|
76 | <para> |
---|
77 | What do you need to do to create a volume? |
---|
78 | <itemizedlist spacing="compact"> |
---|
79 | <listitem><para> |
---|
80 | Create a solid. |
---|
81 | </para></listitem> |
---|
82 | <listitem><para> |
---|
83 | Create a logical volume, using this solid, and adding other |
---|
84 | attributes. |
---|
85 | </para></listitem> |
---|
86 | </itemizedlist> |
---|
87 | </para> |
---|
88 | |
---|
89 | </sect2> |
---|
90 | |
---|
91 | <!-- ******************* Section (Level#2) ****************** --> |
---|
92 | <sect2 id="sect.HowToDefDetectorGeom.ChooseSolid"> |
---|
93 | <title>Choose a Solid |
---|
94 | </title> |
---|
95 | |
---|
96 | <para> |
---|
97 | To create a simple box, you only need to define its name and its |
---|
98 | extent along each of the Cartesian axes. You can find an example |
---|
99 | how to do this in Novice Example N01. |
---|
100 | </para> |
---|
101 | |
---|
102 | <para> |
---|
103 | In the detector description in the source file |
---|
104 | <literal>ExN01DetectorConstruction.cc</literal>, you will find the following |
---|
105 | box definition: |
---|
106 | |
---|
107 | <example id="programlist_HowToDefDetectorGeom_1"> |
---|
108 | <title> |
---|
109 | Creating a box. |
---|
110 | </title> |
---|
111 | <programlisting> |
---|
112 | G4double expHall_x = 3.0*m; |
---|
113 | G4double expHall_y = 1.0*m; |
---|
114 | G4double expHall_z = 1.0*m; |
---|
115 | |
---|
116 | G4Box* experimentalHall_box |
---|
117 | = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); |
---|
118 | </programlisting> |
---|
119 | </example> |
---|
120 | |
---|
121 | This creates a box named "expHall_box" with extent from -3.0 |
---|
122 | meters to +3.0 meters along the X axis, from -1.0 to 1.0 meters in |
---|
123 | Y, and from -1.0 to 1.0 meters in Z. |
---|
124 | </para> |
---|
125 | |
---|
126 | <para> |
---|
127 | It is also very simple to create a cylinder. To do this, you can |
---|
128 | use the <emphasis>G4Tubs</emphasis> class. |
---|
129 | |
---|
130 | <example id="programlist_HowToDefDetectorGeom_2"> |
---|
131 | <title> |
---|
132 | Creating a cylinder. |
---|
133 | </title> |
---|
134 | <programlisting> |
---|
135 | G4double innerRadiusOfTheTube = 0.*cm; |
---|
136 | G4double outerRadiusOfTheTube = 60.*cm; |
---|
137 | G4double hightOfTheTube = 25.*cm; |
---|
138 | G4double startAngleOfTheTube = 0.*deg; |
---|
139 | G4double spanningAngleOfTheTube = 360.*deg; |
---|
140 | |
---|
141 | G4Tubs* tracker_tube |
---|
142 | = new G4Tubs("tracker_tube", |
---|
143 | innerRadiusOfTheTube, |
---|
144 | outerRadiusOfTheTube, |
---|
145 | hightOfTheTube, |
---|
146 | startAngleOfTheTube, |
---|
147 | spanningAngleOfTheTube); |
---|
148 | </programlisting> |
---|
149 | </example> |
---|
150 | |
---|
151 | This creates a full cylinder, named "tracker_tube", of radius 60 |
---|
152 | centimeters and length 50 cm. |
---|
153 | </para> |
---|
154 | |
---|
155 | </sect2> |
---|
156 | |
---|
157 | <!-- ******************* Section (Level#2) ****************** --> |
---|
158 | <sect2 id="sect.HowToDefDetectorGeom.CreateLogicalVol"> |
---|
159 | <title> |
---|
160 | Create a Logical Volume |
---|
161 | </title> |
---|
162 | |
---|
163 | <para> |
---|
164 | To create a logical volume, you must start with a solid and a |
---|
165 | material. So, using the box created above, you can create a simple |
---|
166 | logical volume filled with argon gas (see materials) by entering: |
---|
167 | |
---|
168 | <informalexample> |
---|
169 | <programlisting> |
---|
170 | G4LogicalVolume* experimentalHall_log |
---|
171 | = new G4LogicalVolume(experimentalHall_box,Ar,"expHall_log"); |
---|
172 | </programlisting> |
---|
173 | </informalexample> |
---|
174 | |
---|
175 | This logical volume is named "expHall_log". |
---|
176 | </para> |
---|
177 | |
---|
178 | <para> |
---|
179 | Similarly we create a logical volume with the cylindrical solid |
---|
180 | filled with aluminium |
---|
181 | |
---|
182 | <informalexample> |
---|
183 | <programlisting> |
---|
184 | G4LogicalVolume* tracker_log |
---|
185 | = new G4LogicalVolume(tracker_tube,Al,"tracker_log"); |
---|
186 | </programlisting> |
---|
187 | </informalexample> |
---|
188 | |
---|
189 | |
---|
190 | and named "tracker_log" |
---|
191 | </para> |
---|
192 | |
---|
193 | </sect2> |
---|
194 | |
---|
195 | <!-- ******************* Section (Level#2) ****************** --> |
---|
196 | <sect2 id="sect.HowToDefDetectorGeom.PlaceVolume"> |
---|
197 | <title> |
---|
198 | Place a Volume |
---|
199 | </title> |
---|
200 | |
---|
201 | <para> |
---|
202 | How do you place a volume? You start with a logical volume, and |
---|
203 | then you decide the already existing volume inside of which to |
---|
204 | place it. Then you decide where to place its center within that |
---|
205 | volume, and how to rotate it. Once you have made these decisions, |
---|
206 | you can create a physical volume, which is the placed instance of |
---|
207 | the volume, and embodies all of these atributes. |
---|
208 | </para> |
---|
209 | |
---|
210 | </sect2> |
---|
211 | |
---|
212 | <!-- ******************* Section (Level#2) ****************** --> |
---|
213 | <sect2 id="sect.HowToDefDetectorGeom.CreatePhysicalVol"> |
---|
214 | <title>Create a Physical Volume</title> |
---|
215 | |
---|
216 | <para> |
---|
217 | You create a physical volume starting with your logical volume. |
---|
218 | A physical volume is simply a placed instance of the logical |
---|
219 | volume. This instance must be placed inside a mother logical |
---|
220 | volume. For simplicity it is unrotated: |
---|
221 | </para> |
---|
222 | |
---|
223 | <example id="programlist_HowToDefDetectorGeom_3"> |
---|
224 | <title> |
---|
225 | A simple physical volume. |
---|
226 | </title> |
---|
227 | <programlisting> |
---|
228 | G4double trackerPos_x = -1.0*meter; |
---|
229 | G4double trackerPos_y = 0.0*meter; |
---|
230 | G4double trackerPos_z = 0.0*meter; |
---|
231 | |
---|
232 | G4VPhysicalVolume* tracker_phys |
---|
233 | = new G4PVPlacement(0, // no rotation |
---|
234 | G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), |
---|
235 | // translation position |
---|
236 | tracker_log, // its logical volume |
---|
237 | "tracker", // its name |
---|
238 | experimentalHall_log, // its mother (logical) volume |
---|
239 | false, // no boolean operations |
---|
240 | 0); // its copy number |
---|
241 | </programlisting> |
---|
242 | </example> |
---|
243 | |
---|
244 | <para> |
---|
245 | This places the logical volume <literal>tracker_log</literal> at the |
---|
246 | origin of the mother volume <literal>experimentalHall_log</literal>, shifted |
---|
247 | by one meter along X and unrotated. The resulting physical volume |
---|
248 | is named "tracker" and has a copy number of 0. |
---|
249 | </para> |
---|
250 | |
---|
251 | <para> |
---|
252 | An exception exists to the rule that a physical volume must be |
---|
253 | placed inside a mother volume. That exception is for the World |
---|
254 | volume, which is the largest volume created, and which contains all |
---|
255 | other volumes. This volume obviously cannot be contained in any |
---|
256 | other. Instead, it must be created as a <emphasis>G4PVPlacement</emphasis> |
---|
257 | with a null mother pointer. It also must be unrotated, and it must be |
---|
258 | placed at the origin of the global coordinate system. |
---|
259 | </para> |
---|
260 | |
---|
261 | <para> |
---|
262 | Generally, it is best to choose a simple solid as the World |
---|
263 | volume, and in Example N01, we use the experimental hall: |
---|
264 | |
---|
265 | <example id="programlist_HowToDefDetectorGeom_4"> |
---|
266 | <title> |
---|
267 | The World volume from Example N01. |
---|
268 | </title> |
---|
269 | <programlisting> |
---|
270 | G4VPhysicalVolume* experimentalHall_phys |
---|
271 | = new G4PVPlacement(0, // no rotation |
---|
272 | G4ThreeVector(0.,0.,0.), // translation position |
---|
273 | experimentalHall_log, // its logical volume |
---|
274 | "expHall", // its name |
---|
275 | 0, // its mother volume |
---|
276 | false, // no boolean operations |
---|
277 | 0); // its copy number |
---|
278 | </programlisting> |
---|
279 | </example> |
---|
280 | </para> |
---|
281 | |
---|
282 | </sect2> |
---|
283 | |
---|
284 | |
---|
285 | <!-- ******************* Section (Level#2) ****************** --> |
---|
286 | <sect2 id="sect.HowToDefDetectorGeom.CoordinateRotations"> |
---|
287 | <title> |
---|
288 | Coordinate Systems and Rotations |
---|
289 | </title> |
---|
290 | |
---|
291 | <para> |
---|
292 | In Geant4, the rotation matrix associated to a placed physical |
---|
293 | volume represents the rotation of the reference system of this |
---|
294 | volume with respect to its mother. |
---|
295 | </para> |
---|
296 | |
---|
297 | <para> |
---|
298 | A rotation matrix is normally constructed as in CLHEP, by |
---|
299 | instantiating the identity matrix and then applying a rotation to |
---|
300 | it. This is also demonstrated in Example N04. |
---|
301 | </para> |
---|
302 | |
---|
303 | </sect2> |
---|
304 | </sect1> |
---|