37 global runnr, nev, ecut, tauOnly, work_dir
38 logger.info(
"SHiP proton-on-taget simulator (C) Thomas Ruf, 2014")
40 ap = argparse.ArgumentParser(
41 description=
'Run SHiP "pot" simulation')
42 ap.add_argument(
'-d',
'--debug', action=
'store_true')
43 ap.add_argument(
'-f',
'--force', action=
'store_true', help=
"force overwriting output directory")
44 ap.add_argument(
'-r',
'--run-number', type=int, dest=
'runnr', default=runnr)
45 ap.add_argument(
'-e',
'--ecut', type=float, help=
"energy cut", dest=
'ecut', default=ecut)
46 ap.add_argument(
'-n',
'--num-events', type=int, help=
"number of events to generate", dest=
'nev', default=nev)
47 ap.add_argument(
'-t',
'--tau-only', action=
'store_true', dest=
'tauOnly')
48 ap.add_argument(
'-o',
'--output', type=str, help=
"output directory", dest=
'work_dir', default=
None)
49 args = ap.parse_args()
51 logger.setLevel(logging.DEBUG)
55 tauOnly = args.tauOnly
56 if args.work_dir
is None:
58 work_dir = args.work_dir
59 logger.info(
"params: %s" % args)
60 logger.debug(
"work_dir: %s" % work_dir)
61 logger.debug(
"command line arguments: %s", args)
62 if os.path.exists(work_dir):
63 logger.warn(
"output directory '%s' already exists." % work_dir)
65 logger.warn(
"...cleaning")
66 for root, dirs, files
in os.walk(work_dir):
68 os.unlink(os.path.join(root, f))
70 shutil.rmtree(os.path.join(root, d))
72 logger.warn(
"...use '-f' option to overwrite it")
119myPythia.Initialize(2212, 2212, 400., 0.)
275 print(
"* Constructing geometry...")
278 vac = G4Material.GetMaterial(
"G4_Galactic")
279 g4py.ezgeom.SetWorldMaterial(vac)
280 g4py.ezgeom.ResizeWorld(world_r, world_r, world_r)
282 global snoopy,snoopyPhys,scoreLog
283 snoopy = G4EzVolume(
"Snoopy")
284 snoopy.CreateTubeVolume(vac, 0., 10*m, 50.*m)
285 snoopyPhys = snoopy.PlaceIt(G4ThreeVector(0.,0.,0.*m))
286 snoopyLog = snoopyPhys.GetLogicalVolume()
287 snoopy.SetVisibility(
False)
289 global target,targetPhys
290 iron = G4Material.GetMaterial(
"G4_Fe")
291 air = G4Material.GetMaterial(
"G4_AIR")
292 tungsten = G4Material.GetMaterial(
"G4_W")
293 lead = G4Material.GetMaterial(
"G4_Pb")
294 alum = G4Material.GetMaterial(
"G4_Al")
295 target = G4EzVolume(
"Target")
296 target.CreateTubeVolume(tungsten, 0., 25.*cm, 25.*cm)
297 targetPhys = target.PlaceIt(G4ThreeVector(0.,0.,-50.*m+25.*cm),1,snoopy)
298 target.SetColor(G4Color(0.0,0.5,0.5,1.0))
299 target.SetVisibility(
True)
302 absorber = G4EzVolume(
"Absorber")
305 absorber.CreateTubeVolume(iron, 0., 100.*cm, 150.*cm)
306 absorberPhys = absorber.PlaceIt(G4ThreeVector(0.,0.,-50*m+2*25.*cm+150.*cm),1,snoopy)
307 absorber.SetColor(G4Color(0.898,0.902,0.91,1.0))
308 absorber.SetVisibility(
True)
309 xx = G4VisAttributes()
310 xx.SetForceWireframe(
True)
311 absorberlog = absorberPhys.GetLogicalVolume()
312 absorberlog.SetVisAttributes(xx)
314 scorez = -50.*m+2*25.*cm+2*150.*cm+1*mm
315 score = G4EzVolume(
"Score")
316 score.CreateTubeVolume(vac, 0., 50.*m, 1.*mm)
317 scorePhys = score.PlaceIt(G4ThreeVector(0.,0.,scorez),1,snoopy)
318 scoreLog = scorePhys.GetLogicalVolume()
319 g4py.ezgeom.Construct()