ATLAS Offline Software
Loading...
Searching...
No Matches
python.iov_arrangement Namespace Reference

Functions

 LBTIME_VAL (Run, LumiBlock)
 RUNIOV_VAL ()
 run_iovs_from_lblb (lblb)
 split_by_channel (iovs)
 inverse_lblb (iovs)
 add_result_iov (iov, output_iovs)
 connect_adjacent_iovs (generator)
 flatten_channels (iovs)

Function Documentation

◆ add_result_iov()

python.iov_arrangement.add_result_iov ( iov,
output_iovs )
Consider a single result `iov`, and connect it to existing result iovs
before it if necessary

Also performs translation of channel names to channel IDs.

Definition at line 50 of file iov_arrangement.py.

50def add_result_iov(iov, output_iovs):
51 """
52 Consider a single result `iov`, and connect it to existing result iovs
53 before it if necessary
54
55 Also performs translation of channel names to channel IDs.
56 """
57 last_iov = output_iovs[-1] if output_iovs else None
58
59 if last_iov and last_iov.connected_to(iov):
60 # It is connected to the last IoV, we can just update the last extent
61 output_iovs[-1] = last_iov._replace(until=iov.until)
62
63 else:
64 output_iovs.append(iov)
65

◆ connect_adjacent_iovs()

python.iov_arrangement.connect_adjacent_iovs ( generator)

Definition at line 66 of file iov_arrangement.py.

66def connect_adjacent_iovs(generator):
67 previous = None
68 for iov in generator:
69 if previous and previous.connected_to(iov):
70 previous = previous._replace(until=iov.until)
71 else:
72 if previous:
73 yield previous
74 previous = iov
75
76 if previous:
77 yield previous
78

◆ flatten_channels()

python.iov_arrangement.flatten_channels ( iovs)
Input/Output: list of iovs

If an iov specifies an iterable for its channel, then expand it into 
a list of channels.

Definition at line 79 of file iov_arrangement.py.

79def flatten_channels(iovs):
80 """
81 Input/Output: list of iovs
82
83 If an iov specifies an iterable for its channel, then expand it into
84 a list of channels.
85 """
86 result = iovs.empty()
87 for iov in iovs:
88 if not isinstance(iov.channel, str) and hasattr(iov.channel, "__iter__"):
89 for c in iov.channel:
90 result.append(iov._replace(channel=c))
91 else:
92 result.append(iov)
93
94 return result

◆ inverse_lblb()

python.iov_arrangement.inverse_lblb ( iovs)

Definition at line 34 of file iov_arrangement.py.

34def inverse_lblb(iovs):
35 @staticmethod
36 def from_LBLB_VAL(lblb):
37 return LBTIME_VAL(TimestampType(lblb.StartTime),
38 TimestampType(lblb.EndTime),
39 lblb.since.run, lblb.since.lumi)
40
41 LBTIME_VAL.from_LBLB_VAL = from_LBLB_VAL
42
43 lbtime_iovs = IOVSet(LBTIME_VAL.from_LBLB_VAL(iov) for iov in iovs)
44
45 if sorted(lbtime_iovs) != lbtime_iovs:
46 raise RuntimeError("lblb records are broken")
47
48 return lbtime_iovs
49

◆ LBTIME_VAL()

python.iov_arrangement.LBTIME_VAL ( Run,
LumiBlock )

Definition at line 7 of file iov_arrangement.py.

7def LBTIME_VAL(Run, LumiBlock):
8 pass
9
10@define_iov_type

◆ run_iovs_from_lblb()

python.iov_arrangement.run_iovs_from_lblb ( lblb)

Definition at line 14 of file iov_arrangement.py.

14def run_iovs_from_lblb(lblb):
15 gen = (RUNIOV_VAL(lb.since, lb.until) for lb in lblb)
16 result = IOVSet(connect_adjacent_iovs(gen))
17 return result
18 #return IOVSet(iov._replace(until=iov.until+1) for iov in result)
19

◆ RUNIOV_VAL()

python.iov_arrangement.RUNIOV_VAL ( )

Definition at line 11 of file iov_arrangement.py.

11def RUNIOV_VAL():
12 pass
13

◆ split_by_channel()

python.iov_arrangement.split_by_channel ( iovs)
Assumes `iovs` ordered by channel, then by since.

Definition at line 20 of file iov_arrangement.py.

20def split_by_channel(iovs):
21 """
22 Assumes `iovs` ordered by channel, then by since.
23 """
24 empty_iovset_maker = iovs.empty_maker()
25 result = defaultdict(lambda: empty_iovset_maker())
26 last_channel = None
27 for iov in iovs:
28 if iov.channel != last_channel:
29 last_channel = iov.channel
30 appender = result[last_channel].append
31 appender(iov)
32 return result
33