9 from __future__
import print_function
11 """Dump out MC truth information.
13 This module contains the function dump_truth which will dump out the
14 truth information for the current event in a tabular format.
17 from PyAnalysisUtils
import PDG
18 from PyParticleTools
import PyParticleTools
22 """Return the barcode number for decay N of truth particle T
23 as a string. Return an empty string if there's no such decay.
27 bc = t.child(n).genParticle().
barcode()
33 """Dump truth information for truth particle T to file F."""
35 d.bc = t.genParticle().
barcode()
36 d.name = PDG.pdgid_to_name(t.pdgId())
48 print (
"%(bc)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)
50 print (
" (more than 3 decays)", file=f)
54 """Dump out truth information for the current event.
55 F is the file to which the dump is sent.
56 SGKEY is the StoreGate key which is used to retrieve the truth information.
58 The first column in the dump is the particle barcode number.
59 This is followed by the particle type, and then by the barcode numbers
60 of any decay daughters (up to 3). This is followed by the four-momentum
61 in two versions: first as pt, eta, phi, m and then as px, py, pz, e.
63 parts = [p
for p
in PyParticleTools.getTruthParticles (sgkey)]