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 |
---|
10 | import os |
---|
11 | |
---|
12 | # importing wrapper modules (see the source/*Wrapper directories) |
---|
13 | # created by swig (from the source/*Wrapper/*.i files). |
---|
14 | import CLHEP |
---|
15 | import Tiara |
---|
16 | import G4Kernel |
---|
17 | |
---|
18 | # importing python modules specific to this example |
---|
19 | # (see source/py_modules) |
---|
20 | import tiaraApplication |
---|
21 | import tiaraGenerators |
---|
22 | import tiaraDetectors |
---|
23 | import tiaraSpecifications |
---|
24 | import myUtils |
---|
25 | import variableGeometry |
---|
26 | import slabGeometry |
---|
27 | import runSequence |
---|
28 | |
---|
29 | ########################################################################## |
---|
30 | # random number initialization |
---|
31 | ########################################################################## |
---|
32 | Tiara.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 |
---|
48 | particleCut = {"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 |
---|
56 | beamEnergy = 68 * CLHEP.MeV |
---|
57 | # specify the shieldwidth [25, 50, 100, 150, (200 for 68 MeV case only)] |
---|
58 | shieldWidth = 100 * CLHEP.cm |
---|
59 | |
---|
60 | # available physics lists: TiaraPhysicsList, LHEP_LEAD_HP, LHEP_PRECO_HP |
---|
61 | # CASCADE_HP LHEP_BIC LHEP_BIC_BIC |
---|
62 | physList = Tiara.LHEP_BIC_HP() |
---|
63 | |
---|
64 | # specify the detectors |
---|
65 | scoreDetectorCreator = tiaraDetectors.ThreeZylindricDetectors() |
---|
66 | #scoreDetectorCreator = tiaraDetectors.DetectorSlab() |
---|
67 | |
---|
68 | |
---|
69 | comment = "" |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | ########################################################################## |
---|
83 | # Create a Specification object of the configuaration data |
---|
84 | ########################################################################## |
---|
85 | |
---|
86 | experiment = tiaraSpecifications.Experiment(beamEnergy, |
---|
87 | particleCut["neutron"], |
---|
88 | particleCut, |
---|
89 | shieldWidth, |
---|
90 | "concrete") |
---|
91 | |
---|
92 | tiaraSpecs = 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. |
---|
108 | impGeo = 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. |
---|
115 | impGeo.addCellImportance(width=15.0 * CLHEP.cm, faktor=1) |
---|
116 | for 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 | |
---|
120 | impGeo.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 | |
---|
134 | impScorer = 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 | ########################################################################## |
---|
146 | tApp = 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. |
---|
152 | tApp.visMode() |
---|
153 | |
---|
154 | |
---|
155 | tApp.specifyPhysicsList(physList, particleCut) |
---|
156 | |
---|
157 | # detectors |
---|
158 | tApp.setScoreDetectorCreator(scoreDetectorCreator) |
---|
159 | |
---|
160 | tApp.buildGeometry() |
---|
161 | |
---|
162 | tiara_dir = os.environ["TIARA_BASE"] |
---|
163 | |
---|
164 | tApp.setPhysics() |
---|
165 | |
---|
166 | tApp.visAdd() |
---|
167 | |
---|
168 | ##primGenBuilder = tiaraGenerators.\ |
---|
169 | ## TiaraDPSEnergyGenerator(tiaraSpecs, |
---|
170 | ## tiara_dir + |
---|
171 | ## "/data/expDataConverted/dpsSource.xml") |
---|
172 | #primGenBuilder = tiaraGenerators.TiaraPrimaryGenerator(tiaraSpecs) |
---|
173 | primGenBuilder = tiaraGenerators.FixedEnergyPrimaryGenerator(tiaraSpecs) |
---|
174 | |
---|
175 | tApp.setPrimaryGenerator(primGenBuilder.primGen) |
---|
176 | |
---|
177 | |
---|
178 | tApp.noComponents = 0 |
---|
179 | tApp.config() |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | ########################################################################## |
---|
190 | # creating of the sampler |
---|
191 | ########################################################################## |
---|
192 | parallelSampler = 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 | ########################################################################## |
---|
208 | rc = runSequence.RunConfig() |
---|
209 | |
---|
210 | rc.basePath = "simData" |
---|
211 | rc.tApp = tApp |
---|
212 | rc.tiaraSpecs = tiaraSpecs |
---|
213 | rc.impGeo = impGeo |
---|
214 | rc.impScorer = impScorer |
---|
215 | rc.totalTime = totalTime |
---|
216 | rc.comment = comment |
---|
217 | |
---|
218 | rs = runSequence.RunSequence(rc) |
---|
219 | rs.runNevents(100) |
---|
220 | rs.runLoop() |
---|
221 | |
---|
222 | |
---|
223 | ########################################################################## |
---|
224 | ########################################################################## |
---|