ATLAS Offline Software
Loading...
Searching...
No Matches
python.TriggerEDM Namespace Reference

Functions

 recordable (arg, runVersion=3)
 _addExtraCollectionsToEDMList (edmList, extraList)
 getRawTriggerEDMList (flags, runVersion=-1)
 getTriggerEDMList (flags, key, runVersion=-1)
 _getRun3TrigObjProducedInView (theKey, trigEDMList)
 _handleRun3ViewContainers (el, HLTList)
 getRun3BSList (flags, keys)
 _getRun3TrigObjList (destination, trigEDMList)
 _getRun3TrigEDMSlimList (key, HLTList)
 _getTriggerRun2EDMSlimList (key, edmList)
 getCategory (s)
 _getTypeAndKey (s)
 _keyToLabel (key)
 _getTriggerRun1Run2ObjList (destination, lst)
 getTrigIDTruthList (dst)
 getLvl1ESDList ()
 getLvl1AODList ()
 _getL2PreregistrationList ()
 _getEFPreregistrationList ()
 _getHLTPreregistrationList ()
 getPreregistrationList (version=2, doxAODConversion=True)
 _getL2BSTypeList ()
 _getEFBSTypeList ()
 _getHLTBSTypeList ()
 getTPList (version=2)
 getEDMLibraries ()
 _InsertContainerNameForHLT (typedict)
 getEFRun1BSList ()
 getEFRun2EquivalentList ()
 getL2Run1BSList ()
 getL2Run2EquivalentList ()
 isCLIDDefined (cgen, typename)
 testEDMList (edm_list, error_on_edmdetails=True)

Variables

 log = logging.getLogger('TriggerEDM')
list AllowedOutputFormats = ['BS', 'ESD', 'AODFULL', 'AODSLIM', 'AODBLSSLIM' ]
list _allowedEDMPrefixes = ['HLT_', 'L1_', 'LVL1']

Function Documentation

◆ _addExtraCollectionsToEDMList()

python.TriggerEDM._addExtraCollectionsToEDMList ( edmList,
extraList )
protected
Extend edmList with extraList, keeping track whether a completely new
collection is being added, or a dynamic variable is added to an existing collection, or new targets are added to an existing collection.
The format of extraList is the same as those of TriggerHLTListRun3.

Definition at line 73 of file TriggerEDM.py.

73def _addExtraCollectionsToEDMList(edmList, extraList):
74 """
75 Extend edmList with extraList, keeping track whether a completely new
76 collection is being added, or a dynamic variable is added to an existing collection, or new targets are added to an existing collection.
77 The format of extraList is the same as those of TriggerHLTListRun3.
78 """
79 existing_collections = [(c[0].split("#")[1]).split(".")[0] for c in edmList]
80 insert_idx = getSafeEDMInsertPosition(edmList)
81 for item in extraList:
82 colname = (item[0].split("#")[1]).split(".")[0]
83 if colname not in existing_collections:
84 # a new collection and its Aux container are inserted in front of 'allowTruncation' items.
85 if 'Aux' in colname:
86 edmList.insert(insert_idx+1,item)
87 else:
88 edmList.insert(insert_idx,item)
89 log.info("added new item to Trigger EDM: {}".format(item))
90 else:
91 # Maybe extra dynamic variables or EDM targets are added
92 isAux = "Aux." in item[0]
93 # find the index of the existing item
94 existing_item_nr = [i for i,s in enumerate(edmList) if colname == (s[0].split("#")[1]).split(".")[0]]
95 if len(existing_item_nr) != 1:
96 log.error("Found {} existing edm items corresponding to new item {}, but it must be exactly one!".format(len(existing_item_nr), item))
97 existingItem = edmList[existing_item_nr[0]]
98 if isAux:
99 dynVars = (item[0].split("#")[1]).split(".")[1:]
100 existing_dynVars = (existingItem[0].split("#")[1]).split(".")[1:]
101 existing_dynVars.extend(dynVars)
102 dynVars = list(dict.fromkeys(existing_dynVars))
103 if '' in dynVars:
104 dynVars.remove('')
105 newVars = '.'.join(dynVars)
106 edmTargets = item[1].split(" ") if len(item) > 1 else []
107 existing_edmTargets = existingItem[1].split(" ")
108 edmTargets.extend(existing_edmTargets)
109 edmTargets = list(dict.fromkeys(edmTargets))
110 newTargets = " ".join(edmTargets)
111 typename = item[0].split("#")[0]
112 log.info("old item in Trigger EDM : {}".format(existingItem))
113 signature = existingItem[2] # NOT updated at the moment
114 tags = existingItem[3] if len(existingItem) > 3 else None # NOT updated at the moment
115 edmList.pop(existing_item_nr[0])
116 combName = typename + "#" + colname
117 if isAux:
118 combName += "." + newVars
119 if tags:
120 edmList.insert(existing_item_nr[0], (combName, newTargets, signature, tags))
121 else:
122 edmList.insert(existing_item_nr[0] , (combName, newTargets, signature))
123 log.info("updated item in Trigger EDM: {}".format(edmList[existing_item_nr[0]]))
124
125 if testEDMList(edmList, error_on_edmdetails=False):
126 log.error("edmList contains inconsistencies!")
127
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ _getEFBSTypeList()

python.TriggerEDM._getEFBSTypeList ( )
protected
 List of EF types to be read from BS, used by the TP

Definition at line 592 of file TriggerEDM.py.

