diff --git a/Trigger/TrigSteer/TrigOutputHandling/python/TrigOutputHandlingConfig.py b/Trigger/TrigSteer/TrigOutputHandling/python/TrigOutputHandlingConfig.py index 0a83eec373e6a8ec5edb797d000cfbccaee51c6e..3ca1d2507476f8e648b79508554449a2c2a99b35 100644 --- a/Trigger/TrigSteer/TrigOutputHandling/python/TrigOutputHandlingConfig.py +++ b/Trigger/TrigSteer/TrigOutputHandling/python/TrigOutputHandlingConfig.py @@ -1,10 +1,10 @@ # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -def HLTResultMTMakerCfg(): +def HLTResultMTMakerCfg(name="HLTResultMTMaker"): from TrigOutputHandlingConf import HLTResultMTMaker from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool, defineHistogram - m = HLTResultMTMaker() + m = HLTResultMTMaker(name) # ROBs/SubDets which are enabled but not necessarily part of the ROS-ROB map from libpyeformat_helper import SourceIdentifier,SubDetector @@ -42,6 +42,8 @@ def HLTResultMTMakerCfg(): xbins=10, xmin=0, xmax=10 ), defineHistogram( 'sizeMain', path='EXPERT', type='TH1F', title='Main (physics) HLT Result size;4B words', xbins=100, xmin=-1, xmax=999 ) ] # 1000 k span + + return m def TriggerEDMSerialiserToolCfg(name): @@ -85,4 +87,11 @@ def TriggerEDMSerialiserToolCfg(name): return self.__repr__() serialiser.CollectionsToSerialize = OD() + + from TrigSerializeTP.TrigSerializeTPConf import TrigSerTPTool + from TrigEDMConfig.TriggerEDMRun3 import tpMap + tpTool = TrigSerTPTool() + tpTool.TPMap = tpMap() + serialiser.TPTool = tpTool + return serialiser diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py b/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py index f569bc47d3e2f77eae00af5ccba93ea8c9078b2e..b68a1f8219538b5e019a0c538290a70b7fbc0e60 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/newJOtest.py @@ -22,6 +22,8 @@ flags.Detector.GeometryMDT = True flags.Detector.GeometryTGC = True flags.Detector.GeometryCSC = True flags.Detector.GeometryRPC = True +flags.Trigger.writeBS=True # switches on HLTResultMT creation + flags.needFlagsCategory('Trigger') setupMenu(flags) @@ -76,12 +78,9 @@ acc.foreach_component("*HLTTop/*GenericMonitoringTool*").OutputLevel = WARNING # acc.printConfig() + fname = "newJOtest.pkl" print "Storing config in the config", fname with file(fname, "w") as p: acc.store( p, nEvents=10, useBootStrapFile=False, threaded=True ) p.close() - - - - diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py index b9d1ad7ebafa2ae42e8a391bded383fdeed131a5..1be86b7e7f9fc9334197c291c9d5bb83edcd792d 100644 --- a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py +++ b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun3.py @@ -59,8 +59,36 @@ TriggerHLTList = [ EDMDetails = {} -EDMDetails[ "TrigRoiDescriptorCollection" ] = {'persistent':"TrigRoiDescriptorCollection_p3", 'typealias':'Roi', 'collection':'TrigRoiDescriptorCollection' } +EDMDetails[ "TrigRoiDescriptorCollection" ] = {'persistent':"TrigRoiDescriptorCollection_p3"} +EDMDetails[ "xAOD::TrigCompositeAuxContainer" ] = {'persistent':"xAOD::TrigCompositeAuxContainer_v2"} + +EDMDetails[ "xAOD::TrigEMClusterAuxContainer" ] = {'persistent':"xAOD::TrigEMClusterAuxContainer_v2"} + + + +def persistent( transient ): + """ + Persistent EDM claass, for xAOD it is the actual class version + + Uses list defined above. If absent assumes v1 + """ + if transient in EDMDetails: + return EDMDetails[transient]['persistent'] + return transient+"_v1" + + +def tpMap(): + """ + List + """ + l = {} + for tr in EDMDetails.keys(): + if "xAOD" in tr: + continue + l[tr] = persistent(tr) + return l + diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py index 9fbf72f64a17698d05e01c90944b93e1a575fe94..40a6a7e5428f6db0c6a335dee62a9b0266efaa1e 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/TriggerConfig.py @@ -32,7 +32,7 @@ def collectHypos( steps ): __log.info( "found hypo " + alg.name() + " in " +stepSeq.name() ) hypos[stepSeq.name()].append( alg ) else: - __log.info("DID NOT FIND HYPO" + alg.name()) + __log.verbose("Not a hypo" + alg.name()) return hypos def __decisionsFromHypo( hypo ): @@ -43,6 +43,19 @@ def __decisionsFromHypo( hypo ): return [ t.name() for t in hypo.HypoTools ], hypo.HypoOutputDecisions +def collectViewMakers( steps ): + """ collect all view maker algorithms in the configuration """ + makers = {} # map with name, instance and encompasing recoSequence + for stepSeq in steps.getChildren(): + for recoSeq in stepSeq.getChildren(): + algsInSeq = flatAlgorithmSequences( recoSeq ) + for seq,algs in algsInSeq.iteritems(): + for alg in algs: + if "EventViewCreator" in alg.getFullName(): # TODO base it on checking types of write handles once available + makers[alg.name()] = (alg, recoSeq) + __log.info("Found View Makers: {}".format( " ".join( makers.keys() ) ) ) + return makers + def collectFilters( steps ): """ @@ -170,6 +183,46 @@ def triggerOutputStreamCfg( flags, decObj, outputType ): return acc +def triggerBSOutputCfg( flags, decObj ): + """ + Configure output to be saved in BS + """ + acc = ComponentAccumulator() + + + + from TrigEDMConfig.TriggerEDMRun3 import TriggerHLTList, persistent + from TrigOutputHandling.TrigOutputHandlingConf import HLTResultMTMakerAlg # , StreamTagMakerTool, TriggerBitsMakerTool # TODO add config of these two + from TrigOutputHandling.TrigOutputHandlingConfig import TriggerEDMSerialiserToolCfg, HLTResultMTMakerCfg + + serialiser = TriggerEDMSerialiserToolCfg("Serialiser") + for coll in decObj: + serialiser.addCollectionListToMainResult( [ "{}#remap_{}".format( persistent("xAOD::TrigCompositeContainer"), coll ), + "{}#remap_{}Aux.".format( persistent("xAOD::TrigCompositeAuxContainer"), coll )] ) + + # EDM + EDMCollectionsToRecord=filter( lambda x: "BS" in x[1], TriggerHLTList ) + for item in EDMCollectionsToRecord: + typeName, collName = item[0].split("#") + serialisedTypeColl="{}#{}".format(persistent(typeName), collName) + __log.info( "Serialising {}".format( serialisedTypeColl ) ) + serialiser.addCollectionListToMainResult( [ serialisedTypeColl ] ) + + + # not configuring the two tools below now as we soon will change method to configure them (via TrigConfigSvc) + #stmaker = StreamTagMakerTool() + #bitsmaker = TriggerBitsMakerTool() + + + hltResultMakerTool = HLTResultMTMakerCfg("MakerTool") # want short nme to see in the log + hltResultMakerTool.MakerTools = [ serialiser ] #, stmaker, bitsmaker ] + hltResultMakerAlg = HLTResultMTMakerAlg() + hltResultMakerAlg.ResultMaker = hltResultMakerTool + acc.addEventAlgo( hltResultMakerAlg ) + + return acc + + def triggerAddMissingEDMCfg( flags, decObj ): from DecisionHandling.DecisionHandlingConf import TriggerSummaryAlg @@ -182,19 +235,32 @@ def triggerAddMissingEDMCfg( flags, decObj ): EDMFillerAlg.OutputTools += [ DecisionObjectsFiller ] 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 ] ) + needMerging = filter( lambda x: len(x) >= 4 and x[3].startswith("inViews:"), TriggerHLTList ) + __log.info("These collections need merging: {}".format( " ".join([ c[0] for c in needMerging ])) ) + # group by the view collection name/view maker + from collections import defaultdict + groupedByView = defaultdict(list) + [ groupedByView[c[3]].append( c ) for c in needMerging ] + + for view, colls in groupedByView.iteritems(): + viewCollName = view.split(":")[1] + tool = HLTEDMCreator( "Merger{}".format( viewCollName ) ) + from AthenaCommon.Constants import DEBUG + tool.OutputLevel = DEBUG + for coll in colls: + ctype, cname = coll[0].split("#") + ctype = ctype.split(":")[-1] + viewsColl = coll[3].split(":")[-1] + setattr(tool, ctype+"Views", [ viewsColl ] ) + setattr(tool, ctype+"InViews", [ cname ] ) + setattr(tool, ctype, [ cname ] ) + + # need to add TC collections that need to be remap + #hypo = findClosestHypo( viewCollName ) + #tool.TrigCompositeContainer += hypo.HypoOutputDecisions + EDMFillerAlg.OutputTools += [ tool ] -#egammaViewsMerger.TrigEMClusterContainerViews = [ "EMCaloViews" ] -#egammaViewsMerger.TrigEMClusterContainerInViews = [ clustersKey ] -#egammaViewsMerger.TrigEMClusterContainer = [ clustersKey ] + return EDMFillerAlg @@ -239,7 +305,7 @@ def triggerRunCfg( flags, menu=None ): # collect hypothesis algorithms from all sequence hypos = collectHypos( HLTSteps ) filters = collectFilters( HLTSteps ) - + summaryAcc, summaryAlg = triggerSummaryCfg( flags, hypos ) acc.merge( summaryAcc ) @@ -257,19 +323,25 @@ def triggerRunCfg( flags, menu=None ): acc.merge( menuAcc ) - # output - # if any output stream is requested, schedule "gap" filling algorithm - if flags.Output.ESDFileName != "" or flags.Output.AODFileName != "": - acc.addEventAlgo( triggerAddMissingEDMCfg( flags, decObj ), sequenceName= "HLTTop" ) + + - # configure streams - if flags.Output.ESDFileName != "": - acc.merge( triggerOutputStreamCfg( flags, decObj, "ESD" ) ) - if flags.Output.AODFileName != "": - acc.merge( triggerOutputStreamCfg( flags, decObj, "AOD" ) ) + # output + # if any output stream is requested, schedule merging & gap filling algorithm + if any( (flags.Output.ESDFileName != "", flags.Output.AODFileName != "", flags.Trigger.writeBS) ): + # configure views merging + acc.addEventAlgo( triggerAddMissingEDMCfg( flags, decObj ), sequenceName="HLTTop" ) + + # configure streams + if flags.Output.ESDFileName != "": + acc.merge( triggerOutputStreamCfg( flags, decObj, "ESD" ) ) + if flags.Output.AODFileName != "": + acc.merge( triggerOutputStreamCfg( flags, decObj, "AOD" ) ) + if flags.Trigger.writeBS: + acc.merge( triggerBSOutputCfg( flags, decObj ) ) return acc