test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
python.ParticleDecayDrawer.ParticleDecayDrawer Class Reference
Inheritance diagram for python.ParticleDecayDrawer.ParticleDecayDrawer:

Public Member Functions

def __init__
 
def draw
 

Private Member Functions

def _accept
 
def _decay
 
def _hasValidDaughters
 
def _printP4
 
def _select
 

Detailed Description

Draws particle decay tree 

Definition at line 7 of file ParticleDecayDrawer.py.

Constructor & Destructor Documentation

def python.ParticleDecayDrawer.ParticleDecayDrawer.__init__ (   self)

Definition at line 10 of file ParticleDecayDrawer.py.

10 
11  def __init__(self):
12  print "Init particleDecayDrawer"
13  # booleans: printP4 printPtEtaPhi printVertex

Member Function Documentation

def python.ParticleDecayDrawer.ParticleDecayDrawer._accept (   self,
  candidate,
  skipList 
)
private

Definition at line 14 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._select().

Referenced by python.ParticleDecayDrawer.ParticleDecayDrawer._decay().

14 
15  def _accept(self, candidate, skipList):
16  if candidate in skipList: return False;
17  return self._select(candidate)
def python.ParticleDecayDrawer.ParticleDecayDrawer._decay (   self,
  candidate,
  skipList 
)
private

Definition at line 30 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._accept(), python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), and python.ParticleDecayDrawer.ParticleDecayDrawer._printP4().

Referenced by python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), and python.ParticleDecayDrawer.ParticleDecayDrawer.draw().

30 
31  def _decay(self, candidate, skipList):
32 
33  out = str()
34  if candidate in skipList:
35  return ""
36  skipList.append(candidate)
37 
38  id = candidate.pdg_id()
39  # here the part about the names :-(
40  out += str(id) + self._printP4(candidate)
41 
42  validDau = 0
43  nOfDaughters = candidate.numChildren()
44  for i in xrange(nOfDaughters):
45  if self._accept(candidate.listChildren()[i], skipList): validDau+=1
46  if validDau == 0: return out
47 
48  out += " ->"
49 
50  for i in xrange(nOfDaughters):
51  d = candidate.listChildren()[i]
52  if self._accept(d, skipList):
53  decString = self._decay(d, skipList)
54  if ("->" in decString): out += " ( %s ) " %decString
55  else: out += " %s" %decString
56  return out
def python.ParticleDecayDrawer.ParticleDecayDrawer._hasValidDaughters (   self,
  candidate 
)
private

Definition at line 21 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._select().

21 
22  def _hasValidDaughters(self, candidate):
23  nDaughters = candidate.numChildren()
24  for i in xrange(nDaughters):
25  if self._select(candidate.listChildren()[i]): return True
26  return False
def python.ParticleDecayDrawer.ParticleDecayDrawer._printP4 (   self,
  candidate 
)
private

Definition at line 27 of file ParticleDecayDrawer.py.

Referenced by python.ParticleDecayDrawer.ParticleDecayDrawer._decay().

27 
28  def _printP4(self, candidate):
29  return " "
def python.ParticleDecayDrawer.ParticleDecayDrawer._select (   self,
  candidate 
)
private

Definition at line 18 of file ParticleDecayDrawer.py.

Referenced by python.ParticleDecayDrawer.ParticleDecayDrawer._accept(), python.ParticleDecayDrawer.ParticleDecayDrawer._hasValidDaughters(), and python.ParticleDecayDrawer.ParticleDecayDrawer.draw().

18 
19  def _select(self, candidate):
20  return candidate.status() == 3
def python.ParticleDecayDrawer.ParticleDecayDrawer.draw (   self,
  particles 
)
draw decay tree from list(HepMC.GenParticles)

Definition at line 57 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), and python.ParticleDecayDrawer.ParticleDecayDrawer._select().

57 
58  def draw(self, particles):
59  """ draw decay tree from list(HepMC.GenParticles)"""
60  skipList = []
61  nodesList = []
62  momsList = []
63  for particle in particles:
64  if particle.numParents() > 1:
65  if self._select(particle):
66  skipList.append(particle)
67  nodesList.append(particle)
68  for j in xrange(particle.numParents()):
69  mom = particle.listParents()[j]
70  while (mom.mother()):# != None ):
71  mom = mom.mother()
72  if self._select(mom):
73  momsList.append(mom)
74 
75  print "-- decay --"
76  if len(momsList) > 0:
77  if len(momsList) > 1:
78  for m in xrange(len(momsList)):
79  decString = self._decay( momsList[m], skipList)
80  if len(decString) > 0:
81  print "{ %s } " %decString
82  else:
83  print self._decay(momsList[0], skipList)
84 
85  if len(nodesList) > 0:
86  print "-> "
87  if len(nodesList) > 1:
88  for node in nodesList:
89  skipList.remove(node)
90  decString = self._decay(node, skipList)
91  if len(decString) > 0:
92  if "->" in decString: print " ( %s ) " %decString
93  else: print " " + decString
94  else:
95  skipList.remove(nodesList[0])
96  print self._decay(nodesList[0], skipList)
97 
98  print
99