592def _getEFBSTypeList():
593 """ List of EF types to be read from BS, used by the TP
594 """
595 l = []
596 for item in TriggerEFList:
597 t,k = _getTypeAndKey(item[0])
598 ctype = t
599 if 'collection' in EDMDetails[t]:
600 ctype = EDMDetails[t]['collection']
601 l += [ctype]
602 return l
603

◆ _getEFPreregistrationList()

python.TriggerEDM._getEFPreregistrationList ( )
protected
List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for EF

Definition at line 533 of file TriggerEDM.py.

533def _getEFPreregistrationList():
534 """
535 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for EF
536 """
537 l = []
538 for item in TriggerEFList:
539 if len (item[1]) == 0: continue
540 t,k = _getTypeAndKey(item[0])
541 if('Aux' in t):
542 continue #we don't wat to preregister Aux containers
543 l += [t+"#"+_keyToLabel(k)]
544 return l
545
if(febId1==febId2)

◆ _getHLTBSTypeList()

python.TriggerEDM._getHLTBSTypeList ( )
protected
 List of HLT types to be read from BS, used by the TP

Definition at line 604 of file TriggerEDM.py.

604def _getHLTBSTypeList():
605 """ List of HLT types to be read from BS, used by the TP
606 """
607 l = []
608 for item in TriggerHLTList:
609 t,k = _getTypeAndKey(item[0])
610 ctype = t
611 if 'collection' in EDMDetails[t]:
612 ctype = EDMDetails[t]['collection']
613 l += [ctype]
614 return l
615

◆ _getHLTPreregistrationList()

python.TriggerEDM._getHLTPreregistrationList ( )
protected
List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for merged L2/EF in addition to default L2 and EF

Definition at line 546 of file TriggerEDM.py.

546def _getHLTPreregistrationList():
547 """
548 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for merged L2/EF in addition to default L2 and EF
549 """
550 l = []
551 for item in TriggerHLTList:
552 if len (item[1]) == 0: continue
553 t,k = _getTypeAndKey(item[0])
554 if('Aux' in t):
555 continue #we don't wat to preregister Aux containers
556 l += [t+"#"+_keyToLabel(k)]
557 return l
558
559

◆ _getL2BSTypeList()

python.TriggerEDM._getL2BSTypeList ( )
protected
 List of L2 types to be read from BS, used by the TP

Definition at line 580 of file TriggerEDM.py.

580def _getL2BSTypeList():
581 """ List of L2 types to be read from BS, used by the TP
582 """
583 l = []
584 for item in TriggerL2List:
585 t,k = _getTypeAndKey(item[0])
586 ctype = t
587 if 'collection' in EDMDetails[t]:
588 ctype = EDMDetails[t]['collection']
589 l += [ctype]
590 return l
591

◆ _getL2PreregistrationList()

python.TriggerEDM._getL2PreregistrationList ( )
protected
List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for L2

Definition at line 520 of file TriggerEDM.py.

520def _getL2PreregistrationList():
521 """
522 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for L2
523 """
524 l = []
525 for item in TriggerL2List:
526 if len (item[1]) == 0: continue
527 t,k = _getTypeAndKey(item[0])
528 if('Aux' in t):
529 continue #we don't wat to preregister Aux containers
530 l += [t+"#"+_keyToLabel(k)]
531 return l
532

◆ _getRun3TrigEDMSlimList()

python.TriggerEDM._getRun3TrigEDMSlimList ( key,
HLTList )
protected
Run 3 version
Modified EDM list to remove all dynamic variables
Requires changing the list to have 'Aux.-'

Definition at line 344 of file TriggerEDM.py.

344def _getRun3TrigEDMSlimList(key, HLTList):
345 """
346 Run 3 version
347 Modified EDM list to remove all dynamic variables
348 Requires changing the list to have 'Aux.-'
349 """
350 _edmList = _getRun3TrigObjList(key,[HLTList])
351
352 output = {}
353 for k,v in _edmList.items():
354 output[k] = [_handleRun3ViewContainers( el, HLTList ) for el in v]
355 return output
356
357#************************************************************
358#
359# For Run 1 and Run 2 (not modified (so far))
360#
361#************************************************************

◆ _getRun3TrigObjList()

python.TriggerEDM._getRun3TrigObjList ( destination,
trigEDMList )
protected
Run 3 version
Gives back the Python dictionary  with the content of ESD/AOD (dst) which can be inserted in OKS.

Definition at line 321 of file TriggerEDM.py.

321def _getRun3TrigObjList(destination, trigEDMList):
322 """
323 Run 3 version
324 Gives back the Python dictionary with the content of ESD/AOD (dst) which can be inserted in OKS.
325 """
326 dset = set(destination.split())
327 toadd = defaultdict(list)
328
329 for item in itertools.chain(*trigEDMList):
330 if item[1] == '': # no output has been defined
331 continue
332
333 confset = set(item[1].split())
334
335 if dset & confset: # intersection of the sets
336 colltype, k = _getTypeAndKey(item[0])
337
338 if k not in toadd[colltype]:
339 toadd[colltype] += [k]
340
341 return toadd
342
343
STL class.

◆ _getRun3TrigObjProducedInView()

python.TriggerEDM._getRun3TrigObjProducedInView ( theKey,
trigEDMList )
protected
Run 3 only
Finds a given key from within the trigEDMList.
Returns true if this collection is produced inside EventViews
(Hence, has the special viewIndex Aux decoration applied by steering)

Definition at line 257 of file TriggerEDM.py.

