The Gaudi Framework  master (37c0b60a)
ParticleProperty.py
Go to the documentation of this file.
1 
14 def 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.
23 def 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.
45 try:
46  pids = eval(open("ParticleProperty.dat").read())
47 except FileNotFoundError:
48  pids = generate("ParticleProperty.dat")
GaudiPartProp.Service.AppMgr
AppMgr
Definition: Service.py:41
GaudiPartProp.PartPropSvc
Definition: PartPropSvc.py:1
GaudiPython.Bindings
Definition: Bindings.py:1
ParticleProperty.properties
def properties(pid)
(c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations # # This software i...
Definition: ParticleProperty.py:14
hivetimeline.read
def read(f, regex=".*", skipevents=0)
Definition: hivetimeline.py:32
ParticleProperty.generate
def generate(dat=None)
Definition: ParticleProperty.py:23