def makeChain(name, L1Thresholds, ChainSteps, Streams="physics:Main", Groups=["RATE:TestRateGroup", "BW:TestBW"]): """ In addition to making the chain object fills the flags that are used to generate MnuCOnfig JSON file """ from TriggerMenuMT.HLTMenuConfig.Menu.ChainDefInMenu import ChainProp prop = ChainProp(name=name, l1SeedThresholds=L1Thresholds, groups=Groups) from TriggerMenuMT.HLTMenuConfig.Menu.TriggerConfigHLT import TriggerConfigHLT from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import dictFromChainName chainDict = dictFromChainName(prop) global chainsCounter chainDict["chainCounter"] = chainsCounter chainsCounter += 1 #set default chain prescale chainDict['prescale'] = 1 from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain chainConfig = Chain(name=name, L1Thresholds=L1Thresholds, ChainSteps=ChainSteps) TriggerConfigHLT.registerChain(chainDict, chainConfig) return chainConfig
def generatePhotonsCfg(flags): acc = ComponentAccumulator() from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence, ChainStep, Chain, RecoFragmentsPool from TrigEgammaHypo.TrigEgammaFastCaloHypoTool import TrigEgammaFastCaloHypoToolFromDict from TrigEgammaHypo.TrigEgammaHypoConf import TrigEgammaFastCaloHypoAlgMT l2CaloHypo = TrigEgammaFastCaloHypoAlgMT("EgammaFastPhotonCaloHypo") l2CaloHypo.CaloClusters = 'L2CaloEMClusters' from TriggerMenuMT.HLTMenuConfig.Electron.ElectronRecoSequences import l2CaloRecoCfg l2CaloReco = RecoFragmentsPool.retrieve(l2CaloRecoCfg, flags) acc.merge(l2CaloReco) fastCaloSequence = MenuSequence( Sequence=l2CaloReco.sequence(), Maker=l2CaloReco.inputMaker(), Hypo=l2CaloHypo, HypoToolGen=TrigEgammaFastCaloHypoToolFromDict) fastCaloStep = ChainStep("Photon_step1", [fastCaloSequence]) l2PhotonReco = RecoFragmentsPool.retrieve(l2PhotonRecoCfg, flags) acc.merge(l2PhotonReco) from TrigEgammaHypo.TrigEgammaHypoConf import TrigEgammaFastPhotonHypoAlgMT l2PhotonHypo = TrigEgammaFastPhotonHypoAlgMT() l2PhotonHypo.Photons = "L2Photons" l2PhotonHypo.RunInView = True from TrigEgammaHypo.TrigEgammaFastPhotonHypoTool import TrigEgammaFastPhotonHypoToolFromDict l2PhotonSequence = MenuSequence( Sequence=l2PhotonReco.sequence(), Maker=l2PhotonReco.inputMaker(), Hypo=l2PhotonHypo, HypoToolGen=TrigEgammaFastPhotonHypoToolFromDict) l2PhotonStep = ChainStep("Photon_step2", [l2PhotonSequence]) chains = [ Chain(c.split()[0], c.split()[1], [fastCaloStep, l2PhotonStep]) for c in flags.Trigger.menu.photons ] return acc, chains
def mergeParallel(chainDefList, offset): if offset != -1: log.error("Offset for parallel merging not implemented.") allSteps = [] nSteps = [] chainName = '' l1Thresholds = [] for cConfig in chainDefList: if chainName == '': chainName = cConfig.name elif chainName != cConfig.name: log.error( "Something is wrong with the combined chain name: cConfig.name = %s while chainName = %s", cConfig.name, chainName) allSteps.append(cConfig.steps) nSteps.append(len(cConfig.steps)) l1Thresholds.extend(cConfig.vseeds) import itertools if 'zip_longest' in dir(itertools): from itertools import zip_longest else: from itertools import izip_longest as zip_longest # Use zip_longest so that we get None in case one chain has more steps than the other orderedSteps = list(zip_longest(*allSteps)) combChainSteps = [] log.debug("len(orderedSteps): %d", len(orderedSteps)) for step_index, steps in enumerate(orderedSteps): mySteps = list(steps) log.debug("Merging step counter %d", step_index + 1) combStep = makeCombinedStep(mySteps, step_index + 1, chainDefList) combChainSteps.append(combStep) combinedChainDef = Chain(chainName, ChainSteps=combChainSteps, L1Thresholds=l1Thresholds) log.debug("Parallel merged chain %s with these steps:", chainName) for step in combinedChainDef.steps: log.debug('\n %s', step) return combinedChainDef
def mergeSerial(chainDefList): allSteps = [] nSteps = [] chainName = '' l1Thresholds = [] log.debug('Merge chainDefList:') log.debug(chainDefList) for cConfig in chainDefList: if chainName == '': chainName = cConfig.name elif chainName != cConfig.name: log.error( "Something is wrong with the combined chain name: cConfig.name = %s while chainName = %s", cConfig.name, chainName) allSteps.append(cConfig.steps) nSteps.append(len(cConfig.steps)) l1Thresholds.extend(cConfig.vseeds) serialSteps = serial_zip(allSteps, chainName) mySerialSteps = deepcopy(serialSteps) combChainSteps = [] for step_index, steps in enumerate(mySerialSteps): mySteps = list(steps) combStep = makeCombinedStep(mySteps, step_index + 1, chainDefList) combChainSteps.append(combStep) # check if all chain parts have the same number of steps sameNSteps = all(x == nSteps[0] for x in nSteps) if sameNSteps is True: log.info("All chain parts have the same number of steps") else: log.info( "Have to deal with uneven number of chain steps, there might be none's appearing in sequence list => to be fixed" ) combinedChainDef = Chain(chainName, ChainSteps=combChainSteps, L1Thresholds=l1Thresholds) log.debug("Serial merged chain %s with these steps:", chainName) for step in combinedChainDef.steps: log.debug(' %s', step) return combinedChainDef
def generateChains(flags, chainDict): stepName = getChainStepName('Jet', 1) stepReco, stepView = createStepView(stepName) acc = ComponentAccumulator() acc.addSequence(stepView) # All this should be some common FS cell module? from TrigT2CaloCommon.TrigCaloDataAccessConfig import trigCaloDataAccessSvcCfg acc.merge(trigCaloDataAccessSvcCfg(flags)) cdaSvc = acc.getService( "TrigCaloDataAccessSvc") # should be made primary component acc.printConfig() from TrigT2CaloCommon.CaloDef import clusterFSInputMaker inEventReco = InEventReco("JetReco", inputMaker=clusterFSInputMaker()) cellsname = "CaloCellsFS" clustersname = "HLT_CaloTopoClustersFS" cellmakerCfg = HLTCaloCellMakerCfg(cellsname, cdaSvc) inEventReco.mergeReco(cellmakerCfg) from CaloRec.CaloTopoClusterConfig import CaloTopoClusterCfg inEventReco.mergeReco( CaloTopoClusterCfg(flags, cellsname=cellsname, clustersname=clustersname, doLCCalib=False, sequenceName=inEventReco.recoSeq.name)) #sequencing of actual jet reconstruction from JetRecConfig import JetRecConfig from JetRecConfig.JetDefinition import JetConstit, JetDefinition, xAODType #hardcoded jet collection for now clustermods = ["ECPSFrac", "ClusterMoments"] trigMinPt = 7e3 HLT_EMTopo = JetConstit(xAODType.CaloCluster, ["EM"]) HLT_EMTopo.rawname = clustersname HLT_EMTopo.inputname = clustersname HLT_AntiKt4EMTopo_subjesIS = JetDefinition("AntiKt", 0.4, HLT_EMTopo, ptmin=trigMinPt, ptminfilter=trigMinPt) HLT_AntiKt4EMTopo_subjesIS.modifiers = [ "Calib:TrigRun2:data:JetArea_EtaJES_GSC_Insitu:HLT_Kt4EMTopoEventShape", "Sort" ] + clustermods jetprefix = "HLT_" jetsuffix = "_subjesIS" evsprefix = "HLT_" # May need a switch to disable automatic modifier prerequisite generation jetRecoComps = JetRecConfig.JetRecCfg(HLT_AntiKt4EMTopo_subjesIS, flags, jetprefix, jetsuffix, evsprefix) inEventReco.mergeReco(jetRecoComps) acc.merge(inEventReco, stepReco.getName()) #hypo from TrigHLTJetHypo.TrigJetHypoToolConfig import trigJetHypoToolFromDict hypo = CompFactory.TrigJetHypoAlgMT("TrigJetHypoAlgMT_a4tcem_subjesIS") jetsfullname = jetprefix + HLT_AntiKt4EMTopo_subjesIS.basename + "Jets" + jetsuffix hypo.Jets = jetsfullname acc.addEventAlgo(hypo) jetSequence = CAMenuSequence(Sequence=inEventReco.sequence(), Maker=inEventReco.inputMaker(), Hypo=hypo, HypoToolGen=trigJetHypoToolFromDict, CA=acc) jetStep = ChainStep(name=stepName, Sequences=[jetSequence], chainDicts=[chainDict]) l1Thresholds = [] for part in chainDict['chainParts']: l1Thresholds.append(part['L1threshold']) log.debug('dictionary is: %s\n', pprint.pformat(chainDict)) acc.printConfig() chain = Chain(chainDict['chainName'], L1Thresholds=l1Thresholds, ChainSteps=[jetStep]) return chain
def generateChains(flags, chainDict): firstStepName = getChainStepName('Photon', 1) stepReco, stepView = createStepView(firstStepName) accCalo = ComponentAccumulator() accCalo.addSequence(stepView) l2CaloReco = l2CaloRecoCfg(flags) accCalo.merge(l2CaloReco, sequenceName=stepReco.getName()) # this alg needs EventInfo decorated with the pileup info from LumiBlockComps.LumiBlockMuWriterConfig import LumiBlockMuWriterCfg accCalo.merge(LumiBlockMuWriterCfg(flags)) l2CaloHypo = l2CaloHypoCfg( flags, name='L2PhotonCaloHypo', CaloClusters=recordable('HLT_FastCaloEMClusters')) accCalo.addEventAlgo(l2CaloHypo, sequenceName=stepView.getName()) fastCaloSequence = CAMenuSequence( Sequence=l2CaloReco.sequence(), Maker=l2CaloReco.inputMaker(), Hypo=l2CaloHypo, HypoToolGen=TrigEgammaFastCaloHypoToolFromDict, CA=accCalo) fastCaloStep = ChainStep(firstStepName, [fastCaloSequence]) secondStepName = getChainStepName('Photon', 2) stepReco, stepView = createStepView(secondStepName) accPhoton = ComponentAccumulator() accPhoton.addSequence(stepView) l2PhotonReco = l2PhotonRecoCfg(flags) accPhoton.merge(l2PhotonReco, sequenceName=stepReco.getName()) l2PhotonHypo = l2PhotonHypoCfg(flags, Photons='HLT_FastPhotons', RunInView=True) accPhoton.addEventAlgo(l2PhotonHypo, sequenceName=stepView.getName()) l2PhotonSequence = CAMenuSequence( Sequence=l2PhotonReco.sequence(), Maker=l2PhotonReco.inputMaker(), Hypo=l2PhotonHypo, HypoToolGen=TrigEgammaFastPhotonHypoToolFromDict, CA=accPhoton) l2PhotonStep = ChainStep(secondStepName, [l2PhotonSequence]) l1Thresholds = [] for part in chainDict['chainParts']: l1Thresholds.append(part['L1threshold']) log.debug('dictionary is: %s\n', pprint.pformat(chainDict)) chain = Chain(chainDict['chainName'], L1Thresholds=l1Thresholds, ChainSteps=[fastCaloStep, l2PhotonStep]) return chain
def generateChains(flags, chainDict): import pprint pprint.pprint(chainDict) firstStepName = getChainStepName('Electron', 1) stepReco, stepView = createStepView(firstStepName) accCalo = ComponentAccumulator() accCalo.addSequence(stepView) l2CaloReco = l2CaloRecoCfg(flags) accCalo.merge(l2CaloReco, sequenceName=stepReco.getName()) # this alg needs EventInfo decorated with the pileup info from LumiBlockComps.LumiBlockMuWriterConfig import LumiBlockMuWriterCfg accCalo.merge(LumiBlockMuWriterCfg(flags)) l2CaloHypo = l2CaloHypoCfg( flags, name='L2ElectronCaloHypo', CaloClusters=recordable('HLT_FastCaloEMClusters')) accCalo.addEventAlgo(l2CaloHypo, sequenceName=stepView.getName()) fastCaloSequence = CAMenuSequence( Sequence=l2CaloReco.sequence(), Maker=l2CaloReco.inputMaker(), Hypo=l2CaloHypo, HypoToolGen=TrigEgammaFastCaloHypoToolFromDict, CA=accCalo) accCalo.printConfig() fastCaloStep = ChainStep(name=firstStepName, Sequences=[fastCaloSequence], chainDicts=[chainDict]) secondStepName = getChainStepName('Electron', 2) stepReco, stepView = createStepView(secondStepName) accTrk = ComponentAccumulator() accTrk.addSequence(stepView) # # # fast ID from TrigInDetConfig.TrigInDetConfig import indetInViewRecoCfg fastInDetReco = indetInViewRecoCfg(flags, viewMakerName='ElectronInDet', signature='Electron') accTrk.merge(fastInDetReco, sequenceName=stepReco.getName()) # TODO once tracking fully works remove fake hypos # TODO remove once full tracking is in place fakeHypoAlg = fakeHypoAlgCfg(flags, name='FakeHypoForElectron') def makeFakeHypoTool(chainDict, cfg=None): return CompFactory.getComp("HLTTest::TestHypoTool")( chainDict['chainName']) accTrk.addEventAlgo(fakeHypoAlg, sequenceName=stepView.getName()) fastInDetSequence = CAMenuSequence(Sequence=fastInDetReco.sequence(), Maker=fastInDetReco.inputMaker(), Hypo=fakeHypoAlg, HypoToolGen=makeFakeHypoTool, CA=accTrk) fastInDetStep = ChainStep(name=secondStepName, Sequences=[fastInDetSequence], chainDicts=[chainDict]) l1Thresholds = [] for part in chainDict['chainParts']: l1Thresholds.append(part['L1threshold']) # # # EF calo # # # EF ID # # # offline egamma chain = Chain(chainDict['chainName'], L1Thresholds=l1Thresholds, ChainSteps=[fastCaloStep, fastInDetStep]) return chain
def generateChains( flags, chainDict ): chainDict = splitChainDict(chainDict)[0] # Step 1 (L2MuonSA) stepName = getChainStepName('Muon', 1) stepReco, stepView = createStepView(stepName) acc = ComponentAccumulator() acc.addSequence(stepView) # Set EventViews for L2MuonSA step from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import InViewReco reco = InViewReco("L2MuFastReco") #external data loading to view reco.mergeReco( MuFastViewDataVerifier() ) # decoding # Get RPC BS decoder from MuonConfig.MuonBytestreamDecodeConfig import RpcBytestreamDecodeCfg rpcAcc = RpcBytestreamDecodeCfg( flags, forTrigger=True ) rpcAcc.getEventAlgo("RpcRawDataProvider").RoIs = reco.name+"RoIs" reco.mergeReco( rpcAcc ) # Get RPC BS->RDO convertor from MuonConfig.MuonRdoDecodeConfig import RpcRDODecodeCfg rpcAcc = RpcRDODecodeCfg( flags, forTrigger=True ) rpcAcc.getEventAlgo("RpcRdoToRpcPrepData").RoIs = reco.name+"RoIs" reco.mergeReco( rpcAcc ) # Get TGC BS decoder from MuonConfig.MuonBytestreamDecodeConfig import TgcBytestreamDecodeCfg tgcAcc = TgcBytestreamDecodeCfg( flags, forTrigger=True ) tgcAcc.getEventAlgo("TgcRawDataProvider").RoIs = reco.name+"RoIs" reco.mergeReco( tgcAcc ) # Get TGC BS->RDO convertor from MuonConfig.MuonRdoDecodeConfig import TgcRDODecodeCfg tgcAcc = TgcRDODecodeCfg( flags, forTrigger=True ) tgcAcc.getEventAlgo("TgcRdoToTgcPrepData").RoIs = reco.name+"RoIs" reco.mergeReco( tgcAcc ) # Get MDT BS decoder from MuonConfig.MuonBytestreamDecodeConfig import MdtBytestreamDecodeCfg mdtAcc = MdtBytestreamDecodeCfg( flags, forTrigger=True ) mdtAcc.getEventAlgo("MdtRawDataProvider").RoIs = reco.name+"RoIs" reco.mergeReco( mdtAcc ) # Get MDT BS->RDO convertor from MuonConfig.MuonRdoDecodeConfig import MdtRDODecodeCfg mdtAcc = MdtRDODecodeCfg( flags, forTrigger=True ) mdtAcc.getEventAlgo("MdtRdoToMdtPrepData").RoIs = reco.name+"RoIs" reco.mergeReco( mdtAcc ) # Get CSC BS decoder from MuonConfig.MuonBytestreamDecodeConfig import CscBytestreamDecodeCfg cscAcc = CscBytestreamDecodeCfg( flags, forTrigger=True ) cscAcc.getEventAlgo("CscRawDataProvider").RoIs = reco.name+"RoIs" reco.mergeReco( cscAcc ) # Get CSC BS->RDO convertor from MuonConfig.MuonRdoDecodeConfig import CscRDODecodeCfg cscAcc = CscRDODecodeCfg( flags, forTrigger=True ) cscAcc.getEventAlgo("CscRdoToCscPrepData").RoIs = reco.name+"RoIs" reco.mergeReco( cscAcc ) # Get CSC cluster builder from MuonConfig.MuonRdoDecodeConfig import CscClusterBuildCfg cscAcc = CscClusterBuildCfg( flags, forTrigger=True ) reco.mergeReco( cscAcc ) # Get Reco alg of muFast Step in order to set into the view algAcc, alg = l2MuFastAlgCfg( flags, roisKey=reco.name+"RoIs") l2MuFastAlgAcc = ComponentAccumulator() l2MuFastAlgAcc.addEventAlgo(alg) reco.mergeReco( l2MuFastAlgAcc ) reco.merge( algAcc ) # l2muFastReco = l2MuFastRecoCfg(flags) acc.merge( reco, sequenceName=stepReco.getName() ) ### Set muon step1 ### l2muFastHypo = l2MuFastHypoCfg( flags, name = 'TrigL2MuFastHypo', muFastInfo = 'MuonL2SAInfo' ) acc.addEventAlgo(l2muFastHypo, sequenceName=stepView.getName()) l2muFastSequence = CAMenuSequence( Sequence = reco.sequence(), Maker = reco.inputMaker(), Hypo = l2muFastHypo, HypoToolGen = TrigMufastHypoToolFromDict, CA = acc ) l2muFastStep = ChainStep( name=stepName, Sequences=[l2muFastSequence], chainDicts=[chainDict] ) ### Set muon step2 ### # Please set up L2muComb step here #EF MS only stepEFMSName = getChainStepName('EFMSMuon', 2) stepEFMSReco, stepEFMSView = createStepView(stepEFMSName) #Clone and replace offline flags so we can set muon trigger specific values muonflags = flags.cloneAndReplace('Muon', 'Trigger.Offline.Muon') muonflags.Muon.useTGCPriorNextBC=True muonflags.Muon.enableErrorTuning=False muonflags.Muon.MuonTrigger=True muonflags.Muon.SAMuonTrigger=True muonflags.lock() accMS = ComponentAccumulator() accMS.addSequence(stepEFMSView) from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import InViewReco recoMS = InViewReco("EFMuMSReco") recoMS.inputMaker().RequireParentView = True #Probably this block will eventually need to move somewhere more central from BeamPipeGeoModel.BeamPipeGMConfig import BeamPipeGeometryCfg accMS.merge( BeamPipeGeometryCfg(flags) ) from PixelGeoModel.PixelGeoModelConfig import PixelGeometryCfg accMS.merge(PixelGeometryCfg(flags)) from SCT_GeoModel.SCT_GeoModelConfig import SCT_GeometryCfg accMS.merge(SCT_GeometryCfg(flags)) from TRT_GeoModel.TRT_GeoModelConfig import TRT_GeometryCfg accMS.merge(TRT_GeometryCfg(flags)) from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg accMS.merge(TrackingGeometrySvcCfg(flags)) ################### EFMuonViewDataVerifier = EFMuonViewDataVerifierCfg() recoMS.mergeReco(EFMuonViewDataVerifier) from MuonConfig.MuonSegmentFindingConfig import MooSegmentFinderAlgCfg segCfg = MooSegmentFinderAlgCfg(muonflags,name="TrigMooSegmentFinder",UseTGCNextBC=False, UseTGCPriorBC=False) recoMS.mergeReco(segCfg) from MuonConfig.MuonTrackBuildingConfig import MuonTrackBuildingCfg trkCfg = MuonTrackBuildingCfg(muonflags, name="TrigMuPatTrackBuilder") recoMS.mergeReco(trkCfg) cnvCfg = MuonTrackParticleCnvCfg(muonflags, name = "TrigMuonTrackParticleCnvAlg") recoMS.mergeReco(cnvCfg) from MuonCombinedConfig.MuonCombinedReconstructionConfig import MuonCombinedMuonCandidateAlgCfg candCfg = MuonCombinedMuonCandidateAlgCfg(muonflags, name = "TrigMuonCandidateAlg") recoMS.mergeReco(candCfg) from MuonCombinedConfig.MuonCombinedReconstructionConfig import MuonCreatorAlgCfg creatorCfg = MuonCreatorAlgCfg(muonflags, name = "TrigMuonCreatorAlg") recoMS.mergeReco(creatorCfg) accMS.merge(recoMS, sequenceName=stepEFMSReco.getName()) efmuMSHypo = efMuMSHypoCfg( muonflags, name = 'TrigMuonEFMSonlyHypo', inputMuons = "Muons" ) accMS.addEventAlgo(efmuMSHypo, sequenceName=stepEFMSView.getName()) efmuMSSequence = CAMenuSequence( Sequence = recoMS.sequence(), Maker = recoMS.inputMaker(), Hypo = efmuMSHypo, HypoToolGen = TrigMuonEFMSonlyHypoToolFromDict, CA = accMS ) efmuMSStep = ChainStep( name=stepEFMSName, Sequences=[efmuMSSequence], chainDicts=[chainDict] ) l1Thresholds=[] for part in chainDict['chainParts']: l1Thresholds.append(part['L1threshold']) log.debug('dictionary is: %s\n', pprint.pformat(chainDict)) chain = Chain( name=chainDict['chainName'], L1Thresholds=l1Thresholds, ChainSteps=[ l2muFastStep, efmuMSStep ] ) return chain
def buildChain(self, chainSteps): myChain = Chain(name=self.chainName, ChainSteps=chainSteps, L1Thresholds=[self.L1Threshold]) return myChain