order.process
Contents
order.process#
Classes to define physics processes.
Contents
Class Process#
- class Process(*args, **kwargs)[source]#
Bases:
order.unique.UniqueObject,order.mixins.CopyMixin,order.mixins.AuxDataMixin,order.mixins.TagMixin,order.mixins.DataSourceMixin,order.mixins.LabelMixin,order.mixins.ColorMixinDefinition of a phyiscs process.
Arguments
xsecs should be a mapping of (e.g.) center-of-mass energies to cross sections values (automatically converted to scinum.Number instances).
color, color1, color2 and color3 are forwarded to the
ColorMixin, label and label_short to theLabelMixin, is_data to theDataSourceMixin, tags to theTagMixin, aux to theAuxDataMixin, and name and id to theUniqueObjectconstructor.A process can have parent-child relations to other processes. Initial child processes are set to processes.
Copy behavior
copy()All attributes are copied. Also, please be aware that deep copies of heavily nested process structures might lead to python running into a recursion error (
maximum recursion depth exceeded while calling a Python object). If this is the case, you might want to consider increasing the recursion depth.copy_shallow()All attributes except for (child)
processesandparent_processesare copied.Example
import order as od from scinum import Number, REL p = od.Process( name="ttH", id=1, xsecs={ 13: Number(0.5071, {"scale": 0.036j}), # +-3.6% scale uncertainty }, label=r"$t\bar{t}H$", color=(255, 0, 0), ) p.get_xsec(13).str("%.2f") # -> "0.51 +- 0.02 (scale)" p.label_root # -> "t#bar{t}H" p2 = p.add_process( name="ttH_bb", id=2, xsecs={ 13: p.get_xsec(13) * 0.5824, }, label=p.label + r", $b\bar{b}$", ) p2 == p.get_process("ttH_bb") # -> True p2.label_root # -> "t#bar{t}H, b#bar{b}" p2.has_parent_process("ttH") # -> True
Members
- xsecs#
type: dictionary (any ->
scinum.Number)Cross sections values mapped to keys (e.g. center-of-mass energies).
- processes#
type:
UniqueObjectIndex(read-only)The
UniqueObjectIndexof child processes.
- parent_processes#
type:
UniqueObjectIndex(read-only)The
UniqueObjectIndexof parent processes.
Methods:
get_xsec(key)Returns the cross section (a scinum.Number instance) for a key (e.g.
set_xsec(key, xsec)Sets the cross section for a key (e.g.
add_parent_process(*args, **kwargs)Adds a parent process to the
parent_processesindex and returns it.add_process(*args, **kwargs)Adds a child process to the
processesindex and returns it.Removes all parent processes from the
parent_processesindex.Removes all child processes from the
processesindex.extend_parent_processes(objs)Adds multiple parent processes to the
parent_processesindex and returns the added objects in a list.extend_processes(objs)Adds multiple child processes to the
processesindex and returns the added objects in a list.Returns all child processes from the
processesindex that have no child processes themselves in a recursive fashion.get_parent_process(obj[, deep, default])Returns a parent process given by obj, which might be a name, id, or an instance from the
parent_processesindex.get_process(obj[, deep, default])Returns a child process given by obj, which might be a name, id, or an instance from the
processesindex.Returns all parent processes from the
parent_processesindex that have no parent processes themselves in a recursive fashion.has_parent_process(obj[, deep])Checks if the
parent_processesindex contains an obj, which might be a name, id, or an instance.has_process(obj[, deep])Checks if the
processesindex contains an obj which might be a name, id, or an instance.pretty_print([xsec_key, offset, max_depth, ...])Prints this process and potentially its subprocesses down to a maximum depth max_depth in a structured fashion.
remove_parent_process(obj[, silent])Removes a parent process obj which might be a name, id, or an instance from the
parent_processesindex.remove_process(obj[, silent])Removes a child process given by obj, which might be a name, id, or an instance from the
processesindex and returns the removed object.walk_parent_processes([algo, depth_first, ...])Walks through the
parent_processesindex and per iteration, yields a parent process, its depth relative to this process, and its parent processes in a list that can be modified to alter the walking.walk_processes([algo, depth_first, include_self])Walks through the
processesindex and per iteration, yields a child process, its depth relative to this process, and its child processes in a list that can be modified to alter the walking.Attributes:
Returns True when this process has parent processes, False otherwise.
Returns True when this process has child processes, False otherwise.
Returns True when this process has no child processes, False otherwise.
Returns True when this process has no parent processes, False otherwise.
- get_xsec(key)[source]#
Returns the cross section (a scinum.Number instance) for a key (e.g. a center-of-mass energy). When key is an integer or a number instance, it is converted to float first.
- set_xsec(key, xsec)[source]#
Sets the cross section for a key (e.g. a center-of-mass energy) to xsec. When key is an integer or a number instance, it is converted to float first. When xsec is not a scinum.Number instance, it is converted to one. The (probably converted) value is returned.
- add_parent_process(*args, **kwargs)#
Adds a parent process to the
parent_processesindex and returns it. Also adds this process to theprocessesindex of the added process. SeeUniqueObjectIndex.add()for more info.
- add_process(*args, **kwargs)#
Adds a child process to the
processesindex and returns it. Also adds this process to theparent_processesindex of the added process. SeeUniqueObjectIndex.add()for more info.
- clear_parent_processes()#
Removes all parent processes from the
parent_processesindex. Also removes this process instance from theprocessesindex of all removed process.
- clear_processes()#
Removes all child processes from the
processesindex. Also removes this process instance from theparent_processesindex of all removed processes.
- extend_parent_processes(objs)#
Adds multiple parent processes to the
parent_processesindex and returns the added objects in a list. Also adds this process to theprocessesindex of the added process.
- extend_processes(objs)#
Adds multiple child processes to the
processesindex and returns the added objects in a list. Also adds this process to theparent_processesindex of the added process.
- get_leaf_processes()#
Returns all child processes from the
processesindex that have no child processes themselves in a recursive fashion. Possible duplicates due to nested structures are removed.
- get_parent_process(obj, deep=True, default=no_default)#
Returns a parent process given by obj, which might be a name, id, or an instance from the
parent_processesindex. If deep is True, the lookup is recursive through potentially nested parent processes. When no process is found, default is returned when set. Otherwise, an error is raised.
- get_process(obj, deep=True, default=no_default)#
Returns a child process given by obj, which might be a name, id, or an instance from the
processesindex. If deep is True, the lookup is recursive through potentially nested child processes. When no process is found, default is returned when set. Otherwise, an error is raised.
- get_root_processes()#
Returns all parent processes from the
parent_processesindex that have no parent processes themselves in a recursive fashion. Possible duplicates due to nested structures are removed.
- has_parent_process(obj, deep=True)#
Checks if the
parent_processesindex contains an obj, which might be a name, id, or an instance. If deep is True, the lookup is recursive through potentially nested parent processes.
- property has_parent_processes#
Returns True when this process has parent processes, False otherwise.
- has_process(obj, deep=True)#
Checks if the
processesindex contains an obj which might be a name, id, or an instance. If deep is True, the lookup is recursive through potentially nested child processes.
- property has_processes#
Returns True when this process has child processes, False otherwise.
- property is_leaf_process#
Returns True when this process has no child processes, False otherwise.
- property is_root_process#
Returns True when this process has no parent processes, False otherwise.
- pretty_print(xsec_key=None, offset=40, max_depth=- 1, stream=None, **kwargs)[source]#
Prints this process and potentially its subprocesses down to a maximum depth max_depth in a structured fashion. When xsec_key is set, process cross section values are shown as well with a maximum horizontal distance of offset. stream can be a file object and defaults to sys.stdout. All kwargs are forwarded to the
Number.str()methods of the cross section numbers.
- remove_parent_process(obj, silent=False)#
Removes a parent process obj which might be a name, id, or an instance from the
parent_processesindex. Also removes this instance from theprocessesindex of the removed parent process. Returns the removed object. Unless silent is True, an error is raised if the object was not found. SeeUniqueObjectIndex.remove()for more info.
- remove_process(obj, silent=False)#
Removes a child process given by obj, which might be a name, id, or an instance from the
processesindex and returns the removed object. Also removes this process from theparent_processesindex of the removed process. Unless silent is True, an error is raised if the object was not found. SeeUniqueObjectIndex.remove()for more info.
- walk_parent_processes(algo='bfs', depth_first=False, include_self=False)#
Walks through the
parent_processesindex and per iteration, yields a parent process, its depth relative to this process, and its parent processes in a list that can be modified to alter the walking.The traversal order is defined by algo which allows different values (more info):
"bfs": Breadth-first search."dfs_preorder": Pre-order depth-first search."dfs_postorder": Post-order depth-first search."dfs": Alias for"dfs_preorder"."dfs_pre": Alias for"dfs_preorder"."dfs_post": Alias for"dfs_postorder".
When include_self is True, this process instance is yielded as well with a depth of 0.
- walk_processes(algo='bfs', depth_first=False, include_self=False)#
Walks through the
processesindex and per iteration, yields a child process, its depth relative to this process, and its child processes in a list that can be modified to alter the walking.The traversal order is defined by algo which allows different values (more info):
"bfs": Breadth-first search."dfs_preorder": Pre-order depth-first search."dfs_postorder": Post-order depth-first search."dfs": Alias for"dfs_preorder"."dfs_pre": Alias for"dfs_preorder"."dfs_post": Alias for"dfs_postorder".
When include_self is True, this process instance is yielded as well with a depth of 0.