8 """Draws particle decay tree """
11 print "Init particleDecayDrawer"
15 if candidate
in skipList:
return False;
19 return candidate.status() == 3
22 nDaughters = candidate.numChildren()
23 for i
in xrange(nDaughters):
24 if self.
_select(candidate.listChildren()[i]):
return True
30 def _decay(self, candidate, skipList):
33 if candidate
in skipList:
35 skipList.append(candidate)
37 id = candidate.pdg_id()
39 out += str(id) + self.
_printP4(candidate)
42 nOfDaughters = candidate.numChildren()
43 for i
in xrange(nOfDaughters):
44 if self.
_accept(candidate.listChildren()[i], skipList): validDau+=1
45 if validDau == 0:
return out
49 for i
in xrange(nOfDaughters):
50 d = candidate.listChildren()[i]
52 decString = self.
_decay(d, skipList)
53 if (
"->" in decString): out +=
" ( %s ) " %decString
54 else: out +=
" %s" %decString
58 """ draw decay tree from list(HepMC.GenParticles)"""
62 for particle
in particles:
63 if particle.numParents() > 1:
65 skipList.append(particle)
66 nodesList.append(particle)
67 for j
in xrange(particle.numParents()):
68 mom = particle.listParents()[j]
77 for m
in xrange(len(momsList)):
78 decString = self.
_decay( momsList[m], skipList)
79 if len(decString) > 0:
80 print "{ %s } " %decString
82 print self.
_decay(momsList[0], skipList)
84 if len(nodesList) > 0:
86 if len(nodesList) > 1:
87 for node
in nodesList:
89 decString = self.
_decay(node, skipList)
90 if len(decString) > 0:
91 if "->" in decString:
print " ( %s ) " %decString
92 else:
print " " + decString
94 skipList.remove(nodesList[0])
95 print self.
_decay(nodesList[0], skipList)