| 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">
|
|---|
| 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.2.
|
|---|
| 9 | How 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.
|
|---|
| 11 | Getting 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.
|
|---|
| 13 | How 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.
|
|---|
| 15 | Basic Concepts
|
|---|
| 16 | </h3></div></div></div><p>
|
|---|
| 17 | A detector geometry in Geant4 is made of a number of volumes. The
|
|---|
| 18 | largest volume is called the <span class="bold"><strong>World</strong></span>
|
|---|
| 19 | volume. It must contain, with some margin, all other volumes
|
|---|
| 20 | in the detector geometry. The other volumes are created and placed
|
|---|
| 21 | inside previous volumes, included in the World volume.
|
|---|
| 22 | The most simple (and efficient) shape to describe the World is a box.
|
|---|
| 23 | </p><p>
|
|---|
| 24 | Each volume is created by describing its shape and its physical
|
|---|
| 25 | characteristics, and then placing it inside a containing
|
|---|
| 26 | volume.
|
|---|
| 27 | </p><p>
|
|---|
| 28 | When a volume is placed within another volume, we call the
|
|---|
| 29 | former volume the daughter volume and the latter the mother volume.
|
|---|
| 30 | The coordinate system used to specify where the daughter volume is
|
|---|
| 31 | placed, is the coordinate system of the mother volume.
|
|---|
| 32 | </p><p>
|
|---|
| 33 | To describe a volume's shape, we use the concept of a solid. A
|
|---|
| 34 | solid is a geometrical object that has a shape and specific values
|
|---|
| 35 | for each of that shape's dimensions. A cube with a side of 10
|
|---|
| 36 | centimeters and a cylinder of radius 30 cm and length 75 cm are
|
|---|
| 37 | examples of solids.
|
|---|
| 38 | </p><p>
|
|---|
| 39 | To describe a volume's full properties, we use a logical volume.
|
|---|
| 40 | It includes the geometrical properties of the solid, and adds
|
|---|
| 41 | physical characteristics: the material of the volume; whether it
|
|---|
| 42 | contains any sensitive detector elements; the magnetic field;
|
|---|
| 43 | etc.
|
|---|
| 44 | </p><p>
|
|---|
| 45 | We have yet to describe how to position the volume. To do this
|
|---|
| 46 | you create a physical volume, which places a copy of the logical
|
|---|
| 47 | volume 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.
|
|---|
| 49 | Create a Simple Volume
|
|---|
| 50 | </h3></div></div></div><p>
|
|---|
| 51 | What 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>
|
|---|
| 60 | To create a simple box, you only need to define its name and its
|
|---|
| 61 | extent along each of the Cartesian axes. You can find an example
|
|---|
| 62 | how to do this in Novice Example N01.
|
|---|
| 63 | </p><p>
|
|---|
| 64 | In the detector description in the source file
|
|---|
| 65 | <code class="literal">ExN01DetectorConstruction.cc</code>, you will find the following
|
|---|
| 66 | box definition:
|
|---|
| 67 |
|
|---|
| 68 | </p><div class="example"><a name="programlist_HowToDefDetectorGeom_1"></a><p class="title"><b>Example 2.3.
|
|---|
| 69 | Creating 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 |
|
|---|
| 79 | This creates a box named "expHall_box" with extent from -3.0
|
|---|
| 80 | meters to +3.0 meters along the X axis, from -1.0 to 1.0 meters in
|
|---|
| 81 | Y, and from -1.0 to 1.0 meters in Z.
|
|---|
| 82 | </p><p>
|
|---|
| 83 | It is also very simple to create a cylinder. To do this, you can
|
|---|
| 84 | use 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.
|
|---|
| 87 | Creating 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 |
|
|---|
| 104 | This creates a full cylinder, named "tracker_tube", of radius 60
|
|---|
| 105 | centimeters 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.
|
|---|
| 107 | Create a Logical Volume
|
|---|
| 108 | </h3></div></div></div><p>
|
|---|
| 109 | To create a logical volume, you must start with a solid and a
|
|---|
| 110 | material. So, using the box created above, you can create a simple
|
|---|
| 111 | logical 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 |
|
|---|
| 118 | This logical volume is named "expHall_log".
|
|---|
| 119 | </p><p>
|
|---|
| 120 | Similarly we create a logical volume with the cylindrical solid
|
|---|
| 121 | filled 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 |
|
|---|
| 129 | and 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.
|
|---|
| 131 | Place a Volume
|
|---|
| 132 | </h3></div></div></div><p>
|
|---|
| 133 | How do you place a volume? You start with a logical volume, and
|
|---|
| 134 | then you decide the already existing volume inside of which to
|
|---|
| 135 | place it. Then you decide where to place its center within that
|
|---|
| 136 | volume, and how to rotate it. Once you have made these decisions,
|
|---|
| 137 | you can create a physical volume, which is the placed instance of
|
|---|
| 138 | the 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>
|
|---|
| 140 | You create a physical volume starting with your logical volume.
|
|---|
| 141 | A physical volume is simply a placed instance of the logical
|
|---|
| 142 | volume. This instance must be placed inside a mother logical
|
|---|
| 143 | volume. For simplicity it is unrotated:
|
|---|
| 144 | </p><div class="example"><a name="programlist_HowToDefDetectorGeom_3"></a><p class="title"><b>Example 2.5.
|
|---|
| 145 | A 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>
|
|---|
| 161 | This places the logical volume <code class="literal">tracker_log</code> at the
|
|---|
| 162 | origin of the mother volume <code class="literal">experimentalHall_log</code>, shifted
|
|---|
| 163 | by one meter along X and unrotated. The resulting physical volume
|
|---|
| 164 | is named "tracker" and has a copy number of 0.
|
|---|
| 165 | </p><p>
|
|---|
| 166 | An exception exists to the rule that a physical volume must be
|
|---|
| 167 | placed inside a mother volume. That exception is for the World
|
|---|
| 168 | volume, which is the largest volume created, and which contains all
|
|---|
| 169 | other volumes. This volume obviously cannot be contained in any
|
|---|
| 170 | other. Instead, it must be created as a <span class="emphasis"><em>G4PVPlacement</em></span>
|
|---|
| 171 | with a null mother pointer. It also must be unrotated, and it must be
|
|---|
| 172 | placed at the origin of the global coordinate system.
|
|---|
| 173 | </p><p>
|
|---|
| 174 | Generally, it is best to choose a simple solid as the World
|
|---|
| 175 | volume, 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.
|
|---|
| 178 | The 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.
|
|---|
| 190 | Coordinate Systems and Rotations
|
|---|
| 191 | </h3></div></div></div><p>
|
|---|
| 192 | In Geant4, the rotation matrix associated to a placed physical
|
|---|
| 193 | volume represents the rotation of the reference system of this
|
|---|
| 194 | volume with respect to its mother.
|
|---|
| 195 | </p><p>
|
|---|
| 196 | A rotation matrix is normally constructed as in CLHEP, by
|
|---|
| 197 | instantiating the identity matrix and then applying a rotation to
|
|---|
| 198 | it. 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.
|
|---|
| 200 | Getting 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.
|
|---|
| 202 | How to Specify Materials in the Detector
|
|---|
| 203 | </td></tr></table></div></body></html>
|
|---|