def JetTrackingSequence(dummyFlags, trkopt, RoIs): jetTrkSeq = parOR("JetTrackingSeq_" + trkopt, []) tracksname = "" verticesname = "" if trkopt == "ftf": from TrigInDetConfig.InDetSetup import makeInDetAlgsNoView # Guess FS rather than making it jet-specific? viewAlgs = makeInDetAlgsNoView("JetFS", "FS", rois=recordable(RoIs)) jetTrkSeq += viewAlgs tracksname = recordable("HLT_IDTrack_FS_FTF") verticesname = recordable("HLT_IDVertex_FS") from TrigInDetConfig.TrigInDetPriVtxConfig import makeVertices vtxAlgs = makeVertices("jet", tracksname, verticesname) prmVtx = vtxAlgs[-1] jetTrkSeq += prmVtx tvaname = "JetTrackVtxAssoc_" + trkopt trkcolls = { "Tracks": tracksname, "Vertices": verticesname, "TVA": tvaname, } from JetRecTools.JetRecToolsConfig import trackcollectionmap if trkopt not in trackcollectionmap.keys(): trackcollectionmap[trkopt] = trkcolls # Jet track selection jettrackselloose = getTrackSelTool(trkopt, doWriteTracks=True) jettracksname = jettrackselloose.OutputContainer jettvassoc = getTrackVertexAssocTool(trkopt) trackcollectionmap[trkopt]["JetTracks"] = jettracksname trackcollectionmap[trkopt]["TVA"] = tvaname jettrkprepalg = CompFactory.JetAlgorithm("jetalg_TrackPrep") jettrkprepalg.Tools = [jettrackselloose, jettvassoc] jetTrkSeq += conf2toConfigurable(jettrkprepalg) label = "GhostTrack_{}".format(trkopt) ghosttracksname = "PseudoJet{}".format(label) trackcollectionmap[trkopt]["GhostTracks"] = ghosttracksname trackcollectionmap[trkopt]["GhostTracksLabel"] = label pjgalg = CompFactory.PseudoJetAlgorithm("pjgalg_" + label, InputContainer=tracksname, OutputContainer=ghosttracksname, Label=label, SkipNegativeEnergy=True) jetTrkSeq += conf2toConfigurable(pjgalg) return jetTrkSeq, trkcolls
def make_l1_seq(options=default_options): from AthenaCommon.CFElements import seqOR l1_seq = seqOR('l1Seq') # Configure L1 decoding flags ConfigFlags.Trigger.enableL1Phase1 = options.EnableL1Phase1 ConfigFlags.Trigger.enableL1CaloLegacy = options.EnableL1CaloLegacy # Create inputs for L1Decoder from ByteStream from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1TriggerByteStreamDecoderCfg acc = L1TriggerByteStreamDecoderCfg(ConfigFlags) l1_seq += conf2toConfigurable(acc.getPrimary()) acc.wasMerged() if ConfigFlags.Trigger.enableL1Phase1: from L1Decoder.L1DecoderConfig import getL1TriggerResultMaker l1_seq += conf2toConfigurable(getL1TriggerResultMaker()) # Set menu for L1ConfigSvc from TriggerJobOpts.TriggerFlags import TriggerFlags TriggerFlags.triggerMenuSetup = "LS2_v1" # Ensure LVL1ConfigSvc is initialised before L1Decoder handles BeginRun incident # This should be done by the L1Decoder configuration in new-style job options (with component accumulator) from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc from AthenaCommon.AppMgr import ServiceMgr as svcMgr svcMgr += getL1ConfigSvc(ConfigFlags) # Initialise L1 decoding tools from L1Decoder.L1DecoderConf import CTPUnpackingTool ctpUnpacker = CTPUnpackingTool(ForceEnableAllChains=True) # Can add other tools here if needed from L1Decoder.L1DecoderConf import PrescalingEmulationTool psEmulation = PrescalingEmulationTool() # Schedule the L1Decoder algo with the above tools from L1Decoder.L1DecoderConf import L1Decoder l1decoder = L1Decoder() l1decoder.ctpUnpacker = ctpUnpacker l1decoder.prescaler = psEmulation l1decoder.RoIBResult = "RoIBResult" if ConfigFlags.Trigger.enableL1CaloLegacy or not ConfigFlags.Trigger.enableL1Phase1 else "" l1decoder.L1TriggerResult = "L1TriggerResult" if ConfigFlags.Trigger.enableL1Phase1 else "" l1_seq += l1decoder return l1_seq
def getTimeBurnerStep(self): # Input maker - required by the framework, but inputs don't matter for TimeBurner inputMaker = InputMakerForRoI("IM_TimeBurner") inputMaker.RoITool = ViewCreatorInitialROITool() inputMaker.RoIs = "TimeBurnerInputRoIs" inputMakerSeq = seqAND("TimeBurnerSequence", [inputMaker]) # TimeBurner alg works as a reject-all hypo hypoAlg = conf2toConfigurable(TimeBurnerCfg()) hypoAlg.SleepTimeMillisec = 200 seq = MenuSequence(Sequence=inputMakerSeq, Maker=inputMaker, Hypo=hypoAlg, HypoToolGen=TimeBurnerHypoToolGen) return ChainStep(name='Step1_TimeBurner', Sequences=[seq])
def jetAthSequence(dummyFlags, **jetRecoDict): from TrigT2CaloCommon.CaloDef import clusterFSInputMaker InputMakerAlg = conf2toConfigurable(clusterFSInputMaker()) # Does nothing now, but may need to use this to toggle Insitu calib step # in which case it should be deduced from input flags dataSource = "data" # or mc (recoSequence, sequenceOut) = RecoFragmentsPool.retrieve(jetRecoSequence, None, dataSource=dataSource, **jetRecoDict) jetDefString = jetRecoDictToString(jetRecoDict) JetAthSequence = seqAND("jetAthSequence_" + jetDefString, [InputMakerAlg, recoSequence]) return (JetAthSequence, InputMakerAlg, sequenceOut)
def makeHLTTree(newJO=False, triggerConfigHLT=None): """ creates the full HLT tree""" # Check if triggerConfigHLT exits, if yes, derive information from this # this will be in use once TrigUpgrade test has migrated to TriggerMenuMT completely # get topSequnece from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() # find main HLT top sequence (already set up in runHLT_standalone) from AthenaCommon.CFElements import findSubSequence, findAlgorithm l1decoder = findAlgorithm(topSequence, "L1Decoder") # add the HLT steps Node steps = seqAND("HLTAllSteps") hltTop = findSubSequence(topSequence, "HLTTop") hltTop += steps hltEndSeq = parOR("HLTEndSeq") hltTop += hltEndSeq hltFinalizeSeq = seqAND("HLTFinalizeSeq") # make DF and CF tree from chains finalDecisions = decisionTreeFromChains(steps, triggerConfigHLT.configsList(), triggerConfigHLT.dictsList(), newJO) flatDecisions = [] for step in finalDecisions: flatDecisions.extend(step) summary = makeSummary("Final", flatDecisions) hltEndSeq += summary # TODO - check we are not running things twice. Once here and once in TriggerConfig.py from TriggerJobOpts.TriggerConfig import collectHypos, collectFilters, collectViewMakers, collectDecisionObjects,\ triggerMonitoringCfg, triggerSummaryCfg, triggerMergeViewsAndAddMissingEDMCfg, collectHypoDecisionObjects from AthenaConfiguration.AllConfigFlags import ConfigFlags from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable, appendCAtoAthena # Collections required to configure the algs below hypos = collectHypos(steps) filters = collectFilters(steps) viewMakers = collectViewMakers(steps) Configurable.configurableRun3Behavior = 1 summaryAcc, summaryAlg = triggerSummaryCfg(ConfigFlags, hypos) Configurable.configurableRun3Behavior = 0 # A) First we check if any chain accepted the event hltFinalizeSeq += conf2toConfigurable(summaryAlg) appendCAtoAthena(summaryAcc) # B) Then (if true), we run the accepted event algorithms. # Add any required algs to hltFinalizeSeq here # More collections required to configure the algs below decObj = collectDecisionObjects(hypos, filters, l1decoder, summaryAlg) decObjHypoOut = collectHypoDecisionObjects(hypos, inputs=False, outputs=True) Configurable.configurableRun3Behavior = 1 monAcc, monAlg = triggerMonitoringCfg(ConfigFlags, hypos, filters, l1decoder) Configurable.configurableRun3Behavior = 0 hltEndSeq += conf2toConfigurable(monAlg) appendCAtoAthena(monAcc) Configurable.configurableRun3Behavior = 1 edmAlg = triggerMergeViewsAndAddMissingEDMCfg(['AOD', 'ESD'], hypos, viewMakers, decObj, decObjHypoOut) Configurable.configurableRun3Behavior = 0 # C) Finally, we create the EDM output hltFinalizeSeq += conf2toConfigurable(edmAlg) hltEndSeq += hltFinalizeSeq # Test the configuration from TriggerMenuMT.HLTMenuConfig.Menu.CFValidation import testHLTTree testHLTTree(hltTop)
def Lvl1SimulationSequence(flags=None): """ Configure L1 simulation for Athena MT jobs The code is structure in a way that should be easier to change once New JO system with ComponentAccumulators will be in use """ # for the New JO migration # from AthenaCommon.ComponentAccumulator import ComponentAccumulator # acc = ComponentAccumulator() # all tools then should be added to the acc, cond folders as well. # L1ConfigSvc CA has to be imported and merged # at the end the sequence added to the CA # from AthenaCommon.Logging import logging log = logging.getLogger('TriggerJobOpts.Lvl1Simulation') from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable from AthenaCommon.CFElements import seqAND from AthenaCommon.AppMgr import ServiceMgr as svcMgr from AthenaCommon.AlgSequence import AthSequencer from TriggerJobOpts.TriggerFlags import TriggerFlags # this configuration of the LVL1ConfigSvc is only temporary TriggerFlags.readLVL1configFromXML = True TriggerFlags.outputLVL1configFile = None log.info("setting up LVL1ConfigSvc, including the menu generation") from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc svcMgr += conf2toConfigurable(getL1ConfigSvc(flags)) ################################################## # Calo ################################################## if flags.Trigger.enableL1CaloLegacy: from TrigT1CaloSim.TrigT1CaloSimRun2Config import Run2TriggerTowerMaker caloTowerMaker = Run2TriggerTowerMaker("Run2TriggerTowerMaker25ns") caloTowerMaker.ExtraInputs = [ "LArTTL1Container#LArTTL1EM", "LArTTL1Container#LArTTL1HAD", "TileTTL1Container#TileTTL1Cnt" ] caloTowerMaker.ZeroSuppress = True caloTowerMaker.CellType = 3 from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__Run2CPMTowerMaker from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__Run2JetElementMaker from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__CPMSim from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__JEMJetSim from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__JEMEnergySim from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__CPCMX from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__JetCMX from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__EnergyCMX from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__RoIROD from TrigT1MBTS.TrigT1MBTSConf import LVL1__TrigT1MBTS from TrigT1ZDC.TrigT1ZDCConf import LVL1__TrigT1ZDC l1CaloSim = seqAND( 'l1CaloSim', [ caloTowerMaker, #LVL1__Run2CPMTowerMaker( 'CPMTowerMaker', ExtraInputs=["XYZ#1"], ExtraOutputs=["XYZ#2"]) , LVL1__Run2CPMTowerMaker('CPMTowerMaker'), LVL1__Run2JetElementMaker('JetElementMaker'), LVL1__CPMSim('CPMSim'), LVL1__JEMJetSim('JEMJetSim'), LVL1__JEMEnergySim('JEMEnergySim'), LVL1__CPCMX('CPCMX'), LVL1__JetCMX('JetCMX'), LVL1__EnergyCMX('EnergyCMX'), LVL1__RoIROD('RoIROD'), LVL1__TrigT1MBTS(), LVL1__TrigT1ZDC() ]) from IOVDbSvc.CondDB import conddb L1CaloFolderList = [] #L1CaloFolderList += ["/TRIGGER/L1Calo/V1/Calibration/Physics/PprChanCalib"] L1CaloFolderList += [ "/TRIGGER/L1Calo/V2/Calibration/Physics/PprChanCalib" ] #L1CaloFolderList += ["/TRIGGER/L1Calo/V1/Conditions/RunParameters"] #L1CaloFolderList += ["/TRIGGER/L1Calo/V1/Conditions/DerivedRunPars"] #L1CaloFolderList += ["/TRIGGER/Receivers/Conditions/VgaDac"] #L1CaloFolderList += ["/TRIGGER/Receivers/Conditions/Strategy"] L1CaloFolderList += ["/TRIGGER/L1Calo/V2/Conditions/DisabledTowers"] L1CaloFolderList += ["/TRIGGER/L1Calo/V2/Calibration/PpmDeadChannels"] L1CaloFolderList += [ "/TRIGGER/L1Calo/V2/Configuration/PprChanDefaults" ] for l1calofolder in L1CaloFolderList: #conddb.addFolderWithTag("TRIGGER_OFL", l1calofolder, "HEAD") conddb.addFolder("TRIGGER_OFL", l1calofolder) ################################################## # Muons ################################################## from MuonByteStreamCnvTest.MuonByteStreamCnvTestConf import MuonRdoToMuonDigitTool MuonRdoToMuonDigitTool = MuonRdoToMuonDigitTool( DecodeMdtRDO=False, DecodeRpcRDO=True, DecodeTgcRDO=True, DecodeCscRDO=False, DecodeSTGC_RDO=False, DecodeMM_RDO=False, # for those subdetectors where the decoding is turned off, no need to create a RDO_Decoder ToolHandle mdtRdoDecoderTool="", cscRdoDecoderTool="", stgcRdoDecoderTool="", mmRdoDecoderTool="", RpcDigitContainer="RPC_DIGITS_L1", TgcDigitContainer="TGC_DIGITS_L1") MuonRdoToMuonDigitTool.cscCalibTool = "CscCalibTool" from AthenaCommon.AppMgr import ToolSvc ToolSvc += MuonRdoToMuonDigitTool from MuonByteStreamCnvTest.MuonByteStreamCnvTestConf import MuonRdoToMuonDigit from TrigT1RPCsteering.TrigT1RPCsteeringConf import TrigT1RPC from TrigT1TGC.TrigT1TGCConf import LVL1TGCTrigger__LVL1TGCTrigger TrigT1RPC.useRun3Config = flags.Trigger.enableL1Phase1 LVL1TGCTrigger__LVL1TGCTrigger.useRun3Config = flags.Trigger.enableL1Phase1 if flags.Trigger.enableL1Phase1: # Placeholder for phase-I MUCTPI simulation log.info("Configuring Phase-I MUCTPI simulation") from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config import L1MuctpiPhase1 from TrigT1MuctpiPhase1.TrigT1MuctpiPhase1Config import L1MuctpiPhase1Tool ToolSvc += L1MuctpiPhase1Tool("MUCTPI_AthTool") ToolSvc.MUCTPI_AthTool.LVL1ConfigSvc = svcMgr.LVL1ConfigSvc muctpi = L1MuctpiPhase1() muctpi.LVL1ConfigSvc = svcMgr.LVL1ConfigSvc else: log.info("Configuring legacy (Run 2) MUCTPI simulation") from TrigT1Muctpi.TrigT1MuctpiConfig import L1Muctpi from TrigT1Muctpi.TrigT1MuctpiConfig import L1MuctpiTool ToolSvc += L1MuctpiTool("L1MuctpiTool") ToolSvc.L1MuctpiTool.LVL1ConfigSvc = svcMgr.LVL1ConfigSvc muctpi = L1Muctpi() muctpi.LVL1ConfigSvc = svcMgr.LVL1ConfigSvc # Sets up and configures the muon alignment and detector manager from MuonRecExample import MuonAlignConfig # noqa: F401 l1MuonSim = seqAND( "l1MuonSim", [ MuonRdoToMuonDigit( "MuonRdoToMuonDigit", MuonRdoToMuonDigitTool=ToolSvc.MuonRdoToMuonDigitTool), TrigT1RPC( "TrigT1RPC", Hardware= True, # not sure if needed, not there in old config, present in JO DataDetail=False, RPCbytestream=False, RPCbytestreamFile="", RPCDigitContainer="RPC_DIGITS_L1"), # based on Trigger/TrigT1/TrigT1TGC/python/TrigT1TGCConfig.py # interesting is that this JO sets inexisting properties, commented out below LVL1TGCTrigger__LVL1TGCTrigger( "LVL1TGCTrigger", InputData_perEvent="TGC_DIGITS_L1", MuCTPIInput_TGC="L1MuctpiStoreTGC", MaskFileName12="TrigT1TGCMaskedChannel._12.db"), muctpi ]) # only needed for MC conddb.addFolder("TGC_OFL", "/TGC/TRIGGER/CW_EIFI", className="CondAttrListCollection") conddb.addFolder("TGC_OFL", "/TGC/TRIGGER/CW_BW", className="CondAttrListCollection") conddb.addFolder("TGC_OFL", "/TGC/TRIGGER/CW_TILE", className="CondAttrListCollection") condSeq = AthSequencer("AthCondSeq") from MuonCondSvc.MuonCondSvcConf import TGCTriggerDbAlg condSeq += TGCTriggerDbAlg() ################################################## # Topo ################################################## l1TopoSim = None if flags.Trigger.enableL1Phase1: log.info("No phase1 configuration for L1Topo simulation is available") else: from L1TopoSimulation.L1TopoSimulationConfig import L1TopoSimulation l1TopoSim = L1TopoSimulation() l1TopoSim.MuonInputProvider.ROIBResultLocation = "" #disable input from RoIBResult l1TopoSim.MuonInputProvider.MuctpiSimTool = ToolSvc.L1MuctpiTool # enable the reduced (coarse) granularity topo simulation # currently only for MC from AthenaCommon.GlobalFlags import globalflags if globalflags.DataSource() != 'data': l1TopoSim.MuonInputProvider.MuonEncoding = 1 else: l1TopoSim.MuonInputProvider.MuonEncoding = 0 ################################################## # CTP ################################################## from TrigT1CTP.TrigT1CTPConfig import CTPSimulationInReco ctp = CTPSimulationInReco("CTPSimulation") ctp.DoLUCID = False ctp.DoBCM = False ctp.DoL1Topo = not flags.Trigger.enableL1Phase1 ctp.UseCondL1Menu = False ctp.TrigConfigSvc = svcMgr.LVL1ConfigSvc ctpSim = seqAND("ctpSim", [ctp]) if flags.Trigger.enableL1CaloLegacy or not flags.Trigger.enableL1Phase1: from TrigT1RoIB.TrigT1RoIBConfig import RoIBuilder roib = RoIBuilder("RoIBuilder") roib.DoCalo = flags.Trigger.enableL1CaloLegacy roib.DoMuon = not flags.Trigger.enableL1Phase1 ctpSim += [roib] #l1Sim = seqAND("l1Sim", [caloTowerMaker] ) if l1TopoSim: l1Sim = seqAND("l1Sim", [l1CaloSim, l1MuonSim, l1TopoSim, ctpSim]) else: l1Sim = seqAND("l1Sim", [l1CaloSim, l1MuonSim, ctpSim]) return l1Sim
def configure_hlt_result(hypo_algs): from TrigEDMConfig.DataScoutingInfo import getFullHLTResultID from TrigOutputHandling.TrigOutputHandlingConfig import TriggerEDMSerialiserToolCfg, StreamTagMakerToolCfg, TriggerBitsMakerToolCfg # Tool serialising EDM objects to fill the HLT result serialiser = TriggerEDMSerialiserToolCfg('Serialiser') for hypo in hypo_algs: serialiser.addCollectionListToMainResult([ 'xAOD::TrigCompositeContainer_v1#' + hypo.HypoOutputDecisions, 'xAOD::TrigCompositeAuxContainer_v2#' + hypo.HypoOutputDecisions + 'Aux.', ]) # Data scouting example resultList = [getFullHLTResultID(), 1] collections = set() chain_names = [] for hypo in hypo_algs: for hypo_tool in hypo.HypoTools: chain_names.append(hypo_tool.name()) if hasattr(hypo_tool, 'CreateRandomData'): for coll_name in hypo_tool.CreateRandomData.keys(): collections.add(coll_name) for coll_name in collections: serialiser.addCollectionListToResults([ 'xAOD::TrigCompositeContainer_v1#{:s}'.format(coll_name), 'xAOD::TrigCompositeAuxContainer_v2#{:s}Aux.'.format(coll_name) ], resultList) # StreamTag definitions streamPhysicsMain = { 'name': 'Main', 'type': 'physics', 'obeyLB': True, 'forceFullEventBuilding': True } streamExamplePEB = { 'name': 'ExamplePEB', 'type': 'calibration', 'obeyLB': True, 'forceFullEventBuilding': False } streamExampleDataScoutingPEB = { 'name': 'ExampleDataScoutingPEB', 'type': 'physics', 'obeyLB': True, 'forceFullEventBuilding': False } chain_to_streams = {} for counter, ch in enumerate(chain_names, start=1): if counter % 3 == 1: chain_to_streams[ch] = [streamPhysicsMain] elif counter % 3 == 2: chain_to_streams[ch] = [streamExamplePEB] elif counter % 3 == 0: chain_to_streams[ch] = [streamExampleDataScoutingPEB] menu_json = write_dummy_menu_json(chain_to_streams.keys(), chain_to_streams) # Give the menu json name to HLTConfigSvc from AthenaCommon.AppMgr import ServiceMgr as svcMgr if not hasattr(svcMgr, 'HLTConfigSvc'): from TrigConfigSvc.TrigConfigSvcConfig import HLTConfigSvc svcMgr += HLTConfigSvc() svcMgr.HLTConfigSvc.JsonFileName = menu_json # Tool adding stream tags to HLT result stmaker = StreamTagMakerToolCfg() stmaker.ChainDecisions = 'HLTNav_Summary' stmaker.PEBDecisionKeys = [hypo.HypoOutputDecisions for hypo in hypo_algs] # Tool adding HLT bits to HLT result bitsmaker = TriggerBitsMakerToolCfg() bitsmaker.ChainDecisions = 'HLTNav_Summary' # Configure the HLT result maker to use the above tools from AthenaCommon.AppMgr import ServiceMgr as svcMgr hltResultMaker = svcMgr.HltEventLoopMgr.ResultMaker hltResultMaker.StreamTagMaker = conf2toConfigurable(stmaker) hltResultMaker.MakerTools = [ conf2toConfigurable(tool) for tool in [bitsmaker, serialiser] ]
if option in globals(): setattr(opt, option, globals()[option]) log.info(' %20s = %s' % (option, getattr(opt, option))) else: log.info(' %20s = (Default) %s' % (option, getattr(opt, option))) TriggerFlags.generateMenuDiagnostics = True from TrigConfigSvc.TrigConfigSvcCfg import getHLTConfigSvc, getL1ConfigSvc from AthenaCommon.AppMgr import ServiceMgr as svcMgr from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable from AthenaConfiguration.AllConfigFlags import ConfigFlags ConfigFlags.Trigger.triggerMenuSetup = TriggerFlags.triggerMenuSetup = 'LS2_v1' svcMgr += conf2toConfigurable(getHLTConfigSvc(ConfigFlags)) svcMgr += conf2toConfigurable(getL1ConfigSvc(ConfigFlags)) topSequence = AlgSequence() if opt.doMenu is True: generateL1DecoderAndChainsByMenu(topSequence) else: generateL1DecoderAndChainsManually(topSequence) generateJSON() from AthenaCommon.AppMgr import theApp, ServiceMgr as svcMgr from GaudiSvc.GaudiSvcConf import THistSvc svcMgr += THistSvc() if hasattr(svcMgr.THistSvc, "Output"):
def GetCompatibleComponent(component): if Convert2Configurable: return conf2toConfigurable(component) return component
def triggerOutputCfg(flags, decObj, decObjHypoOut, summaryAlg): # Following cases are considered: # 1) Running in partition or athenaHLT - configure BS output written by the HLT framework # 2) Running offline athena and writing BS - configure BS output written by OutputStream alg # 3) Running offline athena with POOL output - configure POOL output written by OutputStream alg onlineWriteBS = False offlineWriteBS = False writePOOL = False isPartition = len(flags.Trigger.Online.partitionName) > 0 if flags.Trigger.writeBS: if isPartition: onlineWriteBS = True else: offlineWriteBS = True if flags.Output.doWriteRDO or flags.Output.doWriteESD or flags.Output.doWriteAOD: writePOOL = True # Consistency checks if offlineWriteBS and not flags.Output.doWriteBS: __log.error('flags.Trigger.writeBS is True but flags.Output.doWriteBS is False') return None, '' if writePOOL and onlineWriteBS: __log.error("POOL HLT output writing is configured online") return None, '' if writePOOL and offlineWriteBS: __log.error("Writing HLT output to both BS and POOL in one job is not supported at the moment") return None, '' # Determine EDM set name edmSet = '' if writePOOL: edmSet = flags.Trigger.AODEDMSet if flags.Output.doWriteAOD else flags.Trigger.ESDEDMSet elif onlineWriteBS or offlineWriteBS: edmSet = 'BS' # Create the configuration if onlineWriteBS: __log.info("Configuring online ByteStream HLT output") acc = triggerBSOutputCfg(flags, decObj, decObjHypoOut, summaryAlg) # Configure the online HLT result maker to use the above tools # For now use old svcMgr interface as this service is not available from acc.getService() from AthenaCommon.AppMgr import ServiceMgr as svcMgr hltEventLoopMgr = svcMgr.HltEventLoopMgr hltEventLoopMgr.ResultMaker.MakerTools = [] for tool in acc.popPrivateTools(): if 'StreamTagMaker' in tool.getName(): hltEventLoopMgr.ResultMaker.StreamTagMaker = conf2toConfigurable(tool) else: hltEventLoopMgr.ResultMaker.MakerTools += [ conf2toConfigurable(tool) ] elif offlineWriteBS: __log.info("Configuring offline ByteStream HLT output") acc = triggerBSOutputCfg(flags, decObj, decObjHypoOut, summaryAlg, offline=True) elif writePOOL: __log.info("Configuring POOL HLT output") acc = triggerPOOLOutputCfg(flags, decObj, decObjHypoOut, edmSet) else: __log.info("No HLT output writing is configured") acc = ComponentAccumulator() return acc, edmSet
def FtagJetCollection(jetcol, seq, OutputLevel=WARNING): from AthenaCommon.AppMgr import athCondSeq from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior = 1 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable from BTagging.JetParticleAssociationAlgConfig import JetParticleAssociationAlgCfg from BTagging.JetBTaggingAlgConfig import JetBTaggingAlgCfg from BTagging.JetSecVertexingAlgConfig import JetSecVertexingAlgCfg from BTagging.JetSecVtxFindingAlgConfig import JetSecVtxFindingAlgCfg from BTagging.BTagTrackAugmenterAlgConfig import BTagTrackAugmenterAlgCfg from BTagging.BTagHighLevelAugmenterAlgConfig import BTagHighLevelAugmenterAlgCfg from BTagging.HighLevelBTagAlgConfig import HighLevelBTagAlgCfg from AthenaConfiguration.AllConfigFlags import ConfigFlags as cfgFlags jetcol_name_without_Jets = jetcol.replace('Jets', '') BTaggingCollection = cfgFlags.BTagging.OutputFiles.Prefix + jetcol_name_without_Jets kwargs = {} kwargs['Release'] = '22' cfgFlags.Input.Files = jps.AthenaCommonFlags.FilesInput.get_Value() acc = ComponentAccumulator() taggerlist = ['IP2D', 'IP3D', 'SV1', 'SoftMu'] CalibrationChannelAliases = [ "AntiKt4EMPFlow->AntiKt4EMPFlow,AntiKt4EMTopo,AntiKt4TopoEM,AntiKt4LCTopo" ] grades = cfgFlags.BTagging.Grades RNNIPConfig = {'rnnip': ''} JetTagCalibCondAlg = CompFactory.Analysis.JetTagCalibCondAlg jettagcalibcondalg = "JetTagCalibCondAlg" readkeycalibpath = "/GLOBAL/BTagCalib/RUN12" connSchema = "GLOBAL_OFL" if not cfgFlags.Input.isMC: readkeycalibpath = readkeycalibpath.replace("/GLOBAL/BTagCalib", "/GLOBAL/Onl/BTagCalib") connSchema = "GLOBAL" histoskey = "JetTagCalibHistosKey" from IOVDbSvc.CondDB import conddb conddb.addFolder(connSchema, readkeycalibpath, className='CondAttrListCollection') JetTagCalib = JetTagCalibCondAlg(jettagcalibcondalg, ReadKeyCalibPath=readkeycalibpath, HistosKey=histoskey, taggers=taggerlist, channelAliases=CalibrationChannelAliases, IP2D_TrackGradePartitions=grades, RNNIP_NetworkConfig=RNNIPConfig) athCondSeq += conf2toConfigurable(JetTagCalib, indent=" ") acc.merge( JetParticleAssociationAlgCfg(cfgFlags, jetcol_name_without_Jets, "InDetTrackParticles", 'BTagTrackToJetAssociator', **kwargs)) SecVertexingAndAssociators = { 'JetFitter': 'BTagTrackToJetAssociator', 'SV1': 'BTagTrackToJetAssociator' } for k, v in SecVertexingAndAssociators.items(): acc.merge( JetSecVtxFindingAlgCfg(cfgFlags, jetcol_name_without_Jets, "PrimaryVertices", k, v)) acc.merge( JetSecVertexingAlgCfg(cfgFlags, BTaggingCollection, jetcol_name_without_Jets, "PrimaryVertices", k, v)) acc.merge( JetBTaggingAlgCfg(cfgFlags, BTaggingCollection=BTaggingCollection, JetCollection=jetcol_name_without_Jets, PrimaryVertexCollectionName="PrimaryVertices", TaggerList=taggerlist, SVandAssoc=SecVertexingAndAssociators)) postTagDL2JetToTrainingMap = { 'AntiKt4EMPFlow': [ #'BTagging/201903/smt/antikt4empflow/network.json', 'BTagging/201903/rnnip/antikt4empflow/network.json', 'BTagging/201903/dl1r/antikt4empflow/network.json', 'BTagging/201903/dl1/antikt4empflow/network.json', #'BTagging/201903/dl1rmu/antikt4empflow/network.json', ] } acc.merge(BTagTrackAugmenterAlgCfg(cfgFlags)) acc.merge( BTagHighLevelAugmenterAlgCfg(cfgFlags, JetCollection=jetcol_name_without_Jets, BTagCollection=BTaggingCollection, Associator='BTagTrackToJetAssociator')) for jsonfile in postTagDL2JetToTrainingMap[jetcol_name_without_Jets]: acc.merge( HighLevelBTagAlgCfg(cfgFlags, BTaggingCollection=BTaggingCollection, TrackCollection='InDetTrackParticles', NNFile=jsonfile)) Configurable.configurableRun3Behavior = 0 algs = findAllAlgorithms(acc.getSequence("AthAlgSeq")) for alg in algs: seq += conf2toConfigurable(alg) acc.wasMerged() return
def bJetStep2Sequence(): prmVtxKey = "HLT_IDVertex_FS" outputRoIName = "HLT_Roi_Bjet" from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithm from DecisionHandling.DecisionHandlingConf import ViewCreatorCentredOnJetWithPVConstraintROITool InputMakerAlg = EventViewCreatorAlgorithm("IMBJet_step2") # newRoITool = ViewCreatorCentredOnJetWithPVConstraintROITool() newRoITool.RoisWriteHandleKey = recordable(outputRoIName) newRoITool.VertexReadHandleKey = prmVtxKey newRoITool.PrmVtxLink = prmVtxKey.replace("HLT_", "") # InputMakerAlg.mergeUsingFeature = True InputMakerAlg.RoITool = newRoITool # InputMakerAlg.Views = "BTagViews" InputMakerAlg.InViewRoIs = "InViewRoIs" # InputMakerAlg.RequireParentView = False InputMakerAlg.ViewFallThrough = True # BJet specific InputMakerAlg.PlaceJetInView = True InputMakerAlg.InViewJets = recordable("HLT_bJets") # Prepare data objects for view verifier viewDataObjects = [('TrigRoiDescriptorCollection', 'StoreGateSvc+' + InputMakerAlg.InViewRoIs), ('xAOD::VertexContainer', 'StoreGateSvc+' + prmVtxKey), ('xAOD::JetContainer', 'StoreGateSvc+' + InputMakerAlg.InViewJets)] # Second stage of Fast Tracking and Precision Tracking from TriggerMenuMT.HLTMenuConfig.Bjet.BjetTrackingConfiguration import getSecondStageBjetTracking secondStageAlgs, PTTrackParticles = getSecondStageBjetTracking( inputRoI=InputMakerAlg.InViewRoIs, dataObjects=viewDataObjects) from AthenaCommon.Configurable import Configurable Configurable.configurableRun3Behavior = 1 # Flavour Tagging from TriggerMenuMT.HLTMenuConfig.Bjet.BjetFlavourTaggingConfiguration import getFlavourTagging acc_flavourTaggingAlgs, bTaggingContainerName = getFlavourTagging( inputJets=InputMakerAlg.InViewJets, inputVertex=prmVtxKey, inputTracks=PTTrackParticles[0]) Configurable.configurableRun3Behavior = 0 #Conversion of flavour-tagging algorithms from new to old-style from AthenaCommon.CFElements import findAllAlgorithms from AthenaConfiguration.ComponentAccumulator import conf2toConfigurable AllFlavourTaggingAlgs = [] for alg in findAllAlgorithms( acc_flavourTaggingAlgs.getSequence("AthAlgSeq")): AllFlavourTaggingAlgs.append(conf2toConfigurable(alg)) acc_flavourTaggingAlgs.wasMerged( ) #Needed to remove error message; Next we add all algorithms to sequence so this is kind of an old-style merge bJetBtagSequence = seqAND("bJetBtagSequence", secondStageAlgs + AllFlavourTaggingAlgs) InputMakerAlg.ViewNodeName = "bJetBtagSequence" # Sequence BjetAthSequence = seqAND("BjetAthSequence_step2", [InputMakerAlg, bJetBtagSequence]) from TrigBjetHypo.TrigBjetHypoConf import TrigBjetBtagHypoAlgMT hypo = TrigBjetBtagHypoAlgMT("TrigBjetBtagHypoAlg") # keys hypo.BTaggedJetKey = InputMakerAlg.InViewJets hypo.BTaggingKey = bTaggingContainerName hypo.TracksKey = PTTrackParticles[0] hypo.PrmVtxKey = newRoITool.VertexReadHandleKey # links for navigation hypo.BTaggingLink = bTaggingContainerName.replace("HLT_", "") hypo.PrmVtxLink = newRoITool.PrmVtxLink from TrigBjetHypo.TrigBjetOnlineMonitoringMTConfig import TrigBjetOnlineMonitoring hypo.MonTool = TrigBjetOnlineMonitoring() from TrigBjetHypo.TrigBjetBtagHypoTool import TrigBjetBtagHypoToolFromDict return MenuSequence(Sequence=BjetAthSequence, Maker=InputMakerAlg, Hypo=hypo, HypoToolGen=TrigBjetBtagHypoToolFromDict)
def jetRecoSequence(dummyFlags, dataSource, RoIs='HLT_FSJETRoI', **jetRecoDict): jetDefString = jetRecoDictToString(jetRecoDict) recoSeq = parOR("JetRecSeq_" + jetDefString, []) recoAlg = jetRecoDict["recoAlg"] doGrooming = recoAlg.endswith("t") # Maybe other grooming strategies doRecluster = recoAlg.endswith("r") jetNamePrefix = "HLT_" from TrigEDMConfig.TriggerEDMRun3 import recordable from JetRecConfig import ConfigurableCompatibility ConfigurableCompatibility.Convert2Configurable = True from JetRecConfig.JetRecConfig import getConstitPJGAlg, getJetAlgorithm if doRecluster: # Reclustering -- recursively call the basic jet reco and add this to the sequence, # then add another jet algorithm to run the reclustering step basicJetRecoDict = dict(jetRecoDict) basicJetRecoDict["recoAlg"] = "a4" # Standard size for reclustered (basicJetRecoSequence, basicJetsName) = RecoFragmentsPool.retrieve(jetRecoSequence, None, dataSource=dataSource, **basicJetRecoDict) recoSeq += basicJetRecoSequence rcJetPtMin = 15e3 # 15 GeV minimum pt for jets to be reclustered from JetRec.JetRecConf import JetViewAlg filteredJetsName = basicJetsName + "_pt15" recoSeq += JetViewAlg("jetview_" + filteredJetsName, InputContainer=basicJetsName, OutputContainer=filteredJetsName, PtMin=rcJetPtMin) rcJetDef = JetRecoConfiguration.defineReclusteredJets(jetRecoDict) rcJetDef.inputdef.inputname = filteredJetsName rcJetsFullName = jetNamePrefix + rcJetDef.basename + "RCJets_" + jetRecoDict[ "jetCalib"] rcModList = [] # Could set substructure mods rcJetDef.modifiers = rcModList rcConstitPJAlg = getConstitPJGAlg(rcJetDef.inputdef) rcConstitPJKey = rcConstitPJAlg.OutputContainer recoSeq += conf2toConfigurable(rcConstitPJAlg) # Get online monitoring tool from JetRec import JetOnlineMon monTool = JetOnlineMon.getMonTool_TrigJetAlgorithm("HLTJets/" + rcJetsFullName + "/") rcPJs = [rcConstitPJKey] rcJetRecAlg = getJetAlgorithm(rcJetsFullName, rcJetDef, rcPJs, rcModList, monTool) recoSeq += conf2toConfigurable(rcJetRecAlg) sequenceOut = recordable(rcJetsFullName) elif doGrooming: # Grooming needs to be set up similarly to reclustering # --> build ungroomed jets, then add a grooming alg ungroomedJetRecoDict = dict(jetRecoDict) ungroomedJetRecoDict["recoAlg"] = ungroomedJetRecoDict[ "recoAlg"].rstrip("t") # Drop grooming spec ungroomedJetRecoDict["jetCalib"] = "nojcalib" # No need to calibrate ungroomedDef = JetRecoConfiguration.defineJets(ungroomedJetRecoDict) (ungroomedJetRecoSequence, ungroomedJetsName) = RecoFragmentsPool.retrieve( jetRecoSequence, None, dataSource=dataSource, **ungroomedJetRecoDict) recoSeq += conf2toConfigurable(ungroomedJetRecoSequence) # Need to forward the pseudojets of the parents to the groomer parentpjs = getattr( ungroomedJetRecoSequence, "jetalg_{}".format(ungroomedJetsName)).Tools[0].InputPseudoJets groomDef = JetRecoConfiguration.defineGroomedJets( jetRecoDict, ungroomedDef, ungroomedJetsName) groomedJetsFullName = jetNamePrefix + groomDef.basename + "Jets_" + jetRecoDict[ "jetCalib"] groomedModList = JetRecoConfiguration.defineCalibFilterMods( jetRecoDict, dataSource) # Can add substructure mods here # Get online monitoring tool from JetRec import JetOnlineMon monTool = JetOnlineMon.getMonTool_TrigJetAlgorithm( "HLTJets/" + groomedJetsFullName + "/") from JetRecConfig.JetGroomConfig import getJetGroomAlg groomalg = getJetGroomAlg(groomedJetsFullName, groomDef, parentpjs, groomedModList, monTool) recoSeq += conf2toConfigurable(groomalg) sequenceOut = recordable(groomedJetsFullName) else: # Normal jet reconstruction, no reclustering or grooming # Start by adding the topocluster reco sequence # This makes EM clusters! from TriggerMenuMT.HLTMenuConfig.CommonSequences.CaloSequenceSetup import ( caloClusterRecoSequence, LCCaloClusterRecoSequence) if jetRecoDict["calib"] == "em": topoClusterSequence, clustersKey = RecoFragmentsPool.retrieve( caloClusterRecoSequence, flags=None, RoIs=RoIs) elif jetRecoDict["calib"] == "lcw": topoClusterSequence, clustersKey = RecoFragmentsPool.retrieve( LCCaloClusterRecoSequence, flags=None, RoIs=RoIs) else: raise ValueError("Invalid value for calib: '{}'".format( jetRecoDict["calib"])) recoSeq += topoClusterSequence # Set up tracking sequence -- may need to reorganise or relocate # depending on how we want to handle HLT preselection trkcolls = None if jetRecoDict["trkopt"] != "notrk": from .JetTrackingConfig import JetTrackingSequence (jettrkseq, trkcolls) = RecoFragmentsPool.retrieve( JetTrackingSequence, None, trkopt=jetRecoDict["trkopt"], RoIs=RoIs) recoSeq += jettrkseq # Potentially add particle flow reconstruction # Work in progress if "pf" in jetRecoDict["dataType"]: if jetRecoDict["trkopt"] == "notrk": raise RuntimeError( "PFlow jet chain requested with no tracking option!") from eflowRec.PFHLTSequence import PFHLTSequence (pfseq, pfoPrefix) = RecoFragmentsPool.retrieve( PFHLTSequence, None, clustersin=clustersKey, tracktype=jetRecoDict["trkopt"]) recoSeq += pfseq jetDef = JetRecoConfiguration.defineJets(jetRecoDict, pfoPrefix=pfoPrefix) else: jetDef = JetRecoConfiguration.defineJets(jetRecoDict, clustersKey=clustersKey) useConstitMods = ["sktc", "cssktc", "pf", "csskpf"] doConstitMods = jetRecoDict["dataType"] in useConstitMods # chosen jet collection jetsFullName = jetNamePrefix + jetDef.basename + "Jets_" + jetRecoDict[ "jetCalib"] if jetRecoDict["trkopt"] != "notrk": jetsFullName += "_{}".format(jetRecoDict["trkopt"]) sequenceOut = recordable(jetsFullName) if doConstitMods: # Get online monitoring jet rec tool from JetRecTools import OnlineMon monJetRecTool = OnlineMon.getMonTool_Algorithm("HLTJets/" + jetsFullName + "/") from JetRecConfig.ConstModHelpers import getConstitModAlg if jetRecoDict["trkopt"] == "notrk": recoSeq += getConstitModAlg(jetDef.inputdef, suffix="HLT", tvaKey="JetTrackVtxAssoc", vtxKey="PrimaryVertices", monTool=monJetRecTool) else: recoSeq += getConstitModAlg(jetDef.inputdef, suffix="HLT", tvaKey=trkcolls["TVA"], vtxKey=trkcolls["Vertices"], monTool=monJetRecTool) # Add the PseudoJetGetter alg to the sequence constitPJAlg = getConstitPJGAlg(jetDef.inputdef) constitPJKey = constitPJAlg.OutputContainer recoSeq += conf2toConfigurable(constitPJAlg) # Basic list of PseudoJets is just the constituents # Append ghosts (tracks) if desired pjs = [constitPJKey] if trkcolls: pjs.append(trkcolls["GhostTracks"]) from JetRecConfig import JetRecConfig jetModList = [] if jetRecoDict["trkopt"] != "notrk": trkMods = JetRecoConfiguration.defineTrackMods( jetRecoDict["trkopt"]) jetModList += trkMods rhoKey = "auto" if "sub" in jetRecoDict["jetCalib"]: # Add the event shape alg if needed for area subtraction eventShapeAlg = JetRecConfig.getEventShapeAlg( jetDef.inputdef, constitPJKey, "HLT_") recoSeq += conf2toConfigurable(eventShapeAlg) # Not currently written because impossible to merge # across event views, which is maybe a concern in # the case of regional PFlow rhoKey = eventShapeAlg.EventDensityTool.OutputContainer # Import the standard jet modifiers as defined for offline # We can add/configure these differently if desired. In particular, # we could define a TriggerJetMods module if settings need to # diverge substantially e.g. track/vertex collections calibMods = JetRecoConfiguration.defineCalibFilterMods( jetRecoDict, dataSource, rhoKey) jetModList += calibMods # Get online monitoring tool from JetRec import JetOnlineMon monTool = JetOnlineMon.getMonTool_TrigJetAlgorithm("HLTJets/" + jetsFullName + "/") # Generate a JetAlgorithm to run the jet finding and modifiers # (via a JetRecTool instance). jetRecAlg = JetRecConfig.getJetAlgorithm(jetsFullName, jetDef, pjs, jetModList, monTool) recoSeq += conf2toConfigurable(jetRecAlg) # End of basic jet reco pass return (recoSeq, sequenceOut)