16 "My Detector Construction"
19 G4VUserDetectorConstruction.__init__(self)
20 self.
air= gNistManager.FindOrBuildMaterial(
"G4_AIR")
34 global sld_world, lv_world, pv_world, va_world
36 sld_world=
G4Box(
"world", 1.*m, 1.*m, 1.*m)
42 va_world.SetVisibility(
False)
43 lv_world.SetVisAttributes(va_world)
46 global sld_sld, lv_sld, pv_sld
47 sld_sld=
G4Box(
"dummy", 10.*cm, 10.*cm, 10.*cm)
57 sld_box=
G4Box(
"box", 30.*cm, 40.*cm, 60.*cm)
58 self.lv_object.SetSolid(sld_box)
59 self.lv_object.SetVisAttributes(self.
va_red)
60 gRunManager.GeometryHasBeenModified()
65 sld_tubs=
G4Tubs(
"tubs", 10.*cm, 15.*cm, 20.*cm, 0., pi)
66 self.lv_object.SetSolid(sld_tubs)
67 self.lv_object.SetVisAttributes(self.
va_cyan)
68 gRunManager.GeometryHasBeenModified()
73 sld_cons=
G4Cons(
"cons", 5.*cm, 10.*cm, 20.*cm, 25.*cm,
75 self.lv_object.SetSolid(sld_cons)
76 self.lv_object.SetVisAttributes(self.
va_green)
77 gRunManager.GeometryHasBeenModified()
82 sld_para=
G4Para(
"para", 30.*cm, 40.*cm, 60.*cm, pi/4., pi/8., 0.)
83 self.lv_object.SetSolid(sld_para)
84 self.lv_object.SetVisAttributes(self.
va_blue)
85 gRunManager.GeometryHasBeenModified()
90 sld_trd=
G4Trd(
"trd", 30.*cm, 10.*cm, 40.*cm, 15.*cm, 60.*cm)
91 self.lv_object.SetSolid(sld_trd)
92 self.lv_object.SetVisAttributes(self.
va_blue)
93 gRunManager.GeometryHasBeenModified()
98 sld_trap=
G4Trap(
"trap", 60.*cm, 20.*degree, 5.*degree,
99 40.*cm, 30.*cm, 40.*cm, 10.*degree,
100 16.*cm, 10*cm, 14.*cm, 10.*deg)
101 self.lv_object.SetSolid(sld_trap)
102 self.lv_object.SetVisAttributes(self.
va_green)
103 gRunManager.GeometryHasBeenModified()
108 sld_sphere=
G4Sphere(
"sphere", 100.*cm, 120.*cm, 0., 180.*deg,
110 self.lv_object.SetSolid(sld_sphere)
111 self.lv_object.SetVisAttributes(self.
va_cyan)
112 gRunManager.GeometryHasBeenModified()
117 sld_orb=
G4Orb(
"orb", 100.*cm)
118 self.lv_object.SetSolid(sld_orb)
119 self.lv_object.SetVisAttributes(self.
va_red)
120 gRunManager.GeometryHasBeenModified()
125 sld_torus=
G4Torus(
"torus", 40.*cm, 60.*cm, 200.*cm, 0., 90.*deg)
126 self.lv_object.SetSolid(sld_torus)
127 self.lv_object.SetVisAttributes(self.
va_magenta)
128 gRunManager.GeometryHasBeenModified()
136 zvec[:]= [ 5.*cm, 7.*cm, 9.*cm, 11.*cm, 25.*cm, 27.*cm, 29.*cm,
138 rinvec[:]= [0.,0.,0.,0.,0.,0.,0.,0.,0.]
139 routvec[:]= [ 0., 10.*cm, 10.*cm, 5.*cm, 5.*cm, 10.*cm,
140 10.*cm, 2.*cm, 2.*cm ]
143 sld_pcon= CreatePolycone(
"pcon", 0., twopi, 9, zvec, rinvec,routvec)
144 self.lv_object.SetSolid(sld_pcon)
145 self.lv_object.SetVisAttributes(self.
va_cyan)
146 gRunManager.GeometryHasBeenModified()
154 zvec[:]= [ 0., 5.*cm, 8.*cm, 13.*cm, 30.*cm, 32.*cm, 35.*cm ]
155 rinvec[:]= [0.,0.,0.,0.,0.,0.,0. ]
156 routvec[:]= [ 0., 15.*cm, 15.*cm, 4.*cm, 4.*cm, 10.*cm, 10.*cm ]
159 sld_pgon= CreatePolyhedra(
"pgon", 0., twopi, 5, 7, zvec, rinvec,routvec)
160 self.lv_object.SetSolid(sld_pgon)
161 self.lv_object.SetVisAttributes(self.
va_green)
162 gRunManager.GeometryHasBeenModified()
168 self.lv_object.SetSolid(sld_et)
169 self.lv_object.SetVisAttributes(self.
va_cyan)
170 gRunManager.GeometryHasBeenModified()
175 sld_es=
G4Ellipsoid(
"ellipsoid", 10.*cm, 20.*cm, 50.*cm,
177 self.lv_object.SetSolid(sld_es)
178 self.lv_object.SetVisAttributes(self.
va_red)
179 gRunManager.GeometryHasBeenModified()
186 self.lv_object.SetSolid(sld_ec)
187 self.lv_object.SetVisAttributes(self.
va_magenta)
188 gRunManager.GeometryHasBeenModified()
193 sld_hype=
G4Hype(
"hype", 20.*cm, 30.*cm, 0.7, 0.7, 50.*cm)
194 self.lv_object.SetSolid(sld_hype)
195 self.lv_object.SetVisAttributes(self.
va_blue)
196 gRunManager.GeometryHasBeenModified()
202 p2=
G4ThreeVector(0., 2*math.sqrt(2./3.)*cm, -1./math.sqrt(3)*cm)
208 sld_tet=
G4Tet(
"tet", 20.*p1, 20.*p2, 20.*p3, 20.*p4)
209 self.lv_object.SetSolid(sld_tet)
210 self.lv_object.SetVisAttributes(self.
va_green)
211 gRunManager.GeometryHasBeenModified()
216 sld_twb=
G4TwistedBox(
"twistedbox", 30.*deg, 30.*cm, 40.*cm, 60.*cm)
217 self.lv_object.SetSolid(sld_twb)
218 self.lv_object.SetVisAttributes(self.
va_cyan)
219 gRunManager.GeometryHasBeenModified()
225 60.*cm, 20.*deg, 5.*deg,
226 40.*cm, 30.*cm, 40.*cm,
227 16.*cm, 10.*cm, 14.*cm, 10.*deg)
228 self.lv_object.SetSolid(sld_twtrp)
229 self.lv_object.SetVisAttributes(self.
va_blue)
230 gRunManager.GeometryHasBeenModified()
236 40.*cm, 15.*cm, 60.*cm, 30.*deg)
237 self.lv_object.SetSolid(sld_twtrd)
238 self.lv_object.SetVisAttributes(self.
va_green)
239 gRunManager.GeometryHasBeenModified()
245 10.*cm, 15.*cm, 20.*cm, 90.*deg)
246 self.lv_object.SetSolid(sld_twt)
247 self.lv_object.SetVisAttributes(self.
va_magenta)
248 gRunManager.GeometryHasBeenModified()
257 os.environ[
"G4VRML_DEST_DIR"]=
"."
258 os.environ[
"G4VRMLFILE_MAX_FILE_NUM"]=
"1"
259 os.environ[
"G4VRMLFILE_VIEWER"]=
"echo"
263 gRunManager.SetUserInitialization(myDC)
266 g4pytest.ExN01pl.Construct()
269 g4pytest.ParticleGun.Construct()
272 gRunManager.Initialize()
283 (
"g4box", myDC.ConstructBox),
284 (
"g4tubs", myDC.ConstructTubs),
285 (
"g4cons", myDC.ConstructCons),
286 (
"g4para", myDC.ConstructPara),
287 (
"g4trd", myDC.ConstructTrd),
288 (
"g4trap", myDC.ConstructTrap),
289 (
"g4sphere", myDC.ConstructSphere),
290 (
"g4orb", myDC.ConstructOrb),
291 (
"g4torus", myDC.ConstructTorus),
292 (
"g4polycone", myDC.ConstructPolycone),
293 (
"g4polyhedra", myDC.ConstructPolyhedra),
294 (
"g4ellipticaltube", myDC.ConstructEllipticalTube),
295 (
"g4ellipsoid", myDC.ConstructEllipsoid),
296 (
"g4ellipticalcone", myDC.ConstructEllipticalCone),
297 (
"g4hype", myDC.ConstructHype),
298 (
"g4tet", myDC.ConstructTet),
299 (
"g4twistedbox", myDC.ConstructTwistedBox),
300 (
"g4twistedtrap", myDC.ConstructTwistedTrap),
301 (
"g4twistedtrd", myDC.ConstructTwistedTrd),
302 (
"g4twistedtubs", myDC.ConstructTwistedTubs)
307 gRunManager.BeamOn(1)
308 fname=
"%s.wrl" % (s)
309 os.rename(
"g4_00.wrl", fname)