source: trunk/examples/advanced/Tiara/README @ 1317

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

update

File size: 10.5 KB
Line 
1# $Id: README,v 1.21 2005/03/17 19:48:27 daquinog Exp $
2# -------------------------------------------------------------------
3# GEANT4 tag $Name:  $
4# -------------------------------------------------------------------
5
6Simulation of the TIARA experiment using importance sampling
7============================================================
8
9This example is a simulation of the neutron shielding experiment TIARA
10see http://idsun1.kek.jp/nakao/research/tiara/tiara.htm.
11The example is meant to provide a realistic example for
12applying geometrical importance sampling (geometrical splitting and
13Russian roulette).
14In the TIARA experiment neutrons of two different energy distributions
15created by 43 MeV and 68 MeV protons bombarding a 7Li target are measured
16behind several shields. The simulation starts from the neutron spectra.
17In this example the interactions of the neutrons with the (concrete)
18shields are simulated and energy dependent neutron fluxes are measured
19behind the shields. Users may choose to run the simulation for different
20shielding configuration with or without importance sampling.
21The simulated neutron fluxes are compared to the published
22experimental data. The efficiency of applying importance sampling
23depends strongly on the shield thickness and importance configuration.
24The efficiency of the simulations may be obtained as FOM values.
25
26See also "Geant4 User's Guide
27For Application Developers", Chapter "Toolkit Fundamentals"
28Section  "Event Biasing Techniques" and references there.
29
30The example has been tested on CERN RH 7.3 with the
31gcc-3.2.3 and gcc-2.95.2 compilers.
32
33Note for system testing without analysis: see points 1.1, 1.3 and 3.2.
34
35
36
371) Setting the environment
38==========================
39
40You must compile Geant4 with:
41   "G4LIB_BUILD_SHARED" set to 1.
42You need to set:
43   "NeutronHPCrossSections" (e.g. pointing to a directory containing G4NDL3.7)
44
45
46Three examples are given of how to set environment variables
47in the three cases:
48
491.1) PI via AFS (most simple):
50--------------------
51   You have access to afs and you want to use PI for the
52   analysis:
53   Set the following environment variables:
54   "G4ANALYSIS_USE"
55   "PI_BASE_DIR" (where PI has been installed)
56   "SWIG_BASE_DIR"  (where SWIG has been installed)
57
58   Finally source the script envCommon.csh from the directory where you have Tiara
59   installed, e.g. ${G4INSTALL}/examples/advanced/Tiara
60
61
621.2) No afs but a local PI and SWIG installation:
63-----------------------------------------------------
64   You don't use afs but you have a local installation of SWIG and PI
65   Set the following environment variables:
66   "G4ANALYSIS_USE"
67    "PI_BASE_DIR"
68   "SWIG_BASE_DIR"
69
70   Finally source the script envCommon.csh from the directory where
71   you have Tiara installed, e.g. ${G4INSTALL}/examples/advanced/Tiara
72
73
741.3) No afs, no PI and no SWIG (e.g. for system testing):
75-------------------------------------------------------------
76   You don't want to use PI and SWIG and you don't have afs access.
77   Make sure "G4ANALYSIS_USE" is unset (e.g. unsetenv G4ANALYSIS_USE or setenv G4ANALYSIS_USE 0)
78   
79   Note 1: python must be built against a "libc".
80         You may do this by creating a shared library by a command
81         similar to this
82         "ld -shared -o libpython2.3.so --whole-archive libpython2.3.a /usr/lib/libc.so"
83
84   Set the following environment variables:
85   "PYTHONVERSION" (2.3 or higher)
86   "PYTHON_BASE_DIR" (e.g. to  /usr)
87   "SWIG_VERSION" (e.g. 1.3 or higher)
88   "SWIG_BASE_DIR" (e.g. /usr)
89   "CLHEP_BASE_DIR" (e.g. to  /opt/local)
90
91   Finally source the script envCommon.csh from the directory where
92   you have Tiara installed, e.g. ${G4INSTALL}/examples/advanced/Tiara
93   
94   NOTE 2: Passing from a simulation WITH to another WITHOUT analysis implies
95   that the G4ANALYSIS_use should be unset and that the SWIG-wrapper scripts
96   in the directory TiaraWrapper should be deleted. Normally, the whole code
97   should be compiled again using gmake clean_all and, afterwards, gmake.
98   The same procedure should be followed also passing from a simulation WITHOUT
99   to another WITH analysis.
100
1012) Building the example
102=======================
103
104Geant4 has to be compiled using G4LIB_BUILD_SHARED 1 and the one of the
105above environment settings have to be set.
106Type "gmake".
107
108
1092.1) In more detail
110-------------------
111
112Geant4 must be compiled into granular shared libraries.
113Therefore before compiling Geant4 set "G4LIB_BUILD_SHARED" to "1".
114
115External packages used in this example are PI, SWIG and Python.
116
117
1182.2) Cleaning up
119----------------
120To remove the files created by swig ( *_wrap.cc, the corresponding
121.py files) use "gmake swigClean".
122To remove the directories of compiled code related to this example under
123$G4WORKDIR/tmp/$G4SYSTEM/ use "gmake tiaraClean".
124To remove all the files created during the previous compilation, use
125"gmake clean_all".
126
127
1283) Running the example:
129=======================
130
131
1323.1) Using PI
133-----------------
134Change to the sub directory "run" and execute "runSim.py".
135"runSim.py" runs an example configuration which may be
136changed by the user. The results of the simulation are stored in
137the directory "simData".
138The script "runSim.py" periodically prints scoring information to the
139screen.
140It also prints out the relative path of a ".shelve" file.
141This file can be used to access results of the simulation.
142
143In case the example was build using analysis
144results may be viewed e.g. using python or ROOT:
1451) Start python
1462) type: import dataAcess
1473) type: p = dataAcess.ExpMcPlot (shelveFileName,detectorposition)
148         where "shelveFileName" is the name (enclosed in quotes) of the
149         shelve file created during the execution of runSim.py.
150         The name is printed on the screen during execution of runSim.py.
151         "detectorposition" may be "00, "20" or "40" and stand for the
152         detectors 00, 20, 40 cm off beam axis respectively.
1534) type: p.display ()
1545) type: import extractShelve
1556) type: extractShelve.getFluxes (p.she)
156         p.she is the shelve object containing simulation results.
157         This prints the FOM values for the used detectors
158         for two energy regions below and in the peak region.
159         The FOM should be compared to unbiased simulations. To run
160         an unbiased simulation set the importance values to one (see 
161         runSim.py)
162 
163Note: the output files written after every run are incremental! Meaning
164      the file with the highest run number contains the data from
165      all the runs!
166
167The modules (dataAcess, extractShelve) imported in the above steps are
168placed in source/py_modules in files named after the module ending with
169".py".
170
171Since the simulation time used by "runSim.py" is only 5 minutes the
172calculated results have large errors. If you want to see a better result
173do the following changes in "runSim.py".
174Extend the total run time to e,g, 2 hours by setting:
175"totalTime = 2 * myUtils.hour",
176set the print out period to 30 minutes by setting:
177"timeForOneRun = 30 * myUtils.min".
178
179
180
181
1823.2) Not using PI (mainly for system testing)
183-------------------------------------------------
184Change to the sub directory "run" and execute
185runSimNoAnalysis.py.
186
187
188
189
190
1914) Content of the directory:
192============================
193
194
195envCommon.csh - a script to setup environment variables
196    in case the above one of the above environment settings have been
197    done beforehand.
198
199GNUmakefile - for building the example
200
201
202data / - directory containing experimental data
203
204      expDataOrig - experimental data taken from
205                    http://idsun1.kek.jp/nakao/research/tiara/tiara.htm
206
207      expDataConverted  - some of the experimental data and the source
208                    spectra converted into Anaphes DataPointSet
209                    and stored in Anaphes xml format
210
211
212source / - directory containing the source code
213
214        tiara - C++ source code
215
216        CLHEPWrapper - wrapper classes for usage in python
217                     \include\CLHEP.i - specification file for swig
218                     \src\CLHEP_wrap.cc - wrapper created with swig
219
220        G4KernelWrapper - wrapper classes for usage in python
221
222        TiaraWrapper - wrapper classes for usage in python
223
224        py_modules - python modules for running and analysing
225
226        swig.gmk - makefile rules for using swig 
227
228run / - directory for running the example
229       runSim.py - executable example script
230       runSimNoAnalysis.py - executable script for running without
231                             analysis
232
233
234
2355) Technicalities about this example
236===================================
237
238 This example is composed out of a layer of classes written in C++
239(source/tiara/include, source/tiara/src), a layer of python
240shadow classes created by swig (source/CLHEPWrapper,
241source/G4KernelWrapper, source/TiaraWrapper) and a layer of
242python modules (source/py_modules).
243 The C++ layer under source/tiara provides lower level classes closely
244related to the Geant4 kernel.
245 The shadow classes in the source/*Wrapper directories provide classes
246that may be instantiated in a python script or session. This way the
247lower level C++ code can be used directly for scripting in python. The
248shadow classes are declared in the files with extensions ".i" in the
249source/*Wrapper/include directories. Swig is used to create C++ code for
250a library that can be loaded into python and python modules (files with
251extensions .py in the source/*Wrapper directories). When the python
252modules created by swig are imported into python (in a session or a
253script) the corresponding C++ library is automatically loaded as well.
254 The python modules in source/py_modules provide classes and functions
255that may be changed or customized more frequently than the C++ classes
256in source/tiara. These classes complete the construction of geometries,
257take care of the procedure of setting up the simulation, the run sequence
258and the analysis after the simulation has been ran.
259 The script runSim.py is an commented example of using the python modules
260to run a simulation.
261
262
2636) Note about how to call the hadronic physics lists in runSim.py and runSimNoAnalysis.py
264=========================================================================================
265
266It is only necessary to change the physList value in runSim.py or runSimNoAnalysis.py. In the example, there are 4 available physics lists, but of course the user can use whatever physics lists he/she likes and present in the Geant4-7.0 repository. In such a case, the user should also modify the
267/source/TiaraWrapper/include/Tiara.i file in order to create an instantiation of the
268 physics list class. In particular, just follow the same lines already used for the six
269available physics lists.
270
Note: See TracBrowser for help on using the repository browser.