From 15af983d646fe18fd5a057618a3e6721aec9c437 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Thu, 13 Dec 2018 12:45:44 +0000
Subject: [PATCH] More complete trigger output in the ESD

---
 .../python/ElectronMenuConfig.py              |  4 +-
 .../python/PhotonMenuConfig.py                |  3 +-
 .../TrigEDMConfig/python/TriggerEDMRun3.py    | 22 ++++++++---
 .../TriggerJobOpts/python/TriggerConfig.py    | 37 ++++++++++++++++---
 .../Electron/generateElectron.py              |  2 +-
 5 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/ElectronMenuConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/ElectronMenuConfig.py
index d02be104472a..0158dfcdb495 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/python/ElectronMenuConfig.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/python/ElectronMenuConfig.py
@@ -4,7 +4,7 @@
 
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 from TrigT2CaloEgamma.TrigT2CaloEgammaConfig import *
-
+from TrigEDMConfig.TriggerEDMRun3 import recordable
 
 def CaloLUMIBCIDToolCfg( flags, name='CaloLumiBCIDToolDefault' ):
     acc = ComponentAccumulator()
@@ -123,7 +123,7 @@ def l2CaloAlgCfg( flags, roisKey="EMCaloRoIs" ):
     from TrigT2CaloEgamma.TrigT2CaloEgammaConf import T2CaloEgammaFastAlgo
     fastCalo                         = T2CaloEgammaFastAlgo( 'FastEMCaloAlgo' )
     fastCalo.OutputLevel             = DEBUG
-    fastCalo.ClustersName            = 'L2CaloEMClusters'
+    fastCalo.ClustersName            = recordable('L2CaloEMClusters')
     fastCalo.RoIs                    = roisKey
     fastCalo.EtaWidth                = 0.2
     fastCalo.PhiWidth                = 0.2
diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/PhotonMenuConfig.py b/Trigger/TrigValidation/TrigUpgradeTest/python/PhotonMenuConfig.py
index 09546c59da3c..535a6cf7a172 100644
--- a/Trigger/TrigValidation/TrigUpgradeTest/python/PhotonMenuConfig.py
+++ b/Trigger/TrigValidation/TrigUpgradeTest/python/PhotonMenuConfig.py
@@ -4,6 +4,7 @@
 
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 from AthenaCommon.Constants import DEBUG,VERBOSE
+from TrigEDMConfig.TriggerEDMRun3 import recordable
 
 def l2PhotonAlgCfg( flags ):
     acc = ComponentAccumulator()
@@ -11,7 +12,7 @@ def l2PhotonAlgCfg( flags ):
 
     photonFex= L2PhotonFex_1()
     photonFex.TrigEMClusterName = "L2CaloEMClusters"
-    photonFex.PhotonsName = "L2Photons"
+    photonFex.PhotonsName = recordable("L2Photons")
     photonFex.RoIs = "L2PhotonRecoRoIs"
     photonFex.OutputLevel=DEBUG
 
diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
index 7121f9a23da7..d77cc717b2b4 100644
--- a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
+++ b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py
@@ -39,17 +39,27 @@ TriggerHLTList = [
     
 
     
-    ('xAOD::TrigCompositeContainer#L1Seeds',     'BS ESD AODFULL AODSLIM',  'Steer'),
-    ('xAOD::TrigCompositeContainer#L1EM',     'BS ESD AODFULL AODSLIM',  'Steer'),
-    ('xAOD::TrigCompositeContainer#L1MU',     'BS ESD AODFULL AODSLIM',  'Steer'),
-    ('xAOD::TrigCompositeContainer#L1MET',     'BS ESD AODFULL AODSLIM',  'Steer'),
-    ('xAOD::TrigCompositeContainer#L1J',     'BS ESD AODFULL AODSLIM',  'Steer'),
+    ('xAOD::TrigCompositeContainer#L1Seeds',     'BS ESD AODFULL AODSLIM', 'Steer'),
+    ('xAOD::TrigCompositeContainer#L1EM',        'BS ESD AODFULL AODSLIM', 'Steer'),
+    ('xAOD::TrigCompositeContainer#L1MU',        'BS ESD AODFULL AODSLIM', 'Steer'),
+    ('xAOD::TrigCompositeContainer#L1MET',       'BS ESD AODFULL AODSLIM', 'Steer'),
+    ('xAOD::TrigCompositeContainer#L1J',         'BS ESD AODFULL AODSLIM', 'Steer'),
+
+
+    
+    
+    ('xAOD::TrigEMClusterContainer#L2CaloEMClusters',           'BS ESD AODFULL', 'Egamma', 'inViews:FastCaloEMRecoViews'), # last arg specifies in which view container the fragments are
+    ('xAOD::TrigEMClusterAuxContainer#L2CaloEMClustersAux.',    'BS ESD AODFULL', 'Egamma'),
+    ('xAOD::TrigPhotonContainer#L2Photons',                     'BS ESD AODFULL', 'Egamma', 'inViews:L2PhotonRecoViews'),
+    ('xAOD::TrigPhotonAuxContainer#L2PhotonsAux.',              'BS ESD AODFULL', 'Egamma'),
     
+    ('EventInfo#ByteStreamEventInfo',              'ESD', 'Misc'),
+    ('ROIB::RoIBResult#*',                         'ESD', 'Misc'),
 ]
 
 EDMDetails = {}
 
-EDMDetails[ "TrigRoiDescriptor" ]         = {'persistent':"TrigRoiDescriptorCollection_p3",     'typealias':'Roi', 'collection':'TrigRoiDescriptorCollection' }
+EDMDetails[ "TrigRoiDescriptorCollection" ]         = {'persistent':"TrigRoiDescriptorCollection_p3",     'typealias':'Roi', 'collection':'TrigRoiDescriptorCollection' }
 
 
 
diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py
index 416596476077..b770b7233d62 100644
--- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py
+++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py
@@ -106,6 +106,7 @@ def triggerSummaryCfg(flags, hypos):
         __log.info("Final decision of chain  " + c + " will be red from " + cont ) 
     decisionSummaryAlg.FinalDecisionKeys = list(set(allChains.values()))
     decisionSummaryAlg.FinalStepDecisions = allChains
+    decisionSummaryAlg.DecisionsSummaryKey ="HLTSummary"
     return acc, decisionSummaryAlg
         
 
@@ -118,6 +119,7 @@ def triggerMonitoringCfg(flags, hypos, l1Decoder):
     from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool
     mon = TrigSignatureMoniMT()
     mon.L1Decisions="HLTChains"
+    mon.FinalDecisionKey="HLTSummary"
     if len(hypos) == 0:
         __log.warning("Menu is not configured")
         return acc, mon
@@ -144,34 +146,57 @@ def triggerMonitoringCfg(flags, hypos, l1Decoder):
 def triggerOutputStreamCfg( flags, decObj, outputType ):
     """ 
     Configure output stream according to the menu setup (decision objects)
-    and TrigEDMCOnfig (this is still on TODO)
+    and TrigEDMCOnfig
     """
     from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
     itemsToRecord = []
     # decision objects and their Aux stores
-    [ itemsToRecord.extend( [ "xAOD::TrigCompositeContainer#%s"%d, "xAOD::TrigCompositeAuxContainer#%sAux."%d] ) for d in decObj ]
+    def __TCKeys( name ):
+        return [ "xAOD::TrigCompositeContainer#%s" % name, "xAOD::TrigCompositeAuxContainer#%sAux." % name]
+    [ itemsToRecord.extend( __TCKeys(d) ) for d in decObj ]
     # the rest of triger EDM
+    itemsToRecord.extend( __TCKeys( "HLTSummary" ) )
 
+
+    from TrigEDMConfig.TriggerEDMRun3 import TriggerHLTList
+    EDMCollectionsToRecord=filter( lambda x: outputType in x[1] and "TrigCompositeContainer" not in x[0],  TriggerHLTList )
+    itemsToRecord.extend( [ el[0] for el in EDMCollectionsToRecord ] )
+    
     # summary objects
     __log.debug( outputType + " trigger content "+str( itemsToRecord ) )
     acc = OutputStreamCfg( flags, outputType, ItemList=itemsToRecord )
     streamAlg = acc.getEventAlgo("OutputStream"+outputType)
-    streamAlg.ExtraInputs = [("xAOD::TrigCompositeContainer", "HLTFinalDecisions")]
+    streamAlg.ExtraInputs = [("xAOD::TrigCompositeContainer", "HLTSummary")]
+
     return acc
     
 def triggerAddMissingEDMCfg( flags, decObj ):
 
     from DecisionHandling.DecisionHandlingConf import TriggerSummaryAlg    
     EDMFillerAlg = TriggerSummaryAlg( "EDMFillerAlg" )
-    EDMFillerAlg.InputDecision = "HLTChains"
+    EDMFillerAlg.InputDecision  = "HLTChains"
+    EDMFillerAlg.HLTSummary     = "HLTSummaryOutput" # we do not care about this object, configure in order not to clash
 
     from TrigOutputHandling.TrigOutputHandlingConf import HLTEDMCreator
     DecisionObjectsFiller = HLTEDMCreator("DecisionObjectsFiller")
     DecisionObjectsFiller.TrigCompositeContainer = list(decObj)
+    EDMFillerAlg.OutputTools += [ DecisionObjectsFiller ]
 
-    # TODO add configuration for the rest of the EDM
+    from TrigEDMConfig.TriggerEDMRun3 import TriggerHLTList
+    collectionsThatNeedMerging = filter( lambda x: len(x) >= 4 and x[3].startswith("inViews:"),  TriggerHLTList )
+    for c in collectionsThatNeedMerging:
+        tool = HLTEDMCreator(c[0].split("#")[1]+"merger")
+        ctype, cname = c[0].split("#")
+        ctype = ctype.split(":")[-1]        
+        viewsColl = c[3].split(":")[-1]
+        setattr(tool, ctype+"Views", [ viewsColl ] )
+        setattr(tool, ctype+"InViews", [ cname ] )
+        setattr(tool, ctype, [ cname ] )
+        EDMFillerAlg.OutputTools += [ tool ]
+#egammaViewsMerger.TrigEMClusterContainerViews = [ "EMCaloViews" ]
+#egammaViewsMerger.TrigEMClusterContainerInViews = [ clustersKey ]
+#egammaViewsMerger.TrigEMClusterContainer = [ clustersKey ]
 
-    EDMFillerAlg.OutputTools += [ DecisionObjectsFiller ]
     return EDMFillerAlg
     
     
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py
index d2b94502620b..d31ccf04a2db 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLTMenuConfig/Electron/generateElectron.py
@@ -18,7 +18,7 @@ def generateChains( flags,  chainDict ):
     l2CaloHypo = RecoFragmentsPool.retrieve(l2CaloHypoCfg,
                                             flags,
                                             name = 'L2ElectronCaloHypo',
-                                            CaloClusters ='L2CaloEMClusters')
+                                            CaloClusters = 'L2CaloEMClusters' )
 
     l2CaloReco = RecoFragmentsPool.retrieve(l2CaloRecoCfg, flags)
     acc.merge(l2CaloReco)
-- 
GitLab