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

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

Add Geant4 Documentation at 8.12.2008

File size: 7.5 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>FAQ.3.  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="ch10.html" title="Chapter FAQ.  Frequentry Asked Questions"><link rel="prev" href="ch10s02.html" title="FAQ.2.  Run Time Problems"><link rel="next" href="ch10s04.html" title="FAQ.4.  Tracks and steps"><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">FAQ.3. 
9Geometry
10</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch10s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><th width="60%" align="center">Chapter FAQ. 
11Frequentry Asked Questions
12</th><td width="20%" align="right"> <a accesskey="n" href="ch10s04.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="qanda.Geometry"></a>FAQ.3. 
13Geometry
14</h2></div></div></div><div class="qandaset"><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="qanda.Geometry.GenPnt"></a><a name="id553829"></a><b>Q:</b></td><td align="left" valign="top"><p>
15 I have a generic point and I would like to know in which physical
16 volume I'm located in my detector geometry.
17</p></td></tr><tr class="answer"><td align="left" valign="top"><b>A:</b></td><td align="left" valign="top"><p>
18 The best way of doing this is by invoking the G4Navigator. First
19 get a pointer of the navigator through the G4TransportationManager,
20 and then locate the point. i.e.
21 </p><div class="informalexample"><pre class="programlisting">
22 #include "G4TransportationManager.hh"
23 #include "G4Navigator.hh"
24 G4ThreeVector myPoint = ....;
25 G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()
26 -&gt;GetNavigatorForTracking();
27 G4VPhysicalVolume* myVolume = theNavigator-&gt;LocateGlobalPointAndSetup(myPoint);
28 </pre></div><p>
29
30 </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
31 by using the navigator for tracking as shown above, the actual
32 particle gets also -relocated- in the specified position. Therefore,
33 if this information is needed during tracking time, in order to
34 avoid affecting tracking, you should either use an alternative
35 G4Navigator object (which you then assign to your world-volume),
36 or you access the information through the track or touchable as
37 specified in the FAQ for tracking and steps.
38 </p></div><p>
39</p></td></tr><tr class="question"><td align="left" valign="top"><a name="qanda.Geometry.DghtVol"></a><a name="id553875"></a><b>Q:</b></td><td align="left" valign="top"><p>
40 How can I access the daughter volumes of a specific physical volume?
41</p></td></tr><tr class="answer"><td align="left" valign="top"><b>A:</b></td><td align="left" valign="top"><p>
42 Through the associated logical volume.
43 </p><div class="informalexample"><pre class="programlisting">
44 G4VPhysicalVolume* myPVolume = ....;
45 G4LogicalVolume* myLVolume = myPVolume-&gt;GetLogicalVolume();
46 for (G4int i=0; iGetNoDaughters(); i++)
47 myPVolume = myLVolume-&gt;GetDaughter(i);
48 </pre></div><p>
49</p></td></tr><tr class="question"><td align="left" valign="top"><a name="qanda.Geometry.CpyNum"></a><a name="id553906"></a><b>Q:</b></td><td align="left" valign="top"><p>
50 How can I identify the exact copy-number of a specific physical volume
51 in my mass geometry? I tried with GetCopyNo() from my physical volume
52 pointer, but it doesn't seem to work!
53</p></td></tr><tr class="answer"><td align="left" valign="top"><b>A:</b></td><td align="left" valign="top"><p>
54 The correct way to identify -uniquely- a physical volume in your mass
55 geometry is by using the touchables (see also section 4.1.5 of the
56 User's Guide for Application Developers), as follows:
57 </p><div class="informalexample"><pre class="programlisting">
58 G4Step* aStep = ..;
59 G4StepPoint* preStepPoint = aStep-&gt;GetPreStepPoint();
60 G4TouchableHandle theTouchable = preStepPoint-&gt;GetTouchableHandle();
61 G4int copyNo = theTouchable-&gt;GetCopyNumber();
62 G4int motherCopyNo = theTouchable-&gt;GetCopyNumber(1);
63 </pre></div><p>
64
65 where <code class="literal">Copy</code> here stays for any duplicated instance of
66 a physical volume, either if it is a <code class="literal">G4PVPlacement</code>
67 (multiple placements of the same logical volume) or a
68 <code class="literal">G4PVReplica/G4PVParameterised</code>.
69 The method <code class="literal">GetCopyNo()</code> is meant to return only the
70 serial number of placements not duplicated in the geometry tree.
71</p></td></tr><tr class="question"><td align="left" valign="top"><a name="qanda.Geometry.ConvGtoL"></a><a name="id553963"></a><b>Q:</b></td><td align="left" valign="top"><p>
72 How can I determine the exact position in global coordinates in my mass
73 geometry during tracking and how can I convert it to coordinates local
74 to the current volume ?
75</p></td></tr><tr class="answer"><td align="left" valign="top"><b>A:</b></td><td align="left" valign="top"><p>
76 You need again to do it through the touchables (see also section 4.1.5
77 of the User's Guide for Application Developers), as follows:
78 </p><div class="informalexample"><pre class="programlisting">
79 G4Step* aStep = ..;
80 G4StepPoint* preStepPoint = aStep-&gt;GetPreStepPoint();
81 G4TouchableHandle theTouchable = preStepPoint-&gt;GetTouchableHandle();
82 G4ThreeVector worldPosition = preStepPoint-&gt;GetPosition();
83 G4ThreeVector localPosition = theTouchable-&gt;GetHistory()-&gt;
84 GetTopTransform().TransformPoint(worldPosition);
85 </pre></div><p>
86
87 where <code class="literal">worldPosition</code> here stays for the position related
88 to the world volume, while <code class="literal">localPosition</code> refers to the
89 coordinates local to the volume where the particle is currently placed.
90</p></td></tr></tbody></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch10s02.html"><img src="AllResources/IconsGIF/prev.gif" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ch10.html"><img src="AllResources/IconsGIF/up.gif" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ch10s04.html"><img src="AllResources/IconsGIF/next.gif" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">FAQ.2. 
91Run Time Problems
92 </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"> FAQ.4. 
93Tracks and steps
94</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.