257def _getRun3TrigObjProducedInView(theKey, trigEDMList):
258 """
259 Run 3 only
260 Finds a given key from within the trigEDMList.
261 Returns true if this collection is produced inside EventViews
262 (Hence, has the special viewIndex Aux decoration applied by steering)
263 """
264 from TrigEDMConfig.TriggerEDMRun3 import InViews
265
266 return any(coll for coll in itertools.chain(*trigEDMList) if
267 len(coll)>3 and theKey==coll[0].split('#')[1] and
268 any(isinstance(v, InViews) for v in coll[3]))
269
270

◆ _getTriggerRun1Run2ObjList()

python.TriggerEDM._getTriggerRun1Run2ObjList ( destination,
lst )
protected
Gives back the Python dictionary  with the content of ESD/AOD (dst) which can be inserted in OKS.

Definition at line 475 of file TriggerEDM.py.

475def _getTriggerRun1Run2ObjList(destination, lst):
476 """
477 Gives back the Python dictionary with the content of ESD/AOD (dst) which can be inserted in OKS.
478 """
479 dset = set(destination.split())
480
481 toadd = {}
482
483 for item in itertools.chain(*lst):
484 if item[1] == '':
485 continue
486 confset = set(item[1].split())
487 if dset & confset: # intersection of the sets
488 t,k = _getTypeAndKey(item[0])
489 colltype = t
490 if 'collection' in EDMDetails[t]:
491 colltype = EDMDetails[t]['collection']
492 if colltype in toadd:
493 if k not in toadd[colltype]:
494 toadd[colltype] += [k]
495 else:
496 toadd[colltype] = [k]
497 return _InsertContainerNameForHLT(toadd)
498
499

◆ _getTriggerRun2EDMSlimList()

python.TriggerEDM._getTriggerRun2EDMSlimList ( key,
edmList )
protected
Run 2 version
Modified EDM list to remove all dynamic variables
Requires changing the list to have 'Aux.-'

Definition at line 362 of file TriggerEDM.py.

362def _getTriggerRun2EDMSlimList(key, edmList):
363 """
364 Run 2 version
365 Modified EDM list to remove all dynamic variables
366 Requires changing the list to have 'Aux.-'
367 """
368 output = {}
369 for k,v in edmList.items():
370 newnames = []
371 for el in v:
372 if 'Aux' in el:
373 newnames+=[el.split('.')[0]+'.-']
374 else:
375 newnames+=[el]
376 output[k] = newnames
377 return output
378

◆ _getTypeAndKey()

python.TriggerEDM._getTypeAndKey ( s)
protected
 From the strings containing type and key of trigger EDM extract type and key

Definition at line 462 of file TriggerEDM.py.

462def _getTypeAndKey(s):
463 """ From the strings containing type and key of trigger EDM extract type and key
464 """
465 return s[:s.index('#')], s[s.index('#')+1:]
466

◆ _handleRun3ViewContainers()

python.TriggerEDM._handleRun3ViewContainers ( el,
HLTList )
protected

Definition at line 271 of file TriggerEDM.py.

271def _handleRun3ViewContainers( el, HLTList ):
272 if 'Aux.' in el:
273 # Get equivalent non-aux string (fragile!!!)
274 keyNoAux = el.split('.')[0].replace('Aux','')
275 # Check if this interface container is produced inside a View
276 inView = _getRun3TrigObjProducedInView(keyNoAux, [HLTList])
277 if el.split('.')[1] == '':
278 # Aux lists zero dynamic vars to save ...
279 if inView:
280 # ... but it was produced in a View, so we need to add the viewIndex dynamic aux
281 return el.split('.')[0]+'.viewIndex'
282 else:
283 # ... and was not in a View, strip all dynamic
284 return el.split('.')[0]+'.-'
285 else:
286 # Aux lists one or more dynamic vars to save ...
287 if inView:
288 # ... and was produced in a View, so add the viewIndex dynamic as well
289 return el+'.viewIndex'
290 else:
291 # ... and was not produced in a View, keep user-supplied list
292 return el
293 else: # no Aux
294 return el
295
296
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ _InsertContainerNameForHLT()

python.TriggerEDM._InsertContainerNameForHLT ( typedict)
protected

Definition at line 641 of file TriggerEDM.py.

641def _InsertContainerNameForHLT(typedict):
642 import re
643 output = {}
644 for k,v in typedict.items():
645 newnames = []
646 for el in v:
647 if el.startswith('HLT_') or el == 'HLT':
648 prefixAndLabel = el.split('_',1) #only split on first underscore
649 containername = k if 'Aux' not in k else EDMDetails[k]['parent'] #we want the type in the Aux SG key to be the parent type #104811
650 #maybe this is not needed anymore since we are now versionless with the CLIDs but it's not hurting either
651 containername = re.sub('::','__',re.sub('_v[0-9]+$','',containername))
652 newnames+=['_'.join([prefixAndLabel[0],containername]+([prefixAndLabel[1]] if len(prefixAndLabel) > 1 else []))]
653 else:
654 newnames+=[el]
655 output[k] = newnames
656 return output
657

◆ _keyToLabel()

python.TriggerEDM._keyToLabel ( key)
protected
 The key is usually HLT_*, this function returns second part of it or empty string

Definition at line 467 of file TriggerEDM.py.

467def _keyToLabel(key):
468 """ The key is usually HLT_*, this function returns second part of it or empty string
469 """
470 if '_' not in key:
471 return ''
472 else:
473 return key[key.index('_'):].lstrip('_')
474

◆ getCategory()

