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