ATLAS Offline Software
Functions
python.iov_arrangement Namespace Reference

Functions

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

Function Documentation

◆ add_result_iov()

def 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.

50 def 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()

def python.iov_arrangement.connect_adjacent_iovs (   generator)

Definition at line 66 of file iov_arrangement.py.

66 def 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()

def 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.

79 def 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  from six import string_types
87  result = iovs.empty()
88  for iov in iovs:
89  if not isinstance(iov.channel, string_types) and hasattr(iov.channel, "__iter__"):
90  for c in iov.channel:
91  result.append(iov._replace(channel=c))
92  else:
93  result.append(iov)
94 
95  return result

◆ inverse_lblb()

def python.iov_arrangement.inverse_lblb (   iovs)

Definition at line 34 of file iov_arrangement.py.

34 def 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()

def python.iov_arrangement.LBTIME_VAL (   Run,
  LumiBlock 
)

Definition at line 7 of file iov_arrangement.py.

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

◆ run_iovs_from_lblb()

def python.iov_arrangement.run_iovs_from_lblb (   lblb)

Definition at line 14 of file iov_arrangement.py.

14 def 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()

def python.iov_arrangement.RUNIOV_VAL ( )

Definition at line 11 of file iov_arrangement.py.

11 def RUNIOV_VAL():
12  pass
13 

◆ split_by_channel()

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

Definition at line 20 of file iov_arrangement.py.

20 def 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 
python.iov_arrangement.inverse_lblb
def inverse_lblb(iovs)
Definition: iov_arrangement.py:34
python.iov_arrangement.RUNIOV_VAL
def RUNIOV_VAL()
Definition: iov_arrangement.py:11
python.iov_arrangement.run_iovs_from_lblb
def run_iovs_from_lblb(lblb)
Definition: iov_arrangement.py:14
python.iov_arrangement.split_by_channel
def split_by_channel(iovs)
Definition: iov_arrangement.py:20
python.iov_arrangement.add_result_iov
def add_result_iov(iov, output_iovs)
Definition: iov_arrangement.py:50
python.iov_arrangement.LBTIME_VAL
def LBTIME_VAL(Run, LumiBlock)
Definition: iov_arrangement.py:7
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.iov_arrangement.connect_adjacent_iovs
def connect_adjacent_iovs(generator)
Definition: iov_arrangement.py:66
python.iov_arrangement.flatten_channels
def flatten_channels(iovs)
Definition: iov_arrangement.py:79