python.TriggerEDM.getCategory ( s)
From name of object in AOD/ESD found by checkFileTrigSize.py, return category 
Clean up object name 

Definition at line 379 of file TriggerEDM.py.

379def getCategory(s):
380 """ From name of object in AOD/ESD found by checkFileTrigSize.py, return category """
381
382 """ Clean up object name """
383 s = s.strip()
384
385 # To-do
386 # seperate the first part of the string at the first '_'
387 # search in EDMDetails for the key corresponding to the persistent value
388 # if a key is found, use this as the first part of the original string
389 # put the string back together
390
391 if s.count('.') : s = s[:s.index('.')]
392 if s.count('::'): s = s[s.index(':')+2:]
393 if s.count('<'): s = s[s.index('<')+1:]
394 if s.count('>'): s = s[:s.index('>')]
395 if s.count('.') : s = s[:s.index('.')]
396 if s.count('Dyn') : s = s[:s.index('Dyn')]
397
398 # containers from Run 1-2 and 3 require different preprocessing
399 # s12 is for Run 1-2, s is for Run 3
400 s12 = s
401
402 if s12.startswith('HLT_xAOD__') or s12.startswith('HLT_Rec__') or s12.startswith('HLT_Analysis__') :
403 s12 = s12[s12.index('__')+2:]
404 s12 = s12[s12.index('_')+1:]
405 #if s12.count('.') : s12 = s12[:s12.index('.')]
406 s12 = "HLT_"+s12
407 elif s12.startswith('HLT_'):
408 #if s.count('Dyn') : s = s[:s.index('Dyn')]
409 if s12.count('_'): s12 = s12[s12.index('_')+1:]
410 if s12.count('_'): s12 = s12[s12.index('_')+1:]
411 s12 = "HLT_"+s12
412
413 TriggerListRun1 = TriggerL2List + TriggerEFList + TriggerResultsRun1List
414 TriggerListRun2 = TriggerResultsList + TriggerLvl1List + TriggerIDTruth + TriggerHLTList
415 TriggerListRun3 = getRawTriggerEDMList(flags=None, runVersion=3)
416
417 category = ''
418 bestMatch = ''
419
420 """ Loop over all objects already defined in lists (and hopefully categorized!!) """
421 for item in TriggerListRun1+TriggerListRun2:
422 t,k = _getTypeAndKey(item[0])
423
424 """ Clean up type name """
425 if t.count('::'): t = t[t.index(':')+2:]
426 if t.count('<'): t = t[t.index('<')+1:]
427 if t.count('>'): t = t[:t.index('>')]
428 if (s12.startswith(t) and s12.endswith(k)) and (len(t) > len(bestMatch)):
429 bestMatch = t
430 category = item[2]
431
432 if k.count('.'): k = k[:k.index('.')]
433 if (s12 == k):
434 bestMatch = k
435 category = item[2]
436
437 for item in TriggerListRun3:
438 t,k = _getTypeAndKey(item[0])
439
440 """ Clean up type name """
441 if t.count('::'): t = t[t.index(':')+2:]
442 if t.count('<'): t = t[t.index('<')+1:]
443 if t.count('>'): t = t[:t.index('>')]
444
445 if (s.startswith(t) and s.endswith(k)) and (len(t) > len(bestMatch)):
446 bestMatch = t
447 category = item[2]
448
449 if k.count('.'): k = k[:k.index('.')]
450 if (s == k):
451 bestMatch = k
452 category = item[2]
453
454 if category == '' and 'HLTNav' in s:
455 category = 'HLTNav'
456
457 if category == '': return 'NOTFOUND'
458 return category
459
460
461

◆ getEDMLibraries()

python.TriggerEDM.getEDMLibraries ( )

Definition at line 638 of file TriggerEDM.py.

638def getEDMLibraries():
639 return EDMLibraries
640

◆ getEFRun1BSList()

python.TriggerEDM.getEFRun1BSList ( )
List of EF trigger objects that were written to ByteStream in Run 1

Definition at line 658 of file TriggerEDM.py.

658def getEFRun1BSList():
659 """
660 List of EF trigger objects that were written to ByteStream in Run 1
661 """
662 l = []
663 for item in TriggerEFEvolutionList:
664 if len (item[1]) == 0: continue
665 t,k = _getTypeAndKey(item[0])
666 l += [t+"#"+_keyToLabel(k)]
667 return l
668

◆ getEFRun2EquivalentList()

python.TriggerEDM.getEFRun2EquivalentList ( )
List of Run-2 containers equivalent to Run-1 EF containers

Definition at line 669 of file TriggerEDM.py.

669def getEFRun2EquivalentList():
670 """
671 List of Run-2 containers equivalent to Run-1 EF containers
672 """
673 l = []
674 for item in TriggerEFEvolutionList:
675 if len (item[1]) == 0: continue
676 t,k = _getTypeAndKey(item[1])
677 l += [t+"#"+_keyToLabel(k)]
678 return l
679

◆ getL2Run1BSList()

python.TriggerEDM.getL2Run1BSList ( )
List of L2 trigger objects that were written to ByteStream in Run 1

Definition at line 680 of file TriggerEDM.py.

680def getL2Run1BSList():
681 """
682 List of L2 trigger objects that were written to ByteStream in Run 1
683 """
684 l = []
685 for item in TriggerL2EvolutionList:
686 if len (item[1]) == 0: continue
687 t,k = _getTypeAndKey(item[0])
688 l += [t+"#"+_keyToLabel(k)]
689 return l
690

◆ getL2Run2EquivalentList()

