10from TrigEDMConfig.TriggerEDMRun2
import TriggerResultsList,TriggerLvl1List,TriggerHLTList,EDMDetails,EDMLibraries
11from TrigEDMConfig.TriggerEDMRun3
import TriggerHLTListRun3,varToRemoveFromAODSLIM,EDMDetailsRun3,getRun3LowMuEDM
12from TrigEDMConfig.TriggerEDMRun4
import TriggerHLTListRun4,EDMDetailsRun4
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.
79 existing_collections = [(c[0].
split(
"#")[1]).
split(
".")[0]
for c
in edmList]
81 for item
in extraList:
82 colname = (item[0].
split(
"#")[1]).
split(
".")[0]
83 if colname
not in existing_collections:
86 edmList.insert(insert_idx+1,item)
88 edmList.insert(insert_idx,item)
89 log.info(
"added new item to Trigger EDM: {}".format(item))
92 isAux =
"Aux." in item[0]
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]]
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))
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]
114 tags = existingItem[3]
if len(existingItem) > 3
else None
115 edmList.pop(existing_item_nr[0])
116 combName = typename +
"#" + colname
118 combName +=
"." + newVars
120 edmList.insert(existing_item_nr[0], (combName, newTargets, signature, tags))
122 edmList.insert(existing_item_nr[0] , (combName, newTargets, signature))
123 log.info(
"updated item in Trigger EDM: {}".format(edmList[existing_item_nr[0]]))
126 log.error(
"edmList contains inconsistencies!")
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
134 runVersion = flags.Trigger.EDMVersion
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))
142 elif runVersion == 4:
143 edm4ListCopy = TriggerHLTListRun4.copy()
144 edm4protoListCopy = TriggerHLTListProtoRun4.copy()
145 log.debug(
"Removing duplicated item between TriggerHLTListProtoRun4 and TriggerHLTListRun4.")
146 for i
in range(len(edm4protoListCopy)-1, -1, -1):
147 for r4item
in edm4ListCopy:
148 if edm4protoListCopy[i][0] == r4item[0]:
149 del edm4protoListCopy[i]
150 log.error(f
"- Dupe: {r4item} appears in both TriggerHLTListProtoRun4.py and TriggerHLTListRun4.py - please resolve the duplication.")
152 lenPreMerge = len(edm4ListCopy)
153 edm4ListCopy.extend(edm4protoListCopy)
154 lenPostMerge = len(edm4ListCopy)
155 edmListCopy = edm4ListCopy
156 log.info(f
"Added TriggerHLTListProtoRun4 to TriggerHLTListRun4. EDM entries {lenPreMerge} -> {lenPostMerge}")
158 errMsg=
"ERROR the getRawTriggerEDMList function supports runs 3 and 4."
160 raise RuntimeError(errMsg)
162 if flags
and flags.Trigger.ExtraEDMList:
163 log.info(
"Adding extra collections to EDM %i: %s", runVersion, str(flags.Trigger.ExtraEDMList))
170 List (Literally Python dict) of trigger objects to be placed with flags:
171 flags is the CA flag container
172 key can be" 'ESD', 'AODSLIM', 'AODFULL'
173 runVersion can be: '-1 (Auto-configure)', '1 (Run1)', '2 (Run2)', '3' (Run 3), '4' (Run 4)
177 runVersion = flags.Trigger.EDMVersion
180 raise RuntimeError(
"Run-1 EDM is no longer supported")
182 elif runVersion == 2:
186 elif runVersion >= 3:
189 if key
not in AllowedOutputFormats:
190 log.warning(
'Output format: %s is not in list of allowed formats, please check!', key)
200 elif "AODSLIM" in key:
204 if len(varToRemoveFromAODSLIM) == 0:
206 log.info(
"No decorations are listed to be removed from AODSLIM")
209 log.info(
"The following decorations are going to be removed from the listed collections in AODSLIM {}".format(varToRemoveFromAODSLIM))
212 for cont, values
in Run3TrigEDMSLIM.items():
213 if (isinstance(values, list)):
217 coll = value.split(
'.')[0]
219 varRemovedFlag =
False
220 for myTuple
in varToRemoveFromAODSLIM:
223 if var
in value
and coll
in myTuple:
224 varRemovedFlag =
True
225 removeVar =
'.'+var+
'.'
226 newValue = newValue.replace(removeVar,
'.')
228 if newValue[-1:] ==
'.':
229 newValue = newValue[:-1]
231 if varRemovedFlag
is False:
232 newValues.append(value)
233 elif varRemovedFlag
is True:
234 newValues.append(newValue)
236 raise RuntimeError(
"Decoration removed but no new Value was available, not sure what to do...")
239 Run3TrigEDM[cont] = newValues
241 raise RuntimeError(
"Value in Run3TrigEDM dictionary is not a list")
246 log.debug(
'TriggerEDM for EDM set {} contains the following collections: {}'.format(key, Run3TrigEDM) )
251 raise RuntimeError(
"Invalid runVersion=%s supplied to getTriggerEDMList" % runVersion)
343 Extend TriggerHLTListi Run3/Run4 with HLT Navigation objects
349 HLTNavEDMTargets =
''
353 if not flags.Trigger.doOnlineNavigationCompactification:
356 HLTNavEDMTargets =
'BS ESD'
358 for decisionCollection
in allDecisions:
360 if decisionCollection
in hypoDecisions:
362 dynamic =
'.remap_linkColIndices.remap_linkColKeys'
363 if 'PEBInfoWriter' in decisionCollection:
364 dynamic +=
'.PEBROBList.PEBSubDetList'
365 typeName =
'xAOD::TrigCompositeContainer#{:s}'.format(decisionCollection)
366 typeNameAux =
'xAOD::TrigCompositeAuxContainer#{:s}Aux{:s}'.format(decisionCollection, dynamic)
370 thisCollectionHLTNavEDMTargets = HLTNavEDMTargets
371 if decisionCollection.startswith(
"HLTNav_FStep")
or decisionCollection ==
"HLTNav_Summary" or decisionCollection.startswith(
"HLTNav_L1"):
372 thisCollectionHLTNavEDMTargets +=
' CostMonDS'
374 edmList[insert_idx:insert_idx] = [
375 (typeName, thisCollectionHLTNavEDMTargets,
'Steer'),
376 (typeNameAux, thisCollectionHLTNavEDMTargets,
'Steer')]
717 Checks EDM list entries for serialization and configuration compliance.
721 _noAuxList = [
"xAOD::" + contType
for contType
in [
"TrigConfKeys",
"BunchConfKey"]]
723 cgen = clidGenerator(
"",
False)
725 found_allow_truncation =
False
726 serializable_names = []
727 serializable_names_no_label = []
728 serializable_names_no_properties = []
730 for i, edm
in enumerate(edm_list):
734 log.error(
"EDM entry too short for " + edm[0])
738 serializable_name = edm[0]
739 serializable_name_no_label = re.sub(
r"\#.*",
"", serializable_name)
740 serializable_name_no_properties = serializable_name.split(
'.')[0]
742 serializable_names.append(serializable_name)
743 serializable_names_no_label.append(serializable_name_no_label)
744 serializable_names_no_properties.append(serializable_name_no_properties)
748 log.error(
"no CLID for " + serializable_name)
752 if "Aux" not in serializable_name
and "." in serializable_name:
753 log.error(
"A '.' found in non-Aux container name " + serializable_name)
757 if "Aux" in serializable_name
and "Aux." not in serializable_name:
758 log.error(
"no final Aux. in label for " + serializable_name)
762 if serializable_name.count(
"#") != 1:
763 log.error(
"Invalid naming structure for " + serializable_name)
767 if serializable_name.startswith(
"xAOD")
and "Aux" not in serializable_name:
768 cont_type,cont_name = serializable_name.split(
"#")
769 if cont_type
not in _noAuxList:
771 if len(edm_list) == i+1:
773 cont_to_test =
"nothing"
775 cont_to_test = edm_list[i+1][0].
split(
".")[0]+
"."
776 cont_type_short = cont_type.replace(
"Container",
"")
777 pattern = re.compile(cont_type_short+
r".*Aux.*\#"+cont_name+
"Aux.")
778 if not pattern.match(cont_to_test):
780 shallow_pattern = re.compile(
"xAOD::ShallowAuxContainer#"+cont_name+
"Aux.")
781 if not shallow_pattern.match(cont_to_test):
784 log.error(
"Expected relevant Aux container following interface container %s, but found %s instead.",serializable_name,cont_to_test)
789 if len(edm_list[i+1]) > 1
and cont_to_test.count(
"#") == 1:
790 contname_to_test = cont_to_test.split(
"#")[1]
791 targets_to_test =
set(edm_list[i+1][1].
split())
792 if len(targets ^ targets_to_test) > 0:
793 log.error(
"Targets of %s (%s) and %s (%s) do not match",cont_name,targets,contname_to_test,targets_to_test)
797 if i>0
and "Aux" in serializable_name
and "Aux" in edm_list[i-1][0]:
798 log.error(f
"Aux container {serializable_name} needs to folow the "
799 "associated interface container in the EDM list")
804 file_types = edm[1].
split()
805 for file_type
in file_types:
806 if file_type
not in AllowedOutputFormats:
807 log.error(
"unknown file type " + file_type +
" for " + serializable_name)
809 for higher_level,required_lower_level
in [(
'AOD',
'ESD'), (
'SLIM',
'AODFULL')]:
810 if higher_level
in file_type
and required_lower_level
not in file_types:
811 log.error(
"Target list for %s containing '%s' must also contain lower level target '%s'.",serializable_name,file_type,required_lower_level)
815 tags = edm[3]
if len(edm) > 3
else None
816 allow_truncation_flag =
False
818 allow_truncation_flag = allowTruncation
in tags
819 if allow_truncation_flag:
820 found_allow_truncation =
True
822 if found_allow_truncation
and not allow_truncation_flag:
823 log.error(
"All instances of 'allowTruncation' need to be at the END of the EDM serialisation list")
830 if len(
set(serializable_names_no_properties)) != len(serializable_names_no_properties):
831 log.error(
"Duplicates in EDM list! Duplicates found:")
833 for item, count
in collections.Counter(serializable_names_no_properties).items():
835 log.error(str(count) +
"x: " + str(item))
839 if check_edmdetails_for_version > 0:
841 if check_edmdetails_for_version == 3:
842 EDMDetailList = EDMDetailsRun3
843 elif check_edmdetails_for_version >= 4:
844 EDMDetailList = EDMDetailsRun4
845 else: log.warning(
"No EDMDetails for EDM version %d. Skipping EDMDetails check.", check_edmdetails_for_version)
847 for EDMDetail
in EDMDetailList:
848 if EDMDetail
not in serializable_names_no_label:
849 msg =
"EDMDetail for " + EDMDetail +
" does not correspond to any name in TriggerList"
852 else: log.debug(
"Skipping EDMDetails check.")