CMS 3D CMS Logo

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__ (self)
 
def draw (self, particles)
 

Private Member Functions

def _accept (self, candidate, skipList)
 
def _decay (self, candidate, skipList)
 
def _hasValidDaughters (self, candidate)
 
def _printP4 (self, candidate)
 
def _select (self, candidate)
 

Detailed Description

Draws particle decay tree 

Definition at line 9 of file ParticleDecayDrawer.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ParticleDecayDrawer.ParticleDecayDrawer.__init__ (   self)

Definition at line 12 of file ParticleDecayDrawer.py.

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

References edm.print().

Member Function Documentation

◆ _accept()

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

Definition at line 16 of file ParticleDecayDrawer.py.

16  def _accept(self, candidate, skipList):
17  if candidate in skipList: return False;
18  return self._select(candidate)
19 

References python.ParticleDecayDrawer.ParticleDecayDrawer._select().

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

◆ _decay()

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

Definition at line 32 of file ParticleDecayDrawer.py.

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

References python.ParticleDecayDrawer.ParticleDecayDrawer._accept(), python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), python.ParticleDecayDrawer.ParticleDecayDrawer._printP4(), FastTimerService_cff.range, and str.

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

◆ _hasValidDaughters()

def python.ParticleDecayDrawer.ParticleDecayDrawer._hasValidDaughters (   self,
  candidate 
)
private

Definition at line 23 of file ParticleDecayDrawer.py.

23  def _hasValidDaughters(self, candidate):
24  nDaughters = candidate.numChildren()
25  for i in range(nDaughters):
26  if self._select(candidate.listChildren()[i]): return True
27  return False
28 

References python.ParticleDecayDrawer.ParticleDecayDrawer._select(), and FastTimerService_cff.range.

◆ _printP4()

def python.ParticleDecayDrawer.ParticleDecayDrawer._printP4 (   self,
  candidate 
)
private

Definition at line 29 of file ParticleDecayDrawer.py.

29  def _printP4(self, candidate):
30  return " "
31 

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

◆ _select()

def python.ParticleDecayDrawer.ParticleDecayDrawer._select (   self,
  candidate 
)
private

◆ draw()

def python.ParticleDecayDrawer.ParticleDecayDrawer.draw (   self,
  particles 
)
draw decay tree from list(HepMC.GenParticles)

Definition at line 59 of file ParticleDecayDrawer.py.

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

References python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), python.ParticleDecayDrawer.ParticleDecayDrawer._select(), edm.print(), and FastTimerService_cff.range.

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
ntuplePlotting.draw
def draw(name, histos, styles=_defaultStyles, legendLabels=[], **kwargs)
Definition: ntuplePlotting.py:25
str
#define str(s)
Definition: TestProcessor.cc:48
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66