source: trunk/documents/UserDoc/DocBookUsersGuides/ForApplicationDeveloper/xml/Fundamentals/biasing.xml @ 904

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

ajout de la doc

File size: 33.7 KB
Line 
1<!-- ******************************************************** -->
2<!--                                                          -->
3<!--  [History]                                               -->
4<!--    Converted to DocBook: Katsuya Amako, Aug-2006         -->
5<!--    Changed by: Dennis Wright, 25-Jun-2002                -->
6<!--                                                          -->
7<!-- ******************************************************** -->
8
9
10<!-- ******************* Section (Level#1) ****************** -->
11<sect1 id="sect.EvtBias">
12<title>
13Event Biasing Techniques
14</title>
15
16<!-- ******************* Section (Level#2) ****************** -->
17<sect2 id="sect.EvtBias.ScorImpRoul">
18<title>
19Scoring, Geometrical Importance Sampling and Weight Roulette
20</title>
21
22<para>
23Geant4 provides event biasing techniques which may be used to save
24computing time in such applications as the simulation of radiation
25shielding. These are <emphasis>geometrical splitting
26</emphasis> and <emphasis>Russian roulette</emphasis> 
27(also called geometrical importance sampling), and
28<emphasis>weight roulette</emphasis>. Scoring is carried out by <emphasis>G4MultiFunctionalDetector</emphasis> (see <xref
29linkend="sect.Hits.G4Multi" /> and <xref linkend="sect.Hits.G4VPrim" />) using the standard Geant4 scoring technique.
30Biasing specific scorers have been implemented and are described within
31<emphasis>G4MultiFunctionDetector</emphasis> documentation. In this chapter, it is assumed that
32the reader is familiar with both the usage of Geant4 and the
33concepts of importance sampling. More detailed documentation may be
34found in the documents
35<ulink url="http://geant4.web.cern.ch/geant4/collaboration/working_groups/geometry/index.shtml">
36'Latest development in importance sampling and scoring'
37</ulink>.
38A detailed description of different use-cases which employ the sampling
39and scoring techniques can be found in the document
40<ulink url="http://geant4.web.cern.ch/geant4/collaboration/working_groups/geometry/index.shtml">
41'Scoring and geometrical importance sampling use cases'
42</ulink>.
43</para>
44
45<para>
46The purpose of importance sampling is to save computing time by
47sampling less often the particle histories entering "less
48important" geometry regions, and more often in more "important"
49regions. Given the same amount of computing time, an
50importance-sampled and an analogue-sampled simulation must show
51equal mean values, while the importance-sampled simulation will
52have a decreased variance.
53</para>
54
55<para>
56The implementation of scoring is independent of the implementation
57of importance sampling. However both share common concepts.
58<emphasis>Scoring and importance sampling apply to particle types chosen
59by the user</emphasis>, which should be borne in mind when interpreting the
60output of any biased simulation.
61</para>
62
63<para>
64Examples on how to use scoring and importance sampling may be found
65in <literal>examples/extended/biasing</literal> and
66<literal>examples/advanced/Tiara</literal>.
67</para>
68
69
70<!-- ******************* Section (Level#3) ****************** -->
71<sect3 id="sect.EvtBias.ScorImpRoul.Geom">
72<title>
73Geometries
74</title>
75
76<para>
77The kind of scoring referred to in this note and the importance
78sampling apply to spatial cells provided by the user.
79</para>
80
81<para>
82A <emphasis role="bold">cell</emphasis> is a physical volume (further specified
83by it's replica number, if the volume is a replica). Cells may be defined
84in two kinds of geometries:
85
86<orderedlist spacing="compact">
87  <listitem><para>
88    <emphasis role="bold">mass geometry</emphasis>: the geometry setup of the
89    experiment to be simulated. Physics processes apply to this geometry.
90  </para></listitem>
91  <listitem><para>
92    <emphasis role="bold">parallel-geometry</emphasis>: a geometry constructed
93    to define the physical volumes according to which scoring and/or importance
94    sampling is applied.
95  </para></listitem>
96</orderedlist>
97</para>
98
99<para>
100The user has the choice to score and/or sample by importance the
101particles of the chosen type, according to mass geometry or to
102parallel geometry. It is possible to utilize several parallel
103geometries in addition to the mass geometry. This provides the user
104with a lot of flexibility to define separate geometries for
105different particle types in order to apply scoring or/and
106importance sampling.
107</para>
108
109<para>
110<note>
111  Parallel geometries should be constructed using the implementation as
112  described in <xref linkend="sect.ParaGeom"/>.
113
114  There are a few conditions for parallel geometries:
115
116  <itemizedlist spacing="compact">
117  <listitem><para>
118    The world volume for parallel and mass geometries must be identical copies.
119  </para></listitem>
120  <listitem><para>
121    Scoring and importance cells must not share boundaries with the world volume.
122  </para></listitem>
123  </itemizedlist>
124</note>
125</para>
126
127</sect3>
128
129<!-- ******************* Section (Level#3) ****************** -->
130<sect3 id="sect.EvtBias.ScorImpRoul.ChgSamp">
131<title>
132Changing the Sampling
133</title>
134
135<para>
136Samplers are higher level tools which perform the necessary
137changes of the Geant4 sampling in order to apply importance
138sampling and weight roulette.
139</para>
140
141<para>
142Variance reduction (and scoring through the
143<emphasis>G4MultiFunctionalDetector</emphasis>)
144may be combined arbitrarily for chosen particle types and may be applied to the
145mass or to parallel geometries.
146</para>
147
148<para>
149The <literal>G4GeometrySampler</literal> can be applied equally to mass or
150parallel geometries with an abstract interface supplied by <literal>G4VSampler</literal>.
151<literal>G4VSampler</literal> provides
152<literal>Prepare...</literal> methods and a <literal>Configure</literal>
153method:
154
155<anchor id="anchor_EvtBias_G4VSampler" />
156<informalexample>
157<programlisting>
158 class G4VSampler
159 {
160   public: 
161    G4VSampler();
162    virtual ~G4VSampler();
163    virtual void PrepareImportanceSampling(G4VIStore *istore,
164                                           const G4VImportanceAlgorithm
165                                           *ialg = 0) = 0;
166    virtual void PrepareWeightRoulett(G4double wsurvive = 0.5,
167                                      G4double wlimit = 0.25,
168                                      G4double isource = 1) = 0;
169    virtual void PrepareWeightWindow(G4VWeightWindowStore *wwstore,
170                                     G4VWeightWindowAlgorithm *wwAlg = 0,
171                                     G4PlaceOfAction placeOfAction =
172                                     onBoundary) = 0;
173    virtual void Configure() = 0;
174    virtual void ClearSampling() = 0;
175    virtual G4bool IsConfigured() const = 0;
176 };
177</programlisting>
178</informalexample>
179</para>
180
181<para>
182The methods for setting up the desired combination need specific
183information:
184
185<itemizedlist spacing="compact">
186  <listitem><para>
187    Importance sampling: message <literal>PrepareImportanceSampling</literal>
188    with a
189    <link linkend="anchor_EvtBias_G4VIStore">
190    <literal>G4VIStore</literal></link>
191    and optionally a <literal>G4VImportanceAlgorithm</literal>
192  </para></listitem>
193  <listitem><para>
194    Weight window: message <literal>PrepareWeightWindow</literal> with the
195    arguments:
196    <itemizedlist spacing="compact">
197      <listitem><para>
198        <emphasis>*wwstore</emphasis>: a
199        <literal>G4VWeightWindowStore</literal> for retrieving the lower
200        weight bounds for the energy-space cells
201      </para></listitem>
202      <listitem><para>
203        <emphasis>*wwAlg</emphasis>: a
204        <literal>G4VWeightWindowAlgorithm</literal> if a customized algorithm
205        should be used
206      </para></listitem>
207      <listitem><para>
208        <emphasis>placeOfAction</emphasis>: a
209        <literal>G4PlaceOfAction</literal> specifying where to perform the
210        biasing
211      </para></listitem>
212    </itemizedlist>
213  </para></listitem>
214  <listitem><para>
215    Weight roulette: message <literal>PrepareWeightRoulett</literal> with the
216    optional parameters:
217    <itemizedlist spacing="compact">
218      <listitem><para>
219        <emphasis>wsurvive</emphasis>: survival weight
220      </para></listitem>
221      <listitem><para>
222        <emphasis>wlimit</emphasis>: minimal allowed
223        value of weight * source importance / cell importance
224      </para></listitem>
225      <listitem><para>
226        <emphasis>isource</emphasis>: importance of the source cell
227      </para></listitem>
228    </itemizedlist>
229  </para></listitem>
230</itemizedlist>
231</para>
232
233<para>
234Each object of a sampler class is responsible for one particle
235type. The particle type is given to the constructor of the sampler
236classes via the particle type name, e.g. "neutron". Depending on
237the specific purpose, the <literal>Configure()</literal> of a sampler will
238set up specialized processes (derived from <literal>G4VProcess</literal>) for
239transportation in the parallel geometry, importance
240sampling and weight roulette for the given particle type. When
241<literal>Configure()</literal> is invoked the sampler places the processes in
242the correct order independent of the order in which user invoked
243the <literal>Prepare...</literal> methods.
244</para>
245
246<para>
247<note>
248  <para>
249  <itemizedlist spacing="compact">
250  <listitem><para>
251    The <literal>Prepare...()</literal> functions may each only be invoked
252    once.
253  </para></listitem>
254  <listitem><para>
255    To configure the sampling the function <literal>Configure()</literal>
256    must be called <emphasis>after</emphasis> the
257    <literal>G4RunManager</literal> has been initialized and the PhysicsList has
258    been instantiated.
259  </para></listitem>
260  </itemizedlist>
261  </para>
262</note>
263</para>
264
265
266
267
268<para>
269The interface and framework are demonstrated in the
270<literal>examples/extended/biasing</literal> directory, with the main changes being to the
271G4GeometrySampler class and the fact that in the parallel case the WorldVolume
272is a copy of the Mass World.
273
274The parallel geometry now has to inherit from
275<emphasis>G4VUserParallelWorld</emphasis> which also has the <emphasis>GetWorld()</emphasis> method
276in order to retrieve a copy of the mass geometry WorldVolume.
277
278<informalexample>
279<programlisting>
280  class B02ImportanceDetectorConstruction : public G4VUserParallelWorld
281  ghostWorld = GetWorld();
282</programlisting>
283</informalexample>
284
285</para>
286
287<para>
288The constructor for <emphasis>G4GeometrySampler</emphasis> takes a pointer to
289the physical world volume and the particle type name (e.g. "neutron") as arguments.
290In a single mass geometry the sampler is created as follows:
291
292<informalexample>
293<programlisting>
294  G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
295  mgs.SetParallel(false);
296</programlisting>
297</informalexample>
298
299
300Whilst the following lines of code are required in order to set up the sampler for the
301parallel geometry case:
302
303<informalexample>
304<programlisting>
305  G4VPhysicalVolume* ghostWorld = pdet->GetWorldVolume();
306
307  G4GeometrySampler pgs(ghostWorld,"neutron");
308
309  pgs.SetParallel(true);
310</programlisting>
311</informalexample>
312
313
314Also note that the preparation and configuration of the samplers has to be
315carried out <emphasis>after</emphasis> the instantiation of the UserPhysicsList
316and after the initialisation of the <emphasis>G4RunManager</emphasis>:
317
318<informalexample>
319<programlisting>
320  pgs.PrepareImportanceSampling(&amp;aIstore, 0);
321  pgs.Configure();
322</programlisting>
323</informalexample>
324
325Due to the fact that biasing is a process and has to be inserted after all the
326other processes have been created.
327</para>
328
329
330</sect3>
331
332<!-- ******************* Section (Level#3) ****************** -->
333<sect3 id="sect.EvtBias.ScorImpRoul.ImpSamp">
334<title>
335Importance Sampling
336</title>
337
338<para>
339Importance sampling acts on particles crossing boundaries
340between "importance cells". The action taken depends on the
341importance values assigned to the cells. In general a particle
342history is either split or Russian roulette is played if the
343importance increases or decreases, respectively. A weight assigned
344to the history is changed according to the action taken.
345</para>
346
347<para>
348The tools provided for importance sampling require the user to
349have a good understanding of the physics in the problem. This is
350because the user has to decide which particle types require
351importance sampled, define the cells, and assign importance values
352to the cells. If this is not done properly the results cannot be
353expected to describe a real experiment.
354</para>
355
356<para>
357The assignment of importance values to a cell is done using an
358importance store described below.
359</para>
360
361<para>
362An "importance store" with the interface <literal>G4VIStore</literal> is
363used to store importance values related to cells. In order to do
364importance sampling the user has to create an object (e.g. of class
365<literal>G4IStore</literal>) of type <literal>G4VIStore</literal>. The samplers may be
366given a <literal>G4VIStore</literal>. The user fills the store with cells and
367their importance values.
368</para>
369
370<para>
371An importance store has to be constructed with a reference to
372the world volume of the geometry used for importance sampling. This
373may be the world volume of the mass or of a parallel geometry.
374Importance stores derive from the interface <literal>G4VIStore</literal>:
375
376<anchor id="anchor_EvtBias_G4VIStore" />
377<informalexample>
378<programlisting>
379 class  G4VIStore
380 {
381   public:
382     G4VIStore();
383     virtual  ~G4VIStore();
384     virtual G4double GetImportance(const G4GeometryCell &amp;gCell) const = 0;
385     virtual G4bool IsKnown(const G4GeometryCell &amp;gCell) const = 0;
386     virtual const G4VPhysicalVolume &amp;GetWorldVolume() const = 0;
387 };
388</programlisting>
389</informalexample>
390</para>
391
392<para>
393A concrete implementation of an importance store is provided by
394the class <literal>G4VStore</literal>. The <emphasis>public</emphasis>
395part of the class is:
396
397<informalexample>
398<programlisting>
399 class G4IStore : public G4VIStore
400 {
401   public:
402     explicit G4IStore(const G4VPhysicalVolume &amp;worldvolume);
403     virtual ~G4IStore();
404     virtual G4double GetImportance(const G4GeometryCell &amp;gCell) const;
405     virtual G4bool IsKnown(const G4GeometryCell &amp;gCell) const;
406     virtual const G4VPhysicalVolume &amp;GetWorldVolume() const;
407     void AddImportanceGeometryCell(G4double importance,
408                              const G4GeometryCell &amp;gCell);
409     void AddImportanceGeometryCell(G4double importance,
410                              const G4VPhysicalVolume &amp;,
411                                    G4int aRepNum = 0);
412     void ChangeImportance(G4double importance,
413                           const G4GeometryCell &amp;gCell);
414     void ChangeImportance(G4double importance,
415                           const G4VPhysicalVolume &amp;,
416                                 G4int aRepNum = 0);
417     G4double GetImportance(const G4VPhysicalVolume &amp;,
418                                  G4int aRepNum = 0) const ;
419   private: .....
420 };
421</programlisting>
422</informalexample>
423</para>
424
425<para>
426The member function <literal>AddImportanceGeometryCell()</literal> enters
427a cell and an importance value into the importance store. The
428importance values may be returned either according to a physical
429volume and a replica number or according to a
430<literal>G4GeometryCell</literal>. The user must be aware of the
431interpretation of assigning importance values to a cell.
432If scoring is also implemented then this is attached to logical volumes, in
433which case the physical volume and replica number method should be used for
434assigning importance values. See <literal>examples/extended/biasing
435B01</literal> and <literal>B02</literal> for examples of this.
436</para>
437
438<para>
439<note>
440  <para>
441  <itemizedlist spacing="compact">
442  <listitem><para>
443    An importance value must be assigned to every cell.
444  </para></listitem>
445  </itemizedlist>
446  </para>
447</note>
448</para>
449
450<para>
451The different cases:
452
453<itemizedlist spacing="compact">
454  <listitem><para>
455    <emphasis>Cell is not in store</emphasis>
456    <para>
457    Not filling a certain cell in the store will cause an
458    exception.
459    </para>
460  </para></listitem>
461  <listitem><para>
462    <emphasis>Importance value = zero</emphasis>
463    <para>
464    Tracks of the chosen particle type will be killed.
465    </para>
466  </para></listitem>
467  <listitem><para>
468    <emphasis>importance values &gt; 0</emphasis>
469    <para>
470    Normal allowed values
471    </para>
472  </para></listitem>
473  <listitem><para>
474    <emphasis>Importance value smaller zero</emphasis>
475    <para>
476    Not allowed!
477    </para>
478  </para></listitem>
479</itemizedlist>
480</para>
481
482</sect3>
483
484<!-- ******************* Section (Level#3) ****************** -->
485<sect3 id="sect.EvtBias.ScorImpRoul.SampAlgor">
486<title>
487The Importance Sampling Algorithm
488</title>
489
490<para>
491Importance sampling supports using a customized importance
492sampling algorithm. To this end, the sampler interface
493<link linkend="anchor_EvtBias_G4VSampler">
494<literal>G4VSampler</literal></link>
495may be given a pointer to the interface
496<literal>G4VImportanceAlgorithm</literal>:
497
498<informalexample>
499<programlisting>     
500 class G4VImportanceAlgorithm
501 {
502   public: 
503     G4VImportanceAlgorithm();
504     virtual ~G4VImportanceAlgorithm();
505     virtual G4Nsplit_Weight Calculate(G4double ipre,
506                                       G4double ipost,
507                                       G4double init_w) const = 0;
508 };
509</programlisting>
510</informalexample>     
511</para>
512
513<para>
514The method <literal>Calculate()</literal> takes the arguments:
515
516<itemizedlist spacing="compact">
517  <listitem><para>
518    <emphasis>ipre, ipost</emphasis>: importance
519    of the previous cell and the importance of the current cell,
520    respectively.
521  </para></listitem>
522  <listitem><para>
523    <emphasis>init_w</emphasis>: the particles weight
524  </para></listitem>
525</itemizedlist>
526</para>
527
528<para>
529It returns the struct:
530
531<informalexample>
532<programlisting>     
533 class G4Nsplit_Weight
534 {
535   public:
536
537   G4int fN;
538   G4double fW;
539 };
540</programlisting>
541</informalexample>     
542
543<itemizedlist spacing="compact">
544  <listitem><para>
545    <emphasis>fN</emphasis>: the calculated
546    number of particles to exit the importance sampling
547  </para></listitem>
548  <listitem><para>
549    <emphasis>fW</emphasis>: the weight of the particles
550  </para></listitem>
551</itemizedlist>
552</para>
553
554<para>
555The user may have a customized algorithm used by providing a
556class inheriting from <literal>G4VImportanceAlgorithm</literal>.
557</para>
558
559<para>
560If no customized algorithm is given to the sampler the default
561importance sampling algorithm is used. This algorithm is
562implemented in <literal>G4ImportanceAlgorithm</literal>.
563</para>
564
565</sect3>
566
567<!-- ******************* Section (Level#3) ****************** -->
568<sect3 id="sect.EvtBias.ScorImpRoul.WeightWin">
569<title>
570The Weight Window Technique
571</title>
572
573<para>
574The weight window technique is a weight-based alternative to
575importance sampling:
576
577<itemizedlist spacing="compact">
578  <listitem><para>
579    applies splitting and Russian roulette depending on space
580    (cells) and energy
581  </para></listitem>
582  <listitem><para>
583    user defines weight windows in contrast to defining importance
584    values as in importance sampling
585  </para></listitem>
586</itemizedlist>
587</para>
588
589<para>
590In contrast to importance sampling this technique is not weight
591blind. Instead the technique is applied according to the particle
592weight with respect to the current energy-space cell.
593</para>
594
595<para>
596Therefore the technique is convenient to apply in combination
597with other variance reduction techniques such as cross-section
598biasing and implicit capture.
599</para>
600
601<para>
602A weight window may be specified for every cell and for several
603energy regions: <emphasis>space-energy cell</emphasis>.
604
605<figure id="fig.EvtBias.WeightWindow">
606<title>
607  Weight window concept
608</title>
609
610<mediaobject>
611 <imageobject role="fo">
612    <imagedata fileref="./AllResources/Fundamentals/wwconcept.gif"
613               format="GIF" contentwidth="9.0cm" align="center" />
614  </imageobject>
615  <imageobject role="html">
616    <imagedata fileref="./AllResources/Fundamentals/wwconcept.gif"
617               format="GIF" align="center" />
618  </imageobject>
619  <textobject>
620    <phrase>Weight window concept</phrase>
621  </textobject>
622</mediaobject>
623</figure>
624</para>
625
626<!-- ******* Bridgehead ******* -->
627<bridgehead renderas='sect4'>
628Weight window concept
629</bridgehead>
630
631<para>
632  The user specifies a <emphasis>lower weight bound W_L</emphasis> 
633  for every space-energy cell.
634
635  <itemizedlist spacing="compact">
636    <listitem><para>
637      The upper weight bound W_U and the survival weight W_S are
638      calculated as:
639      <para>
640      W_U = C_U <emphasis>W_L</emphasis> and
641      </para>
642      <para>
643      W_S = C_S <emphasis>W_L</emphasis>.
644      </para>
645    </para></listitem>
646    <listitem><para>
647      The user specifies C_S and C_U once for the whole problem.
648    </para></listitem>
649    <listitem><para>
650      The user may give different sets of energy bounds for every cell
651      or one set for all geometrical cells
652    </para></listitem>
653    <listitem><para>
654      Special case: if C_S = C_U = 1 for all energies then weight
655      window is equivalent to importance sampling
656    </para></listitem>
657    <listitem><para>
658      The user can choose to apply the technique: at boundaries, on
659      collisions or on boundaries and collisions
660    </para></listitem>
661  </itemizedlist>
662</para>
663
664<para>
665The energy-space cells are realized by <literal>G4GeometryCell</literal>
666as in importance sampling. The cells are stored in a weight window
667store defined by <literal>G4VWeightWindowStore</literal>:
668
669<informalexample>
670<programlisting>
671 class  G4VWeightWindowStore {
672  public: 
673    G4VWeightWindowStore();
674    virtual  ~G4VWeightWindowStore();
675    virtual G4double GetLowerWeitgh(const G4GeometryCell &amp;gCell,
676                                  G4double partEnergy) const = 0;
677    virtual G4bool IsKnown(const G4GeometryCell &amp;gCell) const = 0;
678    virtual const G4VPhysicalVolume &amp;GetWorldVolume() const = 0;
679 };
680</programlisting>
681</informalexample>
682</para>
683
684<para>
685A concrete implementation is provided:
686
687<informalexample>
688<programlisting>
689  class G4WeightWindowStore: public G4VWeightWindowStore {
690   public: 
691     explicit G4WeightWindowStore(const G4VPhysicalVolume &amp;worldvolume);
692     virtual ~G4WeightWindowStore();
693     virtual G4double GetLowerWeitgh(const G4GeometryCell &amp;gCell,
694                                     G4double partEnergy) const;
695     virtual G4bool IsKnown(const G4GeometryCell &amp;gCell) const;
696     virtual const G4VPhysicalVolume &amp;GetWorldVolume() const;
697     void AddLowerWeights(const G4GeometryCell &amp;gCell,
698                          const std::vector&lt;G4double&gt; &amp;lowerWeights);
699     void AddUpperEboundLowerWeightPairs(const G4GeometryCell &amp;gCell,
700                                         const G4UpperEnergyToLowerWeightMap&amp;
701                                         enWeMap);
702     void SetGeneralUpperEnergyBounds(const
703         std::set&lt;G4double, std::less&lt;G4double&gt; &gt; &amp; enBounds);
704 
705   private::
706   ... 
707  };
708</programlisting>
709</informalexample>
710</para>
711
712<para>
713The user may choose equal energy bounds for all cells. In this
714case a set of upper energy bounds must be given to the store using
715the method <literal>SetGeneralUpperEnergyBounds</literal>. If a general set
716of energy bounds have been set <literal>AddLowerWeights</literal> can be used
717to add the cells.
718</para>
719
720<para>
721Alternatively, the user may chose different energy regions for
722different cells. In this case the user must provide a mapping of
723upper energy bounds to lower weight bounds for every cell using the
724method <literal>AddUpperEboundLowerWeightPairs</literal>.
725</para>
726
727<para>
728Weight window algorithms implementing the interface class
729<literal>G4VWeightWindowAlgorithm</literal> can be used to define a
730customized algorithm:
731
732<informalexample>
733<programlisting>
734 class G4VWeightWindowAlgorithm {
735  public: 
736    G4VWeightWindowAlgorithm();
737    virtual ~G4VWeightWindowAlgorithm();
738    virtual G4Nsplit_Weight Calculate(G4double init_w,
739                                      G4double lowerWeightBound) const = 0;
740 };
741</programlisting>
742</informalexample>
743</para>
744
745<para>
746A concrete implementation is provided and used as a default:
747
748<informalexample>
749<programlisting>
750 class G4WeightWindowAlgorithm : public G4VWeightWindowAlgorithm {
751  public: 
752    G4WeightWindowAlgorithm(G4double upperLimitFaktor = 5,
753                            G4double survivalFaktor = 3,
754                            G4int maxNumberOfSplits = 5);
755    virtual ~G4WeightWindowAlgorithm();
756    virtual G4Nsplit_Weight Calculate(G4double init_w,
757                                      G4double lowerWeightBound) const;
758  private:
759   ...
760};
761</programlisting>
762</informalexample>
763</para>
764
765<para>
766The constructor takes three parameters which are used to:
767calculate the upper weight bound (upperLimitFaktor), calculate the
768survival weight (survivalFaktor), and introduce a maximal number
769(maxNumberOfSplits) of copies to be created in one go.
770</para>
771
772<para>
773In addition, the inverse of the maxNumberOfSplits is used to
774specify the minimum survival probability in case of Russian
775roulette.
776</para>
777
778</sect3>
779
780<!-- ******************* Section (Level#3) ****************** -->
781<sect3 id="sect.EvtBias.ScorImpRoul.WeigRoul">
782<title>
783The Weight Roulette Technique
784</title>
785
786<para>
787Weight roulette (also called weight cutoff) is usually applied
788if importance sampling and implicit capture are used together.
789Implicit capture is not described here but it is useful to note
790that this procedure reduces a particle weight in every collision
791instead of killing the particle with some probability.
792</para>
793
794<para>
795Together with importance sampling the weight of a particle may
796become so low that it does not change any result significantly.
797Hence tracking a very low weight particle is a waste of computing
798time. Weight roulette is applied in order to solve this
799problem.
800</para>
801
802<!-- ******* Bridgehead ******* -->
803<bridgehead renderas='sect4'>
804The weight roulette concept
805</bridgehead>
806
807<para>
808Weight roulette takes into account the importance "Ic" of the
809current cell and the importance "Is" of the cell in which the
810source is located, by using the ratio "R=Is/Ic".
811</para>
812
813<para>
814Weight roulette uses a relative minimal weight limit and a
815relative survival weight. When a particle falls below the weight
816limit Russian roulette is applied. If the particle survives,
817tracking will be continued and the particle weight will be set to
818the survival weight.
819</para>
820
821<para>
822The weight roulette uses the following parameters with their
823default values:
824
825<itemizedlist spacing="compact">
826  <listitem><para>
827    <emphasis>wsurvival</emphasis>: 0.5
828  </para></listitem>
829  <listitem><para>
830    <emphasis>wlimit</emphasis>: 0.25
831  </para></listitem>
832  <listitem><para>
833    <emphasis>isource</emphasis>: 1
834  </para></listitem>
835</itemizedlist>
836</para>
837
838<para>
839The following algorithm is applied:
840</para>
841
842<para>
843If a particle weight "w" is lower than R*wlimit:
844
845<itemizedlist spacing="compact">
846  <listitem><para>
847    the weight of the particle will be changed to "ws = wsurvival*R"
848  </para></listitem>
849  <listitem><para>
850    the probability for the particle to survive is "p = w/ws"
851  </para></listitem>
852</itemizedlist>
853</para>
854
855</sect3>
856</sect2>
857
858
859<!-- ******************* Section (Level#2) ****************** -->
860<sect2 id="sect.EvtBias.PhysBias">
861<title>
862Physics Based Biasing
863</title>
864
865<para>
866Geant4 supports physics based biasing through a number of general
867use, built in biasing techniques. A utility class,
868G4WrapperProcess, is also available to support user defined
869biasing.
870</para>
871
872<!-- ******************* Section (Level#3) ****************** -->
873<sect3 id="sect.EvtBias.PhysBias.BuiltInOpt">
874<title>
875Built in Biasing Options
876</title>
877
878<!-- ******************* Section (Level#4) ****************** -->
879<sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.PrimPart">
880<title>
881Primary Particle Biasing
882</title>
883
884<para>
885Primary particle biasing can be used to increase the number of
886primary particles generated in a particular phase space region of
887interest. The weight of the primary particle is modified as
888appropriate. A general implementation is provided through the
889G4GeneralParticleSource class. It is possible to bias position,
890angular and energy distributions.
891</para>
892
893<para>
894G4GeneralParticleSource is a concrete implementation of
895G4VPrimaryGenerator. To use, instantiate G4GeneralParticleSource in
896the G4VUserPrimaryGeneratorAction class, as demonstrated below.
897
898<informalexample>
899<programlisting>
900   MyPrimaryGeneratorAction::MyPrimaryGeneratorAction() {
901      generator = new G4GeneralParticleSource;
902   }
903
904   void
905   MyPrimaryGeneratorAction::GeneratePrimaries(G4Event*anEvent){
906      generator-&gt;GeneratePrimaryVertex(anEvent);
907   }
908</programlisting>
909</informalexample>
910</para>
911
912<para>
913The biasing can be configured through interactive commands.
914Extensive documentation can be found in
915<ulink url="http://reat.space.qinetiq.com/gps/">
916Primary particle biasing</ulink>.  Examples are also distributed
917with the Geant4 distribution in
918<emphasis role="bold">examples/extended/eventgenerator/exgps</emphasis>.
919</para>
920
921</sect4>
922
923<!-- ******************* Section (Level#4) ****************** -->
924<sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.RadDcy">
925<title>
926Radioactive Decay Biasing
927</title>
928
929<para>
930The G4RadioactiveDecay class simulates the decay of radioactive
931nuclei and implements the following biasing options:
932
933<itemizedlist spacing="compact">
934  <listitem><para>
935    Increase the sampling rate of radionuclides within observation
936    times through a user defined probability distribution function
937  </para></listitem>
938  <listitem><para>
939    Nuclear splitting, where the parent nuclide is split into a
940    user defined number of nuclides
941  </para></listitem>
942  <listitem><para>
943    Branching ratio biasing where branching ratios are sampled with
944    equal probability
945  </para></listitem>
946</itemizedlist>
947</para>
948
949<para>
950G4RadioactiveDecay is a process which must be registered with a
951process manager, as demonstrated below.
952
953<informalexample>
954<programlisting>
955   void MyPhysicsList::ConstructProcess()
956   {
957      ...
958      G4RadioactiveDecay* theRadioactiveDecay =
959         new  G4RadioactiveDecay();
960
961      G4ProcessManager* pmanager = ...
962      pmanager -&gt;AddProcess(theRadioactiveDecay);
963      ...
964   }
965</programlisting>
966</informalexample>
967</para>
968
969<para>
970The biasing can be controlled either in compiled code or through
971interactive commands. Extensive documentation can be found in
972
973<ulink url="http://reat.space.qinetiq.com/septimess/exrdm/">
974Radioactive decay biasing example
975</ulink>
976 and
977<ulink url="http://www.space.qinetiq.com/geant4/rdm.html">
978Radioactive decay biasing
979</ulink>.
980</para>
981
982<para>
983Radioactive decay biasing examples are also distributed with the Geant4
984distribution in
985<emphasis role="bold">examples/extended/radioactivedecay/exrdm</emphasis>.
986</para>
987
988</sect4>
989
990<!-- ******************* Section (Level#4) ****************** -->
991<sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.HadLeadPar">
992<title>
993Hadronic Leading Particle Biasing
994</title>
995
996<para>
997One hadronic leading particle biasing technique is
998implemented in the G4HadLeadBias utility. This method keeps only
999the most important part of the event, as well as representative
1000tracks of each given particle type. So the track with the highest
1001energy as well as one of each of Baryon, pi0, mesons and leptons.
1002As usual, appropriate weights are assigned to the particles.
1003Setting the <emphasis role="bold">SwitchLeadBiasOn</emphasis> 
1004environmental variable will activate this utility.
1005</para>
1006
1007</sect4>
1008
1009<!-- ******************* Section (Level#4) ****************** -->
1010<sect4 id="sect.EvtBias.PhysBias.BuiltInOpt.HadCrsSect">
1011<title>
1012Hadronic Cross Section Biasing
1013</title>
1014
1015<para>
1016Cross section biasing artificially enhances/reduces the cross
1017section of a process. This may be useful for studying thin layer
1018interactions or thick layer shielding. The built in hadronic cross
1019section biasing applies to photon inelastic, electron nuclear and
1020positron nuclear processes.
1021</para>
1022
1023<para>
1024The biasing is controlled through the
1025<emphasis role="bold">BiasCrossSectionByFactor</emphasis> method
1026in G4HadronicProcess, as demonstrated below.
1027
1028<informalexample>
1029<programlisting>
1030   void MyPhysicsList::ConstructProcess()
1031   {
1032      ...
1033      G4ElectroNuclearReaction * theElectroReaction =
1034         new G4ElectroNuclearReaction;
1035
1036      G4ElectronNuclearProcess theElectronNuclearProcess;   
1037      theElectronNuclearProcess.RegisterMe(theElectroReaction);
1038      theElectronNuclearProcess.BiasCrossSectionByFactor(100);
1039 
1040      pManager-&gt;AddDiscreteProcess(&amp;theElectronNuclearProcess);
1041      ... 
1042   }
1043</programlisting>
1044</informalexample>
1045</para>
1046
1047<para>
1048More details can be found in
1049<ulink url="http://www.triumf.ca/geant4-03/talks/03-Wednesday-AM-1/03-J.Wellisch/biasing.hadronics.pdf">
1050Hadronic cross section biasing
1051</ulink>.
1052</para>
1053
1054</sect4>
1055</sect3>
1056
1057
1058<!-- ******************* Section (Level#3) ****************** -->
1059<sect3 id="sect.EvtBias.PhysBias.">
1060<title>
1061G4WrapperProcess
1062</title>
1063
1064<para>
1065G4WrapperProcess can be used to implement user defined event
1066biasing. G4WrapperProcess, which is a process itself, wraps an
1067existing process. By default, all function calls are forwared to
1068the wrapped process. It is a non-invasive way to modify the
1069behaviour of an existing process.
1070</para>
1071
1072<para>
1073To use this utility, first create a derived class inheriting
1074from G4WrapperProcess. Override the methods whose behaviour you
1075would like to modify, for example, PostStepDoIt, and register the
1076derived class in place of the process to be wrapped. Finally,
1077register the wrapped process with G4WrapperProcess. The code
1078snippets below demonstrate its use.
1079
1080<informalexample>
1081<programlisting>
1082   class MyWrapperProcess  : public G4WrapperProcess {
1083   ...
1084    G4VParticleChange* PostStepDoIt(const G4Track&amp; track,
1085                                    const G4Step&amp; step) {
1086       // Do something interesting
1087    }
1088   };
1089
1090
1091   void MyPhysicsList::ConstructProcess()
1092   {
1093   ...
1094      G4LowEnergyBremsstrahlung* bremProcess =
1095         new G4LowEnergyBremsstrahlung();
1096
1097      MyWrapperProcess* wrapper = new MyWrapperProcess();
1098      wrapper-&gt;RegisterProcess(bremProcess);
1099
1100      processManager-&gt;AddProcess(wrapper, -1, -1, 3);
1101   }
1102</programlisting>
1103</informalexample>
1104</para>
1105
1106</sect3>
1107
1108</sect2>
1109</sect1>
Note: See TracBrowser for help on using the repository browser.