14 from __future__
import print_function
19 from PyCool
import cool
20 from CoolLumiUtilities.CoolDataReader
import CoolDataReader
51 self.
menuReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LVL1/Menu')
52 self.
countsReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LVL1COUNTERS')
53 self.
lbtimeReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LBTIME')
54 self.
lblbReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LBLB')
98 runnum =
int(obj.payload()[
'Run'])
114 print(
'TriggerHandler.loadDataByRun(%d) called' % runnum)
132 print(
'TriggerHandler.loadLBLBData(%d) called' % runnum)
139 self.
lblbDict[obj.since()] = (obj.payload()[
'StartTime'], obj.payload()[
'EndTime'])
146 print(
'TriggerHandler.loadTrigChannels(%d) called' % runnum)
162 if self.
verbose or True:
print(
int(obj.channelId()), obj.payload()[
'ItemName'])
164 trigName = obj.payload()[
'ItemName']
165 trigChan =
int(obj.channelId())
173 print(
"Couldn't find", trig,
"in run",
str(runnum))
177 print(
'Found', trig,
'in channel', chan)
184 print(
'TriggerHandler.loadTrigCounts(%d) called' % runnum)
198 for chan
in chanList:
199 if chan < 0:
continue
200 tmpList.append( chan )
204 print(
'breaking up', len(chanList),
'into', nMaxChan,
'for run', runnum)
210 for x
in range(0, len(chanList), nMaxChan):
211 top =
min([x+nMaxChan, len(chanList)])
214 print(
'Initializing block [%d] from %d to %d' % (nChanBlock, x, top))
216 chanBlock.append( chanList[x:top] )
219 for x
in range(nChanBlock):
220 if self.
verbose:
print(
'Channel Selector', chanBlock[x])
229 print(
runLBString(since),
runLBString(until), obj.channelId(), obj.payload()[
'BeforePrescale'], obj.payload()[
'AfterPrescale'], obj.payload()[
'L1Accept'])
233 chan =
int(obj.channelId())
236 print(
'TriggerHandler.loadTrigCounts(%d) - found unknown channel %d in %s!' % (runnum, chan,
runLBString(ss)))
246 self.
trigL1Dict[ss].TBP[trig] = obj.payload()[
'BeforePrescale']
247 self.
trigL1Dict[ss].TAP[trig] = obj.payload()[
'AfterPrescale']
248 self.
trigL1Dict[ss].TAV[trig] = obj.payload()[
'L1Accept']
251 "Convert argument to time in seconds, treating as a literal or date"
257 ts=time.strptime(val,
'%Y-%m-%d:%H:%M:%S/%Z')
258 return int(calendar.timegm(ts))*1000000000
263 ts=time.strptime(val+
'/UTC',
'%Y-%m-%d:%H:%M:%S/%Z')
264 return int(calendar.timegm(ts))*1000000000
267 print(
"ERROR in time specification:",val,
"- use e.g. 2007-05-25:14:01:00/UTC")
271 "Convert the IOVtime (63 bit) to a string representing timestamp"
272 if (iovkey==cool.ValidityKeyMin):
273 return "ValidityKeyMin"
274 elif (iovkey==cool.ValidityKeyMax):
275 return "ValidityKeyMax"
279 return time.strftime(
'%Y-%m-%d:%H:%M:%S/UTC', time.gmtime(stime))
282 "Convert the IOVtime (63 bit) to a string representing timestamp"
283 if (iovkey==cool.ValidityKeyMin):
284 return "ValidityKeyMin"
285 elif (iovkey==cool.ValidityKeyMax):
286 return "ValidityKeyMax"
290 lb = iovkey & 0xFFFFFFFF
291 return "%d/%d" % (run, lb)
295 if __name__ ==
'__main__':
298 th.allL1Triggers =
True
299 tstart =
'2011-10-16:06:00:00'
300 tend =
'2011-10-17:04:00:00'