The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
ParticleProperty.py
Go to the documentation of this file.
14def properties(pid):
15 return {
16 "name": pid.name(),
17 "threeCharge": int(round(pid.charge() * 3)),
18 "hasAnti": pid.selfcc(),
19 }
20
21
22# Generate the PID dictionary and optionally archive.
23def generate(dat=None):
24 # The following is misunderstood by flake8 - the import is needed as it
25 # has necessary side effects
26 import GaudiPartProp.PartPropSvc # noqa: F401
27 from GaudiPython.Bindings import AppMgr
28
29 gaudi = AppMgr()
30 ppsvc = gaudi.gaudiPartProp()
31
32 # Loop over the particles and add entries.
33 pids = {}
34 for pid in ppsvc:
35 pids[pid.pid().pid()] = properties(pid)
36
37 # Archive if requested.
38 if dat:
39 with open(dat, "w") as dat:
40 dat.write(repr(pids))
41 return pids
42
43
44# Load the PID dictionary.
45try:
46 pids = eval(open("ParticleProperty.dat").read())
47except FileNotFoundError:
48 pids = generate("ParticleProperty.dat")
properties(pid)
(c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations # # This software i...