order.process#

Classes to define physics processes.

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.ColorMixin

Definition 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 the LabelMixin, is_data to the DataSourceMixin, tags to the TagMixin, aux to the AuxDataMixin, and name and id to the UniqueObject constructor.

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) processes and parent_processes are 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 UniqueObjectIndex of child processes.

parent_processes#

type: UniqueObjectIndex (read-only)

The UniqueObjectIndex of 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_processes index and returns it.

add_process(*args, **kwargs)

Adds a child process to the processes index and returns it.

clear_parent_processes()

Removes all parent processes from the parent_processes index.

clear_processes()

Removes all child processes from the processes index.

extend_parent_processes(objs)

Adds multiple parent processes to the parent_processes index and returns the added objects in a list.

extend_processes(objs)

Adds multiple child processes to the processes index and returns the added objects in a list.

get_leaf_processes()

Returns all child processes from the processes index 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_processes index.

get_process(obj[, deep, default])

Returns a child process given by obj, which might be a name, id, or an instance from the processes index.

get_root_processes()

Returns all parent processes from the parent_processes index that have no parent processes themselves in a recursive fashion.

has_parent_process(obj[, deep])

Checks if the parent_processes index contains an obj, which might be a name, id, or an instance.

has_process(obj[, deep])

Checks if the processes index 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_processes index.

remove_process(obj[, silent])

Removes a child process given by obj, which might be a name, id, or an instance from the processes index and returns the removed object.

walk_parent_processes([algo, depth_first, ...])

Walks through the parent_processes index 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 processes index 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:

has_parent_processes

Returns True when this process has parent processes, False otherwise.

has_processes

Returns True when this process has child processes, False otherwise.

is_leaf_process

Returns True when this process has no child processes, False otherwise.

is_root_process

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_processes index and returns it. Also adds this process to the processes index of the added process. See UniqueObjectIndex.add() for more info.

add_process(*args, **kwargs)#

Adds a child process to the processes index and returns it. Also adds this process to the parent_processes index of the added process. See UniqueObjectIndex.add() for more info.

clear_parent_processes()#

Removes all parent processes from the parent_processes index. Also removes this process instance from the processes index of all removed process.

clear_processes()#

Removes all child processes from the processes index. Also removes this process instance from the parent_processes index of all removed processes.

extend_parent_processes(objs)#

Adds multiple parent processes to the parent_processes index and returns the added objects in a list. Also adds this process to the processes index of the added process.

extend_processes(objs)#

Adds multiple child processes to the processes index and returns the added objects in a list. Also adds this process to the parent_processes index of the added process.

get_leaf_processes()#

Returns all child processes from the processes index 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_processes index. 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 processes index. 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_processes index 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_processes index 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 processes index 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_processes index. Also removes this instance from the processes index of the removed parent process. Returns the removed object. Unless silent is True, an error is raised if the object was not found. See UniqueObjectIndex.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 processes index and returns the removed object. Also removes this process from the parent_processes index of the removed process. Unless silent is True, an error is raised if the object was not found. See UniqueObjectIndex.remove() for more info.

walk_parent_processes(algo='bfs', depth_first=False, include_self=False)#

Walks through the parent_processes index 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 processes index 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.