10 """Dump out MC truth information.
12 This module contains the function dump_truth which will dump out the
13 truth information for the current event in a tabular format.
16 from PyAnalysisUtils
import PDG
17 from PyParticleTools
import PyParticleTools
21 """Return the unique ID number for decay N of truth particle T
22 as a string. Return an empty string if there's no such decay.
26 bc = t.child(n).genParticle().
id()
32 """Dump truth information for truth particle T to file F."""
34 d.bc = t.genParticle().
id()
35 d.name = PDG.pdgid_to_name(t.pdgId())
47 print (
"%(id)3d %(name)-4s %(da1)4s %(da2)4s %(da3)4s %(pt)6.1f %(eta)5.2f %(phi)5.2f %(m)5.1f %(px)6.1f %(py)6.1f %(pz)6.1f %(e)6.1f" % d.__dict__, file=f)
49 print (
" (more than 3 decays)", file=f)
53 """Dump out truth information for the current event.
54 F is the file to which the dump is sent.
55 SGKEY is the StoreGate key which is used to retrieve the truth information.
57 The first column in the dump is the particle unique ID number.
58 This is followed by the particle type, and then by the unique ID numbers
59 of any decay daughters (up to 3). This is followed by the four-momentum
60 in two versions: first as pt, eta, phi, m and then as px, py, pz, e.
62 parts = [p
for p
in PyParticleTools.getTruthParticles (sgkey)]