CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 9 of file ParticleDecayDrawer.py.

Constructor & Destructor Documentation

def python.ParticleDecayDrawer.ParticleDecayDrawer.__init__ (   self)

Definition at line 12 of file ParticleDecayDrawer.py.

References print().

12 
13  def __init__(self):
14  print("Init particleDecayDrawer")
15  # booleans: printP4 printPtEtaPhi printVertex
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Function Documentation

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

Definition at line 16 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._select().

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

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

Definition at line 32 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._accept(), python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), python.ParticleDecayDrawer.ParticleDecayDrawer._printP4(), sistrip::SpyUtilities.range(), and str.

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

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

Definition at line 23 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._select(), and sistrip::SpyUtilities.range().

23 
24  def _hasValidDaughters(self, candidate):
25  nDaughters = candidate.numChildren()
26  for i in range(nDaughters):
27  if self._select(candidate.listChildren()[i]): return True
28  return False
const uint16_t range(const Frame &aFrame)
def python.ParticleDecayDrawer.ParticleDecayDrawer._printP4 (   self,
  candidate 
)
private

Definition at line 29 of file ParticleDecayDrawer.py.

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

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

Definition at line 20 of file ParticleDecayDrawer.py.

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

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

Definition at line 59 of file ParticleDecayDrawer.py.

References python.ParticleDecayDrawer.ParticleDecayDrawer._decay(), python.ParticleDecayDrawer.ParticleDecayDrawer._select(), print(), and sistrip::SpyUtilities.range().

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