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