Belle II Software light-2406-ragdoll
conditional_iov.py
1
8import basf2
9from iov_conditional import phase_2_conditional, make_conditional_at
10
11
12class PrinterModule(basf2.Module):
13 """Print the given string on each event"""
14
15 def __init__(self, print_string):
16 """Remember the given string to print later"""
17 super().__init__()
18
19 self._print_string = print_string
20
21 def event(self):
22 """And now would be a good time for printing ..."""
23 print(self._print_string)
24
25
26def simulate_run(run_numbers, exp_numbers):
27 assert len(exp_numbers) == len(run_numbers)
28
29 path = basf2.create_path()
30
31 path.add_module("EventInfoSetter", evtNumList=[1] * len(run_numbers), runList=run_numbers, expList=exp_numbers)
32 path.add_module("EventInfoPrinter")
33
34 # Phase 2 path
35 phase2_path = basf2.create_path()
36 phase2_path.add_module(PrinterModule("Phase 2 is here"))
37
38 # Phase 3 path
39 phase3_path = basf2.create_path()
40 phase3_path.add_module(PrinterModule("Phase 3 is here"))
41
42 # No Phase 3 path
43 no_phase3_path = basf2.create_path()
44 no_phase3_path.add_module(PrinterModule("Phase 3 is not here"))
45
46 # Weird path
47 weird_path = basf2.create_path()
48 weird_path.add_module(PrinterModule("Strange condition"))
49
50 # Condition for phase2
51 phase_2_conditional(path, phase2_path=phase2_path)
52
53 # Condition for phase3
54 make_conditional_at(path, iov_list=[(0, 0, 0, -1)], path_when_in_iov=phase3_path, path_when_not_in_iov=no_phase3_path)
55
56 # Some weird condition
57 make_conditional_at(path, iov_list=[(42, 42, 47, 47)], path_when_in_iov=weird_path)
58
59 # Finished path
60 path.add_module(PrinterModule("Finish"))
61
62 basf2.process(path)
63
64
65if __name__ == "__main__":
66 basf2.set_random_seed(1)
67 simulate_run(exp_numbers=[0, 1002], run_numbers=[1, 67])
68 simulate_run(exp_numbers=[42, 43, 47], run_numbers=[41, 1, 48])
_print_string
The string we want to print each event.
def __init__(self, print_string)