3 from __future__
import print_function
7 from PyCool
import cool
9 from CoolRunQuery.utils.AtlRunQueryUtils
import coolDbConn, GetRanges
11 from CoolRunQuery.selector.AtlRunQuerySelectorBase
import Selector
13 from CoolRunQuery.AtlRunQueryRun
import Run
17 super(RunTimeSelector,self).
__init__(name)
21 runlist = [rr
for rr
in runlist
if not rr.startswith(
'last')]
30 rr += [
'%i, %i' % tuple(r) ]
32 rr += [
'%i-%i' % tuple(r) ]
33 return "SELOUT Checking for runs in %s" %
', '.
join(rr)
44 folder = coolDbConn.GetDBConn(schema=
"COOLONL_TRIGGER", db = Selector.condDB(firstRun) ).getFolder(
'/TRIGGER/LUMI/LBLB')
50 objs = folder.browseObjects( rr[0] << 32, ((rr[1]+1) << 32)-1, cool.ChannelSelection(0))
51 while objs.goToNext():
54 runNr,lbNr = RunTimeSelector.runlb(obj.since())
57 if not currentRun
or runNr > currentRun.runNr:
59 currentRun.eor = currentEOR
60 runlist.append(currentRun)
61 currentRun =
Run(runNr)
62 currentRun.sor = payload[
'StartTime']
63 currentRun.lbtimes.extend([(0,0)]*(lbNr-len(currentRun.lbtimes)))
64 currentRun.lbtimes[lbNr-1] = ( payload[
'StartTime'], payload[
'EndTime'] )
65 currentRun.lastlb = lbNr
66 currentEOR = payload[
'EndTime']
68 currentRun.eor = currentEOR
69 runlist.append(currentRun)
72 duration = time() - start
73 print (
" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
83 listOfCoveredRuns = []
84 runlist = self.runTimes.
keys()
89 if timeiov[0]>=x[0]
and timeiov[1]<x[1]
or timeiov[0]<x[0]
and timeiov[1]>x[0]:
90 listOfCoveredRuns += [rt]
92 return (listOfCoveredRuns,lastEOR)
97 super(TimeRunSelector,self).
__init__(name)
103 folder = coolDbConn.GetDBConn(schema=
"COOLONL_TRIGGER", db=Selector.condDB()).getFolder(
'/TRIGGER/LUMI/LBTIME')
104 print (
'SELOUT Checking for runs in time range "%s"' % self.
timelist, end=
'')
110 objs = folder.browseObjects( rr[0], rr[1]+86400000000000, cool.ChannelSelection(0))
111 while objs.goToNext():
112 obj=objs.currentRef()
113 payload=obj.payload()
114 runNr =
int(payload[
'Run'])
124 if not currentRun
or runNr != currentRun.runNr:
126 currentRun.eor = currentEOR
127 runlist.append(currentRun)
128 currentRun =
Run(runNr)
129 currentRun.sor = obj.since()
130 lbNr =
int(payload[
'LumiBlock'])
131 currentRun.lbtimes.extend([(0,0)]*(lbNr-len(currentRun.lbtimes)))
132 currentRun.lbtimes[lbNr-1] = ( obj.since(), obj.until() )
133 currentRun.lastlb = lbNr
134 currentEOR = obj.until()
136 currentRun.eor = currentEOR
137 runlist.append(currentRun)
140 duration = time() - start
141 print (
" ==> %i runs selected (%g sec)" % (len(runlist), duration))