source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Detector/geomPhysical.xml @ 905

Last change on this file since 905 was 904, checked in by garnier, 16 years ago

ajout de la doc

File size: 39.3 KB
Line 
1<!-- ******************************************************** -->
2<!--                                                          -->
3<!--  [History]                                               -->
4<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
5<!--    Changed by: Gabriele Cosmo, 18-Apr-2005               -->
6<!--                                                          -->
7<!-- ******************************************************** -->
8
9
10<!-- ******************* Section (Level#2) ****************** -->
11<sect2 id="sect.Geom.PhysVol">
12<title>
13Physical Volumes
14</title>
15
16<para>
17Physical volumes represent the spatial positioning of the
18volumes describing the detector elements. Several techniques can be
19used. They range from the simple placement of a single copy to the
20repeated positioning using either a simple linear formula or a user
21specified function.
22</para>
23
24<para>
25The simple placement involves the definition of a transformation
26matrix for the volume to be positioned. Repeated positioning is
27defined using the number of times a volume should be replicated at
28a given distance along a given direction. Finally it is possible to
29define a parameterised formula to specify the position of multiple
30copies of a volume. Details about these methods are given
31below.
32</para>
33
34<para>
35<emphasis role="bold">Note</emphasis> - For geometries which vary between runs and for
36which components of the old geometry setup are explicitely
37-deleted-, it is required to consider the proper order of deletion
38(which is the exact inverse of the actual construction, i.e., first
39delete physical volumes and then logical volumes). Deleting a
40logical volume does NOT delete its daughter volumes.
41</para>
42
43<para>
44It is not necessary to delete the geometry setup at the end of a
45job, the system will take care to free the volume and solid stores
46at the end of the job. The user has to take care of the deletion of
47any additional transformation or rotation matrices allocated
48dinamically in his/her own application.
49</para>
50
51<!-- ******************* Section (Level#3) ****************** -->
52<sect3 id="sect.Geom.PhysVol.PlaceSingle">
53<title>
54Placements: single positioned copy
55</title>
56
57<para>
58In this case, the Physical Volume is created by associating a
59Logical Volume with a Rotation Matrix and a Translation vector. The
60Rotation Matrix represents the rotation of the reference frame of
61the considered volume relatively to its mother volume's reference
62frame. The Translation Vector represents the translation of the
63current volume in the reference frame of its mother volume.
64</para>
65
66<para>
67Transformations including reflections are not allowed.
68</para>
69
70<para>
71To create a Placement one must construct it using:
72
73<informalexample>
74<programlisting>
75    G4PVPlacement(       G4RotationMatrix*  pRot,
76                   const G4ThreeVector&amp;     tlate,
77                         G4LogicalVolume*   pCurrentLogical,
78                   const G4String&amp;          pName,
79                         G4LogicalVolume*   pMotherLogical,
80                         G4bool             pMany,
81                         G4int              pCopyNo,
82                         G4bool             pSurfChk=false )
83</programlisting>
84</informalexample>
85
86where:
87
88<informaltable>
89<tgroup cols="2">
90<tbody>
91<row>
92  <entry>
93    <literal>pRot</literal>
94  </entry>
95  <entry>
96    Rotation with respect to its mother volume
97  </entry>
98</row>
99<row>
100  <entry>
101    <literal>tlate</literal>
102  </entry>
103  <entry>
104    Translation with respect to its mother volume
105  </entry>
106</row>
107<row>
108  <entry>
109    <literal>pCurrentLogical</literal>
110  </entry>
111  <entry>
112    The associated Logical Volume
113  </entry>
114</row>
115<row>
116  <entry>
117    <literal>pName</literal>
118  </entry>
119  <entry>
120    String identifier for this placement
121  </entry>
122</row>
123<row>
124  <entry>
125    <literal>pMotherLogical</literal>
126  </entry>
127  <entry>
128    The associated mother volume
129  </entry>
130</row>
131<row>
132  <entry>
133    <literal>pMany</literal>
134  </entry>
135  <entry>
136    For future use. Can be set to false
137  </entry>
138</row>
139<row>
140  <entry>
141    <literal>pCopyNo</literal>
142  </entry>
143  <entry>
144    Integer which identifies this placement
145  </entry>
146</row>
147<row>
148  <entry>
149    <literal>pSurfChk</literal>
150  </entry>
151  <entry>
152    if true activates check for overlaps with existing volumes
153  </entry>
154</row>
155</tbody>
156</tgroup>
157</informaltable>
158</para>
159
160<para>
161Care must be taken because the rotation matrix is not copied by
162a <literal>G4PVPlacement</literal>. So the user must not modify it after
163creating a Placement that uses it. However the same rotation matrix
164can be re-used for many volumes.
165</para>
166
167<para>
168Currently boolean operations are not implemented at the level of
169physical volume. So <literal>pMany</literal> must be false. However, an
170alternative implementation of boolean operations exists. In this
171approach a solid can be created from the union, intersection or
172subtraction of two solids. See  <xref linkend="sect.Geom.Solids.BoolOp" />
173 above for an explanation of this.
174</para>
175
176<para>
177The mother volume must be specified for all volumes
178<emphasis>except</emphasis> the world volume.
179</para>
180
181<para>
182An alternative way to specify a Placement utilizes a different
183method to place the volume. The solid itself is moved by rotating
184and translating it to bring it into the system of coordinates of
185the mother volume. This <emphasis>active</emphasis> method can be utilized using
186the following constructor:
187
188<informalexample>
189<programlisting>
190    G4PVPlacement(       G4Transform3D      solidTransform,
191                         G4LogicalVolume*   pCurrentLogical,
192                   const G4String&amp;          pName,
193                         G4LogicalVolume*   pMotherLogical,
194                         G4bool             pMany,
195                         G4int              pCopyNo,
196                         G4bool             pSurfChk=false )
197</programlisting>
198</informalexample>
199</para>
200
201<para>
202An alternative method to specify the mother volume is to specify
203its placed physical volume. It can be used in either of the above
204methods of specifying the placement's position and rotation. The
205effect will be exactly the same as for using the mother logical
206volume.
207</para>
208
209<para>
210Note that a Placement Volume can still represent multiple
211detector elements. This can happen if several copies exist of the
212mother logical volume. Then different detector elements will belong
213to different branches of the tree of the hierarchy of geometrical
214volumes.
215</para>
216
217</sect3>
218
219<!-- ******************* Section (Level#3) ****************** -->
220<sect3 id="sect.Geom.PhysVol.RepeatVol">
221<title>
222Repeated volumes
223</title>
224
225<para>
226In this case, a single Physical Volume represents multiple copies
227of a volume within its mother volume, allowing to save memory. This
228is normally done when the volumes to be positioned follow a well
229defined rotational or translational symmetry along a Cartesian or
230cylindrical coordinate. The Repeated Volumes technique is available
231for volumes described by CSG solids.
232</para>
233
234<!-- ******* Bridgehead ******* -->
235<bridgehead renderas='sect4'>
236Replicas:
237</bridgehead>
238
239<para>
240Replicas are <emphasis>repeated volumes</emphasis> in the case when the
241multiple copies of the volume are all identical. The coordinate
242axis and the number of replicas need to be specified for the
243program to compute at run time the transformation matrix
244corresponding to each copy.
245
246<informalexample>
247<programlisting>
248    G4PVReplica( const G4String&amp;          pName,
249                       G4LogicalVolume*   pCurrentLogical,
250                       G4LogicalVolume*   pMotherLogical, // OR G4VPhysicalVolume*
251                 const EAxis              pAxis,
252                 const G4int              nReplicas,
253                 const G4double           width,
254                 const G4double           offset=0 )
255</programlisting>
256</informalexample>
257
258where:
259
260<informaltable>
261<tgroup cols="2">
262<tbody>
263<row>
264  <entry>
265    <literal>pName</literal>
266  </entry>
267  <entry>
268    String identifier for the replicated volume
269  </entry>
270</row>
271<row>
272  <entry>
273    <literal>pCurrentLogical</literal>
274  </entry>
275  <entry>
276    The associated Logical Volume
277   </entry>
278</row>
279<row>
280  <entry>
281    <literal>pMotherLogical</literal>
282  </entry>
283  <entry>
284    The associated mother volume
285  </entry>
286</row>
287<row>
288  <entry>
289    <literal>pAxis</literal>
290  </entry>
291  <entry>
292    The axis along with the replication is applied
293  </entry>
294</row>
295<row>
296  <entry>
297    <literal>nReplicas</literal>
298  </entry>
299  <entry>
300    The number of replicated volumes
301  </entry>
302</row>
303<row>
304  <entry>
305    <literal>width</literal>
306  </entry>
307  <entry>
308    The width of a single replica along the axis of replication
309  </entry>
310</row>
311<row>
312  <entry>
313    <literal>offset</literal>
314  </entry>
315  <entry>
316    Possible offset associated to mother offset along the axis of
317    replication
318  </entry>
319</row>
320</tbody>
321</tgroup>
322</informaltable>
323</para>
324
325<para>
326<literal>G4PVReplica</literal> represents <literal>nReplicas</literal> volumes
327differing only in their positioning, and completely <emphasis role="bold">filling</emphasis>
328the containing mother volume. Consequently if a
329<literal>G4PVReplica</literal> is 'positioned' inside a given mother it
330<emphasis role="bold">MUST</emphasis> be the mother's only daughter volume. Replica's
331correspond to divisions or slices that completely fill the mother
332volume and have no offsets. For Cartesian axes, slices are
333considered perpendicular to the axis of replication.
334</para>
335
336<para>
337The replica's positions are calculated by means of a linear
338formula. Replication may occur along:
339
340<itemizedlist spacing="compact">
341  <listitem><para>
342    <emphasis>Cartesian axes <literal>(kXAxis,kYAxis,kZAxis)</literal></emphasis>
343    <para>
344    The replications, of specified width have coordinates of form
345    <literal>(-width*(nReplicas-1)*0.5+n*width,0,0)</literal>
346    </para>
347    <para>
348    where <literal>n=0.. nReplicas-1</literal> for the case of <literal>kXAxis</literal>,
349    and are unrotated.
350    </para>
351  </para></listitem>
352  <listitem><para>
353    <emphasis>Radial axis (cylindrical polar) <literal>(kRho)</literal></emphasis>
354    <para>
355    The replications are cons/tubs sections, centred on the origin and
356    are unrotated.
357    </para>
358    <para>
359    They have radii of <literal>width*n+offset</literal> to
360    <literal>width*(n+1)+offset</literal> where
361    <literal>n=0..nReplicas-1</literal>
362    </para>
363  </para></listitem>
364  <listitem><para>
365    <emphasis>Phi axis (cylindrical polar) <literal>(kPhi)</literal></emphasis>
366    <para>
367    The replications are <emphasis>phi sections</emphasis> or
368    <emphasis>wedges</emphasis>, and of cons/tubs form.
369    </para>
370    <para>
371    They have <literal>phi</literal> of <literal>offset+n*width</literal> to
372    <literal>offset+(n+1)*width</literal> where
373    <literal>n=0..nReplicas-1</literal>
374    </para>
375  </para></listitem>
376</itemizedlist>
377</para>
378
379<para>
380The coordinate system of the replicas is at the centre of each
381replica for the cartesian axis. For the radial case, the coordinate
382system is unchanged from the mother. For the <literal>phi</literal> axis, the
383new coordinate system is rotated such that the X axis bisects the
384angle made by each wedge, and Z remains parallel to the mother's Z
385axis.
386</para>
387
388<para>
389The solid associated via the replicas' logical volume should
390have the dimensions of the first volume created and must be of the
391correct symmetry/type, in order to assist in good
392visualisation.
393</para>
394
395<para>
396ex. For X axis replicas in a box, the solid should be another box
397with the dimensions of the replications. (same Y &amp; Z dimensions
398as mother box, X dimension = mother's X dimension/nReplicas).
399</para>
400
401<para>
402Replicas may be placed inside other replicas, provided the above
403rule is observed. Normal placement volumes may be placed inside
404replicas, provided that they do not intersect the mother's or any
405previous replica's boundaries. Parameterised volumes may not be
406placed inside.
407</para>
408
409<para>
410Because of these rules, it is not possible to place any other
411volume inside a replication in <literal>radius</literal>.
412</para>
413
414<para>
415The world volume <emphasis>cannot</emphasis> act as a replica, therefore it
416cannot be sliced.
417</para>
418
419<para>
420During tracking, the translation + rotation associated with each
421<literal>G4PVReplica</literal> object is modified according to the currently
422'active' replication. The solid is not modified and consequently
423has the wrong parameters for the cases of <literal>phi</literal> and
424<literal>r</literal> replication and for when the cross-section of the mother
425is not constant along the replication.
426</para>
427
428<para>
429Example:
430
431<example id="programlist_Geom.PhysVol_1">
432<title>
433An example of simple replicated volumes with <literal>G4PVReplica</literal>.
434</title>
435<programlisting>
436           G4PVReplica repX("Linear Array",
437                            pRepLogical,
438                            pContainingMother,
439                            kXAxis, 5, 10*mm);
440
441           G4PVReplica repR("RSlices",
442                            pRepRLogical,
443                            pContainingMother,
444                            kRho, 5, 10*mm, 0);
445
446           G4PVReplica repRZ("RZSlices",
447                             pRepRZLogical,
448                             &amp;repR,
449                             kZAxis, 5, 10*mm);
450
451           G4PVReplica repRZPhi("RZPhiSlices",
452                                pRepRZPhiLogical,
453                                &amp;repRZ,
454                                kPhi, 4, M_PI*0.5*rad, 0);
455</programlisting>
456</example>
457</para>
458
459<para>
460<literal>RepX</literal> is an array of 5 replicas of width 10*mm,
461positioned inside and completely filling the volume pointed by
462<literal>pContainingMother</literal>. The mother's X length must be
4635*10*mm=50*mm (for example, if the mother's solid were a Box of
464half lengths [25,25,25] then the replica's solid must be a box of
465half lengths [25,25,5]).
466</para>
467
468<para>
469If the containing mother's solid is a tube of radius 50*mm and
470half Z length of 25*mm, <literal>RepR</literal> divides the mother tube into
4715 cylinders (hence the solid associated with <literal>pRepRLogical</literal>
472must be a tube of radius 10*mm, and half Z length 25*mm);
473<literal>repRZ</literal> divides it into 5 shorter cylinders (the solid
474associated with <literal>pRepRZLogical</literal> must be a tube of radius
47510*mm, and half Z length 5*mm); finally, <literal>repRZPhi</literal> divides
476it into 4 tube segments with full angle of 90 degrees (the solid
477associated with <literal>pRepRZPhiLogical</literal> must be a tube segment of
478radius 10*mm, half Z length 5*mm and delta phi of
479M_PI*0.5*rad).
480</para>
481
482<para>
483No further volumes may be placed inside these replicas. To do so
484would result in intersecting boundaries due to the <literal>r</literal>
485replications.
486</para>
487
488<!-- ******* Bridgehead ******* -->
489<bridgehead renderas='sect4'>
490Parameterised Volumes:
491</bridgehead>
492
493<para>
494Parameterised Volumes are <emphasis>repeated volumes</emphasis> in the case in
495which the multiple copies of a volume can be different in size,
496solid type, or material. The solid's type, its dimensions, the
497material and the transformation matrix can all be parameterised in
498function of the copy number, both when a strong symmetry exist and
499when it does not. The user implements the desired parameterisation
500function and the program computes and updates automatically at run
501time the information associated to the Physical Volume.
502</para>
503
504<para>
505An example of creating a parameterised volume (by dimension and
506position) exists in novice example N02. The implementation is
507provided in the two classes <literal>ExN02DetectorConstruction</literal> and
508<literal>ExN02ChamberParameterisation</literal>.
509</para>
510
511<para>
512To create a parameterised volume, one must first create its
513logical volume like <literal>trackerChamberLV</literal> below. Then one must
514create his own parameterisation class
515(<emphasis>ExN02ChamberParameterisation</emphasis>) and instantiate an object of
516this class (<literal>chamberParam</literal>). We will see how to create the
517parameterisation below.
518
519<example  id="programlist_Geom.PhysVol_2">
520<title>
521An example of Parameterised volumes.
522</title>
523<programlisting>
524  //------------------------------
525  // Tracker segments
526  //------------------------------
527  // An example of Parameterised volumes
528  // dummy values for G4Box -- modified by parameterised volume
529  G4VSolid * solidChamber =
530                new G4Box("chamberBox", 10.*cm, 10.*cm, 10.*cm);
531
532  G4LogicalVolume * trackerChamberLV
533    = new G4LogicalVolume(solidChamber, Aluminum, "trackerChamberLV");
534  G4VPVParameterisation * chamberParam
535    = new ExN02ChamberParameterisation(
536                         6,           //  NoChambers,
537                        -240.*cm,     //  Z of centre of first
538                        80*cm,        //  Z spacing of centres
539                        20*cm,        //  Width Chamber,
540                        50*cm,        //  lengthInitial,
541                        trackerSize*2.); //  lengthFinal
542
543  G4VPhysicalVolume *trackerChamber_phys
544    = new G4PVParameterised("TrackerChamber_parameterisedPV",
545                       trackerChamberLV, // Its logical volume
546                       logicTracker,     // Mother logical volume
547                       kUndefined,       // Allow default voxelising -- no axis
548                       6,                // Number of chambers
549                       chamberParam);    // The parameterisation
550  // "kUndefined" is the suggested choice, giving 3D voxelisation (i.e. along the three
551  // cartesian axes, as is applied for placements.
552  //
553  // Note:  In some cases where volume have clear separation along a single axis,
554  // this axis (eg kZAxis) can be used to choose (force) optimisation only along
555  // this axis in geometrical calculations.
556  // When an axis is given it forces the use of one-dimensional voxelisation.
557</programlisting>
558</example>
559</para>
560
561<para>
562The general constructor is:
563
564<informalexample>
565<programlisting>
566    G4PVParameterised( const G4String&amp;              pName,
567                             G4LogicalVolume*       pCurrentLogical,
568                             G4LogicalVolume*       pMotherLogical, // OR G4VPhysicalVolume*
569                       const EAxis                  pAxis,
570                       const G4int                  nReplicas,
571                             G4VPVParameterisation* pParam,
572                             G4bool                 pSurfChk=false )
573 
574</programlisting>
575</informalexample>
576</para>
577
578<para>
579Note that for a parameterised volume the user must always
580specify a mother volume. So the world volume can <emphasis>never</emphasis> be a
581parameterised volume, nor it can be sliced. The mother volume can
582be specified either as a physical or a logical volume.
583</para>
584
585<para>
586<literal>pAxis</literal> specifies the tracking optimisation algorithm to
587apply: if a valid axis (the axis along which the parameterisation
588is performed) is specified, a simple one-dimensional voxelisation
589algorithm is applied; if "kUndefined" is specified instead, the
590default three-dimensional voxelisation algorithm applied for normal
591placements will be activated. In the latter case, more voxels will
592be generated, therefore a greater amount of memory will be consumed
593by the optimisation algorithm.
594</para>
595
596<para>
597<literal>pSurfChk</literal> if <literal>true</literal> activates a check for
598overlaps with existing volumes or paramaterised instances.
599</para>
600
601<para>
602The parameterisation mechanism associated to a parameterised
603volume is defined in the parameterisation class and its methods.
604Every parameterisation must create two methods:
605
606<itemizedlist spacing="compact">
607  <listitem><para>
608    <literal>ComputeTransformation</literal> defines where one of the copies
609    is placed,
610  </para></listitem>
611  <listitem><para>
612    <literal>ComputeDimensions</literal> defines the size of one copy, and
613  </para></listitem>
614  <listitem><para>
615    a constructor that initializes any member variables that are
616    required.
617  </para></listitem>
618</itemizedlist>
619
620<para>
621An example is <literal>ExN02ChamberParameterisation</literal> that
622parameterises a series of boxes of different sizes
623
624<example id="programlist_Geom.PhysVol_3">
625<title>
626An example of Parameterised boxes of different sizes.
627</title>
628<programlisting>
629 class ExN02ChamberParameterisation : public G4VPVParameterisation
630 {
631   ...
632   void ComputeTransformation(const G4int       copyNo,
633                              G4VPhysicalVolume *physVol) const;
634
635   void ComputeDimensions(G4Box&amp;              trackerLayer,
636                          const G4int             copyNo,
637                          const G4VPhysicalVolume *physVol) const;
638   ...
639 }
640</programlisting>
641</example>
642</para>
643
644<para>
645These methods works as follows:
646</para>
647
648<para>
649The <literal>ComputeTransformation</literal> method is called with a copy
650number for the instance of the parameterisation under
651consideration. It must compute the transformation for this copy,
652and set the physical volume to utilize this transformation:
653
654<informalexample>
655<programlisting>
656 void ExN02ChamberParameterisation::ComputeTransformation
657 (const G4int copyNo,G4VPhysicalVolume *physVol) const
658 {
659   G4double      Zposition= fStartZ + copyNo * fSpacing;
660   G4ThreeVector origin(0,0,Zposition);
661   physVol-&gt;SetTranslation(origin);
662   physVol-&gt;SetRotation(0);
663 }
664</programlisting>
665</informalexample>
666</para>
667
668<para>
669Note that the translation and rotation given in this scheme are
670those for the frame of coordinates (the <emphasis>passive</emphasis> method).
671They are <emphasis role="bold">not</emphasis> for the
672<emphasis>active</emphasis> method, in which the
673solid is rotated into the mother frame of coordinates.
674</para>
675
676<para>
677Similarly the <literal>ComputeDimensions</literal> method is used to set
678the size of that copy.
679
680<informalexample>
681<programlisting>
682 void ExN02ChamberParameterisation::ComputeDimensions
683 (G4Box &amp; trackerChamber, const G4int copyNo,
684  const G4VPhysicalVolume * physVol) const
685 {
686   G4double  halfLength= fHalfLengthFirst + (copyNo-1) * fHalfLengthIncr;
687   trackerChamber.SetXHalfLength(halfLength);
688   trackerChamber.SetYHalfLength(halfLength);
689   trackerChamber.SetZHalfLength(fHalfWidth);
690 }
691</programlisting>
692</informalexample> 
693</para>
694
695<para>
696The user must ensure that the type of the first argument of this
697method (in this example <literal>G4Box &amp;</literal>) corresponds to the
698type of object the user give to the logical volume of parameterised
699physical volume.
700</para>
701
702<para>
703More advanced usage allows the user:
704
705<itemizedlist spacing="compact">
706  <listitem><para>
707    to change the type of solid by creating a <literal>ComputeSolid</literal>
708    method, or
709  </para></listitem>
710  <listitem><para>
711    to change the material of the volume by creating a
712    <literal>ComputeMaterial</literal> method. This method can also utilise
713    information from a parent or other ancestor volume (see the Nested
714    Parameterisation below.)
715  </para></listitem>
716</itemizedlist>
717
718for the parameterisation.
719</para>
720
721<para>
722Example N07 shows a simple parameterisation by material. A more
723complex example is provided in
724<literal>examples/extended/medical/DICOM</literal>, where a phantom grid of
725cells is built using a parameterisation by material defined through
726a map.
727</para>
728
729<note>
730<title>Note</title>
731<para>
732Currently for many cases it is not possible to add
733daughter volumes to a parameterised volume. Only parameterised
734volumes all of whose solids have the same size are allowed to
735contain daughter volumes. When the size or type of solid varies,
736adding daughters is not supported.
737</para>
738
739<para>
740So the full power of parameterised volumes can be used only for
741"leaf" volumes, which contain no other volumes.
742</para>
743</note>
744
745
746<!-- ******* Bridgehead ******* -->
747<bridgehead renderas='sect4'>
748Advanced parameterisations for 'nested' parameterised volumes
749</bridgehead>
750
751<para>
752A new type of parameterisation enables a user to have the
753daughter's material also depend on the copy number of the parent
754when a parameterised volume (daughter) is located inside another
755(parent) repeated volume. The parent volume can be a replica, a
756parameterised volume, or a division if the key feature of modifying
757its contents is utilised. (Note: a 'nested' parameterisation inside
758a placement volume is not supported, because all copies of a
759placement volume must be identical at all levels.)
760</para>
761
762<para>
763In such a " nested" parameterisation , the user must provide a
764<literal>ComputeMaterial</literal> method that utilises the new argument that
765represents the touchable history of the parent volume:
766
767<informalexample>
768<programlisting>
769// Sample Parameterisation
770class SampleNestedParameterisation : public G4VNestedParameterisation
771{
772 public:
773   // .. other methods ...
774    // Mandatory method, required and reason for this class
775    virtual G4Material* ComputeMaterial(G4VPhysicalVolume *currentVol,
776                                                           const G4int no_lev,
777                                                           const G4VTouchable *parentTouch);
778 private:
779    G4Material *material1, *material2; 
780};
781</programlisting>
782</informalexample> 
783</para>
784
785<para>
786The implementation of the method can utilise any information
787from a parent or other ancestor volume of its parameterised
788physical volume, but typically it will use only the copy
789number:
790
791<informalexample>
792<programlisting> 
793 G4Material*
794 SampleNestedParameterisation::ComputeMaterial(G4VPhysicalVolume *currentVol,
795                                               const G4int no_lev,
796                                               const G4VTouchable *parentTouchable)
797 {
798    G4Material *material=0;
799       
800    // Get the information about the parent volume
801    G4int no_parent= parentTouchable-&gt;GetReplicaNumber();
802    G4int no_total= no_parent + no_lev;
803    // A simple 'checkerboard' pattern of two materials
804    if( no_total / 2 == 1 ) material= material1;
805    else  material= material2;
806    // Set the material to the current logical volume
807    G4LogicalVolume* currentLogVol= currentVol-&gt;GetLogicalVolume();
808    currentLogVol-&gt;SetMaterial( material );
809    return material;
810 }
811</programlisting>
812</informalexample> 
813</para>
814
815<para>
816Nested parameterisations are suitable for the case of regular,
817'voxel' geometries in which a large number of 'equal' volumes are
818required, and their only difference is in their material. By
819creating two (or more) levels of parameterised physical volumes it
820is possible to divide space, while requiring only limited
821additional memory for very fine-level optimisation. This provides
822fast navigation. Alternative implementations, taking into account
823the regular structure of such geometries in navigation are under
824study.
825</para>
826
827<!-- ******* Bridgehead ******* -->
828<bridgehead renderas='sect4'>
829Divisions of Volumes
830</bridgehead>
831
832<para>
833Divisions in Geant4 are implemented as a specialized type of
834parameterised volumes.
835</para>
836
837<para>
838They serve to divide a volume into identical copies along one of
839its axes, providing the possibility to define an <emphasis>offset</emphasis>, and
840without the limitation that the daugthers have to fill the mother
841volume as it is the case for the replicas. In the case, for
842example, of a tube divided along its radial axis, the copies are
843not strictly identical, but have increasing radii, although their
844widths are constant.
845</para>
846
847<para>
848To divide a volume it will be necessary to provide:
849
850<orderedlist spacing="compact">
851  <listitem><para>
852    the axis of division, and
853  </para></listitem>
854  <listitem><para>
855    either
856    <itemizedlist spacing="compact">
857      <listitem><para>
858        the number of divisions (so that the width of each division
859        will be automatically calculated), or
860      </para></listitem>
861      <listitem><para>
862        the division width (so that the number of divisions will be
863        automatically calculated to fill as much of the mother as
864        possible), or
865      </para></listitem>
866      <listitem><para>
867        both the number of divisions and the division width (this is
868        especially designed for the case where the copies do not fully fill
869        the mother).
870      </para></listitem>
871    </itemizedlist>
872  </para></listitem>
873</orderedlist>
874</para>
875
876<para>
877An <emphasis>offset</emphasis> can be defined so that the first copy will
878start at some distance from the mother wall. The dividing copies
879will be then distributed to occupy the rest of the volume.
880</para>
881
882<para>
883There are three constructors, corresponding to the three input
884possibilities described above:
885
886<itemizedlist spacing="compact">
887  <listitem><para>
888    Giving only the number of divisions:
889
890    <informalexample>
891    <programlisting>
892     G4PVDivision( const G4String&amp; pName,
893                         G4LogicalVolume* pCurrentLogical,
894                         G4LogicalVolume* pMotherLogical,
895                   const EAxis pAxis,
896                   const G4int nDivisions,
897                   const G4double offset )
898    </programlisting>
899    </informalexample>
900  </para></listitem>
901  <listitem><para>
902    Giving only the division width:
903
904    <informalexample>
905    <programlisting>
906     G4PVDivision( const G4String&amp; pName,
907                         G4LogicalVolume* pCurrentLogical,
908                         G4LogicalVolume* pMotherLogical,
909                   const EAxis pAxis,
910                   const G4double width,
911                   const G4double offset )
912    </programlisting>
913    </informalexample>
914  </para></listitem>
915  <listitem><para>
916    Giving the number of divisions and the division width:
917
918    <informalexample>
919    <programlisting>
920     G4PVDivision( const G4String&amp; pName,
921                         G4LogicalVolume* pCurrentLogical,
922                         G4LogicalVolume* pMotherLogical,
923                   const EAxis pAxis,
924                   const G4int nDivisions,
925                   const G4double width,
926                   const G4double offset )
927    </programlisting>
928    </informalexample>
929  </para></listitem>
930</itemizedlist>
931
932where:
933
934<informaltable>
935<tgroup cols="2">
936<tbody>
937<row>
938  <entry>
939    <literal>pName</literal>
940  </entry>
941  <entry>
942    String identifier for the replicated volume
943  </entry>
944</row>
945<row>
946  <entry>
947    <literal>pCurrentLogical</literal>
948  </entry>
949  <entry>
950    The associated Logical Volume
951  </entry>
952</row>
953<row>
954  <entry>
955    <literal>pMotherLogical</literal>
956  </entry>
957  <entry>
958    The associated mother Logical Volume
959  </entry>
960</row>
961<row>
962  <entry>
963    <literal>pAxis</literal>
964  </entry>
965  <entry>
966    The axis along which the division is applied
967  </entry>
968</row>
969<row>
970  <entry>
971    <literal>nDivisions</literal>
972  </entry>
973  <entry>
974    The number of divisions
975  </entry>
976</row>
977<row>
978  <entry>
979    <literal>width</literal>
980  </entry>
981  <entry>
982    The width of a single division along the axis
983  </entry>
984</row>
985<row>
986  <entry>
987    <literal>offset</literal>
988  </entry>
989  <entry>
990    Possible offset associated to the mother along the axis of division
991  </entry>
992</row>
993</tbody>
994</tgroup>
995</informaltable>
996</para>
997
998<para>
999The parameterisation is calculated automatically using the
1000values provided in input. Therefore the dimensions of the solid
1001associated with <literal>pCurrentLogical</literal> will not be used, but
1002recomputed through the
1003<literal>G4VParameterisation::ComputeDimension()</literal> method.
1004</para>
1005
1006<para>
1007Since <literal>G4VPVParameterisation</literal> may have different
1008<literal>ComputeDimension()</literal> methods for each solid type, the user
1009must provide a solid that is of the same type as of the one
1010associated to the mother volume.
1011</para>
1012
1013<para>
1014As for any replica, the coordinate system of the divisions is
1015related to the centre of each division for the cartesian axis. For
1016the radial axis, the coordinate system is the same of the mother
1017volume. For the phi axis, the new coordinate system is rotated such
1018that the X axis bisects the angle made by each wedge, and Z remains
1019parallel to the mother's Z axis.
1020</para>
1021
1022<para>
1023As divisions are parameterised volumes with constant dimensions,
1024they may be placed inside other divisions, except in the case of
1025divisions along the radial axis.
1026</para>
1027
1028<para>
1029It is also possible to place other volumes inside a volume where a
1030division is placed.
1031</para>
1032
1033<para>
1034The list of volumes that currently support divisioning and the
1035possible division axis are summarised below:
1036
1037<informaltable>
1038<tgroup cols="2">
1039<tbody>
1040<row>
1041  <entry>
1042    <literal>G4Box</literal>
1043  </entry>
1044  <entry>
1045    <literal>kXAxis</literal>, <literal>kYAxis</literal>, <literal>kZAxis</literal>
1046  </entry>
1047</row>
1048<row>
1049  <entry>
1050    <literal>G4Tubs</literal>
1051  </entry>
1052  <entry>
1053    <literal>kRho</literal>, <literal>kPhi</literal>, <literal>kZAxis</literal>
1054  </entry>
1055</row>
1056<row>
1057  <entry>
1058    <literal>G4Cons</literal>
1059  </entry>
1060  <entry>
1061    <literal>kRho</literal>, <literal>kPhi</literal>, <literal>kZAxis</literal>
1062  </entry>
1063</row>
1064<row>
1065  <entry>
1066    <literal>G4Trd</literal>
1067  </entry>
1068  <entry>
1069    <literal>kXAxis</literal>, <literal>kYAxis</literal>, <literal>kZAxis</literal>
1070  </entry>
1071</row>
1072<row>
1073  <entry>
1074    <literal>G4Para</literal>
1075  </entry>
1076  <entry>
1077    <literal>kXAxis</literal>, <literal>kYAxis</literal>, <literal>kZAxis</literal>
1078  </entry>
1079</row>
1080<row>
1081  <entry>
1082    <literal>G4Polycone</literal>
1083  </entry>
1084  <entry>
1085    <literal>kRho</literal>, <literal>kPhi</literal>, <literal>kZAxis</literal> (*)
1086  </entry>
1087</row>
1088<row>
1089  <entry>
1090    <literal>G4Polyhedra</literal>
1091  </entry>
1092  <entry>
1093    <literal>kRho</literal>, <literal>kPhi</literal>, <literal>kZAxis</literal> (**)
1094  </entry>
1095</row>
1096</tbody>
1097</tgroup>
1098</informaltable>
1099</para>
1100
1101
1102<para>
1103(*) - <literal>G4Polycone</literal>:
1104
1105<itemizedlist spacing="compact">
1106  <listitem><para>
1107    <literal>kZAxis</literal> - the number of divisions has to be the same as
1108    solid sections, (i.e. <literal>numZPlanes-1</literal>), the width will
1109    <emphasis>not</emphasis> be taken into account.</para></listitem>
1110</itemizedlist>
1111</para>
1112
1113<para>
1114(**) - <literal>G4Polyhedra</literal>:
1115
1116<itemizedlist spacing="compact">
1117  <listitem><para>
1118    <literal>kPhi</literal> - the number of divisions has to be the same as
1119    solid sides, (i.e. <literal>numSides</literal>), the width will
1120    <emphasis>not</emphasis> be taken into account.
1121  </para></listitem>
1122  <listitem><para>
1123    <literal>kZAxis</literal> - the number of divisions has to be the same as
1124    solid sections, (i.e. <literal>numZPlanes-1</literal>), the width will
1125    <emphasis>not</emphasis> be taken into account.
1126  </para></listitem>
1127</itemizedlist>
1128</para>
1129
1130<para>
1131In the case of division along <literal>kRho</literal> of <literal>G4Cons</literal>,
1132<literal>G4Polycone</literal>, <literal>G4Polyhedra</literal>, if width is provided, it
1133is taken as the width at the <literal>-Z</literal> radius; the width at other
1134radii will be scaled to this one.
1135</para>
1136
1137<para>
1138Examples are given below in listings
1139<xref linkend="programlist_Geom.PhysVol_3" /> and
1140<xref linkend="programlist_Geom.PhysVol_4" />.
1141
1142<example id="programlist_Geom.PhysVol_4"> 
1143<title>
1144An example of a box division along different axes, with or without offset.
1145</title>
1146<programlisting>
1147 G4Box* motherSolid = new G4Box("motherSolid", 0.5*m, 0.5*m, 0.5*m);
1148 G4LogicalVolume* motherLog = new G4LogicalVolume(motherSolid, material, "mother",0,0,0);
1149 G4Para* divSolid = new G4Para("divSolid", 0.512*m, 1.21*m, 1.43*m);
1150 G4LogicalVolume* childLog = new G4LogicalVolume(divSolid, material, "child",0,0,0);
1151
1152 G4PVDivision divBox1("division along X giving nDiv",
1153                      childLog, motherLog, kXAxis, 5, 0.);
1154
1155 G4PVDivision divBox2("division along X giving width and offset",
1156                      childLog, motherLog, kXAxis, 0.1*m, 0.45*m);
1157
1158 G4PVDivision divBox3("division along X giving nDiv, width and offset",
1159                      childLog, motherLog, kXAxis, 3, 0.1*m, 0.5*m);
1160</programlisting>
1161</example>
1162
1163<itemizedlist spacing="compact">
1164  <listitem><para>
1165    <literal>divBox1</literal> is a division of a box along its <literal>X</literal>
1166    axis in 5 equal copies. Each copy will have a dimension in meters
1167    of <literal>[0.2, 1., 1.]</literal>.
1168  </para></listitem>
1169  <listitem><para>
1170    <literal>divBox2</literal> is a division of the same box along its
1171    <literal>X</literal> axis with a width of <literal>0.1</literal> meters and
1172    an offset of <literal>0.5</literal> meters. As the mother dimension along
1173    <literal>X</literal> of
1174    <literal>1</literal> meter (<literal>0.5*m</literal> of halflength),
1175    the division will
1176    be sized in total <literal>1 - 0.45 = 0.55</literal> meters. Therefore,
1177    there's space for 5 copies, the first extending from <literal>-0.05</literal>
1178    to <literal>0.05</literal> meters in the mother's frame and the last from
1179    <literal>0.35</literal> to <literal>0.45</literal> meters.
1180  </para></listitem>
1181  <listitem><para>
1182    <literal>divBox3</literal> is a division of the same box along its
1183    <literal>X</literal> axis in 3 equal copies of width <literal>0.1</literal> 
1184    meters and an offset of <literal>0.5</literal> meters.
1185    The first copy will extend from
1186    <literal>0.</literal> to <literal>0.1</literal> meters in the mother's frame
1187    and the last from <literal>0.2</literal> to <literal>0.3</literal> 
1188    meters.
1189  </para></listitem>
1190</itemizedlist>
1191</para>
1192
1193<example id="programlist_Geom.PhysVol_5">
1194<title>
1195An example of division of a polycone.
1196</title>
1197<programlisting>
1198  G4double* zPlanem = new G4double[3];
1199            zPlanem[0]= -1.*m;
1200            zPlanem[1]= -0.25*m;
1201            zPlanem[2]=  1.*m;
1202  G4double* rInnerm = new G4double[3];
1203            rInnerm[0]=0.;
1204            rInnerm[1]=0.1*m;
1205            rInnerm[2]=0.5*m;
1206  G4double* rOuterm  = new G4double[3];
1207            rOuterm[0]=0.2*m;
1208            rOuterm[1]=0.4*m;
1209            rOuterm[2]=1.*m;
1210  G4Polycone* motherSolid = new G4Polycone("motherSolid", 20.*deg, 180.*deg,
1211                                           3, zPlanem, rInnerm, rOuterm);
1212  G4LogicalVolume* motherLog = new G4LogicalVolume(motherSolid, material, "mother",0,0,0);
1213
1214  G4double* zPlaned = new G4double[3];
1215            zPlaned[0]= -3.*m;
1216            zPlaned[1]= -0.*m;
1217            zPlaned[2]=  1.*m;
1218  G4double* rInnerd = new G4double[3];
1219            rInnerd[0]=0.2;
1220            rInnerd[1]=0.4*m;
1221            rInnerd[2]=0.5*m;
1222  G4double* rOuterd  = new G4double[3];
1223            rOuterd[0]=0.5*m;
1224            rOuterd[1]=0.8*m;
1225            rOuterd[2]=2.*m;
1226  G4Polycone* divSolid = new G4Polycone("divSolid", 0.*deg, 10.*deg,
1227                                        3, zPlaned, rInnerd, rOuterd);
1228  G4LogicalVolume* childLog = new G4LogicalVolume(divSolid, material, "child",0,0,0);
1229
1230  G4PVDivision divPconePhiW("division along phi giving width and offset",
1231                            childLog, motherLog, kPhi, 30.*deg, 60.*deg);
1232
1233  G4PVDivision divPconeZN("division along Z giving nDiv and offset",
1234                          childLog, motherLog, kZAxis, 2, 0.1*m);
1235</programlisting>
1236</example>
1237
1238<itemizedlist spacing="compact">
1239  <listitem><para>
1240    <literal>divPconePhiW</literal> is a division of a polycone along its
1241    <literal>phi</literal> axis in equal copies of width 30 degrees with an
1242    offset of 60 degrees. As the mother extends from 0 to 180 degrees,
1243    there's space for 4 copies. All the copies have a starting angle of
1244    20 degrees (as for the mother) and a <literal>phi</literal> extension of 30
1245    degrees. They are rotated around the <literal>Z</literal> axis by 60 and 30
1246    degrees, so that the first copy will extend from 80 to 110 and the
1247    last from 170 to 200 degrees.
1248  </para></listitem>
1249  <listitem><para>
1250    <literal>divPconeZN</literal> is a division of the same polycone along
1251    its <literal>Z</literal> axis. As the mother polycone has two sections, it
1252    will be divided in two one-section polycones, the first one
1253    extending from -1 to -0.25 meters, the second from -0.25 to 1
1254    meters. Although specified, the offset will not be used.
1255  </para></listitem>
1256</itemizedlist>
1257</para>
1258
1259
1260</sect3>
1261</sect2>
Note: See TracBrowser for help on using the repository browser.