[807] | 1 | #!/usr/bin/env python |
---|
| 2 | # |
---|
| 3 | # $Id: runVisNoAnalysis.py,v 1.5 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(), False) |
---|
| 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 | ##timeForOneRun = 1 * myUtils.min |
---|
| 154 | ##tApp.timedMode(timeForOneRun) |
---|
| 155 | |
---|
| 156 | tApp.specifyPhysicsList(physList, particleCut) |
---|
| 157 | |
---|
| 158 | # detectors |
---|
| 159 | tApp.setScoreDetectorCreator(scoreDetectorCreator) |
---|
| 160 | |
---|
| 161 | tApp.buildGeometry() |
---|
| 162 | |
---|
| 163 | tiara_dir = os.environ["TIARA_BASE"] |
---|
| 164 | |
---|
| 165 | tApp.setPhysics() |
---|
| 166 | |
---|
| 167 | tApp.visAdd() |
---|
| 168 | |
---|
| 169 | ##primGenBuilder = tiaraGenerators.\ |
---|
| 170 | ## TiaraDPSEnergyGenerator(tiaraSpecs, |
---|
| 171 | ## tiara_dir + |
---|
| 172 | ## "/data/expDataConverted/dpsSource.xml") |
---|
| 173 | #primGenBuilder = tiaraGenerators.TiaraPrimaryGenerator(tiaraSpecs) |
---|
| 174 | primGenBuilder = tiaraGenerators.FixedEnergyPrimaryGenerator(tiaraSpecs) |
---|
| 175 | |
---|
| 176 | tApp.setPrimaryGenerator(primGenBuilder.primGen) |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | tApp.noComponents = 0 |
---|
| 180 | tApp.config() |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | ########################################################################## |
---|
| 191 | # creating of the sampler |
---|
| 192 | ########################################################################## |
---|
| 193 | parallelSampler = myUtils.createParallelSampler(impGeo, |
---|
| 194 | impScorer) |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | |
---|
| 206 | ########################################################################## |
---|
| 207 | # create a run config object, a run sequence and run the simulation |
---|
| 208 | ########################################################################## |
---|
| 209 | rc = runSequence.RunConfig() |
---|
| 210 | |
---|
| 211 | rc.basePath = "simData" |
---|
| 212 | rc.tApp = tApp |
---|
| 213 | rc.tiaraSpecs = tiaraSpecs |
---|
| 214 | rc.impGeo = impGeo |
---|
| 215 | rc.impScorer = impScorer |
---|
| 216 | rc.totalTime = totalTime |
---|
| 217 | rc.comment = comment |
---|
| 218 | |
---|
| 219 | rs = runSequence.RunSequence(rc) |
---|
| 220 | rs.runNevents(100) |
---|
| 221 | rs.runLoop() |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | ########################################################################## |
---|
| 225 | ########################################################################## |
---|