SND@LHC Software
Loading...
Searching...
No Matches
g4Ex_args Namespace Reference

Classes

class  MyEventAction
 
class  MyGeneratorAction
 
class  MyRunAction
 
class  MySteppingAction
 
class  MyTrackingAction
 
class  ScoreSD
 

Functions

 get_work_dir (run_number)
 
 init ()
 
 ConstructGeom ()
 

Variables

bool debug = False
 
bool withNtuple = True
 
bool muonNuclear = True
 
str model = "QGSP_BERT_EMX"
 
int runnr = 1
 
int nev = 100
 
int nevTot = 0
 
int myEventnr = 0
 
int mytrack = 1
 
int scoreLog = 1
 
dict myTimer = {'total':0,'pythia':0,'geant4_conv':0}
 
bool tauOnly = False
 
str work_dir = "./"
 
int ecut = 10
 
 logger = logging.getLogger(os.path.splitext(os.path.basename(os.sys.argv[0]))[0])
 
 myPythia = ROOT.TPythia8()
 
 rnr = ROOT.TRandom()
 
 R = int(time.time() % 900000000)
 
dict h = {}
 
 f = ROOT.TFile.Open('pythia8_Geant4_'+str(runnr)+'_'+str(ecut)+'.root', 'RECREATE')
 
list leptons = [12,13,14,15,16]
 
list pionkaons = [211,321]
 
list rest = [130,310,3122]
 
list allPart = []
 
list notWanted = [22,11,-11,990]
 
 rand_engine = Ranlux64Engine()
 
 physList = Geant4.FTFP_BERT()
 
 factory = G4physicslists.G4PhysListFactory()
 
 xx = factory.GetReferencePhysList(model)
 
 myGE = MyGeneratorAction()
 
 myTA = MyTrackingAction()
 
 myRA = MyRunAction()
 
 myEA = MyEventAction()
 
 sens = ScoreSD('Score')
 
 t0 = time.time()
 
 t1 = time.time()
 

Function Documentation

◆ ConstructGeom()

g4Ex_args.ConstructGeom ( )

Definition at line 274 of file g4Ex_args.py.

274def ConstructGeom():
275 print("* Constructing geometry...")
276 world_r = 100.*m
277 # reset world material
278 vac = G4Material.GetMaterial("G4_Galactic")
279 g4py.ezgeom.SetWorldMaterial(vac)
280 g4py.ezgeom.ResizeWorld(world_r, world_r, world_r)
281 # a snoopy world is placed
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)
288 # a target box is placed
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)
300 # = 0.1m3 = 2t
301 # a hadron absorber is placed
302 absorber = G4EzVolume("Absorber")
303# iron alloys saturate at 1.6-2.2T
304 # inner radius outer radius length
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)
313# scoring plane
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()
320

◆ get_work_dir()

g4Ex_args.get_work_dir (   run_number)

Definition at line 28 of file g4Ex_args.py.

28def get_work_dir(run_number):
29 import socket
30 host = socket.gethostname()
31 job_base_name = os.path.splitext(os.path.basename(os.sys.argv[0]))[0]
32 out_dir = "{host}_{base}_{runnr}".format(host=host, base=job_base_name, runnr=run_number)
33 return out_dir
34
35

◆ init()

g4Ex_args.init ( )

Definition at line 36 of file g4Ex_args.py.

36def init():
37 global runnr, nev, ecut, tauOnly, work_dir
38 logger.info("SHiP proton-on-taget simulator (C) Thomas Ruf, 2014")
39
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()
50 if args.debug:
51 logger.setLevel(logging.DEBUG)
52 runnr = args.runnr
53 nev = args.nev
54 ecut = args.ecut
55 tauOnly = args.tauOnly
56 if args.work_dir is None:
57 args.work_dir = get_work_dir(runnr)
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)
64 if args.force:
65 logger.warn("...cleaning")
66 for root, dirs, files in os.walk(work_dir):
67 for f in files:
68 os.unlink(os.path.join(root, f))
69 for d in dirs:
70 shutil.rmtree(os.path.join(root, d))
71 else:
72 logger.warn("...use '-f' option to overwrite it")
73 else:
74 os.makedirs(work_dir)
75

Variable Documentation

◆ allPart

list g4Ex_args.allPart = []

Definition at line 133 of file g4Ex_args.py.

◆ debug

bool g4Ex_args.debug = False

Definition at line 3 of file g4Ex_args.py.

