18 from PyCool
import cool
19 from CoolLumiUtilities.CoolDataReader
import CoolDataReader
50 self.
menuReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LVL1/Menu')
51 self.
countsReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LVL1COUNTERS')
52 self.
lbtimeReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LBTIME')
53 self.
lblbReader = CoolDataReader(
'COOLONL_TRIGGER/COMP200',
'/TRIGGER/LUMI/LBLB')
97 runnum =
int(obj.payload()[
'Run'])
113 print(
'TriggerHandler.loadDataByRun(%d) called' % runnum)
131 print(
'TriggerHandler.loadLBLBData(%d) called' % runnum)
138 self.
lblbDict[obj.since()] = (obj.payload()[
'StartTime'], obj.payload()[
'EndTime'])
145 print(
'TriggerHandler.loadTrigChannels(%d) called' % runnum)
161 if self.
verbose or True:
print(
int(obj.channelId()), obj.payload()[
'ItemName'])
163 trigName = obj.payload()[
'ItemName']
164 trigChan =
int(obj.channelId())
172 print(
"Couldn't find", trig,
"in run",
str(runnum))
176 print(
'Found', trig,
'in channel', chan)
183 print(
'TriggerHandler.loadTrigCounts(%d) called' % runnum)
197 for chan
in chanList:
198 if chan < 0:
continue
199 tmpList.append( chan )
203 print(
'breaking up', len(chanList),
'into', nMaxChan,
'for run', runnum)
209 for x
in range(0, len(chanList), nMaxChan):
210 top =
min([x+nMaxChan, len(chanList)])
213 print(
'Initializing block [%d] from %d to %d' % (nChanBlock, x, top))
215 chanBlock.append( chanList[x:top] )
218 for x
in range(nChanBlock):
219 if self.
verbose:
print(
'Channel Selector', chanBlock[x])
228 print(
runLBString(since),
runLBString(until), obj.channelId(), obj.payload()[
'BeforePrescale'], obj.payload()[
'AfterPrescale'], obj.payload()[
'L1Accept'])
232 chan =
int(obj.channelId())
235 print(
'TriggerHandler.loadTrigCounts(%d) - found unknown channel %d in %s!' % (runnum, chan,
runLBString(ss)))
245 self.
trigL1Dict[ss].TBP[trig] = obj.payload()[
'BeforePrescale']
246 self.
trigL1Dict[ss].TAP[trig] = obj.payload()[
'AfterPrescale']
247 self.
trigL1Dict[ss].TAV[trig] = obj.payload()[
'L1Accept']
250 "Convert argument to time in seconds, treating as a literal or date"
256 ts=time.strptime(val,
'%Y-%m-%d:%H:%M:%S/%Z')
257 return int(calendar.timegm(ts))*1000000000
262 ts=time.strptime(val+
'/UTC',
'%Y-%m-%d:%H:%M:%S/%Z')
263 return int(calendar.timegm(ts))*1000000000
266 print(
"ERROR in time specification:",val,
"- use e.g. 2007-05-25:14:01:00/UTC")
270 "Convert the IOVtime (63 bit) to a string representing timestamp"
271 if (iovkey==cool.ValidityKeyMin):
272 return "ValidityKeyMin"
273 elif (iovkey==cool.ValidityKeyMax):
274 return "ValidityKeyMax"
278 return time.strftime(
'%Y-%m-%d:%H:%M:%S/UTC', time.gmtime(stime))
281 "Convert the IOVtime (63 bit) to a string representing timestamp"
282 if (iovkey==cool.ValidityKeyMin):
283 return "ValidityKeyMin"
284 elif (iovkey==cool.ValidityKeyMax):
285 return "ValidityKeyMax"
289 lb = iovkey & 0xFFFFFFFF
290 return "%d/%d" % (run, lb)
294 if __name__ ==
'__main__':
297 th.allL1Triggers =
True
298 tstart =
'2011-10-16:06:00:00'
299 tend =
'2011-10-17:04:00:00'