10 from TrigEDMConfig.TriggerEDMRun1
import TriggerL2List,TriggerEFList,TriggerResultsRun1List
11 from TrigEDMConfig.TriggerEDMRun2
import TriggerResultsList,TriggerLvl1List,TriggerIDTruth,TriggerHLTList,EDMDetails,EDMLibraries,TriggerL2EvolutionList,TriggerEFEvolutionList
12 from TrigEDMConfig.TriggerEDMRun3
import TriggerHLTListRun3,varToRemoveFromAODSLIM,addExtraCollectionsToEDMList
13 from AthenaCommon.Logging
import logging
14 log = logging.getLogger(
'TriggerEDM')
25 AllowedOutputFormats = [
'BS',
'ESD',
'AODFULL',
'AODSLIM',
'AODCOMM',
'AODBLSSLIM' ]
26 from TrigEDMConfig
import DataScoutingInfo
27 AllowedOutputFormats.extend(DataScoutingInfo.getAllDataScoutingIdentifiers())
29 _allowedEDMPrefixes = [
'HLT_',
'L1_',
'LVL1']
32 Verify that the name is in the list of recorded objects and conform to the name convention
34 In Run 2 it was a delicate process to configure correctly what got recorded
35 as it had to be set in the algorithm that produced it as well in the TriggerEDM.py in a consistent manner.
37 For Run 3 every alg input/output key can be crosschecked against the list of objects to record which is defined here.
38 I.e. in the configuration alg developer would do this:
39 from TriggerEDM.TriggerEDMRun3 import recordable
41 alg.outputKey = recordable("SomeKey")
42 If the names are correct the outputKey is assigned with SomeKey, if there is a missmatch an exception is thrown.
50 log.error(
"Don't call recordable({0}), or add any \"HLTNav_\" collection manually to the EDM. See:collectDecisionObjects.".
format( name ) )
53 if not any([name.startswith(p)
for p
in _allowedEDMPrefixes]):
54 raise RuntimeError( f
"The collection name {name} does not start with any of the allowed prefixes: {_allowedEDMPrefixes}" )
55 if "Aux" in name
and not name[-1] !=
".":
56 raise RuntimeError( f
"The collection name {name} is Aux but the name does not end with the '.'" )
59 for entry
in TriggerHLTListRun3:
60 if entry[0].
split(
"#" )[1] == name:
62 msg =
"The collection name {0} is not declared to be stored by HLT. Add it to TriggerEDMRun3.py".
format( name )
63 log.error(
"ERROR in recordable() - see following stack trace.")
64 raise RuntimeError( msg )
69 List (Literally Python dict) of trigger objects to be placed with flags:
70 key can be" 'ESD', 'AODSLIM', 'AODFULL'
71 run can be: '1 (Run1)', '2 (Run2)', '3' (Run 3), '4' (Run 4)
74 return getTriggerObjList(key,[TriggerL2List,TriggerEFList, TriggerResultsRun1List])
83 if key
in AllowedOutputFormats:
90 log.info(
"Adding extra collections to EDM: %s",
str(extraEDMList))
101 for kcomm,vcomm
in Run3TrigEDMCOMM.items():
102 if kcomm
in Run3TrigEDM:
103 Run3TrigEDM[kcomm].extend(vcomm)
105 Run3TrigEDM[kcomm] = vcomm
107 elif "AODSLIM" in key:
111 if len(varToRemoveFromAODSLIM) == 0:
113 log.info(
"No decorations are listed to be removed from AODSLIM")
116 log.info(
"The following decorations are going to be removed from the listed collections in AODSLIM {}".
format(varToRemoveFromAODSLIM))
119 for cont, values
in Run3TrigEDMSLIM.items():
120 if (isinstance(values, list)):
124 coll = value.split(
'.')[0]
126 varRemovedFlag =
False
127 for myTuple
in varToRemoveFromAODSLIM:
130 if var
in value
and coll
in myTuple:
131 varRemovedFlag =
True
132 removeVar =
'.'+var+
'.'
133 newValue = newValue.replace(removeVar,
'.')
135 if newValue[-1:] ==
'.':
136 newValue = newValue[:-1]
138 if varRemovedFlag
is False:
139 newValues.append(value)
140 elif varRemovedFlag
is True:
141 newValues.append(newValue)
143 raise RuntimeError(
"Decoration removed but no new Value was available, not sure what to do...")
146 Run3TrigEDM[cont] = newValues
148 raise RuntimeError(
"Value in Run3TrigEDM dictionary is not a list")
153 log.debug(
'TriggerEDM for EDM set {} contains the following collections: {}'.
format(key, Run3TrigEDM) )
157 log.warning(
'Output format: %s is not in list of allowed formats, please check!', key)
161 raise RuntimeError(
"Invalid runVersion=%s supplied to getTriggerEDMList" % runVersion)
168 Finds a given key from within the trigEDMList.
169 Returns true if this collection is produced inside EventViews
170 (Hence, has the special viewIndex Aux decoration applied by steering)
172 from TrigEDMConfig.TriggerEDMRun3
import InViews
175 return any(coll
for coll
in itertools.chain(*trigEDMList)
if
176 len(coll)>3
and theKey==coll[0].
split(
'#')[1]
and
177 any(isinstance(v, InViews)
for v
in coll[3]))
183 keyNoAux = el.split(
'.')[0].
replace(
'Aux',
'')
186 if el.split(
'.')[1] ==
'':
190 return el.split(
'.')[0]+
'.viewIndex'
193 return el.split(
'.')[0]+
'.-'
198 return el+
'.viewIndex'
208 The keys should contain BS and all the identifiers used for scouting.
209 Returns list of tuples (typename#key, [keys], [properties]).
212 from TrigEDMConfig.TriggerEDMRun3
import persistent
215 for definition
in TriggerHLTListRun3:
217 typename,collkey = definition[0].
split(
"#")
221 destination = keys &
set(definition[1].
split())
222 if len(destination) > 0:
223 collections.append( (typename+
"#"+collkey,
list(destination),
224 definition[3]
if len(definition)>3
else []) )
232 Gives back the Python dictionary with the content of ESD/AOD (dst) which can be inserted in OKS.
234 dset =
set(destination.split())
235 from collections
import OrderedDict
236 toadd = OrderedDict()
239 for item
in itertools.chain(*trigEDMList):
249 if colltype
in toadd:
250 if k
not in toadd[colltype]:
251 toadd[colltype] += [k]
253 toadd[colltype] = [k]
261 Modified EDM list to remove all dynamic variables
262 Requires changing the list to have 'Aux.-'
265 from collections
import OrderedDict
266 output = OrderedDict()
267 for k,v
in _edmList.items():
282 Modified EDM list to remove all dynamic variables
283 Requires changing the list to have 'Aux.-'
287 for k,v
in _edmList.items():
291 newnames+=[el.split(
'.')[0]+
'.-']
298 """ From name of object in AOD/ESD found by checkFileTrigSize.py, return category """
300 """ Clean up object name """
309 if s.count(
'.') : s = s[:s.index(
'.')]
310 if s.count(
'::'): s = s[s.index(
':')+2:]
311 if s.count(
'<'): s = s[s.index(
'<')+1:]
312 if s.count(
'>'): s = s[:s.index(
'>')]
313 if s.count(
'.') : s = s[:s.index(
'.')]
314 if s.count(
'Dyn') : s = s[:s.index(
'Dyn')]
320 if s12.startswith(
'HLT_xAOD__')
or s12.startswith(
'HLT_Rec__')
or s12.startswith(
'HLT_Analysis__') :
321 s12 = s12[s12.index(
'__')+2:]
322 s12 = s12[s12.index(
'_')+1:]
325 elif s12.startswith(
'HLT_'):
327 if s12.count(
'_'): s12 = s12[s12.index(
'_')+1:]
328 if s12.count(
'_'): s12 = s12[s12.index(
'_')+1:]
331 TriggerListRun1 = TriggerL2List + TriggerEFList + TriggerResultsRun1List
332 TriggerListRun2 = TriggerResultsList + TriggerLvl1List + TriggerIDTruth + TriggerHLTList
333 TriggerListRun3 = TriggerHLTListRun3
338 """ Loop over all objects already defined in lists (and hopefully categorized!!) """
339 for item
in TriggerListRun1+TriggerListRun2:
342 """ Clean up type name """
343 if t.count(
'::'): t = t[t.index(
':')+2:]
344 if t.count(
'<'): t = t[t.index(
'<')+1:]
345 if t.count(
'>'): t = t[:t.index(
'>')]
346 if (s12.startswith(t)
and s12.endswith(k))
and (len(t) > len(bestMatch)):
350 if k.count(
'.'): k = k[:k.index(
'.')]
355 for item
in TriggerListRun3:
358 """ Clean up type name """
359 if t.count(
'::'): t = t[t.index(
':')+2:]
360 if t.count(
'<'): t = t[t.index(
'<')+1:]
361 if t.count(
'>'): t = t[:t.index(
'>')]
363 if (s.startswith(t)
and s.endswith(k))
and (len(t) > len(bestMatch)):
367 if k.count(
'.'): k = k[:k.index(
'.')]
372 if category ==
'' and 'HLTNav' in s:
375 if category ==
'':
return 'NOTFOUND'
381 """ From the strings containing type and key of trigger EDM extract type and key
383 return s[:s.index(
'#')], s[s.index(
'#')+1:]
386 """ The key is usually HLT_*, this function returns second part of it or empty string
391 return key[key.index(
'_'):].lstrip(
'_')
395 Gives back the Python dictionary with the content of ESD/AOD (dst) which can be inserted in OKS.
397 dset =
set(destination.split())
402 for item
in itertools.chain(*lst):
409 if 'collection' in EDMDetails[t]:
410 colltype = EDMDetails[t][
'collection']
411 if colltype
in toadd:
412 if k
not in toadd[colltype]:
413 toadd[colltype] += [k]
415 toadd[colltype] = [k]
421 Gives back the Python dictionary with the truth trigger content of ESD/AOD (dst) which can be inserted in OKS.
427 Gives back the Python dictionary with the lvl1 trigger result content of ESD which can be inserted in OKS.
433 Gives back the Python dictionary with the lvl1 trigger result content of AOD which can be inserted in OKS.
441 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for L2
444 for item
in TriggerL2List:
445 if len (item[1]) == 0:
continue
454 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want in every event for EF
457 for item
in TriggerEFList:
458 if len (item[1]) == 0:
continue
467 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
470 for item
in TriggerHLTList:
471 if len (item[1]) == 0:
continue
481 List (Literally Python list) of trigger objects to be preregistered i.e. this objects we want for all levels
482 version can be: '1 (Run1)', '2 (Run2)'
493 l=
list(dict.fromkeys(objs))
495 raise RuntimeError(
"Invalid version=%s supplied to getPreregistrationList" % version)
502 List (Literally Python list) of trigger objects to be placed in RAW data. i.e. BS after EF
505 for item
in TriggerEFList:
506 if 'DS' in item[1].
split():
513 List (Literally Python list) of trigger objects to be placed in RAW data. i.e. BS after merged L2EF
516 for item
in TriggerHLTList:
517 if 'DS' in item[1].
split():
524 List (Literally Python list) of L2 trigger objects to be placed in output BS
527 for item
in TriggerL2List:
535 List (Literally Python list) of EF trigger objects to be placed in output BS
538 for item
in TriggerEFList:
546 List (Literally Python list) of merged HLT trigger objects to be placed in output BS
549 for item
in TriggerHLTList:
556 """ List of L2 types to be read from BS, used by the TP
559 for item
in TriggerL2List:
562 if 'collection' in EDMDetails[t]:
563 ctype = EDMDetails[t][
'collection']
568 """ List of EF types to be read from BS, used by the TP
571 for item
in TriggerEFList:
574 if 'collection' in EDMDetails[t]:
575 ctype = EDMDetails[t][
'collection']
580 """ List of HLT types to be read from BS, used by the TP
583 for item
in TriggerHLTList:
586 if 'collection' in EDMDetails[t]:
587 ctype = EDMDetails[t][
'collection']
592 """ List of types to be placed in BS after EF
595 for item
in TriggerEFList:
596 if 'DS' in item[1].
split():
599 if 'collection' in EDMDetails[t]:
600 ctype = EDMDetails[t][
'collection']
605 """ List of types to be placed in BS after L2EF
608 for item
in TriggerHLTList:
609 if 'DS' in item[1].
split():
612 if 'collection' in EDMDetails[t]:
613 ctype = EDMDetails[t][
'collection']
620 Mapping of Transient objects to Peristent during serialization (BS creation)
621 version can be: '1 (Run1)', '2 (Run2)'
629 raise RuntimeError(
"Invalid version=%s supplied to getTPList" % version)
631 for t,d
in EDMDetails.items():
633 if 'collection' in d:
634 colltype = EDMDetails[t][
'collection']
635 if colltype
in bslist:
636 l[colltype] = d[
'persistent']
643 Defines how to rename collecion keys in ARA when two types have the same key.
644 i.e. TrigRoiDescriptorCollection#HLT
646 After the remapping they will be named HLT_tau and HLT_roi so are distinct.
648 edm =
set(TriggerL2List + TriggerEFList + TriggerHLTList)
651 tmp = [ i
for i
in keys
if keys.count(i) > 1 ]
663 if 'typealias' not in EDMDetails[t]
or EDMDetails[t][
'typealias'] ==
'':
664 if nonunique[key] == 1:
667 elif nonunique[key] == t:
671 log.error(
"types/keys will catch %s %s", t, key)
675 if 'collection' in EDMDetails[t]:
676 obj = EDMDetails[t][
'collection']
679 bname = key+
'_'+EDMDetails[t][
'typealias']
681 renames[(key, obj)] = bname
691 for k,v
in typedict.items():
694 if el.startswith(
'HLT_')
or el ==
'HLT':
695 prefixAndLabel = el.split(
'_',1)
696 containername = k
if 'Aux' not in k
else EDMDetails[k][
'parent']
698 containername = re.sub(
'::',
'__',re.sub(
'_v[0-9]+$',
'',containername))
699 newnames+=[
'_'.
join([prefixAndLabel[0],containername]+([prefixAndLabel[1]]
if len(prefixAndLabel) > 1
else []))]
707 List of EF trigger objects that were written to ByteStream in Run 1
710 for item
in TriggerEFEvolutionList:
711 if len (item[1]) == 0:
continue
718 List of Run-2 containers equivalent to Run-1 EF containers
721 for item
in TriggerEFEvolutionList:
722 if len (item[1]) == 0:
continue
729 List of L2 trigger objects that were written to ByteStream in Run 1
732 for item
in TriggerL2EvolutionList:
733 if len (item[1]) == 0:
continue
740 List of Run-2 containers equivalent to Run-1 L2 containers
743 for item
in TriggerL2EvolutionList:
744 if len (item[1]) == 0:
continue