source: trunk/examples/extended/geometry/olap/README @ 1346

Last change on this file since 1346 was 807, checked in by garnier, 16 years ago

update

File size: 16.0 KB
Line 
1
2                                     OLAP
3
4                    Debugging Tool for Ovelapping Geometries
5                    ----------------------------------------
6                            (Martin.Liendl@cern.ch)
7
8 1  Abbreviations
9 2  Introduction
10 3  Instrumenting the example with a user-geometry
11 4  Reference of command line commands
12 5  Known Problems
13
14
151 Abbreviations
16===============
17
18LV ... instance of G4LogicalVolume
19
20PV ... instance of G4VPhysicalVolume (Placement, Replica or Parameterised)
21
22MV ... mother volume, also referred as NewMother
23
24DV ... daughter volume
25
26NewWorld ... a geometry consisting of one MV and several DVs. The world
27volume is a enlarged bounding box into which the MV is put. Optionally the
28MV can be rotated according to user given parameters inside the NewWorld.
29
30
312 Introduction
32==============
33
34Intersecting DVs inside the same MV or a DV protruding from its MV
35are said to be overlapping. Thus a complete geometry is correct, if
36all direct DVs of any given MV are not intersecting mutually or whith
37their MV. To be noticed that the tool described here cannot do this in
38a perfect way, strictly speaking, but allows to identify most defects in
39the geometry if any. If the check fails, the error is located and can be
40fixed easily. Checking means, that a geantino is shot from a given point
41A to another point B and viceversa from B to A.
42At each step of the geantino's track a boundary crossing has occurred
43(only geometry limits the geantino's steps!). If the set of boundary
44crossings from A to B is different from the set going from B to A
45(within a given Geant4 tolerance), some volumes must be overlapping
46along the line connecting A and B. To locate the overlaps more easily,
47the full geometry (which can be very complex in 'depth' in a hierarchical
48sense) is not used but only a subset consisting of a user selectable
49MV and all contained DVs. Then a user defined 'grid' of geantinos
50is shot through this simple geometry and possible overlaps are detected
51and reported. Checking all MVs in this way is then equivalent to checking
52the full geometry and has the advantage of identifying the cause of
53overlap directly.
54
55
563 Instrumenting the example with a user-geometry
57================================================
58
59A very tiny geometry (RandomDetector.hh,.cc) is provided within the example.
60It is instantiated in the file olapex.cc.
61
62
633.1 Configuring the user-geometry
64---------------------------------
65
66The geometry debugging tools can be used for any Geant4 geometry. The
67geometry which one wants to debug must be available as subclass of
68G4VUserDetectorConstruction and must be used to construct the OlapDetConstr.
69Just read the code in olapex.cc and see how any geometry
70has to be prepared for debugging. The only thing to do is to use the provided
71Olap-UserActions in the main() of the Geant4 program:
72
73G4RunManager * runManager = new G4RunManager;
74
75// special primary generator for geantino shooting (in a grid)
76
77runManager->SetUserAction(new OlapGenerator);
78
79// the full geometry (which will be debugged)
80
81G4VUserDetectorConstruction * origGeom = new RandomDetector;
82
83// wrap full geometry into Olap-Geometry class
84
85OlapDetConstr * olapGeom = new OlapDetConstr(origGeom);
86
87// set wrapped geometry for Geant4 to use
88
89runManager->SetUserInitialization(olapGeom);
90
91// special physics list (nothing but transportation)
92
93runManager->SetUserInitialization(new OlapPhysicsList);
94
95// now create all UserActions ...
96
97OlapRunAction * olapRunAction = new OlapRunAction;
98
99OlapEventAction * olapEventAction = new OlapEventAction(olapRunAction);
100
101OlapSteppingAction * olapSteppingAction =
102
103  new OlapSteppingAction(olapEventAction);
104
105runManager->SetUserAction(olapRunAction);
106
107runManager->SetUserAction(olapEventAction);
108
109runManager->SetUserAction(olapSteppingAction);
110
111
1123.2 Navigating the geometry from command line
113----------------------------------------------
114
115Unix like navigation of the logical volume hierarchy is provided by
116the /olap/cd command. The root of the logical volume tree can be accessed
117by the character '/'.  Any node in the volume tree can be accessed by a '/'
118separated string of regular expressions. If '/' is at the beginning of the string,
119the tree hierarchy is transversed from the root otherwise from the
120currently chosen logical volume. Further the command /olap/goto <regexp>
121can be used to jump to the first LogicalVolume matching the <regexp>.
122
123Every succesful navigational command (/olap/cd, olap/goto) results
124in the construction of a NewWorld, the MV beeing the argument of the
125navigational command and the DVs beeing the direct daughters of the MV.
126
127/olap/pwd always shows where in the full geometrical hierarchy the
128current NewWorld and MV is located.
129
130
1313.3 Detecting Overlaps
132----------------------
133
134First determine the density of the grid of geantinos using
135
136/olap/grid 7 7 7
137
138which returns the number of events (= pairs of geantinos) which will
139be shot through the NewWorld geometry (in this case 147 geantino pairs).
140
141To start overlap detection type
142
143/olap/trigger
144
145After all 147 events are processed, a summary of detected overlaps
146is given. Multiple detected overlaps are only reported once
147
148Error reports are written to G4cerr and to a log file if this is chosen
149(see section on output). The output looks like this:
150
151===== collected overlaps of run [1] (ol=2)
152
153--[1]--------------------------
154
155delta=51
156
157vol 1: point=(-23,0,-40.02) vol 2: point=(-74,0,-40.02) axis=0
158
159A -> B:
160[0]: ins=[i] PVName=[NewWorld:0] Type=[N] P=(-0,-0,-0) R=[0,90,90,90,0,0]
161G4Box: x/2=1234.23 y/2=1234.23 z/2=60.06
162[1]: ins=[o] PVName=[SiliconPatchPanel:0] Type=[N] P=(-0,-0,-0) R=[0,90,90,90,0,0]
163G4Tubs: z/2=60 rIn=74 rOut=1233 startPhi=0 deltaPhi=6.28319
164[2]: ins=[s] PVName=[SiliconPatchPanel1:1] Type=[N] P=(-0,-0,-40) R=[0,90,90,90,0,0]
165G4Tubs: z/2=20 rIn=23 rOut=1135 startPhi=0 deltaPhi=6.28319
166
167B -> A:
168[0]: ins=[i] PVName=[NewWorld:0] Type=[N] P=(-0,-0,-0) R=[0,90,90,90,0,0]
169G4Box: x/2=1234.23 y/2=1234.23 z/2=60.06
170
171'delta' denotes the detected overlap distance. Two volumes are overlapping
172at least this distance. The following coordinates of points are points
173on the boundary of the overlapping volumes. In case of no overlap
174they should be the same points. The first point was found when tracking
175from A to B, while the second point was found when tracking from B
176to A. Using the command
177/olap/delta <DELTA> <unit>
178the accuracy for detecting an overlap can be set. Overlaps will only
179be reported if two volumes overlap at least DELTA*unit on one of the
180genantino tracks scanning the volumes.
181The default value is 1 nm, which is quite tight.
182
183To identify the overlapping volumes,
184the NavigationHistories of the two points are also shown in the output.
185The format of these histories is as follows:
186
187[A]: ins=[B] PVName=[C] Type=[D] P=(E) R=[F] G
188
189A --> Level in G4Navigationhistory
190
191B --> Stepping point is 'inside' vol [2], 'on surface' [1] or 'outside'
192  [0] (mostly biased by numerical limits)
193
194C --> PhysicalVolume-name:copy-no
195
196D --> [N]..placement, [R]..repicated, [P]..parameterized
197
198E --> Position(intern.units)
199
200F --> Rotation(in deg:phiX,thetaX,phiY,..)
201
202G --> Solidtype: specification
203
204In the sample output given above, one can deduce that 'SiliconPatchPanel1'
205with copy-no 1 is overlapping its mother 'SiliconPatchPanel'.
206A schematic sketch of this situation is below:
207
208(x=0)                                                      (x=-1234*mm)
209(B) <----------------------------------------------------> (A)
210 
211  -------------------------------------------------------
212  |NewWorld                                             |
213  |        -------------------------------------------  |
214  |        |SiliconPatchPanel                        |  |
215  |        |                                         |  |
216  |    -----------------------------------           |  |
217  |    |SiliconPatchPanel1               |           |  |
218  |    |                                 |           |  |
219  |....x...*.............................|...........|..|
220  |    |                                 |           |  |
221  |    -----------------------------------           |  |
222  |        |                                         |  |
223  |        -------------------------------------------  |
224  |                                                     |
225  -------------------------------------------------------                     
226
227... = geantino rays from (A) to (B) and from (B) to (A)
228 x  = point found when tracking from (A) to (B)
229 *  = point found wehn tracking from (B) to (A)
230 
231 'x' and '*' should be on the same position in case of no
232 overlaps. But they are not, because 'SiliconPatchPanel1' is
233 protruding its mother volume 'SiliconPatchPanel'.
234 The output report always assigns a point to the volume which
235 is left behind the current direction of the geantino ray.
236 In the example 'x' is assigned to 'SiliconPatchPanel1', because
237 the tracking direction was (A) to (B). On the other hand side,
238 '*' is assigned to 'NewWorld', because the tracking direction
239 was (B) to (A).
240
2413.4 Handling the output
242-----------------------
243
244The output from the overlap detection can be written to file. The program
245provides two possibilities: 'Global logging', which creates one file,
246or 'logging by volume' where each logical volume puts its overlapping
247error into a file.
248
249To instantiate global logging type:
250
251/olap/log <path/filename>
252
253where path/filename is omittable, and the default is olap.log which
254will be created in the current directory. Alternatively one can type
255the path (must end with /), or only the filename. To stop the logging,
256type
257
258/olap/log false
259
260(or exit the program)
261
262The logging by volume command is
263
264/olap/logByVolume <path/>
265
266where the path is once again omittable. If the path is specified, it
267is important that it ends with / . Each log file will then be called
268NameOfLogicalVolume.log, for example SiliconPatchPanel.log. Again
269the logging can be stopped by typing
270
271/olap/logByVolume false
272
273Logging can be done from batch mode with a macro file, or when running
274the program. If the path is specified, it has to exist. The logging
275files are using the append format.
276
277
2784 Reference of command line commands
279====================================
280
2814.1 Terminology
282---------------
283
284NewWorld: NewWorld is the world volume of the chosen subset of the
285detector where overlap detection takes place. Its solid is a box slightly
286larger than the bounding box of the NewMother solid.
287
288NewMother(MV): The user chosen mother volume where overlap detection takes
289place. It is positioned into origin of the NewWorld. Only
290the first level of daughter volumes is then placed inside the NewMother.
291
292
2934.2 Commands for geometry navigation
294------------------------------------
295
296All command line commands are available in the Geant4 command directory
297/olap. For a short help inside Geant4 type help and choose the olap
298command directory.
299
300Commands for navigating the geometry always navigate the full logical
301hierarchy and set the current logical volume to the NewMother.
302Overlaps are detected only between the volumes of the first layer of
303daughters of NewMother and between the daughters and their mother
304volume.
305
306/olap/ls: list all logical daughters of the current NewMother
307
308/olap/pwd: prints the position of the current NewMother within the
309logical hierarchy of the full geometry.
310
311/olap/rotate <theta> <phi> <alpha> <angle-unit>: Defines the rotation
312of the NewMother inside the NewWorld. The rotation will be applied only
313in subsequent navigational commands such as /olap/goto or /olap/cd.
314The rotation axis is defined by the angles <theta> and <phi>, the rotation
315angle around this axis by the angle <alpha>.
316Rotating the NewMother can be particulary helpfull in cases where
317boundaries of the NewMother or of the daugher volumes are parallel
318to the bounderies of the NewWorld-box. Parallesl boundaries often cause
319numierical ambiguities during tracking time resulting in fake overlap
320detections.
321
322/olap/goto <regexp>: Sets the current NewMother to the logical Volume
323which name matches <regexp>. Search order is always descending construction
324order of volumes. If more than one volume matches the <regexp> the
325first match is chosen.
326
327/olap/cd <regexp-1>/<regexp-2>...: Unix-like changing of the current
328NewMother. The argument /olap/cd / sets the topmost logical volume
329of the full geometry to NewMother. olap/cd /Tracker sets the first
330logical daughter of the topmost logical volume which name matches
331Tracker to NewMother. olap/cd .. moves up one step in the logical
332hierarchy and sets the corresponding logical volume to NewMother.
333Combinations are possible, e.g.: /olap/cd Abc.*xy/../../cdef
334
335/olap/list <regexp>: Lists all logical volumes whose name matches <regexp>
336without changing the NewMother.
337
338
3394.2 Commands for overlap detection
340----------------------------------
341
342/olap/grid a b c: Sets a grid for geantino pairs flying through the
343NewWorld. There will be a*b geantino pairs flying parallel to the
344z-axis in a regular grid, b*c parallel to the x-axis and a*c parallel
345to the y-axis.
346
347/olap/delta value unit: Sets boundary tolerance for overlaps in units
348of length.
349
350/olap/trigger: Start geantino shooting in the current NewWorld according
351to the defined grid.
352
353/olap/triggerFull n: Starting from the current NewWorld, the trigger-command
354is applied n times, each time changing the NewWorld by traversing
355the logical volume subtree. If -1 is given as argument (or n > number
356of subtree nodes), the whole subtree is checked.
357
358
3594.3 Commands for logging
360------------------------
361
362/olap/log <path/filename>: Puts the output into one global file.
363Default-filename is olap.log.
364
365/olap/logByVolume <path/>: Each logical volume makes its own file called
366NameOfLogicalVolume.log where overlap errors for that specific volume
367are put.
368
369
3705. Known Problem
371================
372
373. Overlaps of the same two volumes are sometimes reported more the one
374  time at the end of a run
375
376. Fake overlaps are reported sometimes when many boundaries of volumes
377  are parallel to the axis of 'NewWorld'. In this case, try to
378  use /olap/rotate to rotate the volumes inside 'NewWorld', set the
379  'NewWorld' again and redo the overlap scan.
380
381. Fake overlaps can be reported when the Geant4 tracking algorithm
382  gets 'caught' between volume boundaries (many small steps ...)
383
384. Visualization of overlaps is not yet correctly supported.
385
386
387----------------------------------------------------------------------------
388END OF README
389please don't read stuff below ...
390----------------------------------------------------------------------------
391
392[[********************************** experimental ***********************
3933.3
394If visualization
395was enabled, the detected overlaps are visualized with green markers
396as shown in Fig. [fig:olap]. In this figure the NewMother is visualized
397in blue and her daughters in red.
398]]************************************************************************
399
400[[*** The following is experimental ***************************************
401Visualization can also be enabled from the command line. Simply type
402/olap/syncVis 1
403where the argument is a boolean and '0' turns the visualization off.
404If turned on every change of NewMother should also trigger a redraw
405of the chosen visualization driver. If the viewer is not updated,
406a flush can be triggered by /vis/viewer/update. Using VRML2FILE as
407visualization output, ECalBarrelAlveola_2 can be viewed in an appropriate
408VRML viewer:([fig] <fig:alv>Example of a NewWorld with a NewMother
409in red and her daughters in blue (Alveola structure and contained
410crystals of the CMS Ecal). )
411
412]]********************************************************************
413
414
415[[************************************** experimental **********************
4164.4 Commands for visulization
417-----------------------------
418
419/olap/syncVis 1/0: Enables visualization. Every change of NewMother
420should trigger a redraw. The argument is a boolean where '1' turns
421it on and '0' off.
422
423/olap/saveVis <filename>: Saves the current color scheme to an ASCII
424file. (The visualisation attributes can also be modified in this file
425externally.)
426
427/olap/saveVis <filename>: Loads a color scheme from an ASCII file.
428The color scheme must be compatible with the active Geant4 geometry
429in memory.
430]]***************************************************************************
Note: See TracBrowser for help on using the repository browser.