The Gaudi Framework  master (37c0b60a)
PythiaID.py
Go to the documentation of this file.
1 
14 def properties(pid, sgn=1):
15  return {
16  "name": pid.name(sgn),
17  "threeCharge": pid.chargeType(sgn),
18  "hasAnti": pid.hasAnti(),
19  "isLepton": pid.isLepton(),
20  "isQuark": pid.isQuark(),
21  "isDiQuark": pid.isDiquark(),
22  "isHadron": pid.isHadron(),
23  "isMeson": pid.isMeson(),
24  "isBaryon": pid.isBaryon(),
25  "jSpin": pid.spinType(),
26  }
27 
28 
29 # Generate the PID dictionary and optionally archive.
30 def generate(dat=None):
31  import pythia8
32 
33  pythia = pythia8.Pythia("", False)
34 
35  # Loop over the particles.
36  pid, pids = 1, {}
37  while pid != 0:
38  pids[pid] = properties(pythia.particleData.particleDataEntryPtr(pid))
39  if pids[pid]["hasAnti"]:
40  pids[-pid] = properties(pythia.particleData.particleDataEntryPtr(pid), -1)
41  pid = pythia.particleData.nextId(abs(pid))
42 
43  # Archive if requested.
44  if dat:
45  with open(dat, "w") as dat:
46  dat.write(repr(pids))
47  return pids
48 
49 
50 # Load the Pythia dictionary.
51 try:
52  pids = eval(open("PythiaID.dat").read())
53 except FileNotFoundError:
54  pids = generate("PythiaID.dat")
PythiaID.generate
def generate(dat=None)
Definition: PythiaID.py:30
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition: ParticleID.h:191
hivetimeline.read
def read(f, regex=".*", skipevents=0)
Definition: hivetimeline.py:32
PythiaID.properties
def properties(pid, sgn=1)
(c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations # # This software i...
Definition: PythiaID.py:14