3 from DQUtils
import fetch_iovs, process_iovs, IOVSet
6 "Raised when an unknown trigger is requested for a time interval"
8 LVL1_MENU =
"COOLONL_TRIGGER::/TRIGGER/LVL1/Menu"
12 Returns the set of iovs for which the trigger is valid
15 raise NotImplementedError(
"Implementation incomplete")
18 iovs =
fetch_iovs(LVL1_MENU, runs=iovrange.since.run, what=[
"ItemName"])
20 result = [i
for i
in iovs
if i.ItemName == trigger]
24 assert len(result) == 1,
"This should not happen."
26 channel = result[0].channel
28 iovs =
fetch_iovs(LVL1_MENU, *iovrange, channels=[channel], what=[
"ItemName"])
30 return iovs.select(ItemName = trigger)
32 def compute_lumi(lbs, lumis, iovs, exclude_iovsets=[], good_runs=None):
34 Compute luminosity for an IOVSet iovs using lbs, lumis from fetch_lumi_inputs.
36 exclude_iovsets is a list of IOVSets for channels to be excluded from the
37 calculation such as not_ready, busy, etc.
39 good_runs is an optional set of runs to consider, such as the set of runs
40 which are OK for physics.
48 inputs =
process_iovs(lbs, lumis, iovs, *exclude_iovsets)
50 for since, until, states
in inputs:
51 lb, lumi, good, excludes = states[0], states[1], states[2], states[3:]
55 if not lb
or not lumi
or not good
or any(excludes):
59 if good_runs
and since.run
not in good_runs:
62 total_lumi += (lb.EndTime - lb.StartTime)/1e9 * lumi.LBAvInstLumi
68 Compute luminosity per channel for an IOVSet iovs using
69 lbs, lumis from fetch_lumi_inputs.
71 exclude_iovsets is a list of IOVSets for channels to be excluded from the
72 calculation such as not_ready, busy, etc.
74 good_runs is an optional set of runs to consider, such as the set of runs
75 which are OK for physics.
77 Return type is a dictionary of {channel name: lumi}
80 chans, iovsets = iovs.chans_iovsets
95 num_exclude = len(exclude_iovsets)
96 full_iovsets = exclude_iovsets
97 full_iovsets.extend(iovsets)
99 for since, until, states
in inputs:
103 (lb, lumi), defectstates = states[:2], states[2:]
104 excludes, defects = defectstates[:num_exclude], defectstates[num_exclude:]
109 if not lb
or not lumi
or any(excludes):
113 if good_runs
and since.run
not in good_runs:
117 lumi = (lb.EndTime - lb.StartTime)/1e9 * lumi.LBAvInstLumi
119 for name, defect_iov
in zip(chans, defects):
121 result[name] = result.get(name, 0) + lumi
127 Retrieve information required to calculate the luminosity from the database
129 lbs =
fetch_iovs(
"LBLB", *range_iov, with_channel=
False)
132 lumis =
fetch_iovs(
"COOLONL_TRIGGER::/TRIGGER/LUMI/OnlPrefLumi",
137 lumis = IOVSet(l
for l
in lumis
if (l.Valid & 0xFFFF) % 10 == 0)
140 lumi_folder =
"COOLOFL_TRIGGER::/TRIGGER/OFLLUMI/OflPrefLumi"