4 iov_conditional - Functions to Execute Paths Depending on Experiment Phases
5 ===========================================================================
7 This module contains some convenience functions to execute different paths
8 depending on the experiment run number. This allows to write one common steering
9 file for phases 2 and 3.
12 All Modules will be initialized on startup of the framework. This might
13 cause problems if the modules initialize some common global state. For
14 example adding :b2:mod:`Geometry` modules with different parameters will not
19 PHASE2_IOVS = [(1, 0, 4, -1), (1002, 0, 1002, -1)]
22 def make_conditional_at(path, iov_list, path_when_in_iov, path_when_not_in_iov=None):
24 Branch the current path execution based on the given iov list. If the
25 current exp/run is met by one of the IoV conditions, execute the path given
26 in ``path_when_in_iov`` and continue the normal path afterwards. Otherwise
27 execute the ``path_when_not_in_iov`` when given.
29 Basically, this function is just a wrapper around adding the
30 :b2:mod:`IoVDependentCondition` module to the path.
33 If you just need to distinguish between phase 2/3 please use
34 `phase_2_conditional()`
38 >>> make_conditional_at(path, iov_list=[(0, 0, 0, -1)],
39 ... path_when_in_iov=exp_0_path,
40 ... path_when_not_in_iov=not_exp_0_path)
42 will branch the path for all events with experiment number 0 to the modules
43 in ``exp_0_path`` and into ``not_exp_0_path`` in all other cases.
46 path (basf2.Path): Branch the execution of the given path.
47 iov_list (list(tuple)): Under which IoV conditions should the
48 ``path_when_in_iov`` be executed. It should be a list in the form
49 ``[(min exp, min run, max exp, max run), ...]``
50 path_when_in_iov (basf2.Path): Which branch to execute, if one of the IoV conditions is met.
51 path_when_not_in_iov (basf2.Path): If given, execute this path in all cases, none IoV condition is met.
53 condition_module = path.add_module(
"IoVDependentCondition", iovList=iov_list)
54 condition_module.if_true(path_when_in_iov, basf2.AfterConditionPath.CONTINUE)
55 if path_when_not_in_iov:
56 condition_module.if_false(path_when_not_in_iov, basf2.AfterConditionPath.CONTINUE)
59 def phase_2_conditional(path, phase2_path, phase3_path=None):
61 Handy shortcut for phase 2/3 conditional module execution.
64 `make_conditional_at()`
67 path (basf2.Path): Branch the execution of the given path.
68 phase2_path (basf2.Path): Call this path only when in phase 2.
69 phase3_path (basf2.Path): When given, call this path only when in phase 3.
71 make_conditional_at(path=path, iov_list=PHASE2_IOVS,
72 path_when_in_iov=phase2_path, path_when_not_in_iov=phase3_path)