◆ ecut

int g4Ex_args.ecut = 10

Definition at line 16 of file g4Ex_args.py.

◆ f

g4Ex_args.f = ROOT.TFile.Open('pythia8_Geant4_'+str(runnr)+'_'+str(ecut)+'.root', 'RECREATE')

Definition at line 127 of file g4Ex_args.py.

◆ factory

g4Ex_args.factory = G4physicslists.G4PhysListFactory()

Definition at line 329 of file g4Ex_args.py.

◆ h

dict g4Ex_args.h = {}

Definition at line 125 of file g4Ex_args.py.

◆ leptons

list g4Ex_args.leptons = [12,13,14,15,16]

Definition at line 130 of file g4Ex_args.py.

◆ logger

g4Ex_args.logger = logging.getLogger(os.path.splitext(os.path.basename(os.sys.argv[0]))[0])

Definition at line 24 of file g4Ex_args.py.

◆ model

str g4Ex_args.model = "QGSP_BERT_EMX"

Definition at line 6 of file g4Ex_args.py.

◆ muonNuclear

bool g4Ex_args.muonNuclear = True

Definition at line 5 of file g4Ex_args.py.

◆ myEA

g4Ex_args.myEA = MyEventAction()

Definition at line 346 of file g4Ex_args.py.

◆ myEventnr

int g4Ex_args.myEventnr = 0

Definition at line 10 of file g4Ex_args.py.

◆ myGE

g4Ex_args.myGE = MyGeneratorAction()

Definition at line 334 of file g4Ex_args.py.

◆ myPythia

g4Ex_args.myPythia = ROOT.TPythia8()

Definition at line 96 of file g4Ex_args.py.

◆ myRA

g4Ex_args.myRA = MyRunAction()

Definition at line 343 of file g4Ex_args.py.

◆ myTA

g4Ex_args.myTA = MyTrackingAction()

Definition at line 337 of file g4Ex_args.py.

◆ myTimer

dict g4Ex_args.myTimer = {'total':0,'pythia':0,'geant4_conv':0}

Definition at line 13 of file g4Ex_args.py.

◆ mytrack

int g4Ex_args.mytrack = 1

Definition at line 11 of file g4Ex_args.py.

◆ nev

int g4Ex_args.nev = 100

Definition at line 8 of file g4Ex_args.py.

◆ nevTot

int g4Ex_args.nevTot = 0

Definition at line 9 of file g4Ex_args.py.

◆ notWanted

list g4Ex_args.notWanted = [22,11,-11,990]

Definition at line 137 of file g4Ex_args.py.

◆ physList

g4Ex_args.physList = Geant4.FTFP_BERT()

Definition at line 324 of file g4Ex_args.py.

◆ pionkaons

list g4Ex_args.pionkaons = [211,321]

Definition at line 131 of file g4Ex_args.py.

◆ R

g4Ex_args.R = int(time.time() % 900000000)

Definition at line 116 of file g4Ex_args.py.

◆ rand_engine

g4Ex_args.rand_engine = Ranlux64Engine()

Definition at line 144 of file g4Ex_args.py.

◆ rest

list g4Ex_args.rest = [130,310,3122]

Definition at line 132 of file g4Ex_args.py.

◆ rnr

g4Ex_args.rnr = ROOT.TRandom()

Definition at line 97 of file g4Ex_args.py.

◆ runnr

int g4Ex_args.runnr = 1

Definition at line 7 of file g4Ex_args.py.

◆ scoreLog

int g4Ex_args.scoreLog = 1

Definition at line 12 of file g4Ex_args.py.

◆ sens

g4Ex_args.sens = ScoreSD('Score')

Definition at line 352 of file g4Ex_args.py.

◆ t0

g4Ex_args.t0 = time.time()

Definition at line 355 of file g4Ex_args.py.

◆ t1

g4Ex_args.t1 = time.time()

Definition at line 357 of file g4Ex_args.py.

◆ tauOnly

bool g4Ex_args.tauOnly = False

Definition at line 14 of file g4Ex_args.py.

◆ withNtuple

bool g4Ex_args.withNtuple = True

Definition at line 4 of file g4Ex_args.py.

◆ work_dir

str g4Ex_args.work_dir = "./"

Definition at line 15 of file g4Ex_args.py.

◆ xx

g4Ex_args.xx = factory.GetReferencePhysList(model)

Definition at line 330 of file g4Ex_args.py.