33 Truncate input iovs so that their length does not exceed the length
36 Also clean up records which go from (run, 0) to (run+1, 0)
38 `run_lengths` should be a dictionary {run_number: lumiblock count}
42 Given an iov, correct its since and until if necessary
46 if iov.since.run == iov.until.run-1
and iov.until.lumi == 0:
47 iov = iov._replace(until=RunLumi(run, 0xFFFFFFFF))
49 if run
in run_lengths:
50 run_length = run_lengths[run]
51 if iov.until.lumi > run_length:
52 iov = iov._replace(until=RunLumi(run, run_length))
54 if iov.since >= iov.until:
59 return [_
for _
in map(fix_iov, iovs)
if _
is not None]
84 result_iovs = [[]
for i
in iovs]
85 active_states, ended_states = [
set()
for i
in iovs], [
set()
for i
in iovs]
87 def bind_to_run(run_iov, active_states):
89 Given a run_iov and a set of active iovs, emit iovs which are bound
92 for active_state
in sorted(active_states):
93 iov = active_state._replace(
94 since=
max(run_iov.since+1, active_state.since),
95 until=
min(run_iov.until, active_state.until))
97 if iov.since != iov.until:
101 for position, index, beginning, iov
in iov_yielder(run_iovs, *iovs):
108 for active, ended
in zip(active_states, ended_states):
109 active.difference_update(ended)
114 for i, chan_active_states
in enumerate(active_states):
115 result_iovs[i].extend(bind_to_run(iov, chan_active_states))
121 action = active_states[index]
if beginning
else ended_states[index]