ATLAS Offline Software
AtlRunQuerySelectorTrigger.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 from __future__ import print_function
4 
5 """Provides Trigger related selectors:
6 
7 TriggerSelector Trigger menu from TriggerDB
8 TrigKeySelector SMK
9 BGSKeySelector BGK
10 L1TrigKeySelector L1PSK
11 HLTTrigKeySelector HLTPSK
12 RatesSelector L1 rates from COOL
13 
14 """
15 
16 import re,sys
17 
18 from time import time
19 from collections import defaultdict
20 
21 from PyCool import cool
22 
23 from CoolRunQuery.selector.AtlRunQuerySelectorBase import Selector, RunLBBasedCondition
24 from CoolRunQuery.utils.AtlRunQueryUtils import coolDbConn, GetRanges
25 
26 
27 class TrigKeySelector(RunLBBasedCondition):
28  def __init__(self, name):
29  self.showRelease = False
30  self.showTrigKeys = False
31  self.smkCutRange = None
32  self.relCutRange = None
33  self.trigkeys = None
34  self.release = None
35  super(TrigKeySelector,self).__init__(name=name,
36  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/HLT/HltConfigKeys',
37  channelKeys = [(0,'SMK','MasterConfigurationKey'),
38  (0,'Release','ConfigSource')])
39  self.applySelection = False
40 
41  def setSelectSMK(self,smks):
42  self.trigkeys = smks
43  if self.trigkeys:
44  self.smkCutRange = GetRanges(self.trigkeys)
45  self.applySelection = True
46 
47  def setSelectRelease(self,release):
48  self.release = release
49  if self.release:
50  self.relCutRange = GetRanges(','.join(self.release), intRepFnc=self.relStringToInt)
51  self.applySelection = True
52 
53  def setShow(self, what):
54  if what == 'smk':
55  super(TrigKeySelector,self).setShowOutput('SMK')
56  self.showTrigKeys = True
57  if what == 'release':
58  super(TrigKeySelector,self).setShowOutput('Release')
59  self.showRelease = True
60 
61  def relStringToInt(self, r):
62  major, minor, sub, patch = ([int(x) for x in r.split('.')] + [0,0,0,0])[0:4]
63  if sub<10:
64  sub*=10
65  return 1000000*major+10000*minor+100*sub+patch
66 
67  def __str__(self):
68  if self.applySelection:
69  if self.trigkeys and self.release:
70  return 'SELOUT Checking if SMK matches "%s" and release matches "%s"' % (self.trigkeys,self.release)
71  elif self.trigkeys:
72  return 'SELOUT Checking if SMK matches "%s"' % self.trigkeys
73  else:
74  return 'SELOUT Checking if release matches "%s"' % (self.release)
75  else:
76  if self.showTrigKeys and self.showRelease:
77  return "Retrieving SMK and release version"
78  elif self.showTrigKeys:
79  return "Retrieving SMK"
80  else:
81  return "Retrieving release version"
82 
83  def passes(self,values,key):
84  if self.smkCutRange:
85  smkPass = False
86  try:
87  val = int(values)
88  except ValueError:
89  self.selDataMissing = True
90  smkPass = True
91  else:
92  for cr in self.smkCutRange:
93  if val>=cr[0] and val<=cr[1]:
94  smkPass= True
95  if not smkPass:
96  return False
97  if self.relCutRange:
98  relPass = False
99  val = values[1]
100  if val=='n.a.':
101  self.selDataMissing = True
102  relPass = True
103  else:
104  val = val.split(',')
105  if len(val)>1:
106  val = self.relStringToInt(val[1])
107  for cr in self.relCutRange:
108  if val>=cr[0] and val<=cr[1]:
109  relPass= True
110  else:
111  self.selDataMissing = True
112  relPass = True
113  if not relPass:
114  return False
115  return True
116 
117  def prettyValue(self, value, key):
118  if key=='Release' and value!="n.a." and ',' in value:
119  return value.split(',')[1]
120  return value
121 
122  def valueForStorage(self, condData, key):
123  if key=='Release' and ';' in condData:
124  [db,rel,relfull] = condData.split(';')
125  return {"db" : db, "release" : rel, "releaseFullName" : relfull}
126  elif key == 'SMK':
127  try:
128  smk = int(condData)
129  except ValueError:
130  smk = 0
131  return {"value": smk}
132 
133  def runAfterQuery(self,runlist):
134 
135  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import getSmkNames, getRandom, triggerDBAlias
136 
137  smksByLHCRun = {
138  1: set(),
139  2: set(),
140  3: defaultdict(set)
141  }
142  smkNamesByLHCRun = {}
143 
144  for run in runlist:
145  try:
146  smk = int(run.result['SMK'])
147  except (ValueError, KeyError):
148  continue
149 
150  if run.lhcRun < 3:
151  smksByLHCRun[run.lhcRun].add(smk)
152  else:
153  try:
154  dbAlias = run.data['Release'][0]["db"]
155  except KeyError:
156  smk = run.data['SMK'][0].value
157  dbAlias = "TRIGGERDB_RUN3" if smk>=3000 else "TRIGGERDBDEV1_I8"
158  smksByLHCRun[run.lhcRun][dbAlias].add(smk)
159 
160  smkNamesByLHCRun[1] = getSmkNames(smksByLHCRun[1], triggerDBAlias(lhcRun=1))
161  smkNamesByLHCRun[2] = getSmkNames(smksByLHCRun[2], triggerDBAlias(lhcRun=2))
162  smkNamesByLHCRun[3] = {}
163  for dbAlias in smksByLHCRun[3]:
164  smkNamesByLHCRun[3].update( getSmkNames(smksByLHCRun[3][dbAlias], dbAlias) )
165 
166  for run in runlist:
167  try:
168  smk = int(run.result['SMK'])
169  except (ValueError, KeyError):
170  continue
171 
172  if smk in smkNamesByLHCRun[run.lhcRun]:
173  info = list(smkNamesByLHCRun[run.lhcRun][smk])
174  else:
175  info = ["Name unknown", 0, "no comment"]
176  if info[2]=="" or info[2]=="~":
177  info[2]="no comment"
178  run.stats['SMK'] = {
179  "info": tuple(info),
180  "random": getRandom(smk, run.lhcRun)
181  }
182 
183 
184 class BGSKeySelector(RunLBBasedCondition):
185  def __init__(self, name):
186  self.showBGKeys = False
187  super(BGSKeySelector,self).__init__(name=name,
188  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/LVL1/BunchGroupKey',
189  channelKeys = [(0,'BGS Key','Lvl1BunchGroupConfigurationKey')])
190  def __str__(self):
191  return "Retrieving Bunch group set key"
192 
193  def passes(self,values,key):
194  return True
195 
196  def prettyValue(self, value, key):
197  if not str.isdigit(value):
198  return None
199  return int(value)
200 
201  def runAfterQuery(self,runlist):
202  for k in self.ResultKey():
203  for run in runlist:
204  run.stats[k] = { "blocks" : [], "first" : 0 }
205  entries = run.data[k]
206  if len(entries)==0:
207  continue
208  blocks = []
209  for entry in entries:
210  v = entry.value
211  if len(blocks) > 0 and blocks[-1][0]==v and blocks[-1][2]==entry.startlb:
212  blocks[-1][2] = entry.endlb
213  else:
214  blocks += [ [v, entry.startlb, entry.endlb] ]
215  run.stats[k] = { "blocks" : blocks, "first" : entries[0].value }
216 
217 
218 class L1TrigKeySelector(RunLBBasedCondition):
219  def __init__(self, name):
220  self.showTrigKeys = False
221  super(L1TrigKeySelector,self).__init__(name=name,
222  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/LVL1/Lvl1ConfigKey',
223  channelKeys = [(0,'L1 PSK','Lvl1PrescaleConfigurationKey')])
224 
225  def __str__(self):
226  return "Retrieving L1 PSK"
227 
228  def passes(self,values,key):
229  return True
230 
231  def prettyValue(self, value, key):
232  return int(value) if str.isdigit(value) else None
233 
234  def runAfterQuery(self,runlist):
235  for k in self.ResultKey():
236  for run in runlist:
237  run.stats[k] = { "blocks" : [], "first" : 0 }
238  entries = run.data[k]
239  if len(entries)==0:
240  continue
241  blocks = []
242  for entry in entries:
243  v = entry.value
244  if v == "n.a.":
245  v = None
246  if len(blocks) > 0 and blocks[-1][0]==v and blocks[-1][2]==entry.startlb:
247  blocks[-1][2] = entry.endlb
248  else:
249  blocks += [ [v, entry.startlb, entry.endlb] ]
250  run.stats[k] = { "blocks" : blocks, "first" : entries[0].value }
251  HLTTrigKeySelector.combineHltL1Keys(runlist)
252 
253 
254 class HLTTrigKeySelector(RunLBBasedCondition):
255  def __init__(self, name):
256  self.showTrigKeys = False
257  if Selector.condDB() == 'OFLP200':
258  super(HLTTrigKeySelector,self).__init__(name=name,
259  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/HLT/HltConfigKeys',
260  channelKeys = [(0,'HLT PSK','HltPrescaleConfigurationKey')])
261  else:
262  super(HLTTrigKeySelector,self).__init__(name=name,
263  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/HLT/PrescaleKey',
264  channelKeys = [(0,'HLT PSK','HltPrescaleKey')])
265 
266  def __str__(self):
267  return "Retrieving HLT PSK"
268 
269  def passes(self,values,key):
270  return True
271 
272  def prettyValue(self, value, key):
273  if not str.isdigit(value):
274  return None
275  return int(value)
276 
277  def runAfterQuery(self,runlist):
278  for k in self.ResultKey():
279  for run in runlist:
280  blocks = []
281  run.stats[k] = {}
282  for entry in run.data[k]:
283  v = entry.value
284  if v == "n.a.":
285  v = None
286  if len(blocks) > 0 and blocks[-1][0]==v and blocks[-1][2]==entry.startlb:
287  blocks[-1][2] = entry.endlb
288  else:
289  blocks += [ [v, entry.startlb, entry.endlb] ]
290  run.stats[k] = { "blocks" : blocks, "first" : run.data[k][0].value }
291 
292  HLTTrigKeySelector.combineHltL1Keys(runlist)
293 
294  @classmethod
295  def combineHltL1Keys(cls, runlist):
296  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import isTriggerRun2
297  l1keysByDbAlias = defaultdict(set)
298  hltkeysByDbAlias = defaultdict(set)
299 
300  l1keysRun1 = set() # to collect run 1 keys
301  hltkeysRun1 = set()
302  l1keysRun2 = set() # to collect run 2 keys
303  hltkeysRun2 = set()
304  for run in runlist:
305  if run.lhcRun == 3:
306  try:
307  dbAlias = run.data['Release'][0]["db"]
308  except KeyError:
309  smk = run.data['SMK'][0].value
310  dbAlias = "TRIGGERDB_RUN3" if smk>=3000 else "TRIGGERDBDEV1_I8"
311  if 'L1 PSK' in run.stats:
312  l1keysByDbAlias[dbAlias].update( [x[0] for x in run.stats['L1 PSK']['blocks']] )
313  if 'HLT PSK' in run.stats:
314  hltkeysByDbAlias[dbAlias].update( [x[0] for x in run.stats['HLT PSK']['blocks']] )
315  elif isTriggerRun2(run_number = run.runNr): # run 2
316  if 'L1 PSK' in run.stats:
317  l1keysRun2.update( [x[0] for x in run.stats['L1 PSK']['blocks']] )
318  if 'HLT PSK' in run.stats:
319  hltkeysRun2.update( [x[0] for x in run.stats['HLT PSK']['blocks']] )
320  else: # run 1
321  if 'L1 PSK' in run.stats:
322  l1keysRun1.update( [x[0] for x in run.stats['L1 PSK']['blocks']] )
323  if 'HLT PSK' in run.stats:
324  hltkeysRun1.update( [x[0] for x in run.stats['HLT PSK']['blocks']] )
325 
326  # we need L1 and HLT keys before it makes sense to continue
327  if len(l1keysRun1)+len(l1keysRun2)+len(l1keysByDbAlias) == 0:
328  return
329  if len(hltkeysRun1)+len(hltkeysRun2)+len(hltkeysByDbAlias) == 0:
330  return
331 
332  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import getL1PskNames, getHLTPskNames
333  l1namesRun1 = getL1PskNames(l1keysRun1, lhcRun = 1)
334  hltnamesRun1 = getHLTPskNames(hltkeysRun1, lhcRun = 1)
335  l1namesRun2 = getL1PskNames(l1keysRun2, lhcRun = 2)
336  hltnamesRun2 = getHLTPskNames(hltkeysRun2, lhcRun = 2)
337  l1NamesByDbAlias = {}
338  hltNamesByDbAlias = {}
339  for dbAlias in l1keysByDbAlias:
340  l1NamesByDbAlias[dbAlias] = getL1PskNames(l1keysByDbAlias[dbAlias], dbAlias = dbAlias)
341  for dbAlias in hltkeysByDbAlias:
342  hltNamesByDbAlias[dbAlias] = getHLTPskNames(hltkeysByDbAlias[dbAlias], dbAlias = dbAlias)
343 
344  for run in runlist:
345  if run.lhcRun == 3:
346  try:
347  dbAlias = run.data['Release'][0]["db"]
348  except KeyError:
349  smk = run.data['SMK'][0].value
350  dbAlias = "TRIGGERDB_RUN3" if smk>=3000 else "TRIGGERDBDEV1_I8"
351  l1names = l1NamesByDbAlias[dbAlias]
352  hltnames = hltNamesByDbAlias[dbAlias]
353  elif isTriggerRun2(run_number = run.runNr): # run 2
354  l1names = l1namesRun2
355  hltnames = hltnamesRun2
356  else:
357  l1names = l1namesRun1
358  hltnames = hltnamesRun1
359  if not ('L1 PSK' in run.stats and 'HLT PSK' in run.stats):
360  continue
361  ic = 0
362  blocks = set()
363  for l1key, l1beg, l1end in run.stats['L1 PSK' ]['blocks']:
364  for hltkey, hltbeg, hltend in run.stats['HLT PSK' ]['blocks']:
365  lbmin = max(ic,min(l1beg,hltbeg))
366  lbmax = min(l1end-1,hltend-1)
367  if lbmin > lbmax or lbmin == 0 or lbmax == 0:
368  continue
369  ic = lbmax + 1
370  # accept if new
371  l1name = l1names[l1key] if l1key else ""
372  hltname = hltnames[hltkey] if hltkey else ""
373  elm = (lbmin, lbmax, l1key, hltkey, l1name, hltname)
374  blocks.update([elm])
375  run.stats['PSK' ] = {'blocks' : sorted(list(blocks)) }
376 
377 
378 class RatesSelector(RunLBBasedCondition):
379  def __init__(self, name, trigger=[]):
380  # trigger can be ["*Electron*", "L1_*"]
381  # rate will be printed for all triggers matching the pattern
382 
383  super(RatesSelector,self).__init__(
384  name=name,
385  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/LUMI/LVL1COUNTERS',
386  channelKeys = [(-1,'TriggerRates','TriggerName')]
387  )
388 
389  self.trigger=trigger
390  from CoolRunQuery.AtlRunQuerySelectorWorker import SelectorWorker
391  self.trigSel = SelectorWorker.getRetrieveSelector('trigger','TriggerSelector')
392  if len(trigger)>0:
393  self.trigSel.addShowTriggerPattern(','.join(trigger))
394 
395  def addPattern(self,pattern):
396  if pattern=="" or pattern=="L1":
397  pattern="L1_EM5,L1_TAU5,L1_XE10,L1_J5,L1_MBTS_4_4,L1_MU6"
398  self.trigSel.addShowTriggerPattern(pattern)
399  self.trigger += pattern.split(',')
400 
401 
402  def __str__(self):
403  return "Retrieving trigger rates for %r" % ','.join(self.trigger)
404 
405  def select(self, runlist):
406  start = time()
407  print (self, end='')
408  sys.stdout.flush()
409 
410  fL1R = coolDbConn.GetDBConn(self.schema,db=Selector.condDB()).getFolder(self.folder)
411 
412  for r in runlist:
413  menu = r.result['TriggerMenu']
414 
415  namelookup = 256*['']
416  channellist = []
417  for tr in menu:
418  if not tr.name.startswith("L1_"):
419  continue
420  ch = tr.counter
421  namelookup[ch] = tr.name
422  channellist.append(ch)
423 
424  if len(channellist)>50:
425  r.addResult(self.ResultKey()[0], "Too many L1 triggers requested (%i), maximum is 50" % len(channellist))
426  continue
427 
428  if len(channellist)==0:
429  r.addResult(self.ResultKey()[0], "No match")
430  continue
431 
432  channellist.sort()
433  ch = channellist[0]
434  chanselL1 = cool.ChannelSelection(ch,ch,cool.ChannelSelection.sinceBeforeChannel)
435  for ch in channellist[1:]:
436  chanselL1.addChannel(ch)
437 
438  iovmin=(r.runNr << 32)+0
439  iovmax=((r.runNr+1) << 32)-1
440 
441  countsholder = defaultdict(list)
442 
443  # the hlt part
444  objs = fL1R.browseObjects( iovmin, iovmax, chanselL1)
445  while objs.goToNext():
446  obj=objs.currentRef()
447  ch = obj.channelId()
448  countsholder[namelookup[ch]].append((obj.since()&0xFFFFFFFF,
449  obj.payloadValue('BeforePrescale'),
450  obj.payloadValue('AfterPrescale'),
451  obj.payloadValue('L1Accept')))
452 
453  r.addResult(self.ResultKey()[0], countsholder)
454 
455  duration = time() - start
456 
457  if self.applySelection:
458  print (" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
459  else:
460  print (" ==> Done (%g sec)" % duration)
461 
462  return runlist
463 
464 
465 class TriggerSelector(RunLBBasedCondition):
466 
467  def __init__(self, name, trigger=[]):
468  # trigger can be ["*Electron*", "L1_*"]
469  # will select runs that satiesfy an 'or' of all patterns in the list
470  # a pattern without number are checked for existence
471  # a pattern with number will be checked against the sum of the events in all matching triggers
472  from CoolRunQuery.AtlRunQuerySelectorWorker import SelectorWorker
473  SelectorWorker.getRetrieveSelector('trigkey','TrigKeySelector')
474  SelectorWorker.getRetrieveSelector('l1trigkey','L1TrigKeySelector')
475  SelectorWorker.getRetrieveSelector('hlttrigkey','HLTTrigKeySelector')
476 
477  super(TriggerSelector,self).__init__(name=name,
478  dbfolderkey='COOLONL_TRIGGER::/TRIGGER/HLT/Menu',
479  channelKeys = [(-1,'TriggerMenu','ChainName')])
480 
481  self.triggers = ' or '.join(trigger)
482  self.applySelection = (len(trigger)>0)
485 
486  for s in trigger:
487  s += "$"
488  p = re.compile(s.split()[0].replace(',','|').replace('*','.*').replace('?','.').replace('%','.*'), re.I)
489  self.seltriggerpatterns += [p]
490 
491 
492  def addShowTriggerPattern(self, triggerpattern):
493  if triggerpattern=="":
494  triggerpattern = "*"
495  self.showtriggerpatterns += triggerpattern.split(',')
496 
497  def __str__(self):
498  if self.applySelection:
499  return 'SELOUT Checking if the trigger name matches "%s"' % self.triggers
500  else:
501  return "Retrieving trigger names [%s]" % ','.join(self.showtriggerpatterns)
502 
503 
504  def getL1Prescales(self, runl1psks):
505  """
506  runl1psks is a dict run -> [l1psk,...]
507  """
508  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import getL1Prescales
509  l1pscache = dict()
510  for run_number, pss in runl1psks.items():
511  for l1psk in pss:
512  l1pscache[(run_number,l1psk)] = getL1Prescales(l1psk,run_number = run_number)
513  return l1pscache
514 
515  def getHLTPrescales(self, runhltpsks):
516  """
517  runhltpsks is a dict run -> [hltpsk,...]
518  """
519  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import getHLTPrescales
520  l2pscache = dict()
521  efpscache = dict()
522  for run_number, pss in runhltpsks.items():
523  for psk in pss:
524  l2pscache[(run_number,psk)], efpscache[(run_number,psk)] = getHLTPrescales(psk, run_number = run_number)
525 
526  return l2pscache, efpscache
527 
528 
529  def getMenuFromRun(self, smks):
530  from CoolRunQuery.utils.AtlRunQueryTriggerUtils import getL1Menu, getHLTMenu
531 
532  l1menucache = dict()
533  l2menucache = defaultdict(dict)
534  efmenucache = defaultdict(dict)
535 
536  # fill the menu and prescale caches
537  for smk in set(smks):
538 
539  # the l1 menu
540  l1items = getL1Menu(smk)
541  l1menucache[smk] = l1items
542 
543  # the hlt menu
544  l2chains, efchains = getHLTMenu(smk)
545  d2 = l2menucache[smk] = dict([(c.counter,c) for c in l2chains])
546 
547  # connect the levels (assign lower counter)
548  for chain in efchains:
549  if chain.lowername=="":
550  continue
551  cc = chain.counter
552  if (cc in d2) and (chain.lowername == d2[cc].name):
553  chain.lower = d2[cc]
554  chain.lowercounter = cc
555  continue
556  for l2ch in l2chains:
557  if chain.lowername == l2ch.name:
558  chain.lower = l2ch
559  chain.lowercounter = l2ch.counter
560  break
561 
562  for chain in l2chains:
563  if chain.lowername == "":
564  continue
565  for l1item in l1items:
566  if l1item and chain.lowername == l1item.name:
567  chain.lower = l1item
568  chain.lowercounter = l1item.counter
569  break
570 
571  # set display flag
572  for item in l1items + l2chains + efchains:
573  if item:
574  item.forshow = self.matchShowPattern(item.name)
575 
576  # set 'selected' flag
577  if self.applySelection:
578  for item in l1items + l2chains + efchains:
579  if item:
580  item.forselect = self.matchSelectPattern(item.name)
581 
582  return l1menucache, l2menucache, efmenucache
583 
584 
585  def select(self, runlist):
586  start = time()
587  # some preparation: compile the show patterns
589  if '*' in self.showtriggerpatterns:
590  self.compiledShowPatterns = ['all']
591  else:
592  for p in self.showtriggerpatterns:
593  p += "$"
594  self.compiledShowPatterns += [re.compile(p.replace('*','.*').replace('?','.').replace('%','.*'),re.I)]
595 
596  print (self, end='')
597  sys.stdout.flush()
598  newrunlist = []
599 
600  smks = [int(r.result['SMK']) for r in runlist]
601  runl1psks = dict()
602  runhltpsks = dict()
603  for r in runlist:
604  runl1psks[r.runNr] = [l1psk for (l1psk,firstlb,lastlb) in r.stats['L1 PSK']['blocks']]
605  runhltpsks[r.runNr] = [hltpsk for (hltpsk,firstlb,lastlb) in r.stats['HLT PSK']['blocks']]
606 
607  l1menucache, l2menucache, efmenucache = self.getMenuFromRun(smks)
608 
609  l1pscache = self.getL1Prescales(runl1psks)
610 
611  l2pscache, efpscache = self.getHLTPrescales(runhltpsks) # for RUN 2 only efpscache is filled, l2pscache is None
612 
613  for run in runlist: # go through old runlist and see
614 
615  smk = int(run.result['SMK'])
616  psks = [(x[2],x[3]) for x in run.stats['PSK']['blocks']]
617 
618  l1items = [it for it in l1menucache[smk] if it and (it.forshow or it.forselect)]
619  l2chains = [ch for ch in l2menucache[smk].values() if (ch.forshow or ch.forselect) and not ch.multiseeded]
620  efchains = [ch for ch in efmenucache[smk].values() if (ch.forshow or ch.forselect) and not ch.multiseeded and ch.lower and not ch.lower.multiseeded]
621 
622  value = defaultdict(list)
623 
624  for item in l1items:
625  for l1psk,hltpsk in psks:
626  if not l1psk:
627  value[item].append(None)
628  continue
629  itemps = l1pscache[(run.runNr,l1psk)][item.counter]
630  value[item].append(itemps if itemps>=0 else -1)
631 
632  for l2chain in l2chains:
633  for l1psk,hltpsk in psks:
634  if not l1psk or not hltpsk:
635  value[l2chain].append(None)
636  continue
637  chainps,chainpt = l2pscache[(smk,hltpsk)][l2chain.counter]
638  if chainps<0:
639  value[l2chain].append(-1)
640  continue
641  chainps *= l1pscache[(run.runNr,l1psk)][l2chain.lowercounter]
642  value[l2chain].append(chainps if chainps>=0 else -1)
643 
644  for efchain in efchains:
645  l2chain = efchain.lower
646  for l1psk,hltpsk in psks:
647  if not l1psk or not hltpsk:
648  value[efchain].append(None)
649  continue
650  chainps,chainpt = efpscache[(smk,hltpsk)][efchain.counter]
651  if chainps<0:
652  value[efchain].append(-1)
653  continue
654  l2chainps,l2chainpt = l2pscache[(smk,hltpsk)][l2chain.counter]
655  chainps *= l2chainps
656  if chainps<0:
657  value[efchain].append(-1)
658  continue
659  chainps *= l1pscache[(run.runNr,l1psk)][l2chain.lowercounter]
660  value[efchain].append(chainps if chainps>=0 else -1)
661 
662  # remove all the disabled triggers
663  for tr,pslist in value.items():
664  if not any([ps is None or ps>=0 for ps in pslist]):
665  value.pop(tr)
666 
667  if self.applySelection and not self.passes(value):
668  continue
669  newrunlist += [run.runNr]
670 
671  run.addResult(self.ResultKey()[0], value)
672 
673  runlist = [r for r in runlist if r.runNr in newrunlist]
674 
675  duration = time() - start
676 
677  if self.applySelection:
678  print (" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
679  else:
680  print (" ==> Done (%g sec)" % duration)
681 
682  return runlist
683 
684  def matchShowPattern(self,name):
685  if len(self.compiledShowPatterns)==0 or self.compiledShowPatterns[0]=='all':
686  return True
687  else:
688  return any([p.match(name) for p in self.compiledShowPatterns])
689 
690 
691  def matchSelectPattern(self,name):
692  return any([p.match(name) for p in self.seltriggerpatterns])
693 
694  def prettyValue(self, value):
695  form = []
696  for v in value:
697  if len(v)==2:
698  form += ["%s (%s)" % (v[0],','.join(v[1]))]
699  else:
700  form += ["%s (%s|%s)" % v]
701  return ', '.join(form)
702 
703 
704  def passes(self,triggers):
705  for chain in triggers:
706  if chain.forselect:
707  return True
708  return False
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.runAfterQuery
def runAfterQuery(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:277
python.utils.AtlRunQueryTriggerUtils.getL1Menu
def getL1Menu(smk)
Definition: AtlRunQueryTriggerUtils.py:529
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.runAfterQuery
def runAfterQuery(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:133
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.setShow
def setShow(self, what)
Definition: AtlRunQuerySelectorTrigger.py:53
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector
Definition: AtlRunQuerySelectorTrigger.py:184
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.__init__
def __init__(self, name, trigger=[])
Definition: AtlRunQuerySelectorTrigger.py:467
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.trigSel
trigSel
Definition: AtlRunQuerySelectorTrigger.py:391
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:67
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.triggers
triggers
Definition: AtlRunQuerySelectorTrigger.py:481
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.prettyValue
def prettyValue(self, value)
Definition: AtlRunQuerySelectorTrigger.py:694
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.passes
def passes(self, values, key)
Definition: AtlRunQuerySelectorTrigger.py:193
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector
Definition: AtlRunQuerySelectorTrigger.py:254
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.prettyValue
def prettyValue(self, value, key)
Definition: AtlRunQuerySelectorTrigger.py:231
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.passes
def passes(self, values, key)
Definition: AtlRunQuerySelectorTrigger.py:269
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.select
def select(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:585
python.utils.AtlRunQueryTriggerUtils.getSmkNames
def getSmkNames(smks, dbAlias)
Definition: AtlRunQueryTriggerUtils.py:465
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.valueForStorage
def valueForStorage(self, condData, key)
Definition: AtlRunQuerySelectorTrigger.py:122
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:190
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.setSelectSMK
def setSelectSMK(self, smks)
Definition: AtlRunQuerySelectorTrigger.py:41
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.prettyValue
def prettyValue(self, value, key)
Definition: AtlRunQuerySelectorTrigger.py:272
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.getMenuFromRun
def getMenuFromRun(self, smks)
Definition: AtlRunQuerySelectorTrigger.py:529
python.utils.AtlRunQueryTriggerUtils.getHLTPskNames
def getHLTPskNames(psk, dbAlias=None, run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:443
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.select
def select(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:405
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.trigkeys
trigkeys
Definition: AtlRunQuerySelectorTrigger.py:33
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.seltriggerpatterns
seltriggerpatterns
Definition: AtlRunQuerySelectorTrigger.py:483
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.getHLTPrescales
def getHLTPrescales(self, runhltpsks)
Definition: AtlRunQuerySelectorTrigger.py:515
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:497
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.addPattern
def addPattern(self, pattern)
Definition: AtlRunQuerySelectorTrigger.py:395
python.utils.AtlRunQueryTriggerUtils.triggerDBAlias
def triggerDBAlias(run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:33
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector
Definition: AtlRunQuerySelectorTrigger.py:465
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:266
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector
Definition: AtlRunQuerySelectorTrigger.py:218
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.relStringToInt
def relStringToInt(self, r)
Definition: AtlRunQuerySelectorTrigger.py:61
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.showTrigKeys
showTrigKeys
Definition: AtlRunQuerySelectorTrigger.py:30
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.release
release
Definition: AtlRunQuerySelectorTrigger.py:34
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.relCutRange
relCutRange
Definition: AtlRunQuerySelectorTrigger.py:32
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector
Definition: AtlRunQuerySelectorTrigger.py:27
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.selDataMissing
selDataMissing
Definition: AtlRunQuerySelectorTrigger.py:89
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.runAfterQuery
def runAfterQuery(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:234
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.__init__
def __init__(self, name)
Definition: AtlRunQuerySelectorTrigger.py:219
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.__init__
def __init__(self, name)
Definition: AtlRunQuerySelectorTrigger.py:185
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.applySelection
applySelection
Definition: AtlRunQuerySelectorTrigger.py:482
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.showTrigKeys
showTrigKeys
Definition: AtlRunQuerySelectorTrigger.py:256
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.utils.AtlRunQueryTriggerUtils.getRandom
def getRandom(smk, lhcRun)
Definition: AtlRunQueryTriggerUtils.py:613
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.showtriggerpatterns
showtriggerpatterns
Definition: AtlRunQuerySelectorTrigger.py:484
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.applySelection
applySelection
Definition: AtlRunQuerySelectorTrigger.py:39
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:225
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.setSelectRelease
def setSelectRelease(self, release)
Definition: AtlRunQuerySelectorTrigger.py:47
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.getL1Prescales
def getL1Prescales(self, runl1psks)
Definition: AtlRunQuerySelectorTrigger.py:504
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.compiledShowPatterns
compiledShowPatterns
Definition: AtlRunQuerySelectorTrigger.py:588
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.trigger
trigger
Definition: AtlRunQuerySelectorTrigger.py:389
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.showRelease
showRelease
Definition: AtlRunQuerySelectorTrigger.py:29
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.matchSelectPattern
def matchSelectPattern(self, name)
Definition: AtlRunQuerySelectorTrigger.py:691
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.combineHltL1Keys
def combineHltL1Keys(cls, runlist)
Definition: AtlRunQuerySelectorTrigger.py:295
python.utils.AtlRunQueryUtils.GetRanges
def GetRanges(rangestr, intRepFnc=stringToIntOrTime, maxval=1<< 30)
Definition: AtlRunQueryUtils.py:328
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.passes
def passes(self, values, key)
Definition: AtlRunQuerySelectorTrigger.py:228
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.__init__
def __init__(self, name, trigger=[])
Definition: AtlRunQuerySelectorTrigger.py:379
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.passes
def passes(self, triggers)
Definition: AtlRunQuerySelectorTrigger.py:704
python.selector.AtlRunQuerySelectorTrigger.RatesSelector
Definition: AtlRunQuerySelectorTrigger.py:378
python.utils.AtlRunQueryTriggerUtils.isTriggerRun2
def isTriggerRun2(run_number=None, smk=None, isRun2=None)
Definition: AtlRunQueryTriggerUtils.py:21
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.prettyValue
def prettyValue(self, value, key)
Definition: AtlRunQuerySelectorTrigger.py:117
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.smkCutRange
smkCutRange
Definition: AtlRunQuerySelectorTrigger.py:31
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.__init__
def __init__(self, name)
Definition: AtlRunQuerySelectorTrigger.py:28
python.selector.AtlRunQuerySelectorTrigger.L1TrigKeySelector.showTrigKeys
showTrigKeys
Definition: AtlRunQuerySelectorTrigger.py:220
python.utils.AtlRunQueryTriggerUtils.getL1PskNames
def getL1PskNames(psk, dbAlias=None, run_number=None, smk=None, lhcRun=None)
Definition: AtlRunQueryTriggerUtils.py:419
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.matchShowPattern
def matchShowPattern(self, name)
Definition: AtlRunQuerySelectorTrigger.py:684
python.selector.AtlRunQuerySelectorTrigger.TriggerSelector.addShowTriggerPattern
def addShowTriggerPattern(self, triggerpattern)
Definition: AtlRunQuerySelectorTrigger.py:492
python.selector.AtlRunQuerySelectorTrigger.HLTTrigKeySelector.__init__
def __init__(self, name)
Definition: AtlRunQuerySelectorTrigger.py:255
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.prettyValue
def prettyValue(self, value, key)
Definition: AtlRunQuerySelectorTrigger.py:196
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.runAfterQuery
def runAfterQuery(self, runlist)
Definition: AtlRunQuerySelectorTrigger.py:201
python.selector.AtlRunQuerySelectorTrigger.RatesSelector.__str__
def __str__(self)
Definition: AtlRunQuerySelectorTrigger.py:402
python.selector.AtlRunQuerySelectorTrigger.BGSKeySelector.showBGKeys
showBGKeys
Definition: AtlRunQuerySelectorTrigger.py:186
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
python.selector.AtlRunQuerySelectorTrigger.TrigKeySelector.passes
def passes(self, values, key)
Definition: AtlRunQuerySelectorTrigger.py:83
python.utils.AtlRunQueryTriggerUtils.getHLTMenu
def getHLTMenu(smk)
Definition: AtlRunQueryTriggerUtils.py:489