From b0c2506219ad87df01a809bd15d4a9ddc5583936 Mon Sep 17 00:00:00 2001 From: cdelitzs <chris.malena.delitzsch@cern.ch> Date: Tue, 10 May 2022 09:49:59 +0200 Subject: [PATCH 1/3] Add protection in case prereq not able to run --- .../Jet/JetRecConfig/python/JetRecConfig.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py index db009e48d2ca..aefdb9978519 100644 --- a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py +++ b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py @@ -690,7 +690,7 @@ def removeComponentFailingConditions(jetdef, configflags=None, raiseOnFailure=Tr nOut+=1 jetlog.info(f"{fullname} : removing {compType} {comp} reason={reason}") - if fullkey in jetdef._prereqOrder: + if fullkey in jetdef._prereqOrder: jetdef._prereqOrder.remove(fullkey) if compType=='ghost': removeFromList(jetdef._prereqOrder, 'input:'+comp) @@ -749,6 +749,18 @@ def removeGroomModifFailingConditions(groomdef, configflags, raiseOnFailure=True groomdef.modifiers = mods_filtered + for prereq in groomdef._prereqDic: + cInstance = groomdef._prereqDic[prereq] + ok, reason = isComponentPassingConditions(cInstance, configflags, groomdef._prereqDic) + + if not ok : + if raiseOnFailure: + raise Exception("JetGrooming {} can NOT be scheduled. Failure of {} {} reason={}".format( + groomdef, 'prereq', prereq, reason) ) + + jetlog.info(f"{groomdef.fullname()} : removing prerequisite {prereq} reason={reason}") + + removeFromList(groomdef._prereqOrder, prereq) def isComponentPassingConditions(component, configflags, prereqDic): """Test if component is compatible with configflags. -- GitLab From fad69b290d6b7fe4ce7eccac8ad77a75a006a21e Mon Sep 17 00:00:00 2001 From: cdelitzs <chris.malena.delitzsch@cern.ch> Date: Tue, 10 May 2022 09:50:32 +0200 Subject: [PATCH 2/3] Protection in case PrimaryVertices not available --- .../src/HLTMinBiasEffMonitoringAlg.cxx | 12 ++++++------ .../src/HLTMinBiasTrkMonAlg.cxx | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasEffMonitoringAlg.cxx b/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasEffMonitoringAlg.cxx index 0b6495656328..b39525cb48bd 100644 --- a/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasEffMonitoringAlg.cxx +++ b/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasEffMonitoringAlg.cxx @@ -37,15 +37,15 @@ StatusCode HLTMinBiasEffMonitoringAlg::fillHistograms(const EventContext& contex auto vertexHandle = SG::makeHandle(m_vertexKey, context); const xAOD::Vertex* priVtx = nullptr; - for (auto vtx : *vertexHandle) { - if (vtx->vertexType() == xAOD::VxType::PriVtx) { - priVtx = vtx; - break; + if(vertexHandle.isValid()){ + for (auto vtx : *vertexHandle) { + if (vtx->vertexType() == xAOD::VxType::PriVtx) { + priVtx = vtx; + break; + } } } - - auto offlineTrkHandle = SG::makeHandle(m_offlineTrkKey, context); int countPassing = 0; int countPassingVtx = 0; diff --git a/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasTrkMonAlg.cxx b/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasTrkMonAlg.cxx index db457e415530..c4a67ad52f9e 100644 --- a/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasTrkMonAlg.cxx +++ b/Trigger/TrigMonitoring/TrigMinBiasMonitoring/src/HLTMinBiasTrkMonAlg.cxx @@ -111,13 +111,16 @@ StatusCode HLTMinBiasTrkMonAlg::monitorTrkCounts(const EventContext& context) co float priVtxZ = 999; // intentionally - initial zPos auto vertexHandle = SG::makeHandle(m_vertexKey, context); const xAOD::Vertex* priVtx = nullptr; - for (auto vtx : *vertexHandle) { - if (vtx->vertexType() == xAOD::VxType::PriVtx) { - priVtxZ = vtx->z(); - priVtx = vtx; - break; + if(vertexHandle.isValid()){ + for (auto vtx : *vertexHandle) { + if (vtx->vertexType() == xAOD::VxType::PriVtx) { + priVtxZ = vtx->z(); + priVtx = vtx; + break; + } } } + auto offlineVtxZ = Scalar("offlineVtxZ", priVtxZ); auto offlineTrkHandle = SG::makeHandle(m_offlineTrkKey, context); @@ -247,4 +250,4 @@ StatusCode HLTMinBiasTrkMonAlg::monitorTrkCounts(const EventContext& context) co } return StatusCode::SUCCESS; -} \ No newline at end of file +} -- GitLab From dff4088e147bf48a6cce8247a9604bbb3ab00115 Mon Sep 17 00:00:00 2001 From: cdelitzs <chris.malena.delitzsch@cern.ch> Date: Wed, 11 May 2022 11:39:20 +0200 Subject: [PATCH 3/3] Avoid code duplication for removal of prereqs/mods --- .../Jet/JetRecConfig/python/JetRecConfig.py | 95 +++++++------------ 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py index aefdb9978519..3767d612872a 100644 --- a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py +++ b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py @@ -671,37 +671,6 @@ def removeComponentFailingConditions(jetdef, configflags=None, raiseOnFailure=Tr ## do not raise an exceptin immediately. Instead collect all failure ## then report all of them, then raise - fullname = jetdef.fullname() - - # define a helper function returning a filtered list of components. - def filterList(inList, compType): - nOut=0 - outList=[] - basekey= compType+':' if compType!="" else "" - # loop over components in the list to be filtered - for comp in inList: - fullkey = basekey+comp - cInstance = jetdef._prereqDic[fullkey] - ok, reason = isComponentPassingConditions(cInstance, jetdef._cflags, jetdef._prereqDic) - if not ok : - if raiseOnFailure: - raise Exception("JetDefinition {} can NOT be scheduled. Failure of {} {} reason={}".format( - jetdef, compType, comp, reason) ) - - nOut+=1 - jetlog.info(f"{fullname} : removing {compType} {comp} reason={reason}") - if fullkey in jetdef._prereqOrder: - jetdef._prereqOrder.remove(fullkey) - if compType=='ghost': - removeFromList(jetdef._prereqOrder, 'input:'+comp) - removeFromList(jetdef._prereqOrder, 'extinput:'+comp) - else: - outList.append(comp) - jetlog.info(" *** Number of {} filtered components = {} final list={}".format(compType, nOut, outList) ) - - return outList - # --------- - # --------- # first check if the input can be obtained. If not return. ok,reason = isComponentPassingConditions( jetdef.inputdef, jetdef._cflags, jetdef._prereqDic) @@ -713,54 +682,61 @@ def removeComponentFailingConditions(jetdef, configflags=None, raiseOnFailure=Tr if isinstance( jetdef.inputdef, JetInputConstitSeq): # remove ConstitModifiers failing conditions. - jetdef.inputdef.modifiers = filterList( jetdef.inputdef.modifiers, 'cmod' ) + jetdef.inputdef.modifiers = filterJetDefList(jetdef, jetdef.inputdef.modifiers, 'cmod', raiseOnFailure, jetdef._cflags) # call the helper function to perform filtering : - jetdef.ghostdefs = filterList( jetdef.ghostdefs, "ghost") - jetdef.modifiers = filterList( jetdef.modifiers, "mod") + jetdef.ghostdefs = filterJetDefList(jetdef, jetdef.ghostdefs, "ghost", raiseOnFailure, jetdef._cflags) + jetdef.modifiers = filterJetDefList(jetdef, jetdef.modifiers, "mod", raiseOnFailure, jetdef._cflags) # finally filter all possible intermediate dependency : - filterList( list(jetdef._prereqOrder), "") + filterJetDefList(jetdef, list(jetdef._prereqOrder), "", raiseOnFailure, jetdef._cflags) return True def removeGroomModifFailingConditions(groomdef, configflags, raiseOnFailure=True): - mods_filtered = [] - - for mod in groomdef.modifiers: - fullkey = 'mod:'+mod - cInstance = groomdef._prereqDic[fullkey] - ok, reason = isComponentPassingConditions(cInstance, configflags, groomdef._prereqDic) + groomdef.modifiers = filterJetDefList(groomdef, groomdef.modifiers, "mod", raiseOnFailure, configflags) + filterJetDefList(groomdef, list(groomdef._prereqOrder), "", raiseOnFailure, configflags) - if not ok : - if raiseOnFailure: - raise Exception("JetGrooming {} can NOT be scheduled. Failure of {} {} reason={}".format( - groomdef, 'mod', mod, reason) ) - jetlog.info(f"{groomdef.fullname()} : removing modifier {mod} reason={reason}") - if fullkey in groomdef._prereqOrder: - groomdef._prereqOrder.remove(fullkey) - else: - mods_filtered.append(mod) +# define a helper function to filter components from jet definition +def filterJetDefList(jetdef, inList, compType, raiseOnFailure, configFlags): - groomdef.modifiers = mods_filtered + nOut=0 + outList=[] + basekey= compType+':' if compType!="" else "" - for prereq in groomdef._prereqDic: - cInstance = groomdef._prereqDic[prereq] - ok, reason = isComponentPassingConditions(cInstance, configflags, groomdef._prereqDic) + fullname = jetdef.fullname() + # loop over components in the list to be filtered + for comp in inList: + fullkey = basekey+comp + cInstance = jetdef._prereqDic[fullkey] + ok, reason = isComponentPassingConditions(cInstance, configFlags, jetdef._prereqDic) if not ok : if raiseOnFailure: - raise Exception("JetGrooming {} can NOT be scheduled. Failure of {} {} reason={}".format( - groomdef, 'prereq', prereq, reason) ) + raise Exception("JetDefinition {} can NOT be scheduled. Failure of {} {} reason={}".format( + jetdef, compType, comp, reason) ) + + nOut+=1 + jetlog.info(f"{fullname} : removing {compType} {comp} reason={reason}") + if fullkey in jetdef._prereqOrder: + jetdef._prereqOrder.remove(fullkey) + if compType=='ghost': + removeFromList(jetdef._prereqOrder, 'input:'+comp) + removeFromList(jetdef._prereqOrder, 'extinput:'+comp) + else: + outList.append(comp) + + jetlog.info(" *** Number of {} filtered components = {} final list={}".format(compType, nOut, outList) ) + + return outList + - jetlog.info(f"{groomdef.fullname()} : removing prerequisite {prereq} reason={reason}") - removeFromList(groomdef._prereqOrder, prereq) def isComponentPassingConditions(component, configflags, prereqDic): """Test if component is compatible with configflags. @@ -780,9 +756,6 @@ def isComponentPassingConditions(component, configflags, prereqDic): - - - def isAthenaRelease(): return 'Ath' in os.environ.get("AtlasProject", "") -- GitLab