source: trunk/documents/UserDoc/UsersGuides/ForApplicationDeveloper/html/Detector/geomNav.html

Last change on this file was 1208, checked in by garnier, 15 years ago

CVS update

File size: 12.9 KB
Line 
1<html>
2<head>
3<title>ADG: Geometry</title>
4</head>
5
6<!-- Changed by: Gabriele Cosmo, 18-Apr-2005 -->
7<!-- $Id: geomNav.html,v 1.5 2006/11/24 20:18:30 asaim Exp $ -->
8<!-- $Name:  $ -->
9<body>
10<table WIDTH="100%"><TR>
11<td>
12<a href="../../../../Overview/html/index.html">
13<IMG SRC="../../../../resources/html/IconsGIF/Overview.gif" ALT="Overview"></a>
14<a href="geometry.html">
15<IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents"></a>
16<a href="geomReflection.html">
17<IMG SRC="../../../../resources/html/IconsGIF/Previous.gif" ALT="Previous"></a>
18<a href="geomEditor.html">
19<IMG SRC="../../../../resources/html/IconsGIF/Next.gif" ALT="Next"></a>
20</td>
21<td ALIGN="Right">
22<font SIZE="-1" COLOR="#238E23">
23<b>Geant4 User's Guide</b>
24<br>
25<b>For Application Developers</b>
26<br>
27<b>Geometry</b>
28</font>
29</td>
30</tr></table>
31<br><br>
32
33<a name="4.1.8">
34<h2>4.1.8 The Geometry Navigator</h2></a>
35
36<p>
37Navigation through the geometry at tracking time is implemented by the class
38<tt>G4Navigator</tt>. The navigator is used to locate points in the geometry
39and compute distances to geometry boundaries. At tracking time, the navigator
40is intended to be the only point of interaction with tracking.<br>
41
42Internally, the G4Navigator has several private helper/utility classes:
43<ul>
44 <li><b>G4NavigationHistory</b> - stores the compounded transformations,
45     replication/parameterisation information, and volume pointers at each
46     level of the hierarchy to the current location. The volume types
47     at each level are also stored - whether normal (placement),
48     replicated or parameterised.</li>
49 <li><b>G4NormalNavigation</b> - provides location & distance computation
50     functions for geometries containing 'placement' volumes, with no voxels.
51     </li>
52 <li><b>G4VoxelNavigation</b> - provides location and distance computation
53     functions for geometries containing 'placement' physical volumes with
54     voxels. Internally a stack of voxel information is maintained. Private
55     functions allow for isotropic distance computation to voxel boundaries
56     and for computation of the 'next voxel' in a specified direction.</li>
57 <li><b>G4ParameterisedNavigation</b> - provides location and distance
58     computation functions for geometries containing parameterised volumes
59     with voxels. Voxel information is maintained similarly to
60     <tt>G4VoxelNavigation</tt>, but computation can also be simpler by
61     adopting voxels to be one level deep only (<I>unrefined</I>, or 1D
62     optimisation)</li>
63 <li><b>G4ReplicaNavigation</b> - provides location and distance computation
64     functions for replicated volumes.</li>
65</ul>
66In addition, the navigator maintains a set of flags for exiting/entry
67optimisation.  A navigator is not a singleton class;  this is mainly to
68allow a design extension in future (e.g geometrical event biasing).
69</p>
70
71<a name="4.1.8.1">
72<h3>4.1.8.1 Navigation and Tracking</h3></a>
73
74<p>
75The main functions required for tracking in the geometry are described below.
76Additional functions are provided to return the net transformation of volumes
77and for the creation of touchables. None of the functions implicitly requires
78that the geometry be described hierarchically.
79<ul>
80 <li><b>SetWorldVolume()</b><br>
81   Sets the first volume in the hierarchy. It must be unrotated and
82   untranslated from the origin.</li>
83 <li><b>LocateGlobalPointAndSetup()</b><br>
84   Locates the volume containing the specified global point. This
85   involves a traverse of the hierarchy, requiring the computation of
86   compound transformations, testing replicated and parameterised volumes
87   (etc). To improve efficiency this search may be performed relative
88   to the last, and this is the recommended way of calling the
89   function. A 'relative' search may be used for the first call of the
90    function which will result in the search defaulting to a search from
91   the root node of the hierarchy.
92   Searches may also be performed using a <tt>G4TouchableHistory</tt>.</li>
93 <li><b>LocateGlobalPointAndUpdateTouchableHandle()</b><br>
94   First, search the geometrical hierarchy like the above method
95   <tt>LocateGlobalPointAndSetup()</tt>. Then use the volume found and its
96   navigation history to update the touchable.</li>
97 <li><B>ComputeStep()</B><BR>
98   Computes the distance to the next boundary intersected along the
99   specified unit direction from a specified point. The point must be
100   have been located prior to calling <tt>ComputeStep()</tt>.<BR>
101   When calling <tt>ComputeStep()</tt>, a proposed physics step is passed.
102   If it can be determined that the first intersection lies at or beyond that
103   distance then <tt>kInfinity</tt> is returned. In any case, if the returned
104   step is greater than the physics step, the physics step must be taken.</li>
105 <li><B>SetGeometricallyLimitedStep()</B><BR>
106   Informs the navigator that the last computed step was taken in its
107   entirety. This enables entering/exiting optimisation, and should be
108   called prior to calling <tt>LocateGlobalPointAndSetup()</tt>.</li>
109 <li><b>CreateTouchableHistory()</b><br>
110   Creates a <tt>G4TouchableHistory</tt> object, for which the caller has
111   deletion responsibility. The 'touchable' volume is the volume returned
112   by the last Locate operation. The object includes a copy of the current
113   NavigationHistory, enabling the efficient relocation of points
114   in/close to the current volume in the hierarchy.</li>
115</ul>
116 As stated previously, the navigator makes use of utility classes to
117 perform location and step computation functions. The different navigation
118 utilities manipulate the <tt>G4NavigationHistory</tt> object.<BR>
119 In <tt>LocateGlobalPointAndSetup()</tt> the process of locating a
120 point breaks down into three main stages - optimisation,
121 determination that the point is contained with a subtree (mother and
122 daughters), and determination of the actual containing daughter. The
123 latter two can be thought of as scanning first 'up' the hierarchy
124 until a volume that is guaranteed to contain the point is found, and
125 then scanning 'down' until the actual volume that contains the point
126 is found.<BR>
127 In <tt>ComputeStep()</tt> three types of computation are treated
128 depending on the current containing volume:
129 <ul>
130 <li>The volume contains normal (placement) daughters (or none)</li>
131 <li>The volume contains a single parameterised volume object,
132     representing many volumes</li>
133 <li>The volume is a replica and contains normal (placement) daughters</li>
134 </ul>
135</P>
136
137<a name="4.1.8.2">
138<h3>4.1.8.2 Using the navigator to locate points</h3></a>
139
140<P>
141More than one navigator objects can be created inside an application; these
142navigators can act independently for different purposes. The main navigator
143which is <i>activated</i> automatically at the startup of a simulation program
144is the navigator used for the <i>tracking</i> and attached the world volume
145of the main tracking (or <i>mass</i>) geometry.<br>
146The navigator for tracking can be retrieved at any state of the application
147by messagging the <tt>G4TransportationManager</tt>:
148<pre>
149     G4Navigator* tracking_navigator =
150       G4TransportationManager::GetInstance()->GetNavigatorForTracking();
151</pre>
152The navigator for tracking also retains all the information of the current
153history of volumes transversed at a precise moment of the tracking during a
154run. Therefore, if the navigator for tracking is used during tracking for
155locating a generic point in the tree of volumes, the actual particle gets
156also -relocated- in the specified position and tracking will be of course
157affected !<br>
158In order to avoid the problem above and provide information about location
159of a point without affecting the tracking, it is suggested to either use an
160alternative <tt>G4Navigator</tt> object (which can then be assigned to the
161world-volume), or access the information through the step.
162</P>
163
164<P>
165<b>Using the 'step' to retrieve geometrical information</b>
166</P>
167<P>
168During the tracking run, geometrical information can be retrieved through
169the touchable handle associated to the current step. For example, to identify
170the exact copy-number of a specific physical volume in the mass geometry,
171one should do the following:
172<pre>
173      // Given the pointer to the step object ...
174      //
175      G4Step* aStep = ..;
176
177      // ... retrieve the 'pre-step' point
178      //
179      G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
180
181      // ... retrieve a touchable handle and access to the information
182      //
183      G4TouchableHandle theTouchable = preStepPoint->GetTouchableHandle();
184      G4int copyNo = theTouchable->GetCopyNumber();
185      G4int motherCopyNo = theTouchable->GetCopyNumber(1);
186</pre>
187To determine the exact position in global coordinates in the mass geometry
188and convert to local coordinates (local to the current volume):
189<pre>
190      G4ThreeVector worldPosition = preStepPoint->GetPosition();
191      G4ThreeVector localPosition = theTouchable->GetHistory()->
192                    GetTopTransform().TransformPoint(worldPosition);
193</pre>
194</P>
195
196<P>
197<b>Using an alternative navigator to locate points</b>
198</P>
199<P>
200In order to know (when in the <i>idle</i> state of the application) in which
201physical volume a given point is located in the detector geometry, it is
202necessary to create an alternative navigator object first and assign it to
203the world volume:
204<pre>
205     G4Navigator* aNavigator = new G4Navigator();
206     aNavigator->SetWorldVolume(worldVolumePointer);
207</pre>
208Then, locate the point <tt>myPoint</tt> (defined in global coordinates),
209retrieve a <i>touchable handle</i> and do whatever you need with it:
210<pre>
211     aNavigator->LocateGlobalPointAndSetup(myPoint);
212     G4TouchableHistoryHandle aTouchable =
213       aNavigator->CreateTouchableHistoryHandle();
214
215     // Do whatever you need with it ...
216     // ... convert point in local coordinates (local to the current volume)
217     //
218     G4ThreeVector localPosition = aTouchable->GetHistory()->
219                   GetTopTransform().TransformPoint(myPoint);
220
221     // ... convert back to global coordinates system
222     G4ThreeVector globalPosition = aTouchable->GetHistory()->
223                   GetTopTransform().Inverse().TransformPoint(localPosition);
224</pre>
225If outside of the tracking run and given a generic local position (local to a
226given volume in the geometry tree), it is -not- possible to determine a priori
227its global position and convert it to the global coordinates system.
228The reason for this is rather simple, nobody can guarantee that the given
229(local) point is located in the right -copy- of the physical volume !
230In order to retrieve this information, some extra knowledge related to the
231absolute position of the physical volume is required first, i.e. one should
232first determine a global point belonging to that volume, eventually making
233a dedicated scan of the geometry tree through a dedicated <tt>G4Navigator</tt>
234object and then apply the method above after having created the touchable for
235it.
236</P>
237
238<a name="4.1.8.3">
239<h3>4.1.8.3 Navigation in parallel geometries</h3></a>
240
241<P>
242Since release 8.2 of Geant4, it is possible to define geometry trees which
243are <i>parallel</i> to the tracking geometry and having them assigned to
244navigator objects that transparently communicate in sync with the normal
245tracking geometry.
246</P>
247<P>
248Parallel geometries can be defined for several uses (fast shower
249parameterisation, geometrical biasing, particle scoring, readout
250geometries, etc ...) and can <i>overlap</i> with the mass geometry defined
251for the tracking. The <i>parallel</i> transportation will be activated only
252after the registration of the parallel geometry in the detector description
253setup; see Section <a href="parallelWorld.html">4.7</a> for how to define a parallel
254geometry and register it to the run-manager.<br>
255The <tt>G4TransportationManager</tt> provides all the utilities to verify,
256retrieve and activate the navigators associated to the various parallel
257geometries defined.
258</P>
259
260<a name="4.1.8.4">
261<h3>4.1.8.4 Run-time commands</h3></a>
262
263<P>
264When running in <i>verbose</i> mode (i.e. the default, <TT>G4VERBOSE</TT>
265set while installing the Geant4 kernel libraries), the navigator provides
266a few commands to control its behavior. It is possible to select different
267verbosity levels (up to 5), with the command:
268<pre>
269     geometry/navigator/verbose [verbose_level]
270</pre>
271or to force the navigator to run in <I>check</I> mode:
272<pre>
273     geometry/navigator/check_mode [true/false]
274</pre>
275The latter will force more strict and less tolerant checks in step/safety
276computation to verify the correctness of the solids' response in the
277geometry.<br>
278
279By combining <i>check_mode</i> with verbosity level-1, additional verbosity
280checks on the response from the solids can be activated.
281<p></p>
282
283<hr>
284<a href="../../../../Authors/html/subjectsToAuthors.html">
285<i>About the authors</a></i> </P>
286
287</body>
288</html>
Note: See TracBrowser for help on using the repository browser.