python.TriggerEDM.getL2Run2EquivalentList ( )
List of Run-2 containers equivalent to Run-1 L2 containers

Definition at line 691 of file TriggerEDM.py.

691def getL2Run2EquivalentList():
692 """
693 List of Run-2 containers equivalent to Run-1 L2 containers
694 """
695 l = []
696 for item in TriggerL2EvolutionList:
697 if len (item[1]) == 0: continue
698 t,k = _getTypeAndKey(item[1])
699 l += [t+"#"+_keyToLabel(k)]
700 return l
701

◆ getLvl1AODList()

python.TriggerEDM.getLvl1AODList ( )
Gives back the Python dictionary  with the lvl1 trigger result content of AOD which can be inserted in OKS.

Definition at line 512 of file TriggerEDM.py.

512def getLvl1AODList():
513 """
514 Gives back the Python dictionary with the lvl1 trigger result content of AOD which can be inserted in OKS.
515 """
516 return _getTriggerRun1Run2ObjList('AODFULL',[TriggerLvl1List])
517
518
519

◆ getLvl1ESDList()

python.TriggerEDM.getLvl1ESDList ( )
Gives back the Python dictionary  with the lvl1 trigger result content of ESD which can be inserted in OKS.

Definition at line 506 of file TriggerEDM.py.

506def getLvl1ESDList():
507 """
508 Gives back the Python dictionary with the lvl1 trigger result content of ESD which can be inserted in OKS.
509 """
510 return _getTriggerRun1Run2ObjList('ESD',[TriggerLvl1List])
511

◆ getPreregistrationList()

python.TriggerEDM.getPreregistrationList ( version = 2,
doxAODConversion = True )
List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want for all levels
version can be: '1 (Run1)', '2 (Run2)'

Definition at line 560 of file TriggerEDM.py.

560def getPreregistrationList(version=2, doxAODConversion=True):
561 """
562 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want for all levels
563 version can be: '1 (Run1)', '2 (Run2)'
564 """
565
566 l=[]
567 if version==2:
568 l = _getHLTPreregistrationList()
569 elif version==1:
570 # remove duplicates while preserving order
571 objs=_getL2PreregistrationList()+_getEFPreregistrationList()
572 if doxAODConversion:
573 objs += _getHLTPreregistrationList()
574 l=list(dict.fromkeys(objs))
575 else:
576 raise RuntimeError("Invalid version=%s supplied to getPreregistrationList" % version)
577 return l
578
579

◆ getRawTriggerEDMList()

python.TriggerEDM.getRawTriggerEDMList ( flags,
runVersion = -1 )
The static EDM list does still need some light manipulation before it can be used commonly.
Never import TriggerHLTListRun3 or TriggerHLTListRun4 directly, always fetch them via this function

Definition at line 128 of file TriggerEDM.py.

128def getRawTriggerEDMList(flags, runVersion=-1):
129 """
130 The static EDM list does still need some light manipulation before it can be used commonly.
131 Never import TriggerHLTListRun3 or TriggerHLTListRun4 directly, always fetch them via this function
132 """
133 if runVersion == -1:
134 runVersion = flags.Trigger.EDMVersion
135
136 if runVersion == 3:
137 edmListCopy = TriggerHLTListRun3.copy()
138 if flags and flags.Trigger.addRun3LowMuEDM:
139 LowMuEDM = getRun3LowMuEDM(flags)
140 log.info( "Adding low mu collections to EDM %i: %s", runVersion, str(LowMuEDM))
141 _addExtraCollectionsToEDMList(edmListCopy, LowMuEDM)
142 elif runVersion == 4:
143 edm4ListCopy = TriggerHLTListRun4.copy()
144 edm3ListCopy = TriggerHLTListRun3.copy()
145 log.debug("Removing duplicated item between TriggerHLTListRun3 and TriggerHLTListRun4.")
146 for i in range(len(edm3ListCopy)-1, -1, -1): # Back iterate by index, we might be removing as we go
147 for r4item in edm4ListCopy:
148 if edm3ListCopy[i][0] == r4item[0]:
149 del edm3ListCopy[i]
150 log.debug(f"- Dupe: {r4item} is removed from TriggerHLTListRun3 to be updated by TriggerHLTListRun4")
151 break
152 lenPreMerge = len(edm3ListCopy)
153 edm4ListCopy.extend(edm3ListCopy)
154 lenPostMerge = len(edm4ListCopy)
155 edmListCopy = edm4ListCopy
156 log.info(f"Added TriggerHLTListRun4 to TriggerHLTListRun3. EDM entries {lenPreMerge} -> {lenPostMerge}")
157 if testEDMList(edmListCopy, error_on_edmdetails=False):
158 log.error("edmList contains inconsistencies!")
159 else:
160 errMsg="ERROR the getRawTriggerEDMList function supports runs 3 and 4."
161 log.error(errMsg)
162 raise RuntimeError(errMsg)
163
164 if flags and flags.Trigger.ExtraEDMList:
165 log.info( "Adding extra collections to EDM %i: %s", runVersion, str(flags.Trigger.ExtraEDMList))
166 _addExtraCollectionsToEDMList(edmListCopy, flags.Trigger.ExtraEDMList)
167
168 return edmListCopy
169

◆ getRun3BSList()

