ATLAS Offline Software
Loading...
Searching...
No Matches
python.truth Namespace Reference

Classes

class  _Truthtmp

Functions

 do_decay (t, n)
 dump_one_truth (t, f=sys.stdout)
 dump_truth (f=sys.stdout, sgkey="SpclMC", maxn=None)

Detailed Description

Dump out MC truth information.

This module contains the function dump_truth which will dump out the
truth information for the current event in a tabular format.

Function Documentation

◆ do_decay()

python.truth.do_decay ( t,
n )
Return the unique ID number for decay N of truth particle T
as a string.  Return an empty string if there's no such decay.

Definition at line 20 of file truth.py.

20def do_decay (t, n):
21 """Return the unique ID number for decay N of truth particle T
22as a string. Return an empty string if there's no such decay.
23"""
24 if t.nDecay() <= n:
25 return ''
26 bc = t.child(n).genParticle().id()
27 return str(bc)
28

◆ dump_one_truth()

python.truth.dump_one_truth ( t,
f = sys.stdout )
Dump truth information for truth particle T to file F.

Definition at line 31 of file truth.py.

31def dump_one_truth (t, f=sys.stdout):
32 """Dump truth information for truth particle T to file F."""
33 d = _Truthtmp()
34 d.bc = t.genParticle().id()
35 d.name = PDG.pdgid_to_name(t.pdgId())
36 d.da1 = do_decay(t, 0)
37 d.da2 = do_decay(t, 1)
38 d.da3 = do_decay(t, 2)
39 d.pt = t.pt()/1000
40 d.eta = t.eta()
41 d.phi = t.phi()
42 d.m = t.m()/1000
43 d.px = t.px()/1000
44 d.py = t.py()/1000
45 d.pz = t.pz()/1000
46 d.e = t.e()/1000
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)
48 if t.nDecay() > 3:
49 print (" (more than 3 decays)", file=f)
50
51

◆ dump_truth()

python.truth.dump_truth ( f = sys.stdout,
sgkey = "SpclMC",
maxn = None )
Dump out truth information for the current event.
F is the file to which the dump is sent.
SGKEY is the StoreGate key which is used to retrieve the truth information.

The first column in the dump is the particle unique ID number.
This is followed by the particle type, and then by the unique ID numbers
of any decay daughters (up to 3).  This is followed by the four-momentum
in two versions: first as pt, eta, phi, m and then as px, py, pz, e.

Definition at line 52 of file truth.py.

52def dump_truth(f=sys.stdout, sgkey="SpclMC", maxn=None):
53 """Dump out truth information for the current event.
54F is the file to which the dump is sent.
55SGKEY is the StoreGate key which is used to retrieve the truth information.
56
57The first column in the dump is the particle unique ID number.
58This is followed by the particle type, and then by the unique ID numbers
59of any decay daughters (up to 3). This is followed by the four-momentum
60in two versions: first as pt, eta, phi, m and then as px, py, pz, e.
61"""
62 parts = [p for p in PyParticleTools.getTruthParticles (sgkey)]
63 if maxn is not None:
64 parts = parts[:maxn]
65 for t in parts:
66 dump_one_truth (t, f)
67 return