source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/FAQ/geometry.xml@ 1345

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

CVS update

File size: 4.9 KB
Line 
1<!-- ******************************************************** -->
2<!-- -->
3<!-- [History] -->
4<!-- 1st version created: Katsuya Amako, Dec-2006 -->
5<!-- -->
6<!-- ******************************************************** -->
7
8
9<!-- ********************* QandA Section ******************** -->
10<section id="qanda.Geometry">
11<title>
12Geometry
13</title>
14
15<qandaset defaultlabel="qanda">
16
17
18<!-- ******* QandA Entry ******** -->
19<qandaentry id="qanda.Geometry.GenPnt">
20
21<question><para>
22 I have a generic point and I would like to know in which physical
23 volume I'm located in my detector geometry.
24</para></question>
25
26<answer><para>
27 The best way of doing this is by invoking the G4Navigator. First
28 get a pointer of the navigator through the G4TransportationManager,
29 and then locate the point. i.e.
30 <informalexample><programlisting>
31 #include "G4TransportationManager.hh"
32 #include "G4Navigator.hh"
33 G4ThreeVector myPoint = ....;
34 G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()
35 -&gt;GetNavigatorForTracking();
36 G4VPhysicalVolume* myVolume = theNavigator-&gt;LocateGlobalPointAndSetup(myPoint);
37 </programlisting></informalexample>
38
39 <note>
40 <title>Note</title>
41 <para>
42 by using the navigator for tracking as shown above, the actual
43 particle gets also -relocated- in the specified position. Therefore,
44 if this information is needed during tracking time, in order to
45 avoid affecting tracking, you should either use an alternative
46 G4Navigator object (which you then assign to your world-volume),
47 or you access the information through the track or touchable as
48 specified in the FAQ for tracking and steps.
49 </para>
50 </note>
51</para></answer>
52
53</qandaentry>
54
55<!-- ******* QandA Entry ******** -->
56<qandaentry id="qanda.Geometry.DghtVol">
57
58<question><para>
59 How can I access the daughter volumes of a specific physical volume?
60</para></question>
61
62<answer><para>
63 Through the associated logical volume.
64 <informalexample><programlisting>
65 G4VPhysicalVolume* myPVolume = ....;
66 G4LogicalVolume* myLVolume = myPVolume-&gt;GetLogicalVolume();
67 for (G4int i=0; iGetNoDaughters(); i++)
68 myPVolume = myLVolume-&gt;GetDaughter(i);
69 </programlisting></informalexample>
70</para></answer>
71
72</qandaentry>
73
74<!-- ******* QandA Entry ******** -->
75<qandaentry id="qanda.Geometry.CpyNum">
76
77<question><para>
78 How can I identify the exact copy-number of a specific physical volume
79 in my mass geometry? I tried with GetCopyNo() from my physical volume
80 pointer, but it doesn't seem to work!
81</para></question>
82
83<answer><para>
84 The correct way to identify -uniquely- a physical volume in your mass
85 geometry is by using the touchables (see also section 4.1.5 of the
86 User's Guide for Application Developers), as follows:
87 <informalexample><programlisting>
88 G4Step* aStep = ..;
89 G4StepPoint* preStepPoint = aStep-&gt;GetPreStepPoint();
90 G4TouchableHandle theTouchable = preStepPoint-&gt;GetTouchableHandle();
91 G4int copyNo = theTouchable-&gt;GetCopyNumber();
92 G4int motherCopyNo = theTouchable-&gt;GetCopyNumber(1);
93 </programlisting></informalexample>
94
95 where <literal>Copy</literal> here stays for any duplicated instance of
96 a physical volume, either if it is a <literal>G4PVPlacement</literal>
97 (multiple placements of the same logical volume) or a
98 <literal>G4PVReplica/G4PVParameterised</literal>.
99 The method <literal>GetCopyNo()</literal> is meant to return only the
100 serial number of placements not duplicated in the geometry tree.
101</para></answer>
102
103</qandaentry>
104
105<!-- ******* QandA Entry ******** -->
106<qandaentry id="qanda.Geometry.ConvGtoL">
107
108<question><para>
109 How can I determine the exact position in global coordinates in my mass
110 geometry during tracking and how can I convert it to coordinates local
111 to the current volume ?
112</para></question>
113
114<answer><para>
115 You need again to do it through the touchables (see also section 4.1.5
116 of the User's Guide for Application Developers), as follows:
117 <informalexample><programlisting>
118 G4Step* aStep = ..;
119 G4StepPoint* preStepPoint = aStep-&gt;GetPreStepPoint();
120 G4TouchableHandle theTouchable = preStepPoint-&gt;GetTouchableHandle();
121 G4ThreeVector worldPosition = preStepPoint-&gt;GetPosition();
122 G4ThreeVector localPosition = theTouchable-&gt;GetHistory()-&gt;
123 GetTopTransform().TransformPoint(worldPosition);
124 </programlisting></informalexample>
125
126 where <literal>worldPosition</literal> here stays for the position related
127 to the world volume, while <literal>localPosition</literal> refers to the
128 coordinates local to the volume where the particle is currently placed.
129</para></answer>
130
131</qandaentry>
132
133
134</qandaset>
135</section>
Note: See TracBrowser for help on using the repository browser.