source: trunk/examples/extended/biasing/README @ 1330

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

update

File size: 6.3 KB
Line 
1
2                        Examples for event biasing
3                        --------------------------
4
5This directory includes example applications to demonstrate the usage of
6different variance reduction techniques supported in Geant4, or possible
7from the user applications.
8
9
10General remark to variance reduction
11------------------------------------
12The tools provided for importance sampling (or geometrical splitting and
13Russian roulette) and for the weight window technique require the user to
14have a good understanding of the physics in the problem. This is because
15the user has to decide which particle types have to be biased, define the
16cells (physical volumes, replicas) and assign importances or weight
17windows to that cells. If this is not done properly it can not be
18expected that the results describe a real experiment. The examples given
19here only demonstrate how to use the tools technically. They don't intend
20to produce physical correct results.
21
22General remark to scoring
23-------------------------
24A interface G4VScorer is provided for the user. The user may create his
25own class to perform the desired scoring. The user defined class
26therefore should inherit from the interface G4VScorer.
27An example of an implementation of a scorer is G4Scorer
28which may be found in source/event.
29The scoring in these examples is done with a G4Scorer.
30The variance reduction techniques and scoring do not support all options
31of the Geant4 geometry. It only supports physical volumes and simple
32replicas.
33To identify a physical volume (or replica) objects of the class
34G4GeometryCell are used. Scoring is done according to these
35cells and importance values or the weight windows  may be assigned to
36them.
37When scoring is done in a parallel geometry special action has to be taken
38to prevent counting of "collisions" with boundaries of the mass geometry
39as interactions. This is differently handled when scoring is done in the
40mass geometry.
41
42--> G4GeometryCell of the parallel geometry must not share boundaries with
43the world volume! <--
44
45Known problems
46--------------
47In the following scenario it can happen that a particle is not
48biased and it's weight is therefore not changed even if it crosses
49a boundary where biasing should happen.
50Importance and weight window sampling create particles on boundaries
51between volumes. If the GPIL method of a physical process returns
520 as step length for a particle on a boundary and if the PostStepDoIt of
53that process changes the direction of the particle to go back in the
54former volume the biasing won't be invoked.
55This will produce particles with weights that do not correspondent to the
56importance of the current volumes.
57
58Further information:
59--------------------
60Short description of importance sampling and scoring:
61http://cern.ch/geant4/working_groups/geometry/biasing/Sampling.html
62
63Example B01
64===========
65
66The example uses importance sampling or the weight window technique
67according to an input parameter. It uses scoring in both cases.
68Importance values or weight windows are defined according to the mass
69geometry. In this example the weight window technique is configured such
70that it behaves equivalent to importance sampling: The window is actually
71not a window but simply the inverse of the importance value and only
72one energy region is used that covers all energies in the problem.
73The user may change the weight window configuration by changing the
74initialization of the weight window algorithm in example,cc.
75Different energy bounds for the weight window technique may be specified
76in B01DetectorConstruction.
77
78The executable takes one optional argument: 0 or 1. Without argument or
79with argument: 0, the importance sampling is applied with argument: 1,
80the weight window technique is applied.
81
82
83Example B02
84===========
85
86This example uses a parallel geometry to define G4GeometryCell objects
87for scoring and importance sampling. In addition it customizes
88the scoring. In this example one scorer creates a histogram.
89
90Compiling and running
91---------------------
92Can be compiled and executed on a RedHat-7.3 system with gcc-3.2.3
93compiler and the tcsh shell.
94To compile this example you need AIDA 3.2.1 installed. To link
95and run it you need a AIDA compliant analysis package. The
96GNUmakefile of this example shows how to use AIDA through PI as
97analysis interface.
98Histograms are saved in HBOOK format. It can be displayed with PAW or
99compatible packages.
100You need to set the following variables in your environment:
101   "G4ANALYSIS_USE"
102   "PI_BASE_DIR" (where PI has been installed)
103Finally, source the script setupPI.csh.
104
105Now you should be able to run gmake and to run exampleB02.
106
107The example stores the plot in the file b02.hbook.
108To look at the histogram using lizard you also may use PI 1.2.1
109http://cern.ch/PI.
110
111
112Example B03
113===========
114
115This example uses Geant4 and in particular importance sampling and
116scoring through python. It creates a simple histogram. It's meant
117to demonstrate how to use a customized scorer and importance sampling
118in combination with a scripting language, python.
119Geant4 code is executed from a python session. Therefore, swig is used
120to create python shadow classes and to generate the code necessary to
121use the Geant4 libraries from a python session.
122It can be built and run using PI:  http://cern.ch/PI.
123At the end a histogram called "trackentering.hbook" is created and can be
124displayed using standard packages (such as PAW).
125
126Building, compiling and running
127-------------------------------
128
129You need to set the following variables in your environment:
130   "G4ANALYSIS_USE"
131   "PI_BASE_DIR"    (where PI has been installed)
132   "SWIG_BASE_DIR"  (where SWIG 1.3.15 has been installed)
133Finally source the script setupPI.csh.
134
135You may run gmake now.
136You should be able to execute the file B03RunApplication.py from your
137shell or from a lizard session now.
138 
139At the moment the plotting is not available using a python script, but
140it is planned in future releases. A histogram is created and later displayed
141using standard analysis packages.
142
143To clean all the added files, just type gmake clean_all.
144
145Files in B03;
146B03Application.py: Is a example class utilizing importance sampling
147   and scoring using python.
148B03RunApplication.py: Is a python script running the example.
149   It may be executed from the shell or in a python session.
150B03App.py: Is created by swig using swig.
Note: See TracBrowser for help on using the repository browser.