From 0a16fc2d0e22e2368a7ab5eb320abecf6556a739 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Fri, 12 Oct 2018 12:28:16 +0200
Subject: [PATCH] add DecisionSummary maker alg and rewire monitoring to use it

---
 .../TrigUpgradeTest/share/egamma.withViews.py |   3 +-
 .../TrigUpgradeTest/share/mu.withViews.py     | 138 ++++--------------
 .../TrigUpgradeTest/share/simpleJetJob.py     |   9 +-
 3 files changed, 39 insertions(+), 111 deletions(-)

diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
index d2b08e5a5d9..8f1fe8fde34 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py
@@ -294,7 +294,6 @@ steps = seqAND("HLTSteps", [ step0filter, step0, step1filter, step1, step2filter
 
 from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
 mon = TrigSignatureMoniMT()
-mon.FinalDecisions = [ "ElectronL2Decisions", "MuonL2Decisions", "WhateverElse" ]
 from TrigUpgradeTest.TestUtils import MenuTest
 mon.ChainsList = list( set( topSequence.L1DecoderTest.ChainToCTPMapping.keys() ) )
 #mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
@@ -379,7 +378,7 @@ hltResultMaker.MonTool.Histograms = [ defineHistogram( 'TIME_build', path='EXPER
 ################################################################################
 # assemble top list of algorithms
 
-hltTop = seqOR( "hltTop", [ steps, mon, summary, StreamESD, summMaker, hltResultMaker ] )
+hltTop = seqOR( "hltTop", [ steps, summMaker, mon, hltResultMaker, summary, StreamESD ] )
 topSequence += hltTop
 
 ###### Begin Cost Monitoring block
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/mu.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/mu.withViews.py
index b4a8f2b43d5..30ad737f6bf 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/share/mu.withViews.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/share/mu.withViews.py
@@ -87,7 +87,29 @@ CTPToChainMapping = {"HLT_mu6":       "L1_MU6",
 testChains =[x for x, y in CTPToChainMapping.items()]
 topSequence.L1DecoderTest.ChainToCTPMapping = CTPToChainMapping
 
+def __mon(finalCollName, stepColls=[]):
+    from TrigOutputHandling.TrigOutputHandlingConf import DecisionSummaryMakerAlg
+    summMaker = DecisionSummaryMakerAlg()
+    summMaker.FinalDecisionKeys = [ finalCollName ]
+    summMaker.FinalStepDecisions = dict.fromkeys( testChains, finalCollName )  
+    
+    ### final monitor algorithm  
+    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
+    mon = TrigSignatureMoniMT()
+    from TrigUpgradeTest.TestUtils import MenuTest
+    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
+    mon.OutputLevel = DEBUG
 
+    if len(stepColls) == 0:
+      stepColls=[ finalCollName ]
+    
+    for n, coll in  enumerate(stepColls):
+      stepCollector = DecisionCollectorTool("Step%dCollector" % n )
+      stepCollector.Decisions = [ coll ]
+      mon.CollectorTools += [ stepCollector ]
+
+    
+    return [ summMaker, mon ]
 
 
 # ===============================================================================================
@@ -622,21 +644,9 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==False:
     summary = summarySteps("FinalAlg", ["L2MuonFastDecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "L2MuonFastDecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    mon.CollectorTools = [ step1Collector ]
-
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps]+ __mon("L2MuonFastDecisions")+ [ summary, StreamESD ] )
     topSequence += hltTop   
 
 
@@ -652,21 +662,10 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==False:
     summary = summarySteps("FinalAlg", ["EFMuonSADecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "EFMuonSADecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "EFMuonSADecisions"]
-    mon.CollectorTools = [ step1Collector ]
-
+  
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps] + __mon("EFMuonSADecisions") + [ summary, StreamESD ] )
     topSequence += hltTop   
 
 
@@ -685,23 +684,9 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==False:
     summary = summarySteps("FinalAlg", ["EFMuonSADecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "EFMuonSADecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    step2Collector = DecisionCollectorTool("Step2Collector")
-    step2Collector.Decisions = [ "EFMuonSADecisions"]
-    mon.CollectorTools = [ step1Collector, step2Collector ]
-
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps] + __mon("EFMuonSADecisions", ["L2MuonFastDecisions", "EFMuonSADecisions"]) + [summary, StreamESD ] )
     topSequence += hltTop   
 
 
@@ -722,23 +707,9 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==True:
     summary = summarySteps("FinalAlg", ["MuonL2CBDecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "MuonL2CBDecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    step2Collector = DecisionCollectorTool("Step2Collector")
-    step2Collector.Decisions = [ "MuonL2CBDecisions" ]
-    mon.CollectorTools = [ step1Collector, step2Collector ]
-
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps]+ __mon("MuonL2CBDecisions",["L2MuonFastDecisions", "MuonL2CBDecisions"] ) +[summary, StreamESD ] )
     topSequence += hltTop   
 
 
@@ -760,25 +731,10 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==True:
     summary = summarySteps("FinalAlg", ["EFMuonSADecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "EFMuonSADecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    step2Collector = DecisionCollectorTool("Step2Collector")
-    step2Collector.Decisions = [ "MuonL2CBDecisions" ]
-    step3Collector = DecisionCollectorTool("Step3Collector")
-    step3Collector.Decisions = [ "EFMuonSADecisions"]
-    mon.CollectorTools = [ step1Collector, step2Collector, step3Collector ]
 
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps ] + __mon( "EFMuonSADecisions", [ "L2MuonFastDecisions",  "MuonL2CBDecisions", "EFMuonSADecisions"]) + [summary, StreamESD ] )
     topSequence += hltTop   
 
 
@@ -800,25 +756,9 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==True:
     summary = summarySteps("FinalAlg", ["MuonL2IsoDecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "MuonL2IsoDecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    step2Collector = DecisionCollectorTool("Step2Collector")
-    step2Collector.Decisions = [ "MuonL2CBDecisions" ]
-    step3Collector = DecisionCollectorTool("Step3Collector")
-    step3Collector.Decisions = [ "MuonL2IsoDecisions"]
-    mon.CollectorTools = [ step1Collector, step2Collector, step3Collector ]
-
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps ]+ __mon( "MuonL2IsoDecisions", [ "L2MuonFastDecisions", "MuonL2CBDecisions", "MuonL2IsoDecisions"]) +[ summary, StreamESD ] )
     topSequence += hltTop   
 
  
@@ -840,25 +780,9 @@ if TriggerFlags.doMuon==True and TriggerFlags.doID==True:
     summary = summarySteps("FinalAlg", ["EFMuonSADecisions", "MuonL2IsoDecisions"] )
     summary.OutputTools = [ muonViewsMerger ]
 
-    ### final monitor algorithm
-    from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
-    mon = TrigSignatureMoniMT()
-    mon.FinalDecisions = [ "EFMuonSADecisions", "WhateverElse" ]
-    from TrigUpgradeTest.TestUtils import MenuTest
-    mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
-    mon.OutputLevel = DEBUG
-
-    step1Collector = DecisionCollectorTool("Step1Collector")
-    step1Collector.Decisions = [ "L2MuonFastDecisions" ]
-    step2Collector = DecisionCollectorTool("Step2Collector")
-    step2Collector.Decisions = [ "MuonL2CBDecisions" ]
-    step3Collector = DecisionCollectorTool("Step3Collector")
-    step3Collector.Decisions = [ "EFMuonSADecisions", "MuonL2IsoDecisions"]
-    mon.CollectorTools = [ step1Collector, step2Collector, step3Collector ]
-
     StreamESD = muonStreamESD(muonViewsMerger)
 
-    hltTop = seqOR( "hltTop", [ HLTsteps, mon, summary, StreamESD ] )
+    hltTop = seqOR( "hltTop", [ HLTsteps ] + __mon("EFMuonSADecisions", ["L2MuonFastDecisions", "MuonL2CBDecisions", "EFMuonSADecisions"]) +[ summary, StreamESD ] )
     topSequence += hltTop   
 
    
@@ -866,3 +790,5 @@ def TMEF_TrkMaterialProviderTool(name='TMEF_TrkMaterialProviderTool',**kwargs):
     from TrkMaterialProvider.TrkMaterialProviderConf import Trk__TrkMaterialProviderTool
     kwargs.setdefault("UseCaloEnergyMeasurement", False)
     return Trk__TrkMaterialProviderTool(name,**kwargs)
+
+
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/simpleJetJob.py b/Trigger/TrigValidation/TrigUpgradeTest/share/simpleJetJob.py
index 0fc007edc97..803e33cf457 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/share/simpleJetJob.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/share/simpleJetJob.py
@@ -87,12 +87,15 @@ if TriggerFlags.doCalo:
   
      ### final monitor algorithm
      from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
+     from TrigOutputHandling.TrigOutputHandlingConf import DecisionSummaryMakerAlg
+     summMaker = DecisionSummaryMakerAlg()
+     summMaker.FinalDecisionKeys = [ hypo.HypoOutputDecisions ]
+     summMaker.FinalStepDecisions = dict.fromkeys( testChains, hypo.HypoOutputDecisions )
+
      mon = TrigSignatureMoniMT()
-     mon.FinalDecisions = [ hypo.HypoOutputDecisions ]
      from TrigUpgradeTest.TestUtils import MenuTest
      mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) )
      mon.OutputLevel = DEBUG
-
     
-     hltTop = seqOR( "hltTop", [ HLTsteps, mon ] )
+     hltTop = seqOR( "hltTop", [ HLTsteps, summMaker, mon ] )
      topSequence += hltTop   
-- 
GitLab