python.TriggerEDM.getRun3BSList ( flags,
keys )
The keys should contain BS and all the identifiers used for scouting.
Returns list of tuples (typename#key, [keys], [properties]).

Definition at line 297 of file TriggerEDM.py.

297def getRun3BSList(flags, keys):
298 """
299 The keys should contain BS and all the identifiers used for scouting.
300 Returns list of tuples (typename#key, [keys], [properties]).
301 """
302
303 from TrigEDMConfig.TriggerEDMRun3 import persistent
304 keys = set(keys[:])
305 collections = []
306 _HLTList = getRawTriggerEDMList(flags, 3)
307 for definition in _HLTList:
308
309 typename,collkey = definition[0].split("#")
310 # normalise collection name and the key (decorations)
311 typename = persistent(typename)
312 collkey = _handleRun3ViewContainers( collkey, _HLTList )
313 destination = keys & set(definition[1].split())
314 if len(destination) > 0:
315 collections.append( (typename+"#"+collkey, list(destination),
316 definition[3] if len(definition)>3 else []) )
317
318 return collections
319
320

◆ getTPList()

python.TriggerEDM.getTPList ( version = 2)
Mapping  of Transient objects to Peristent during serialization (BS creation)
version can be: '1 (Run1)', '2 (Run2)'

Definition at line 616 of file TriggerEDM.py.

616def getTPList(version=2):
617 """
618 Mapping of Transient objects to Peristent during serialization (BS creation)
619 version can be: '1 (Run1)', '2 (Run2)'
620 """
621 l = {}
622 if version==2:
623 bslist = _getHLTBSTypeList()
624 elif version==1:
625 bslist = list(set(_getL2BSTypeList() + _getEFBSTypeList()))
626 else:
627 raise RuntimeError("Invalid version=%s supplied to getTPList" % version)
628
629 for t,d in EDMDetails.items():
630 colltype = t
631 if 'collection' in d:
632 colltype = EDMDetails[t]['collection']
633 if colltype in bslist:
634 l[colltype] = d['persistent']
635 return l
636
637

◆ getTriggerEDMList()

python.TriggerEDM.getTriggerEDMList ( flags,
key,
runVersion = -1 )
List (Literally Python dict) of trigger objects to be placed with flags:
flags is the CA flag container
key can be" 'ESD', 'AODSLIM', 'AODFULL'
runVersion can be: '-1 (Auto-configure)', '1 (Run1)', '2 (Run2)', '3' (Run 3), '4' (Run 4)

Definition at line 170 of file TriggerEDM.py.

170def getTriggerEDMList(flags, key, runVersion=-1):
171 """
172 List (Literally Python dict) of trigger objects to be placed with flags:
173 flags is the CA flag container
174 key can be" 'ESD', 'AODSLIM', 'AODFULL'
175 runVersion can be: '-1 (Auto-configure)', '1 (Run1)', '2 (Run2)', '3' (Run 3), '4' (Run 4)
176 """
177 # We allow for this to be overriden as Run1 bytestream actually need to request the Run2 EDM due to it additionally undergoing a transient xAOD migration.
178 if runVersion == -1:
179 runVersion = flags.Trigger.EDMVersion
180
181 if runVersion == 1:
182 return _getTriggerRun1Run2ObjList(key, [TriggerL2List,TriggerEFList, TriggerResultsRun1List])
183
184 elif runVersion == 2:
185 edmList = _getTriggerRun1Run2ObjList(key, [TriggerHLTList, TriggerResultsList])
186 return _getTriggerRun2EDMSlimList(key, edmList) if 'SLIM' in key else edmList
187
188 elif runVersion >= 3:
189 RawEDMList = getRawTriggerEDMList(flags=flags, runVersion=runVersion)
190
191 if key not in AllowedOutputFormats: # AllowedOutputFormats is the entire list of output formats including ESD
192 log.warning('Output format: %s is not in list of allowed formats, please check!', key)
193 return _getRun3TrigObjList(key, [RawEDMList])
194
195 # this keeps only the dynamic variables that have been specified in TriggerEDMRun3
196 Run3TrigEDM = {}
197 Run3TrigEDMSLIM = {}
198
199 if "AODFULL" in key:
200 Run3TrigEDM.update(_getRun3TrigEDMSlimList(key, RawEDMList))
201
202 elif "AODSLIM" in key:
203 # remove the variables that are defined in TriggerEDMRun3.varToRemoveFromAODSLIM from the containers
204
205 # get all containers from list that are marked with AODSLIM
206 if len(varToRemoveFromAODSLIM) == 0:
207 Run3TrigEDM.update(_getRun3TrigEDMSlimList(key, RawEDMList))
208 log.info("No decorations are listed to be removed from AODSLIM")
209 else:
210 Run3TrigEDMSLIM.update(_getRun3TrigEDMSlimList(key, RawEDMList))
211 log.info("The following decorations are going to be removed from the listed collections in AODSLIM {}".format(varToRemoveFromAODSLIM))
212 # Go through all container values and remove the variables to remove
213 # Format of Run3TrigEDMSLIM is {'xAOD::Cont': ['coll1.varA.varB', 'coll2.varD',...],...}
214 for cont, values in Run3TrigEDMSLIM.items():
215 if (isinstance(values, list)):
216 newValues = []
217 for value in values:
218 newValue = value+'.'
219 coll = value.split('.')[0]
220
221 varRemovedFlag = False
222 for myTuple in varToRemoveFromAODSLIM:
223 var = myTuple[0]
224
225 if var in value and coll in myTuple:
226 varRemovedFlag = True
227 removeVar = '.'+var+'.'
228 newValue = newValue.replace(removeVar, '.')
229
230 if newValue[-1:] == '.':
231 newValue = newValue[:-1]
232
233 if varRemovedFlag is False:
234 newValues.append(value)
235 elif varRemovedFlag is True:
236 newValues.append(newValue)
237 else:
238 raise RuntimeError("Decoration removed but no new Value was available, not sure what to do...")
239
240 # Filling the Run3TrigEDM dictionary with the new set of values for each cont
241 Run3TrigEDM[cont] = newValues
242 else:
243 raise RuntimeError("Value in Run3TrigEDM dictionary is not a list")
244
245 else: # ESD
246 Run3TrigEDM.update(_getRun3TrigEDMSlimList(key, RawEDMList))
247
248 log.debug('TriggerEDM for EDM set {} contains the following collections: {}'.format(key, Run3TrigEDM) )
249 return Run3TrigEDM
250
251
252 else:
253 raise RuntimeError("Invalid runVersion=%s supplied to getTriggerEDMList" % runVersion)
254
255
256

◆ getTrigIDTruthList()

python.TriggerEDM.getTrigIDTruthList ( dst)
Gives back the Python dictionary  with the truth trigger content of ESD/AOD (dst) which can be inserted in OKS.

Definition at line 500 of file TriggerEDM.py.

500def getTrigIDTruthList(dst):
501 """
502 Gives back the Python dictionary with the truth trigger content of ESD/AOD (dst) which can be inserted in OKS.
503 """
504 return _getTriggerRun1Run2ObjList(dst,[TriggerIDTruth])
505

◆ isCLIDDefined()

python.TriggerEDM.isCLIDDefined ( cgen,
typename )
Checks container type name is hashable

Definition at line 702 of file TriggerEDM.py.

702def isCLIDDefined(cgen,typename):
703 """
704 Checks container type name is hashable
705 """
706 c = cgen.genClidFromName(typename)
707 return (cgen.getNameFromClid(c) is not None)
708

◆ recordable()

python.TriggerEDM.recordable ( arg,
runVersion = 3 )
Verify that the name is in the list of recorded objects and conform to the name convention

In Run 2 it was a delicate process to configure correctly what got recorded
as it had to be set in the algorithm that produced it as well in the TriggerEDM.py in a consistent manner.

For Run 3 every alg input/output key can be crosschecked against the list of objects to record which is defined here.
I.e. in the configuration alg developer would do this:
from TriggerEDM.TriggerEDMRun3 import recordable

alg.outputKey = recordable("SomeKey")
If the names are correct the outputKey is assigned with SomeKey, if there is a missmatch an exception is thrown.

Definition at line 37 of file TriggerEDM.py.

37def recordable( arg, runVersion=3 ):
38 """
39 Verify that the name is in the list of recorded objects and conform to the name convention
40
41 In Run 2 it was a delicate process to configure correctly what got recorded
42 as it had to be set in the algorithm that produced it as well in the TriggerEDM.py in a consistent manner.
43
44 For Run 3 every alg input/output key can be crosschecked against the list of objects to record which is defined here.
45 I.e. in the configuration alg developer would do this:
46 from TriggerEDM.TriggerEDMRun3 import recordable
47
48 alg.outputKey = recordable("SomeKey")
49 If the names are correct the outputKey is assigned with SomeKey, if there is a missmatch an exception is thrown.
50
51 """
52
53 # Allow passing DataHandle as argument - convert to string and remove store name
54 name = str(arg).replace('StoreGateSvc+','')
55
56 if "HLTNav_" in name:
57 log.error( "Don't call recordable({0}), or add any \"HLTNav_\" collection manually to the EDM. See:collectDecisionObjects.".format( name ) )
58 pass
59 else: #negative filtering
60 if not any([name.startswith(p) for p in _allowedEDMPrefixes]):
61 raise RuntimeError( f"The collection name {name} does not start with any of the allowed prefixes: {_allowedEDMPrefixes}" )
62 if "Aux" in name and not name[-1] != ".":
63 raise RuntimeError( f"The collection name {name} is Aux but the name does not end with the '.'" )
64
65 if runVersion >= 3:
66 for entry in TriggerHLTListRun3:
67 if entry[0].split( "#" )[1] == name:
68 return arg
69 msg = "The collection name {0} is not declared to be stored by HLT. Add it to TriggerEDMRun3.py".format( name )
70 log.error("ERROR in recordable() - see following stack trace.")
71 raise RuntimeError( msg )
72

◆ testEDMList()

python.TriggerEDM.testEDMList ( edm_list,
error_on_edmdetails = True )
Checks EDM list entries for serialization and configuration compliance.

Definition at line 709 of file TriggerEDM.py.

709def testEDMList(edm_list, error_on_edmdetails = True):
710 """
711 Checks EDM list entries for serialization and configuration compliance.
712 """
713
714 #xAOD types that don't expect accompanying Aux containers
715 _noAuxList = ["xAOD::" + contType for contType in ["TrigConfKeys", "BunchConfKey"]]
716
717 cgen = clidGenerator("", False)
718 return_code = 0
719 found_allow_truncation = False
720 serializable_names = []
721 serializable_names_no_label = []
722 serializable_names_no_properties = []
723
724 for i, edm in enumerate(edm_list):
725
726 #check has sufficient entries
727 if len(edm) < 3:
728 log.error("EDM entry too short for " + edm[0])
729 return_code = 1
730 continue
731
732 serializable_name = edm[0]
733 serializable_name_no_label = re.sub(r"\#.*", "", serializable_name)
734 serializable_name_no_properties = serializable_name.split('.')[0]
735
736 serializable_names.append(serializable_name)
737 serializable_names_no_label.append(serializable_name_no_label)
738 serializable_names_no_properties.append(serializable_name_no_properties)
739
740 #check container type name is hashable
741 if not isCLIDDefined(cgen,serializable_name_no_label):
742 log.error("no CLID for " + serializable_name)
743 return_code = 1
744
745 #check that no '.' in entries _not_ containing 'Aux'
746 if "Aux" not in serializable_name and "." in serializable_name:
747 log.error("A '.' found in non-Aux container name " + serializable_name)
748 return_code = 1
749
750 #check for Aux "."
751 if "Aux" in serializable_name and "Aux." not in serializable_name:
752 log.error("no final Aux. in label for " + serializable_name)
753 return_code = 1
754
755 #check contains exactly one #
756 if serializable_name.count("#") != 1:
757 log.error("Invalid naming structure for " + serializable_name)
758 return_code = 1
759 else: # only proceed if type and name can be separated
760 #check that every interface xAOD container directly followed by matching Aux container.
761 if serializable_name.startswith("xAOD") and "Aux" not in serializable_name:
762 cont_type,cont_name = serializable_name.split("#")
763 if cont_type not in _noAuxList:
764 auxmismatch = False
765 if len(edm_list) == i+1:
766 auxmismatch = True
767 cont_to_test = "nothing"
768 else:
769 cont_to_test = edm_list[i+1][0].split(".")[0]+"."
770 cont_type_short = cont_type.replace("Container","")
771 pattern = re.compile(cont_type_short+r".*Aux.*\#"+cont_name+"Aux.")
772 if not pattern.match(cont_to_test):
773 #test if shallow container type.
774 shallow_pattern = re.compile("xAOD::ShallowAuxContainer#"+cont_name+"Aux.")
775 if not shallow_pattern.match(cont_to_test):
776 auxmismatch = True
777 if auxmismatch:
778 log.error("Expected relevant Aux container following interface container %s, but found %s instead.",serializable_name,cont_to_test)
779 return_code = 1
780 else:
781 #check that targets of interface and aux container match
782 targets = set(edm[1].split())
783 if len(edm_list[i+1]) > 1 and cont_to_test.count("#") == 1:
784 contname_to_test = cont_to_test.split("#")[1]
785 targets_to_test = set(edm_list[i+1][1].split())
786 if len(targets ^ targets_to_test) > 0:
787 log.error("Targets of %s (%s) and %s (%s) do not match",cont_name,targets,contname_to_test,targets_to_test)
788 return_code = 1
789
790 #check that Aux always follows non-Aux (our deserialiser relies on that)
791 if i>0 and "Aux" in serializable_name and "Aux" in edm_list[i-1][0]:
792 log.error(f"Aux container {serializable_name} needs to folow the "
793 "associated interface container in the EDM list")
794 return_code = 1
795
796 #check target types are valid. Check that target lists containing higher level targets
797 #have required low level targets (ESD for AOD targets, AODFULL for SLIM targets).
798 file_types = edm[1].split() # might return empty list, this is fine - 0 output file types allowed for an EDM entry (in case of obsolete containers)
799 for file_type in file_types:
800 if file_type not in AllowedOutputFormats:
801 log.error("unknown file type " + file_type + " for " + serializable_name)
802 return_code = 1
803 for higher_level,required_lower_level in [('AOD','ESD'), ('SLIM','AODFULL')]:
804 if higher_level in file_type and required_lower_level not in file_types:
805 log.error("Target list for %s containing '%s' must also contain lower level target '%s'.",serializable_name,file_type,required_lower_level)
806 return_code = 1
807
808 # Check allowTuncation is only at the end
809 tags = edm[3] if len(edm) > 3 else None
810 allow_truncation_flag = False
811 if tags:
812 allow_truncation_flag = allowTruncation in tags
813 if allow_truncation_flag:
814 found_allow_truncation = True
815
816 if found_allow_truncation and not allow_truncation_flag:
817 log.error("All instances of 'allowTruncation' need to be at the END of the EDM serialisation list")
818 return_code = 1
819
820 #end of for loop over entries. Now do complete list checks.
821
822 #check for duplicates:
823 #check that no two EDM entries match after stripping out characters afer '.'
824 if not len(set(serializable_names_no_properties)) == len(serializable_names_no_properties):
825 log.error("Duplicates in EDM list! Duplicates found:")
826 import collections.abc
827 for item, count in collections.Counter(serializable_names_no_properties).items():
828 if count > 1:
829 log.error(str(count) + "x: " + str(item))
830 return_code = 1
831
832 #check EDMDetails
833 for EDMDetail in EDMDetailsRun3.keys():
834 if EDMDetail not in serializable_names_no_label:
835 msg = "EDMDetail for " + EDMDetail + " does not correspond to any name in TriggerList"
836 if error_on_edmdetails:
837 log.error(msg)
838 return_code = 1
839 else:
840 log.warning(msg)
841
842 return return_code

Variable Documentation

◆ _allowedEDMPrefixes

list python.TriggerEDM._allowedEDMPrefixes = ['HLT_', 'L1_', 'LVL1']
protected

Definition at line 36 of file TriggerEDM.py.

◆ AllowedOutputFormats

list python.TriggerEDM.AllowedOutputFormats = ['BS', 'ESD', 'AODFULL', 'AODSLIM', 'AODBLSSLIM' ]

Definition at line 32 of file TriggerEDM.py.

◆ log

python.TriggerEDM.log = logging.getLogger('TriggerEDM')

Definition at line 21 of file TriggerEDM.py.