Belle II Software  release-08-01-10
DecayParticleNode Class Reference

Public Member Functions

def __init__ (self, name)
 
def get_prefixes (self, always_include_indices=False, use_relative_indices=False)
 
def build (cls, decay_string)
 

Public Attributes

 name
 name of the particle
 
 selected
 whether or not this particle is selected
 
 children
 mapping of children decayIndex->Node
 

Private Member Functions

def __walk (self, always_include_indices, use_relative_indices, current_prefix, current_path)
 

Detailed Description

Class to present selected particles from a DecayString as tree structure.
For each node of the tree we safe the name of the particle, whether it is
selected and a dictionary of all children (as mapping decayIndex -> Node)

Definition at line 170 of file utils.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name 
)
Just set default values

Definition at line 177 of file utils.py.

177  def __init__(self, name):
178  """Just set default values"""
179 
180  self.name = name
181 
182  self.selected = False
183 
184  self.children = {}
185 

Member Function Documentation

◆ __walk()

def __walk (   self,
  always_include_indices,
  use_relative_indices,
  current_prefix,
  current_path 
)
private
Recursively walk the tree and collect all prefixes

See:
    `get_prefixes`

Arguments:
    always_include_indices (bool): see `get_prefixes()`
    use_relative_indices (bool): see `get_prefixes()`
    current_prefix: the current prefix so far collected from any parent
        particle.
    current_path: the current path of indices so far collected from any
        parent particle.

Definition at line 217 of file utils.py.

◆ build()

def build (   cls,
  decay_string 
)
Build a tree of selected particles from a `DecayString`

This will return a `DecayParticleNode` instance which is the top of a
tree of all the selected particles from the decat string.

Arguments:
    decay_string (str): `DecayString` containing at least one selected particle

Definition at line 266 of file utils.py.

◆ get_prefixes()

def get_prefixes (   self,
  always_include_indices = False,
  use_relative_indices = False 
)
Recursively walk through the tree of selected particles and return a list
of prefixes for aliases and a tuple of decay indexes for that prefix.

For example for ``B0 -> [D0 -> ^pi+] ^pi0`` it might return

>>> DecayParticleNode.build('^B0 -> [D0 -> ^pi+] ^pi0').get_prefixes()
[ ("", None), ("D0_pi", (0, 0)), ("pi0", (1,)) ]

and to create aliases from these one would use the indices as arguments for
the b2:var:`daughter` meta variable.

This function will make sure that prefix names are unique: If there are
multiple siblings of one node with the same particle name they will be
distinguised by either suffixing them with the decay index (if
``use_relative_indices=False``) or they will just be enumerated
starting at 0 otherwise.

Arguments:
    always_include_indices (bool): If True always add the index of the
        particle to the prefix, otherwise the index is only added if
        more than one sibling of the same particle exist.
    use_relative_indices (bool): If True the indices used will **not**
        be the daughter indices in the full decay string but just the
        relative indices: If multiple sibling particles with the same
        name they will be just numbered starting at zero as they appear
        in the aliases.

Definition at line 186 of file utils.py.


The documentation for this class was generated from the following file: