6 from PyCool
import cool
8 from CoolRunQuery.utils.AtlRunQueryUtils
import coolDbConn, GetRanges
10 from CoolRunQuery.selector.AtlRunQuerySelectorBase
import Selector
12 from CoolRunQuery.AtlRunQueryRun
import Run
16 super(RunTimeSelector,self).
__init__(name)
20 runlist = [rr
for rr
in runlist
if not rr.startswith(
'last')]
29 rr += [
'%i, %i' % tuple(r) ]
31 rr += [
'%i-%i' % tuple(r) ]
32 return "SELOUT Checking for runs in %s" %
', '.
join(rr)
43 folder = coolDbConn.GetDBConn(schema=
"COOLONL_TRIGGER", db = Selector.condDB(firstRun) ).getFolder(
'/TRIGGER/LUMI/LBLB')
49 objs = folder.browseObjects( rr[0] << 32, ((rr[1]+1) << 32)-1, cool.ChannelSelection(0))
50 while objs.goToNext():
53 runNr,lbNr = RunTimeSelector.runlb(obj.since())
56 if not currentRun
or runNr > currentRun.runNr:
58 currentRun.eor = currentEOR
59 runlist.append(currentRun)
60 currentRun =
Run(runNr)
61 currentRun.sor = payload[
'StartTime']
62 currentRun.lbtimes.extend([(0,0)]*(lbNr-len(currentRun.lbtimes)))
63 currentRun.lbtimes[lbNr-1] = ( payload[
'StartTime'], payload[
'EndTime'] )
64 currentRun.lastlb = lbNr
65 currentEOR = payload[
'EndTime']
67 currentRun.eor = currentEOR
68 runlist.append(currentRun)
71 duration = time() - start
72 print (
" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
82 listOfCoveredRuns = []
83 runlist = self.runTimes.
keys()
88 if timeiov[0]>=x[0]
and timeiov[1]<x[1]
or timeiov[0]<x[0]
and timeiov[1]>x[0]:
89 listOfCoveredRuns += [rt]
91 return (listOfCoveredRuns,lastEOR)
96 super(TimeRunSelector,self).
__init__(name)
102 folder = coolDbConn.GetDBConn(schema=
"COOLONL_TRIGGER", db=Selector.condDB()).getFolder(
'/TRIGGER/LUMI/LBTIME')
103 print (
'SELOUT Checking for runs in time range "%s"' % self.
timelist, end=
'')
109 objs = folder.browseObjects( rr[0], rr[1]+86400000000000, cool.ChannelSelection(0))
110 while objs.goToNext():
111 obj=objs.currentRef()
112 payload=obj.payload()
113 runNr =
int(payload[
'Run'])
123 if not currentRun
or runNr != currentRun.runNr:
125 currentRun.eor = currentEOR
126 runlist.append(currentRun)
127 currentRun =
Run(runNr)
128 currentRun.sor = obj.since()
129 lbNr =
int(payload[
'LumiBlock'])
130 currentRun.lbtimes.extend([(0,0)]*(lbNr-len(currentRun.lbtimes)))
131 currentRun.lbtimes[lbNr-1] = ( obj.since(), obj.until() )
132 currentRun.lastlb = lbNr
133 currentEOR = obj.until()
135 currentRun.eor = currentEOR
136 runlist.append(currentRun)
139 duration = time() - start
140 print (
" ==> %i runs selected (%g sec)" % (len(runlist), duration))