def efLateMuAlgSequence(ConfigFlags): from TriggerMenuMT.HLTMenuConfig.Muon.MuonSetup import muEFInsideOutRecoSequence, makeMuonPrepDataAlgs, muonIDFastTrackingSequence eflateViewsMaker = EventViewCreatorAlgorithm("IMeflatemu") roiTool = ViewCreatorNamedROITool( ) # Use an existing ROI which is linked to the navigation with a custom name. roiTool.ROILinkName = "feature" # The ROI is actually linked as Step 1's feature. So the custom name is "feature". # eflateViewsMaker.mergeUsingFeature = True # Expect to have efLateMuRoIAlgSequence produce one Decision Object per lateROI, keep these distinct in the merging eflateViewsMaker.RoITool = roiTool # eflateViewsMaker.Views = "MUEFLATEViewRoIs" eflateViewsMaker.InViewRoIs = "MUEFLATERoIs" # eflateViewsMaker.ViewFallThrough = True #decode data in these RoIs viewAlgs_MuonPRD = makeMuonPrepDataAlgs(RoIs=eflateViewsMaker.InViewRoIs) #ID fast tracking muFastIDRecoSequence = muonIDFastTrackingSequence( eflateViewsMaker.InViewRoIs, "Late") #inside-out reco sequence muonEFInsideOutRecoSequence, sequenceOut = muEFInsideOutRecoSequence( eflateViewsMaker.InViewRoIs, "LateMu") lateMuRecoSequence = parOR( "lateMuonRecoSequence", [viewAlgs_MuonPRD, muFastIDRecoSequence, muonEFInsideOutRecoSequence]) #Final sequence running in view eflateViewsMaker.ViewNodeName = lateMuRecoSequence.name() muonSequence = seqAND("lateMuonOutSequence", [eflateViewsMaker, lateMuRecoSequence]) return (muonSequence, eflateViewsMaker, sequenceOut)
def HLTFSTopoRecoSequence(RoIs): cellMaker = HLTCellMaker(RoIs, outputName="CaloCellsFS", algSuffix="FS") topoClusterMaker = _algoHLTTopoCluster(inputEDM=cellMaker.CellsName, algSuffix="FS") RecoSequence = parOR("TopoClusterRecoSequenceFS", [cellMaker, topoClusterMaker]) return (RecoSequence, topoClusterMaker.CaloClusters)
def precisionElectronSequence(ConfigFlags): """ fourth step: precision electron.....""" InViewRoIs = "precisionElectron" # EVCreator: precisionElectronViewsMaker = EventViewCreatorAlgorithm( "IMprecisionElectron") precisionElectronViewsMaker.RoIsLink = "initialRoI" precisionElectronViewsMaker.RoITool = ViewCreatorInitialROITool() precisionElectronViewsMaker.InViewRoIs = InViewRoIs precisionElectronViewsMaker.Views = "precisionElectronViews" #precisionElectronViews precisionElectronViewsMaker.ViewFallThrough = True precisionElectronViewsMaker.RequireParentView = True # Configure the reconstruction algorithm sequence from TriggerMenuMT.HLTMenuConfig.Electron.PrecisionElectronRecoSequences import precisionElectronRecoSequence (electronPrecisionRec, electronPrecisionTrack, sequenceOut) = precisionElectronRecoSequence(InViewRoIs) electronPrecisionInViewAlgs = parOR( "electronPrecisionInViewAlgs", [electronPrecisionTrack, electronPrecisionRec]) precisionElectronViewsMaker.ViewNodeName = "electronPrecisionInViewAlgs" electronPrecisionAthSequence = seqAND( "electronPrecisionAthSequence", [precisionElectronViewsMaker, electronPrecisionInViewAlgs]) return (electronPrecisionAthSequence, precisionElectronViewsMaker, sequenceOut)
def createCFTree(CFseq): """ Creates AthSequencer nodes with sequences attached """ log.debug(" *** Create CF Tree for CFSequence %s", CFseq.step.name) filterAlg = CFseq.filter.Alg #empty step: if len(CFseq.step.sequences) == 0: seqAndWithFilter = seqAND(CFseq.step.name, [filterAlg]) return seqAndWithFilter stepReco = parOR( CFseq.step.name + CFNaming.RECO_POSTFIX ) # all reco algoritms from al lthe sequences in a parallel sequence seqAndView = seqAND( CFseq.step.name + CFNaming.VIEW_POSTFIX, [stepReco]) # include in seq:And to run in views: add here the Hypo seqAndWithFilter = seqAND( CFseq.step.name, [filterAlg, seqAndView]) # add to the main step+filter recoSeq_list = set() hypo_list = set() for menuseq in CFseq.step.sequences: menuseq.addToSequencer(recoSeq_list, hypo_list) stepReco += [recoseq for recoseq in recoSeq_list] seqAndView += [hypo for hypo in hypo_list] if CFseq.step.isCombo: seqAndView += CFseq.step.combo.Alg return seqAndWithFilter
def muEFSAFSAlgSequence(ConfigFlags): efsafsInputMaker = EventViewCreatorAlgorithm("IMMuonFS") fsRoiTool = ViewCreatorFSROITool() fsRoiTool.RoisWriteHandleKey = "MuonFS_RoIs" # efsafsInputMaker.RoIsLink = "initialRoI" # Only expect to get in one FS RI efsafsInputMaker.RoITool = fsRoiTool # Use new FS roi (note: the ViewCreatorInitialROITool should work excactly the same here) # efsafsInputMaker.Views = "MUFSViewRoI" efsafsInputMaker.InViewRoIs = "MUFSRoIs" # efsafsInputMaker.ViewFallThrough = True ### get EF reco sequence ### from TriggerMenuMT.HLTMenuConfig.Muon.MuonSetup import muEFSARecoSequence, makeMuonPrepDataAlgs viewAlgs_MuonPRD = makeMuonPrepDataAlgs(RoIs=efsafsInputMaker.InViewRoIs, forFullScan=True) muEFSAFSRecoSequence, sequenceOut = muEFSARecoSequence( efsafsInputMaker.InViewRoIs, 'FS') muEFFSRecoSequence = parOR("muEFSAFSRecoSequence", [viewAlgs_MuonPRD, muEFSAFSRecoSequence]) efsafsInputMaker.ViewNodeName = muEFFSRecoSequence.name() muonEFSAFSSequence = seqAND("muonEFSAFSSequence", [efsafsInputMaker, muEFFSRecoSequence]) return (muonEFSAFSSequence, efsafsInputMaker, sequenceOut)
def HLTLCTopoRecoSequence(RoIs='InViewRoIs'): cellMaker = HLTCellMaker(RoIs, outputName="CaloCellsLC", algSuffix="LC") topoClusterMaker = _algoHLTTopoClusterLC(inputEDM=cellMaker.CellsName, algSuffix="LC") RecoSequence = parOR("TopoClusterRecoSequenceLC", [cellMaker, topoClusterMaker]) return (RecoSequence, topoClusterMaker.CaloClusters)
def muFastAlgSequence(ConfigFlags): ### set the EVCreator ### l2MuViewsMaker = EventViewCreatorAlgorithm("IMl2Mu") # l2MuViewsMaker.RoIsLink = "initialRoI" # ROI is from L1 l2MuViewsMaker.RoITool = ViewCreatorInitialROITool() # ROI is from L1 # l2MuViewsMaker.Views = "MUViewRoIs" l2MuViewsMaker.InViewRoIs = "MURoIs" # l2MuViewsMaker.ViewFallThrough = True ### get muFast reco sequence ### from TriggerMenuMT.HLTMenuConfig.Muon.MuonSetup import muFastRecoSequence, makeMuonPrepDataAlgs viewAlgs_MuonPRD = makeMuonPrepDataAlgs(RoIs=l2MuViewsMaker.InViewRoIs) muFastRecoSequence, sequenceOut = muFastRecoSequence( l2MuViewsMaker.InViewRoIs, doFullScanID=False) muFastSequence = parOR("muFastRecoSequence", [viewAlgs_MuonPRD, muFastRecoSequence]) l2MuViewsMaker.ViewNodeName = muFastSequence.name() l2muFastSequence = seqAND("l2muFastSequence", [l2MuViewsMaker, muFastSequence]) return (l2muFastSequence, l2MuViewsMaker, sequenceOut)
def getRecosStepSeq( stepNumber ): """ """ getFiltersStepSeq( stepNumber ) # make sure there is filters step before recos name = 'Step{}{}'.format(stepNumber, CFNaming.RECO_POSTFIX) seq = parOR( name ) acc.addSequence( seq, parentName = mainSequenceName ) return seq
def runTest(self): # replicate HLT issue, it occured because the sequnces were recorded in the order of storing in the dict and thus the # some of them (in this case hltSteps) did not have properties recorded acc = ComponentAccumulator() acc.addSequence(seqOR("hltTop")) algos2 = TestAlgo("RecoAlgInTop") acc.addEventAlgo(algos2, sequenceName="hltTop") # some algo acc.addSequence(seqAND("hltSteps"), parentName="hltTop") acc.addSequence(parOR("hltStep_1"), parentName="hltSteps") acc.addSequence(seqAND("L2CaloEgammaSeq"), "hltStep_1") acc.addSequence(parOR("hltStep_2"), parentName="hltSteps") acc.moveSequence("L2CaloEgammaSeq", "hltStep_2") fout = open("testFile2.pkl", "wb") acc.store(fout) fout.close()
def setUp(self): # trivial case without any nested sequences log.setLevel(DEBUG) dummyCfgFlags = AthConfigFlags() dummyCfgFlags.lock() def AlgsConf1(flags): acc = ComponentAccumulator() a1 = TestAlgo("Algo1") a2 = TestAlgo("Algo2") return acc, [a1, a2] def AlgsConf2(flags): acc = ComponentAccumulator() result, algs = AlgsConf1(flags) acc.merge(result) a = TestAlgo("Algo3") print("algo3 when created %s" % id(a)) algs.append(a) return acc, algs acc = ComponentAccumulator() # top level algs acc1, algs = AlgsConf2(dummyCfgFlags) acc.merge(acc1) acc.addEventAlgo(algs) def AlgsConf3(flags): acc = ComponentAccumulator() na1 = TestAlgo("NestedAlgo1") return acc, na1 def AlgsConf4(flags): acc, na1 = AlgsConf3(flags) NestedAlgo2 = TestAlgo("NestedAlgo2") NestedAlgo2.OutputLevel = 7 return acc, na1, NestedAlgo2 acc.addSequence(seqAND("Nest")) acc.addSequence(seqAND("subSequence1"), parentName="Nest") acc.addSequence(parOR("subSequence2"), parentName="Nest") acc.addSequence(seqAND("sub2Sequence1"), parentName="subSequence1") acc.addSequence(seqAND("sub3Sequence1"), parentName="subSequence1") acc.addSequence(seqAND("sub4Sequence1"), parentName="subSequence1") accNA1 = AlgsConf4(dummyCfgFlags) acc.merge(accNA1[0]) acc.addEventAlgo(accNA1[1:], "sub2Sequence1") outf = open("testFile.pkl", "wb") acc.store(outf) outf.close() self.acc = acc
def getFiltersStepSeq( stepNumber ): """ Returns sequence containing all filters for a step """ name = 'Step{}_{}'.format(stepNumber, CFNaming.FILTER_POSTFIX) if stepNumber > 1: getRecosStepSeq( stepNumber -1 ) # make sure steps sequencers are correctly made: Step1_filter, Step1_recos, Step2_filters, Step2_recos ... seq = parOR( name ) acc.addSequence( seq, parentName = mainSequenceName ) return seq
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 muEFCBAlgSequence(ConfigFlags): #By default the EFCB sequence will run both outside-in and #(if zero muons are found) inside-out reconstruction from TrigMuonEF.TrigMuonEFConf import MuonFilterAlg, MergeEFMuonsAlg from TriggerMenuMT.HLTMenuConfig.Muon.MuonSetup import muEFCBRecoSequence, muEFInsideOutRecoSequence efcbViewsMaker = EventViewCreatorAlgorithm("IMefcbtotal") # efcbViewsMaker.RoIsLink = "roi" # Merge based on L2SA muon efcbViewsMaker.RoITool = ViewCreatorPreviousROITool( ) # Spawn EventViews on L2SA muon ROI # efcbViewsMaker.Views = "MUEFCBViewRoIs" efcbViewsMaker.InViewRoIs = "MUEFCBRoIs" # efcbViewsMaker.RequireParentView = True efcbViewsMaker.ViewFallThrough = True efcbViewsMaker.mergeUsingFeature = True #outside-in reco sequence muEFCBRecoSequence, sequenceOutCB = muEFCBRecoSequence( efcbViewsMaker.InViewRoIs, "RoI") #Algorithm to filter events with no muons muonFilter = MuonFilterAlg("FilterZeroMuons") muonFilter.MuonContainerLocation = sequenceOutCB #inside-out reco sequence - runs only if filter is passed muonEFInsideOutRecoSequence, sequenceOutInsideOut = muEFInsideOutRecoSequence( efcbViewsMaker.InViewRoIs, "RoI") muonInsideOutSequence = seqAND("muonEFInsideOutSequence", [muonFilter, muonEFInsideOutRecoSequence]) #combine outside-in and inside-out sequences muonRecoSequence = parOR("muonEFCBandInsideOutRecoSequence", [muEFCBRecoSequence, muonInsideOutSequence]) #Merge muon containers from outside-in and inside-out reco muonMerger = MergeEFMuonsAlg("MergeEFMuons") muonMerger.MuonCBContainerLocation = sequenceOutCB muonMerger.MuonInsideOutContainerLocation = sequenceOutInsideOut muonMerger.MuonOutputLocation = muNames.EFCBName sequenceOut = muonMerger.MuonOutputLocation #Add merging alg in sequence with reco sequences mergeSequence = seqOR("muonCBInsideOutMergingSequence", [muonRecoSequence, muonMerger]) #Final sequence running in view efcbViewsMaker.ViewNodeName = mergeSequence.name() muonSequence = seqAND("muonEFCBandInsideOutSequence", [efcbViewsMaker, mergeSequence]) return (muonSequence, efcbViewsMaker, sequenceOut)
def createStepRecoNode(name, seq_list, dump=False): """ elementary HLT reco step, contianing all sequences of the step """ log.debug("Create reco step %s with %d sequences", name, len(seq_list)) stepCF = parOR(name + CFNaming.RECO_POSTFIX) for seq in seq_list: stepCF += createCFTree(seq) if dump: dumpSequence(stepCF, indent=0) return stepCF
def precisionPhotonRecoSequence(RoIs): """ With this function we will setup the sequence of offline EgammaAlgorithms so to make a photon for TrigEgamma Sequence of algorithms is the following: - egammaRecBuilder/TrigEgammaRecPhoton creates egammaObjects out of clusters and tracks. Here, at HLT photons we will only use clusters. - photonSuperClusterBuilder algorithm will create superclusters out of the toposlusters and tracks in egammaRec under the photon hypothesis https://gitlab.cern.ch/atlas/athena/blob/master/Reconstruction/egamma/egammaAlgs/python/egammaSuperClusterBuilder.py#L26 - TopoEgammBuilder will create photons and electrons out of trakcs and SuperClusters. Here at HLT photons the aim is to ignore electrons and not use tracks at all. https://gitlab.cern.ch/atlas/athena/blob/master/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx """ log.debug('precisionPhotonRecoSequence(RoIs = %s)', RoIs) # First the data verifiers: # Here we define the data dependencies. What input needs to be available for the Fexs (i.e. TopoClusters from precisionCalo) in order to run from TriggerMenuMT.HLTMenuConfig.Egamma.PrecisionCaloSequenceSetup import precisionCaloMenuDefs import AthenaCommon.CfgMgr as CfgMgr ViewVerify = CfgMgr.AthViews__ViewDataVerifier( "PrecisionPhotonPhotonViewDataVerifier") ViewVerify.DataObjects = [ ('xAOD::CaloClusterContainer', 'StoreGateSvc+' + precisionCaloMenuDefs.precisionCaloClusters), ('CaloCellContainer', 'StoreGateSvc+CaloCells') ] # Retrieve the factories now from TriggerMenuMT.HLTMenuConfig.Photon.TrigPhotonFactories import TrigEgammaRecPhoton, TrigPhotonSuperClusterBuilder, TrigTopoEgammaPhotons log.debug('retrieve(precisionPhotonRecoSequence,None,RoIs = %s)', RoIs) # The sequence of these algorithms thesequence = parOR( "precisionPhotonAlgs" ) # This thing creates the sequence with name precisionPhotonAlgs thesequence += ViewVerify # Add to the sequence the three steps: # - TrigEgammaBuilder, TrigPhotonSuperClusters, TrigTopoEgammaPhotons TrigEgammaAlgo = TrigEgammaRecPhoton() TrigEgammaAlgo.InputTopoClusterContainerName = precisionCaloMenuDefs.precisionCaloClusters thesequence += TrigEgammaAlgo trigPhotonAlgo = TrigPhotonSuperClusterBuilder() trigPhotonAlgo.InputEgammaRecContainerName = TrigEgammaAlgo.egammaRecContainer thesequence += trigPhotonAlgo trigTopoEgammaAlgo = TrigTopoEgammaPhotons() trigTopoEgammaAlgo.SuperPhotonRecCollectionName = trigPhotonAlgo.SuperPhotonRecCollectionName collectionOut = trigTopoEgammaAlgo.PhotonOutputName thesequence += trigTopoEgammaAlgo return (thesequence, collectionOut)
def caloClusterRecoSequence( flags, name="HLTCaloClusterMakerFS", RoIs="HLT_FSJETRoI", outputName="HLT_TopoCaloClustersFS"): """ Create the EM-level fullscan clusters """ cell_sequence, cells_name = RecoFragmentsPool.retrieve(cellRecoSequence, flags=None, RoIs=RoIs) from TrigCaloRec.TrigCaloRecConfig import TrigCaloClusterMakerMT_topo alg = TrigCaloClusterMakerMT_topo( name, doMoments=True, doLC=False, cells=cells_name) alg.CaloClusters = recordable(outputName) return parOR(name+"RecoSequence", [cell_sequence, alg]), alg.CaloClusters
def cellRecoSequence(flags, name="HLTCaloCellMakerFS", RoIs="HLT_FSJETRoI", outputName="CaloCellsFS"): """ Produce the full scan cell collection """ if not RoIs: from L1Decoder.L1DecoderConfig import mapThresholdToL1RoICollection RoIs = mapThresholdToL1RoICollection("FSNOSEED") from TrigT2CaloCommon.CaloDef import setMinimalCaloSetup setMinimalCaloSetup() from AthenaCommon.AppMgr import ServiceMgr as svcMgr from TrigCaloRec.TrigCaloRecConfig import HLTCaloCellMaker alg = HLTCaloCellMaker(name) alg.RoIs=RoIs alg.TrigDataAccessMT=svcMgr.TrigCaloDataAccessSvc alg.CellsName=outputName return parOR(name+"RecoSequence", [alg]), alg.CellsName
def make_hlt_seq(num_chains, concurrent=False): hypo_algs = make_all_hypo_algs(num_chains, concurrent) configure_hlt_result(hypo_algs) summary_algs = make_summary_algs(hypo_algs) from AthenaCommon.CFElements import seqOR, parOR all_algs = [] if concurrent: hypo_seq = parOR('hypoSeq', hypo_algs) all_algs.append(hypo_seq) else: all_algs.extend(hypo_algs) all_algs.extend(summary_algs) return seqOR('hltTop', all_algs)
def LCCaloClusterRecoSequence( flags, name="HLTCaloClusterCalibratorLCFS", RoIs="HLT_FSJETRoI", outputName="HLT_TopoCaloClustersLCFS"): """ Create the LC calibrated fullscan clusters The clusters will be created as a shallow copy of the EM level clusters """ em_sequence, em_clusters = RecoFragmentsPool.retrieve(caloClusterRecoSequence, flags=None, RoIs=RoIs) from TrigCaloRec.TrigCaloRecConfig import TrigCaloClusterCalibratorMT_LC alg = TrigCaloClusterCalibratorMT_LC( name, InputClusters = em_clusters, OutputClusters = outputName, OutputCellLinks = outputName+"_cellLinks") return parOR(name+"RecoSequence", [em_sequence, alg]), alg.OutputClusters
def tauCaloRecoSequence(InViewRoIs, SeqName): global TauCaloJetContainer # lc sequence (lcTopoInViewSequence, lcCaloSequenceOut) = RecoFragmentsPool.retrieve(HLTLCTopoRecoSequence, InViewRoIs) tauCaloRoiUpdaterAlg = _algoTauRoiUpdater(inputRoIs=InViewRoIs, clusters=lcCaloSequenceOut) updatedRoIs = tauCaloRoiUpdaterAlg.RoIOutputKey tauCaloOnlyAlg = _algoTauCaloOnly(L1RoIs=InViewRoIs, inputRoIs=updatedRoIs, clusters=lcCaloSequenceOut) RecoSequence = parOR( SeqName, [lcTopoInViewSequence, tauCaloRoiUpdaterAlg, tauCaloOnlyAlg]) return (RecoSequence, tauCaloOnlyAlg.Key_trigTauJetOutputContainer)
def fastPhotonMenuSequence(): """Creates secpond step photon sequence""" from TriggerMenuMT.HLTMenuConfig.CommonSequences.CaloSequenceSetup import CaloMenuDefs ViewVerify = CfgMgr.AthViews__ViewDataVerifier( "FastPhotonViewDataVerifier") ViewVerify.DataObjects = [('xAOD::TrigEMClusterContainer', 'StoreGateSvc+' + CaloMenuDefs.L2CaloClusters), ('TrigRoiDescriptorCollection', 'StoreGateSvc+EMIDRoIs')] from TrigEgammaHypo.TrigEgammaFastPhotonFexMTConfig import EgammaFastPhotonFex_1 thePhotonFex = EgammaFastPhotonFex_1() thePhotonFex.TrigEMClusterName = CaloMenuDefs.L2CaloClusters thePhotonFex.PhotonsName = recordable("HLT_FastPhotons") #thePhotonFex.RoIs="EMIDRoIs" l2PhotonViewsMaker = EventViewCreatorAlgorithm("IMl2Photon") l2PhotonViewsMaker.RoIsLink = "initialRoI" l2PhotonViewsMaker.InViewRoIs = "EMIDRoIs" #l2PhotonViewsMaker.InViewRoIs = "EMCaloRoIs" l2PhotonViewsMaker.RoITool = ViewCreatorInitialROITool() l2PhotonViewsMaker.Views = "EMPhotonViews" l2PhotonViewsMaker.ViewFallThrough = True l2PhotonViewsMaker.RequireParentView = True thePhotonFex.RoIs = l2PhotonViewsMaker.InViewRoIs photonInViewAlgs = parOR("photonInViewAlgs", [ViewVerify, thePhotonFex]) l2PhotonViewsMaker.ViewNodeName = "photonInViewAlgs" from TrigEgammaHypo.TrigEgammaHypoConf import TrigEgammaFastPhotonHypoAlgMT thePhotonHypo = TrigEgammaFastPhotonHypoAlgMT() thePhotonHypo.Photons = thePhotonFex.PhotonsName thePhotonHypo.RunInView = True # this needs to be added: #electronDecisionsDumper = DumpDecisions("electronDecisionsDumper", Decisions = theElectronHypo.Output ) photonAthSequence = seqAND("photonAthSequence", [l2PhotonViewsMaker, photonInViewAlgs]) from TrigEgammaHypo.TrigEgammaFastPhotonHypoTool import TrigEgammaFastPhotonHypoToolFromDict return MenuSequence(Maker=l2PhotonViewsMaker, Sequence=photonAthSequence, Hypo=thePhotonHypo, HypoToolGen=TrigEgammaFastPhotonHypoToolFromDict)
def PFHLTSequence(dummyflags, clustersin, tracktype): PFTrkSel = getPFTrackSel(tracktype) PFAlg = getPFAlg(clustersin, tracktype) PFCCreator, PFNCreator = getPFOCreators(tracktype) # Create HLT "parallel OR" sequence holding the PF algs # Can be inserted into the jet building sequence from AthenaCommon.CFElements import parOR pfSequence = parOR("HLTPFlow_" + tracktype, [PFTrkSel, PFAlg, PFCCreator, PFNCreator]) pfoPrefix = "HLT_" + tracktype log.debug("Created sequence:\n%s", pfSequence) return pfSequence, pfoPrefix
def createStepFilterNode(name, seq_list, dump=False): """ elementary HLT filter step: OR node containing all Filters of the sequences. The node gates execution of next reco step """ log.debug("Create filter step %s with %d filters", name, len(seq_list)) filter_list = [] for seq in seq_list: filterAlg = seq.filter.Alg log.info("createStepFilterNode: Add %s to filter node %s", filterAlg.name(), name) if filterAlg not in filter_list: filter_list.append(filterAlg) stepCF = parOR(name + CFNaming.FILTER_POSTFIX, subs=filter_list) if dump: dumpSequence(stepCF, indent=0) return stepCF
def HLTRoITopoRecoSequence(RoIs): import AthenaCommon.CfgMgr as CfgMgr HLTRoITopoRecoSequenceVDV = CfgMgr.AthViews__ViewDataVerifier( "HLTRoITopoRecoSequenceVDV") HLTRoITopoRecoSequenceVDV.DataObjects = [ ('TrigRoiDescriptorCollection', 'StoreGateSvc+PrecisionCaloRoIs'), ('CaloBCIDAverage', 'StoreGateSvc+CaloBCIDAverage'), ('ILArHVScaleCorr', 'ConditionStore+LArHVScaleCorrRecomputed') ] cellMaker = HLTCellMaker(RoIs, algSuffix="RoI") topoClusterMaker = _algoHLTTopoCluster(inputEDM=cellMaker.CellsName, algSuffix="RoI") RecoSequence = parOR( "RoITopoClusterRecoSequence", [HLTRoITopoRecoSequenceVDV, cellMaker, topoClusterMaker]) return (RecoSequence, topoClusterMaker.CaloClusters)
def muCombAlgSequence(ConfigFlags): ### set the EVCreator ### l2muCombViewsMaker = EventViewCreatorAlgorithm("IMl2muComb") newRoITool = ViewCreatorFetchFromViewROITool() newRoITool.RoisWriteHandleKey = recordable( "HLT_Roi_L2SAMuon") #RoI collection recorded to EDM newRoITool.InViewRoIs = muNames.L2forIDName #input RoIs from L2 SA views # l2muCombViewsMaker.RoIsLink = "initialRoI" # ROI for merging is still from L1, we get exactly one L2 SA muon per L1 ROI l2muCombViewsMaker.RoITool = newRoITool # Create a new ROI centred on the L2 SA muon from Step 1 # l2muCombViewsMaker.Views = "MUCombViewRoIs" #output of the views maker (key in "storegate") l2muCombViewsMaker.InViewRoIs = "MUIDRoIs" # Name of the RoI collection inside of the view, holds the single ROI used to seed the View. # l2muCombViewsMaker.RequireParentView = True l2muCombViewsMaker.ViewFallThrough = True #if this needs to access anything from the previous step, from within the view ### get ID tracking and muComb reco sequences ### from TriggerMenuMT.HLTMenuConfig.Muon.MuonSetup import muCombRecoSequence, muonIDFastTrackingSequence muCombRecoSequence, sequenceOut = muCombRecoSequence( l2muCombViewsMaker.InViewRoIs, "FTF") #Filter algorithm to run muComb only if non-Bphysics muon chains are active from TrigMuonEF.TrigMuonEFConf import MuonChainFilterAlg from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponentsNaming import CFNaming muonChainFilter = MuonChainFilterAlg("FilterBphysChains") bphysChains = getBphysChainNames() muonChainFilter.ChainsToFilter = bphysChains muonChainFilter.InputDecisions = [ CFNaming.inputMakerOutName(l2muCombViewsMaker.name()) ] muonChainFilter.L2MuCombContainer = sequenceOut muCombFilterSequence = seqAND("l2muCombFilterSequence", [muonChainFilter, muCombRecoSequence]) extraLoads = [] from IOVDbSvc.CondDB import conddb if not conddb.folderRequested('/PIXEL/DCS/FSMSTATUS'): extraLoads += [('CondAttrListCollection', 'ConditionStore+/PIXEL/DCS/FSMSTATUS')] if not conddb.folderRequested('/PIXEL/DCS/FSMSTATE'): extraLoads += [('CondAttrListCollection', 'ConditionStore+/PIXEL/DCS/FSMSTATE')] for decision in muonChainFilter.InputDecisions: extraLoads += [('xAOD::TrigCompositeContainer', 'StoreGateSvc+' + decision)] muFastIDRecoSequence = muonIDFastTrackingSequence( l2muCombViewsMaker.InViewRoIs, "", extraLoads) muCombIDSequence = parOR("l2muCombIDSequence", [muFastIDRecoSequence, muCombFilterSequence]) l2muCombViewsMaker.ViewNodeName = muCombIDSequence.name() l2muCombSequence = seqAND("l2muCombSequence", [l2muCombViewsMaker, muCombIDSequence]) return (l2muCombSequence, l2muCombViewsMaker, sequenceOut)
def tauIdTrackSequence(RoIs, name): tauIdTrackSequence = seqAND(name) signName = "Tau" if ("Iso" in name) or ("TrackTwo" in name) or ("EF" in name): signName = 'TauIso' from TrigInDetConfig.InDetSetup import makeInDetAlgs viewAlgs, viewVerify = makeInDetAlgs(whichSignature=signName, separateTrackParticleCreator=signName, rois=RoIs) tauViewDataVerifierName = "" if "FTFId" in name: tauViewDataVerifierName = "tauViewDataVerifierIdFTF" elif "FTFTrackInView" in name: tauViewDataVerifierName = "tauViewDataVerifierTrackFTF" elif "FTFTrackTwo" in name: tauViewDataVerifierName = "tauViewDataVerifierTrackTwoFTF" elif "FTFIso" in name: tauViewDataVerifierName = "tauViewDataVerifierIsoFTF" elif "EF" in name: tauViewDataVerifierName = "tauViewDataVerifierEF" from TrigInDetConfig.InDetSetup import makeInDetAlgs viewAlgs, viewVerify = makeInDetAlgs(whichSignature=signName, separateTrackParticleCreator=signName, rois=RoIs, viewVerifier=tauViewDataVerifierName) if "FTFIso" in name: viewVerify.DataObjects += [ ('xAOD::TauJetContainer', 'StoreGateSvc+HLT_TrigTauRecMerged_CaloOnlyMVA') ] else: viewVerify.DataObjects += [ ('xAOD::TauJetContainer', 'StoreGateSvc+HLT_TrigTauRecMerged_CaloOnly') ] viewVerify.DataObjects += [ ('xAOD::TauTrackContainer', 'StoreGateSvc+HLT_tautrack_dummy'), ('TrigRoiDescriptorCollection', 'StoreGateSvc+' + RoIs), ('xAOD::EventInfo', 'StoreGateSvc+EventInfo'), ('SG::AuxElement', 'StoreGateSvc+EventInfo.AveIntPerXDecor'), ('SG::AuxElement', 'StoreGateSvc+EventInfo.ActIntPerXDecor'), ('TrigRoiDescriptorCollection', 'StoreGateSvc+TAUCaloRoIs') ] # Make sure the required objects are still available at whole-event level from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from IOVDbSvc.CondDB import conddb if not conddb.folderRequested("PixelClustering/PixelClusNNCalib"): viewVerify.DataObjects += [('TTrainedNetworkCollection', 'ConditionStore+PixelClusterNN'), ('TTrainedNetworkCollection', 'ConditionStore+PixelClusterNNWithTrack')] if globalflags.InputFormat.is_bytestream(): viewVerify.DataObjects += [ ('InDetBSErrContainer', 'StoreGateSvc+PixelByteStreamErrs'), ('IDCInDetBSErrContainer', 'StoreGateSvc+SCT_ByteStreamErrs') ] else: topSequence.SGInputLoader.Load += [('TRT_RDO_Container', 'StoreGateSvc+TRT_RDOs')] viewVerify.DataObjects += [('TRT_RDO_Container', 'StoreGateSvc+TRT_RDOs')] for viewAlg in viewAlgs: tauIdTrackSequence += viewAlg if "TrigFastTrackFinder" in viewAlg.name(): TrackCollection = viewAlg.TracksName if "InDetTrigTrackParticleCreatorAlg" in viewAlg.name(): TrackParticlesName = viewAlg.TrackParticlesName if "FTFTrackInView" in name: tauPreselectionAlg = _algoTauPreselection(inputRoIs=RoIs, tracks=TrackParticlesName, step="Track") tauIdTrackSequence += tauPreselectionAlg elif "TrackTwo" in name: tauPreselectionAlg = _algoTauPreselection(inputRoIs=RoIs, tracks=TrackParticlesName, step="TrackTwo") tauIdTrackSequence += tauPreselectionAlg #Precision Tracking PTAlgs = [] #List of precision tracking algs PTTracks = [] #List of TrackCollectionKeys PTTrackParticles = [] #List of TrackParticleKeys from TrigInDetConfig.InDetPT import makeInDetPrecisionTracking #When run in a different view than FTF some data dependencies needs to be loaded through verifier #Pass verifier as an argument and it will automatically append necessary DataObjects@NOTE: Don't provide any verifier if loaded in the same view as FTF precName = "" if "FTFId" in name: precName = 'tauId' elif "FTFTrackInView" in name: precName = 'tauTrk' elif "FTFTrackTwo" in name: precName = 'tauTrkTwo' elif "FTFIso" in name: precName = 'tau' elif "EF" in name: precName = 'tauEF' PTTracks, PTTrackParticles, PTAlgs = makeInDetPrecisionTracking( precName, verifier=False, rois=RoIs, inputFTFtracks=TrackCollection) PTSeq = parOR("precisionTrackingIn" + precName, PTAlgs) #Get last tracks from the list as input for other alg tauIdTrackSequence += PTSeq trackParticles = PTTrackParticles[-1] if "FTFId" in name: tauPrecisionAlg = _algoTauPrecision(inputRoIs=RoIs, tracks=trackParticles, step="Id") elif "FTFTrackInView" in name: tauPrecisionAlg = _algoTauPrecision(inputRoIs=RoIs, tracks=trackParticles, step="Track") elif "FTFTrackTwo" in name: tauPrecisionAlg = _algoTauPrecision(inputRoIs=RoIs, tracks=trackParticles, step="TrackTwo") elif "FTFIso" in name: tauPrecisionAlg = _algoTauPrecisionMVA(inputRoIs=RoIs, tracks=trackParticles, step="PrecisionMVA") elif "EF" in name: tauPrecisionAlg = _algoTauPrecisionMVA(inputRoIs=RoIs, tracks=trackParticles, step="EF") tauIdTrackSequence += tauPrecisionAlg sequenceOut = tauPrecisionAlg.Key_trigTauJetOutputContainer return tauIdTrackSequence, sequenceOut
def JetRecCfg(jetdef, configFlags, jetnameprefix="", jetnamesuffix="", evsprefix="", jetnameoverride=None): # Ordinarily we want to have jet collection names be descriptive and derived from # the configured reconstruction. # Nevertheless, we allow an explicit specification when necessary # e.g. to ensure that the correct name is used in grooming operations if jetnameoverride: jetsfullname = jetnameoverride else: jetsfullname = jetnameprefix + jetdef.basename + "Jets" + jetnamesuffix jetlog.info("Setting up to find {0}".format(jetsfullname)) sequencename = jetsfullname components = ComponentAccumulator() from AthenaCommon.CFElements import parOR components.addSequence(parOR(sequencename)) deps = resolveDependencies(jetdef) # Schedule the various input collections. # We don't have to worry about ordering, as the scheduler # will handle the details. Just merge the components. # # To facilitate running in serial mode, we also prepare # the constituent PseudoJetAlgorithm here (needed for rho) inputcomps = JetInputCfg(deps["inputs"], configFlags, sequenceName=jetsfullname, evsprefix=evsprefix) constitpjalg = inputcomps.getPrimary() constitpjkey = constitpjalg.OutputContainer components.merge(inputcomps) pjs = [constitpjkey] # Schedule the ghost PseudoJetAlgs for ghostdef in deps["ghosts"]: ghostpjalg = getGhostPJGAlg(ghostdef) components.addEventAlgo(ghostpjalg, sequencename) ghostpjkey = ghostpjalg.OutputContainer pjs.append(ghostpjkey) # Generate a JetAlgorithm to run the jet finding and modifiers # (via a JetRecTool instance). mergepjalg = CompFactory.PseudoJetMerger( "pjmergealg_" + jetsfullname, InputPJContainers=pjs, OutputContainer="PseudoJetMerged_" + jetsfullname) components.addEventAlgo(mergepjalg, sequencename) jetrecalg = getJetRecAlg(jetsfullname, jetdef, "PseudoJetMerged_" + jetsfullname, deps["mods"]) components.addEventAlgo(jetrecalg, sequencename) jetlog.info( "Scheduled JetAlgorithm instance \"jetalg_{0}\"".format(jetsfullname)) return components
def precisionElectronRecoSequence(RoIs): """ With this function we will setup the sequence of offline EgammaAlgorithms so to make a electron for TrigEgamma Sequence of algorithms is the following: - egammaRecBuilder/TrigEgammaRecElectron creates egammaObjects out of clusters and tracks. - electronSuperClusterBuilder algorithm will create superclusters out of the toposlusters and tracks in egammaRec under the electron hypothesis https://gitlab.cern.ch/atlas/athena/blob/master/Reconstruction/egamma/egammaAlgs/python/egammaSuperClusterBuilder.py#L26 - TopoEgammBuilder will create photons and electrons out of trakcs and SuperClusters. Here at HLT electrons the aim is to ignore photons. https://gitlab.cern.ch/atlas/athena/blob/master/Reconstruction/egamma/egammaAlgs/src/topoEgammaBuilder.cxx """ log.debug('precisionElectronRecoSequence(RoIs = %s)', RoIs) # First the data verifiers: # Here we define the data dependencies. What input needs to be available for the Fexs (i.e. TopoClusters from precisionCalo) in order to run from TriggerMenuMT.HLTMenuConfig.Egamma.PrecisionCaloSequenceSetup import precisionCaloMenuDefs import AthenaCommon.CfgMgr as CfgMgr ## Taking Fast Track information computed in 2nd step ## TrackCollection = "TrigFastTrackFinder_Tracks_Electron" ViewVerifyTrk = CfgMgr.AthViews__ViewDataVerifier( "FastTrackViewDataVerifier") ViewVerifyTrk.DataObjects = [ ('TrackCollection', 'StoreGateSvc+' + TrackCollection), ('xAOD::CaloClusterContainer', 'StoreGateSvc+' + precisionCaloMenuDefs.precisionCaloClusters), ('CaloCellContainer', 'StoreGateSvc+CaloCells'), ('SG::AuxElement', 'StoreGateSvc+EventInfo.AveIntPerXDecor'), ('IDCInDetBSErrContainer', 'StoreGateSvc+SCT_FlaggedCondData_TRIG'), ('TrigRoiDescriptorCollection', 'StoreGateSvc+precisionElectron'), ('IDCInDetBSErrContainer', 'StoreGateSvc+SCT_ByteStreamErrs') ] # the load below doesn't always work # These objects must be loaded from SGIL if not from CondInputLoader from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() from IOVDbSvc.CondDB import conddb if not conddb.folderRequested("PixelClustering/PixelClusNNCalib"): ViewVerifyTrk.DataObjects += [ ('TTrainedNetworkCollection', 'ConditionStore+PixelClusterNN'), ('TTrainedNetworkCollection', 'ConditionStore+PixelClusterNNWithTrack') ] if globalflags.InputFormat.is_bytestream(): ViewVerifyTrk.DataObjects += [ ('InDetBSErrContainer', 'StoreGateSvc+PixelByteStreamErrs'), ('IDCInDetBSErrContainer', 'StoreGateSvc+SCT_ByteStreamErrs') ] else: topSequence.SGInputLoader.Load += [('TRT_RDO_Container', 'StoreGateSvc+TRT_RDOs')] ViewVerifyTrk.DataObjects += [('TRT_RDO_Container', 'StoreGateSvc+TRT_RDOs')] """ Precision Track Related Setup.... """ PTAlgs = [] PTTracks = [] PTTrackParticles = [] from TrigInDetConfig.InDetPT import makeInDetPrecisionTracking PTTracks, PTTrackParticles, PTAlgs = makeInDetPrecisionTracking( "electron", ViewVerifyTrk, inputFTFtracks=TrackCollection, rois=RoIs) PTSeq = parOR("precisionTrackingInElectrons", PTAlgs) trackParticles = PTTrackParticles[-1] electronPrecisionTrack = parOR("electronPrecisionTrack") electronPrecisionTrack += ViewVerifyTrk electronPrecisionTrack += PTSeq """ Retrieve the factories now """ from TriggerMenuMT.HLTMenuConfig.Electron.TrigElectronFactories import TrigEgammaRecElectron, TrigElectronSuperClusterBuilder, TrigTopoEgammaElectronCfg from TriggerMenuMT.HLTMenuConfig.Egamma.TrigEgammaFactories import TrigEMTrackMatchBuilder #The sequence of these algorithms thesequence = parOR("precisionElectron_" + RoIs) # Create the sequence of three steps: # - TrigEgammaRecElectron, TrigElectronSuperClusterBuilder, TrigTopoEgammaElectron trackMatchBuilder = TrigEMTrackMatchBuilder() trackMatchBuilder.TrackParticlesName = trackParticles TrigEgammaAlgo = TrigEgammaRecElectron() TrigEgammaAlgo.InputTopoClusterContainerName = precisionCaloMenuDefs.precisionCaloClusters TrigEgammaAlgo.TrackMatchBuilderTool = trackMatchBuilder thesequence += TrigEgammaAlgo trigElectronAlgo = TrigElectronSuperClusterBuilder() trigElectronAlgo.InputEgammaRecContainerName = TrigEgammaAlgo.egammaRecContainer thesequence += trigElectronAlgo trigTopoEgammaAlgo = TrigTopoEgammaElectronCfg() trigTopoEgammaAlgo.SuperElectronRecCollectionName = trigElectronAlgo.SuperElectronRecCollectionName collectionOut = trigTopoEgammaAlgo.ElectronOutputName thesequence += trigTopoEgammaAlgo from TriggerMenuMT.HLTMenuConfig.Egamma.TrigEgammaFactories import TrigElectronIsoBuilderCfg isoBuilder = TrigElectronIsoBuilderCfg() thesequence += isoBuilder return (thesequence, electronPrecisionTrack, collectionOut)
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 generateDecisionTree(chains): acc = ComponentAccumulator() mainSequenceName = 'HLTAllSteps' acc.addSequence( seqAND(mainSequenceName) ) @memoize def getFiltersStepSeq( stepNumber ): """ Returns sequence containing all filters for a step """ name = 'Step{}_{}'.format(stepNumber, CFNaming.FILTER_POSTFIX) if stepNumber > 1: getRecosStepSeq( stepNumber -1 ) # make sure steps sequencers are correctly made: Step1_filter, Step1_recos, Step2_filters, Step2_recos ... seq = parOR( name ) acc.addSequence( seq, parentName = mainSequenceName ) return seq @memoize def getRecosStepSeq( stepNumber ): """ """ getFiltersStepSeq( stepNumber ) # make sure there is filters step before recos name = 'Step{}{}'.format(stepNumber, CFNaming.RECO_POSTFIX) seq = parOR( name ) acc.addSequence( seq, parentName = mainSequenceName ) return seq @memoize def getSingleMenuSeq( stepNumber, stepName ): """ """ name = "Menu{}{}".format(stepNumber, stepName) seq = seqAND( name ) allRecoSeqName = getRecosStepSeq( stepNumber ).name acc.addSequence(seq, parentName = allRecoSeqName ) return seq @memoize def getFilterAlg( stepNumber, stepName ): """ Returns, if need be created, filter for a given step """ filtersStep = getFiltersStepSeq( stepNumber ) singleMenuSeq = getSingleMenuSeq( stepNumber, stepName ) filterName = CFNaming.filterName( stepName ) filterAlg = CompFactory.RoRSeqFilter( filterName ) acc.addEventAlgo( filterAlg, sequenceName=filtersStep.name ) acc.addEventAlgo( filterAlg, sequenceName=singleMenuSeq.name ) log.debug('Creted filter {}'.format(filterName)) return filterAlg @memoize def findInputMaker( stepCounter, stepName ): seq = getSingleMenuSeq( stepCounter, stepName ) algs = findAllAlgorithms( seq ) for alg in algs: if isInputMakerBase(alg): return alg raise Exception("No input maker in seq "+seq.name) @memoize def findAllInputMakers( stepCounter, stepName ): seq = getSingleMenuSeq( stepCounter, stepName ) algs = findAllAlgorithms( seq ) result = [] for alg in algs: if isInputMakerBase(alg): result.append(alg) if result: return result else: raise Exception("No input maker in seq "+seq.name) @memoize def findHypoAlg( stepCounter, stepName ): seq = getSingleMenuSeq( stepCounter, stepName ) algs = findAllAlgorithms( seq ) for alg in algs: if isHypoBase(alg): return alg raise Exception("No hypo alg in seq "+seq.name) @memoize def findAllHypoAlgs( stepCounter, stepName ): seq = getSingleMenuSeq( stepCounter, stepName ) algs = findAllAlgorithms( seq ) result = [] for alg in algs: if isHypoBase(alg): result.append(alg) if result: return result else: raise Exception("No hypo alg in seq "+seq.name) @memoize def findComboHypoAlg( stepCounter, stepName ): seq = getSingleMenuSeq( stepCounter, stepName ) algs = findAllAlgorithms( seq ) for alg in algs: if isComboHypoAlg(alg): return alg raise Exception("No combo hypo alg in seq "+seq.name) def addAndAssureUniqness( prop, toadd, context="" ): if toadd not in prop: log.info("{} value {} not there".format(context, toadd)) return list( prop ) + [ toadd ] else: log.info("{} value {} already there".format(context, toadd)) return list( prop ) def assureUnsetOrTheSame(prop, toadd, context): """ Central function setting strnig like proeprties (collection keys). Assures that valid names are not overwritten. """ if prop == "" or prop == toadd: return toadd if prop != toadd: raise Exception("{}, when setting property found conflicting values, existing {} and new {}".format(context, prop, toadd)) # create all sequences and filter algs, merge CAs from signatures (decision CF) for chain in chains: for stepCounter, step in enumerate( chain.steps, 1 ): getFilterAlg( stepCounter, step.name ) recoSeqName = getSingleMenuSeq( stepCounter, step.name ).name if step.isCombo: # add merged reco sequence stepRecoName = step.name + CFNaming.RECO_POSTFIX stepViewName = step.name + CFNaming.VIEW_POSTFIX acc.addSequence( seqAND(stepViewName), parentName=recoSeqName ) acc.addSequence( parOR(stepRecoName), parentName=stepViewName ) for sequence in step.sequences: for stepView in sequence.ca.getSequence().Members: for viewMember in stepView.Members: if isHypoBase(viewMember): # add hypo alg to view sequence acc.addEventAlgo( viewMember, sequenceName=stepViewName ) else: # add reco sequence to merged _reco for recoAlg in viewMember.Members: acc.addSequence( recoAlg, parentName=stepRecoName ) # elements from ca were moved above to the appropriate sequences # so sequence and algorithms are considered as merged sequence.ca._algorithms = {} sequence.ca._sequence.Members = [] acc.merge(sequence.ca, sequenceName=recoSeqName) # create combo hypo comboHypo = CompFactory.ComboHypo( step.combo.Alg.getName() ) acc.addEventAlgo( comboHypo, sequenceName=stepViewName ) else: acc.merge( step.sequences[0].ca, sequenceName=recoSeqName ) # cleanup settings made by Chain & related objects (can be removed in the future) for chain in chains: for stepCounter, step in enumerate( chain.steps, 1 ): filterAlg = getFilterAlg( stepCounter, step.name ) filterAlg.Input = [] filterAlg.Output = [] imAlgs = findAllInputMakers( stepCounter, step.name ) for imAlg in imAlgs: imAlg.InputMakerInputDecisions = [] imAlg.InputMakerOutputDecisions = "" hypoAlgs = findAllHypoAlgs( stepCounter, step.name ) for hypoAlg in hypoAlgs: hypoAlg.HypoInputDecisions = "" hypoAlg.HypoOutputDecisions = "" if step.isCombo: comboHypoAlg = findComboHypoAlg( stepCounter, step.name ) comboHypoAlg.MultiplicitiesMap = {} comboHypoAlg.HypoInputDecisions = [] comboHypoAlg.HypoOutputDecisions = [] # connect all outputs (decision DF) for chain in chains: for stepCounter, step in enumerate( chain.steps, 1 ): for seqCounter, sequence in enumerate( step.sequences ): # Filters linking filterAlg = getFilterAlg( stepCounter, step.name ) if step.isCombo: chainDictLegs = ' '.join(map(str, [dic['chainName'] for dic in step.chainDicts])) filterAlg.Chains = addAndAssureUniqness( filterAlg.Chains, chainDictLegs, "{} filter alg chains".format( filterAlg.name ) ) else: filterAlg.Chains = addAndAssureUniqness( filterAlg.Chains, chain.name, "{} filter alg chains".format( filterAlg.name ) ) if stepCounter == 1: filterAlg.Input = addAndAssureUniqness( filterAlg.Input, chain.L1decisions[0], "{} L1 input".format( filterAlg.name ) ) else: # look into the previous step hypoOutput = findHypoAlg( stepCounter-1, chain.steps[chain.steps.index( step )-1].name ).HypoOutputDecisions filterAlg.Input = addAndAssureUniqness( filterAlg.Input, hypoOutput, "{} input".format( filterAlg.name ) ) # Input Maker linking im = findAllInputMakers( stepCounter, step.name )[seqCounter] for i in filterAlg.Input: filterOutputName = CFNaming.filterOutName( filterAlg.name, i ) filterAlg.Output = addAndAssureUniqness( filterAlg.Output, filterOutputName, "{} output".format( filterAlg.name ) ) im.InputMakerInputDecisions = addAndAssureUniqness( im.InputMakerInputDecisions, filterOutputName, "{} input".format( im.name ) ) imOutputName = CFNaming.inputMakerOutName( im.name ) im.InputMakerOutputDecisions = assureUnsetOrTheSame( im.InputMakerOutputDecisions, imOutputName, "{} IM output".format( im.name ) ) # Hypo linking hypoAlg = findAllHypoAlgs( stepCounter, step.name )[seqCounter] hypoAlg.HypoInputDecisions = assureUnsetOrTheSame( hypoAlg.HypoInputDecisions, im.InputMakerOutputDecisions, "{} hypo input".format( hypoAlg.name ) ) hypoOutName = CFNaming.hypoAlgOutName( hypoAlg.name ) hypoAlg.HypoOutputDecisions = assureUnsetOrTheSame( hypoAlg.HypoOutputDecisions, hypoOutName, "{} hypo output".format( hypoAlg.name ) ) # Hypo Tools if step.isCombo: from TriggerMenuMT.HLTMenuConfig.Menu.ChainDictTools import splitChainInDict chainDictLeg = splitChainInDict(chain.name)[seqCounter] hypoAlg.HypoTools.append( sequence._hypoToolConf.confAndCreate( chainDictLeg ) ) # to be deleted after ComboHypos will be properly configured and included in DF hypoAlg.HypoTools.append( sequence._hypoToolConf.confAndCreate( TriggerConfigHLT.getChainDictFromChainName( chain.name ) ) ) else: hypoAlg.HypoTools.append( sequence._hypoToolConf.confAndCreate( TriggerConfigHLT.getChainDictFromChainName( chain.name ) ) ) # Combo Hypo linking if step.isCombo: comboHypoAlg = findComboHypoAlg( stepCounter, step.name ) comboHypoAlg.MultiplicitiesMap[chain.name] = step.multiplicity comboInputList = findAllHypoAlgs( stepCounter, step.name ) for comboInput in comboInputList: comboHypoAlg.HypoInputDecisions = addAndAssureUniqness( comboHypoAlg.HypoInputDecisions, comboInput.name, "{} comboHypo input".format( comboHypoAlg.name ) ) comboOutName = CFNaming.comboHypoOutputName( comboHypoAlg.name, comboInput.name ) comboHypoAlg.HypoOutputDecisions = addAndAssureUniqness( comboHypoAlg.HypoOutputDecisions, comboOutName, "{} comboHypo output".format( comboHypoAlg.name ) ) # Combo Hypo Tools for comboToolConf in step.comboToolConfs: comboHypoAlg.ComboHypoTools.append( comboToolConf.confAndCreate( TriggerConfigHLT.getChainDictFromChainName( chain.name ) ) ) for chain in chains: for stepCounter, step in enumerate( chain.steps, 1 ): filterAlg = getFilterAlg( stepCounter, step.name ) log.info("FilterAlg {} Inputs {} Outputs {}".format( filterAlg.name, filterAlg.Input, filterAlg.Output ) ) imAlg = findInputMaker( stepCounter, step.name ) log.info("InputMaker {} Inputs {} Outputs {}".format( imAlg.name, imAlg.InputMakerInputDecisions, imAlg.InputMakerOutputDecisions ) ) hypoAlg = findHypoAlg( stepCounter, step.name ) log.info("HypoAlg {} Inputs {} Outputs {}".format( hypoAlg.name, hypoAlg.HypoInputDecisions, hypoAlg.HypoOutputDecisions ) ) return acc