source: trunk/examples/advanced/Tiara/run/runVisMode.py @ 1317

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

update

File size: 6.0 KB
Line 
1#!/usr/bin/env python
2#
3# $Id: runVisMode.py,v 1.8 2006/06/26 10:12:05 ahoward Exp $
4# -------------------------------------------------------------------
5# GEANT4 tag $Name:  $
6# -------------------------------------------------------------------
7
8
9# importing python libraries
10import os
11
12# importing wrapper modules (see the source/*Wrapper directories)
13# created by swig (from the source/*Wrapper/*.i files).
14import CLHEP
15import Tiara
16import G4Kernel
17
18# importing python modules specific to this example
19# (see source/py_modules)
20import tiaraApplication
21import tiaraGenerators
22import tiaraDetectors
23import tiaraSpecifications
24import myUtils
25import variableGeometry
26import slabGeometry
27import runSequence
28
29##########################################################################
30# random number initialization
31##########################################################################
32Tiara.setRandomSeed(891011);
33#Tiara.setRandomStatus("dTest/tiara-2003_5_27_20_5_39_pcgeant2/randomNumberFile_run00003");   
34
35
36
37
38
39
40
41
42
43
44##########################################################################
45# experiment and simulation specific data
46##########################################################################
47# create a list of particles and give a lower energy cut
48particleCut = {"neutron" : 3 * CLHEP.MeV,
49               "gamma"   : 1 * CLHEP.MeV,
50               "proton"  : 1 * CLHEP.MeV,
51               "deuteron": 1 * CLHEP.MeV,
52               "triton"  : 1 * CLHEP.MeV,
53               "alpha"   : 1 * CLHEP.MeV}
54
55# specify if the source neutrons shoul be form the 43 or 68 MeV protons
56beamEnergy = 68 * CLHEP.MeV
57# specify the shieldwidth [25, 50, 100, 150, (200 for 68 MeV case only)]
58shieldWidth = 100 * CLHEP.cm
59
60# available physics lists: TiaraPhysicsList, LHEP_LEAD_HP, LHEP_PRECO_HP
61# CASCADE_HP LHEP_BIC  LHEP_BIC_BIC
62physList = Tiara.LHEP_BIC_HP()
63
64# specify the detectors
65scoreDetectorCreator = tiaraDetectors.ThreeZylindricDetectors()
66#scoreDetectorCreator = tiaraDetectors.DetectorSlab()
67
68
69comment = ""
70
71
72
73
74
75
76
77
78
79
80
81
82##########################################################################
83# Create a Specification object of the configuaration data
84##########################################################################
85
86experiment = tiaraSpecifications.Experiment(beamEnergy,     
87                                           particleCut["neutron"],
88                                           particleCut,
89                                           shieldWidth,
90                                           "concrete")
91
92tiaraSpecs = tiaraSpecifications.Specifications(Tiara.TiaraDimensions(),
93                                                experiment,
94                                                Tiara.TiaraMaterials())
95
96
97
98
99
100
101
102
103
104##########################################################################
105# definition of the importance geometry importance values and a scorer
106##########################################################################
107# create a parallel geometry.
108impGeo = variableGeometry.VariableImpSlabGeometry(tiaraSpecs)
109
110
111# introduce "importance cells" into the shielding region
112# In this case the width of all the shields in the shielding region
113# are equal and the importance staring from one doubles
114# from cell to cell in the beam direction.
115impGeo.addCellImportance(width=15.0 * CLHEP.cm, faktor=1)
116for i in range(9):
117    # to run unbiased set: faktor=1     in the next line
118    impGeo.addCellImportance(width=15.0 * CLHEP.cm, faktor=2)
119
120impGeo.construct()
121
122# Make sure the widths given in the above way add up to the
123# shield widths e.g. 25, 50, ... cm.
124# The importance geometries take care to give the importance value 1
125# to the volume before the shield and to assign the same importance
126# as the last cell in the shield region to the volume behind the shield.
127
128# an alternative
129#impGeo = slabGeometry.SlabedImportanceGeometry(tiaraSpecs,
130#                                               10.0 * CLHEP.cm,
131#                                               1.5)
132
133
134impScorer = G4Kernel.G4Scorer()
135
136
137
138
139
140
141
142##########################################################################
143# Creation of a TiaraApplet to define the run mode, physics list,
144# detector type and the primary generator
145##########################################################################
146tApp = tiaraApplication.TiaraApplet(tiaraSpecs,
147                                    Tiara.TiaraSim_GetTiaraSim())
148
149
150# chise if you want to run in a timed mode (for a given time) or in
151# the visualization mode to see the detector.
152tApp.visMode()
153
154
155tApp.specifyPhysicsList(physList, particleCut)
156
157# detectors
158tApp.setScoreDetectorCreator(scoreDetectorCreator)
159
160tApp.buildGeometry()
161
162tiara_dir = os.environ["TIARA_BASE"]
163
164tApp.setPhysics()
165
166tApp.visAdd()
167
168##primGenBuilder = tiaraGenerators.\
169##                 TiaraDPSEnergyGenerator(tiaraSpecs,
170##                                         tiara_dir +
171##                                         "/data/expDataConverted/dpsSource.xml")
172#primGenBuilder = tiaraGenerators.TiaraPrimaryGenerator(tiaraSpecs)
173primGenBuilder = tiaraGenerators.FixedEnergyPrimaryGenerator(tiaraSpecs)
174
175tApp.setPrimaryGenerator(primGenBuilder.primGen)
176
177
178tApp.noComponents = 0
179tApp.config()
180
181
182
183
184
185
186
187
188
189##########################################################################
190# creating of the sampler
191##########################################################################
192parallelSampler = myUtils.createParallelSampler(impGeo,
193                                                impScorer)
194
195
196
197
198
199
200
201
202
203
204
205##########################################################################
206# create a run config object, a run sequence and run the simulation
207##########################################################################
208rc = runSequence.RunConfig()
209
210rc.basePath = "simData"
211rc.tApp = tApp
212rc.tiaraSpecs = tiaraSpecs
213rc.impGeo = impGeo
214rc.impScorer = impScorer
215rc.totalTime = totalTime
216rc.comment = comment
217
218rs = runSequence.RunSequence(rc)
219rs.runNevents(100)
220rs.runLoop()
221
222
223##########################################################################
224##########################################################################
Note: See TracBrowser for help on using the repository browser.