Exemple #1
0
    def runTest(self):
        destinationCA = ComponentAccumulator()
        destinationCA.addSequence(seqAND("dest"))

        sourceCA = ComponentAccumulator()
        sourceCA.addEventAlgo(TestAlgo("alg1"))
        sourceCA.addEventAlgo(TestAlgo("alg2"))
        sourceCA.addSequence(seqAND("innerSeq"))
        sourceCA.addEventAlgo(TestAlgo("alg3"), sequenceName="innerSeq")

        destinationCA.merge(sourceCA, sequenceName="dest")

        #destinationCA.merge( sourceCA )
        self.assertIsNotNone(
            findAlgorithm(destinationCA.getSequence("dest"), "alg1"),
            "Algorithm not placed in sub-sequence")
        self.assertIsNotNone(
            findSubSequence(destinationCA.getSequence(), "innerSeq"),
            "The sequence is not added")
        self.assertIsNotNone(
            findAlgorithm(destinationCA.getSequence("dest"), "alg3"),
            "Algorithm deep in thesource CA not placed in sub-sequence of destiantion CA"
        )
        destinationCA.wasMerged()
        sourceCA.wasMerged()
Exemple #2
0
def JetCopyAlgCfg(ConfigFlags, buildjetsname, copyjetsname):
    copycfg = ComponentAccumulator()

    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other
    sequencename = "JetCopySeq"
    copycfg.addSequence(CompFactory.AthSequencer(sequencename))

    # Create the JetCopier, set some standard options
    jcopy = CompFactory.JetCopier("copier")
    jcopy.InputJets = buildjetsname

    # Add a simple jet modifier to the JetRecAlg
    jclsmoms = CompFactory.JetClusterMomentsTool("clsmoms",
                                                 JetContainer=copyjetsname)

    # Create the JetRecAlg, configure it to use the copier
    # using constructor syntax instead
    # (equivalent to setting properties with "=")
    jra = CompFactory.JetRecAlg(
        "JRA_copy",
        Provider=jcopy,  # Single ToolHandle
        Modifiers=[jclsmoms],  # ToolHandleArray
        OutputContainer=copyjetsname)

    # Add the alg to the ComponentAccumulator in the named sequence
    copycfg.addEventAlgo(jra, sequencename)
    return copycfg
Exemple #3
0
def JetGroomAlgCfg(ConfigFlags, buildjetsname, groomjetsname):
    groomcfg = ComponentAccumulator()

    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other
    sequencename = "JetGroomSeq"
    groomcfg.addSequence(CompFactory.AthSequencer(sequencename))

    # Create the JetGroomer, provide it with a JetTrimmer
    jtrim = CompFactory.JetTrimming("trimSmallR2Frac5", RClus=0.2, PtFrac=0.05)
    jtrim.UngroomedJets = buildjetsname
    jtrim.ParentPseudoJets = "PseudoJetMerged_" + buildjetsname

    # Create the JetRecAlg, configure it to use the builder
    # using constructor syntax instead
    # (equivalent to setting properties with "=")
    jra = CompFactory.JetRecAlg(
        "JRA_trim",
        Provider=jtrim,  # Single ToolHandle
        Modifiers=[],  # ToolHandleArray
        OutputContainer=groomjetsname)

    # Add the alg to the ComponentAccumulator in the named sequence
    groomcfg.addEventAlgo(jra, sequencename)
    return groomcfg
Exemple #4
0
def JetGroomCfg(groomdef, configFlags, jetnameprefix="",jetnamesuffix=""):
    jetsfullname = jetnameprefix+groomdef.basename+jetnamesuffix+"Jets"
    jetlog.info("Setting up to find {0}".format(jetsfullname))

    sequencename = jetsfullname

    components = ComponentAccumulator()
    from AthenaCommon.AlgSequence import AthSequencer
    components.addSequence( AthSequencer(sequencename) )

    # Check if the ungroomed jets exist in the input file.
    # If not, we need to configure their reconstruction.
    filecontents = configFlags.Input.Collections
    if groomdef.ungroomedname not in filecontents:
        from . import JetRecCfg
        components.merge(JetRecCfg(groomdef.ungroomeddef, configFlags,
                                   jetnameoverride=groomdef.ungroomedname))
    else:
        # FIXME: Need to schedule rebuilding of pseudojets
        pass

    # FIXME: Add calls to JetModConfig.getFinalModifierListAndPrereqs
    components.addEventAlgo(getJetGroomAlg(jetsfullname,groomdef,groomdef.modifiers))

    return components
Exemple #5
0
def RunHighLevelTaggersCfg(inputFlags, JetCollection, Associator, TrainingMaps,
                           TimeStamp):
    result = ComponentAccumulator()

    AthSequencer = CompFactory.AthSequencer

    BTagCollection = inputFlags.BTagging.OutputFiles.Prefix + JetCollection
    sequenceName = BTagCollection + "_HLTaggers"
    if TimeStamp:
        BTagCollection += '_' + TimeStamp
        sequenceName += '_' + TimeStamp

    HLBTagSeq = AthSequencer(sequenceName, Sequential=True)
    result.addSequence(HLBTagSeq)

    result.merge(
        BTagHighLevelAugmenterAlgCfg(inputFlags,
                                     JetCollection=JetCollection,
                                     BTagCollection=BTagCollection,
                                     Associator=Associator,
                                     sequenceName=sequenceName))
    for dl2 in TrainingMaps:
        result.merge(
            HighLevelBTagAlgCfg(inputFlags, BTagCollection,
                                'InDetTrackParticles', dl2, sequenceName))

    return result
Exemple #6
0
 def selfSequence():
     from AthenaCommon.CFElements import seqAND
     accTop = ComponentAccumulator()
     accTop.wasMerged()
     seq1 = seqAND("seq1")
     seq1_again = seqAND("seq1")
     accTop.addSequence(seq1)
     accTop.addSequence(seq1_again, parentName="seq1")
Exemple #7
0
    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
Exemple #8
0
def JetInputCfg(ConfigFlags):
    inputcfg = ComponentAccumulator()
    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other
    sequencename = "JetInputSeq"

    inputcfg.addSequence(CompFactory.AthSequencer(sequencename))

    from xAODBase.xAODType import xAODType

    # Apply some corrections to the topoclusters
    # Example with property assignments
    jetmodseq = CompFactory.JetConstituentModSequence("JetMod_LCOrigin")
    jetmodseq.InputType = xAODType.CaloCluster
    jetmodseq.InputContainer = "CaloCalTopoClusters"
    jetmodseq.OutputContainer = "LCOriginTopoClusters"

    # Build the list of modifiers to run
    # Configuration with constructor keywords
    modlist = [
        CompFactory.CaloClusterConstituentsOrigin(
            "ClusterOrigin", InputType=xAODType.CaloCluster)
    ]
    jetmodseq.Modifiers = modlist

    # We need a JetAlgorithm to run the modseq, which is a tool
    jetmodalg = CompFactory.JetAlgorithm("JetModAlg_LCOrigin",
                                         Tools=[jetmodseq])

    # Add the alg to the sequence in the ComponentAccumulator
    inputcfg.addEventAlgo(jetmodalg, sequencename)

    # Create a PseudoJetAlgorithm

    constitpjgalg = CompFactory.PseudoJetAlgorithm(
        "pjgalg_LCTopo",
        InputContainer="LCOriginTopoClusters",
        OutputContainer="PseudoJetLCTopo",
        Label="LCTopo",
        SkipNegativeEnergy=True)

    ghostpjgalg = CompFactory.PseudoJetAlgorithm(
        "pjgalg_GhostTruth",
        InputContainer="TruthParticles",
        OutputContainer="PseudoJetGhostTruth",
        Label="GhostTruth",
        SkipNegativeEnergy=True)

    pjcs = [constitpjgalg.OutputContainer, ghostpjgalg.OutputContainer]

    # Add the algs to the sequence in the ComponentAccumulator
    inputcfg.addEventAlgo(constitpjgalg, sequencename)
    inputcfg.addEventAlgo(ghostpjgalg, sequencename)

    return inputcfg, pjcs
Exemple #9
0
def getAssocCA(config, sequencename='METAssociation', METName=''):
    components = ComponentAccumulator()
    from AthenaConfiguration.ComponentFactory import CompFactory
    AthSequencer = CompFactory.AthSequencer
    components.addSequence(AthSequencer(sequencename))
    assocAlg = getMETAssocAlg(algName='METAssociation_' + METName,
                              configs={config.suffix: config})
    components.addEventAlgo(assocAlg, sequencename)
    if not METName == '':
        makerAlg = getMETMakerAlg(METName)
        components.addEventAlgo(makerAlg, sequencename)
    return components
Exemple #10
0
def JetBuildAlgCfg(ConfigFlags, buildjetsname):
    buildcfg = ComponentAccumulator()

    # Create a sequence that holds a set of algorithms
    # -- mainly for understanding how chunks of the job
    #    relate to each other

    sequencename = "JetBuildSeq"
    buildcfg.addSequence(CompFactory.AthSequencer(sequencename))
    # Merge in config to get jet inputs
    inputcfg, pjcs = JetInputCfg(ConfigFlags)
    buildcfg.merge(inputcfg)

    # Create a merger to build the PseudoJetContainer for this specific jet collection
    mergepjalg = CompFactory.PseudoJetMerger(
        "pjmergealg_" + buildjetsname,
        InputPJContainers=pjcs,
        OutputContainer="PseudoJetMerged_" + buildjetsname)

    buildcfg.addEventAlgo(mergepjalg)

    # Create the JetClusterer, set some standard options
    jclust = CompFactory.JetClusterer("builder")
    jclust.JetAlgorithm = "AntiKt"
    jclust.JetRadius = 1.0
    jclust.PtMin = 10e3  # MeV
    jclust.InputPseudoJets = "PseudoJetMerged_" + buildjetsname
    jclust.JetInputType = 1  # Hardcoded "magic number" for now
    # See https://gitlab.cern.ch/atlas/athena/blob/master/Event/xAOD/xAODJet/xAODJet/JetContainerInfo.h
    # This should get its own dictionary.

    # Add a simple jet modifier to the JetRecAlg
    jclsmoms = CompFactory.JetClusterMomentsTool("clsmoms",
                                                 JetContainer=buildjetsname)

    # Create the JetRecAlg, configure it to use the builder
    # using constructor syntax instead
    # (equivalent to setting properties with "=")
    jra = CompFactory.JetRecAlg(
        "JRA_build",
        Provider=jclust,  # Single ToolHandle
        Modifiers=[jclsmoms],  # ToolHandleArray
        OutputContainer=buildjetsname)

    # Add the alg to the ComponentAccumulator in the named sequence
    buildcfg.addEventAlgo(jra, sequencename)
    return buildcfg
Exemple #11
0
    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()
Exemple #12
0
def METTrack_Cfg(configFlags):
    sequencename = "METReconstruction_Track"

    components = ComponentAccumulator()
    from AthenaConfiguration.ComponentFactory import CompFactory
    AthSequencer = CompFactory.AthSequencer
    components.addSequence(AthSequencer(sequencename))
    cfg_trk = METConfig('Track',
                        configFlags, [BuildConfig('SoftTrk', 'Track')],
                        [RefConfig('TrackFilter', 'PVTrack')],
                        doTracks=configFlags.MET.UseTracks)

    cfg_trk.refiners['TrackFilter'].DoLepRecovery = True
    cfg_trk.refiners['TrackFilter'].DoVxSep = configFlags.MET.UseTracks
    cfg_trk.refiners['TrackFilter'].DoEoverPSel = True
    recoAlg = getMETRecoAlg(algName='METRecoAlg_Track',
                            configs={"Track": cfg_trk})
    components.addEventAlgo(recoAlg, sequencename)
    return components
Exemple #13
0
    def skip_test_sequences_merging(self):
        from AthenaConfiguration.AllConfigFlags import ConfigFlags
        ConfigFlags.lock()
        from AthenaCommon.Logging import logging
        logging.getLogger('ComponentAccumulator').setLevel(DEBUG)

        print("ca1")
        ca1 = ComponentAccumulator()
        ca1.addEventAlgo(TestAlgo("alg1"))
        ca1.printConfig()
        ca1.addSequence(seqAND("someSequence"))

        print("ca2")
        from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
        ca2 = OutputStreamCfg(ConfigFlags,
                              "RDO",
                              ItemList=[
                                  "SCT_RDO_Container#SCT_RDOs",
                                  "InDetSimDataCollection#SCT_SDO_Map"
                              ])
        ca2.printConfig()

        print("after merge")
        ca1.merge(ca2)
        ca1.printConfig()

        self.assertEqual(len(ca1._allSequences), 2,
                         "Dangling sequences not maintained")

        print("Instantiating top CA")
        from AthenaConfiguration.MainServicesConfig import MainServicesCfg
        topca = MainServicesCfg(ConfigFlags)
        topca.printConfig()

        print("Merging to the top level CA")
        topca.merge(ca1)
        topca.printConfig()
        topca.wasMerged()
Exemple #14
0
def METCalo_Cfg(configFlags):
    sequencename = "METReconstruction_Calo"

    components = ComponentAccumulator()
    from AthenaConfiguration.ComponentFactory import CompFactory
    AthSequencer = CompFactory.AthSequencer
    components.addSequence(AthSequencer(sequencename))
    ############################################################################
    # EMTopo

    cfg_emt = METConfig('EMTopo',
                        configFlags, [BuildConfig('SoftClus', 'EMTopo')],
                        doRegions=True,
                        doOriginCorrClus=False)

    ############################################################################
    # LocHadTopo

    cfg_lht = METConfig('LocHadTopo',
                        configFlags, [BuildConfig('SoftClus', 'LocHadTopo')],
                        doRegions=True,
                        doOriginCorrClus=False)

    ############################################################################
    # Calo regions
    #SWITCH OFF CELLS WHEN RUNNING ON AOD
    cfg_calo = METConfig('Calo',
                         configFlags, [BuildConfig('CaloReg')],
                         doCells=False)

    recoAlg_calo = getMETRecoAlg(algName='METRecoAlg_Calo',
                                 configs={
                                     "EMTopo": cfg_emt,
                                     "LocHadTopo": cfg_lht,
                                     "Calo": cfg_calo
                                 })
    components.addEventAlgo(recoAlg_calo, sequencename)
    return components
Exemple #15
0
        def selfMergedGrandParentSequence():
            from AthenaCommon.CFElements import seqAND
            acc1 = ComponentAccumulator()
            acc1.wasMerged()
            acc1.addSequence(seqAND("seq1"))

            acc2 = ComponentAccumulator()
            acc2.wasMerged()
            acc2.addSequence(seqAND("seq2"))
            acc2.addSequence(seqAND("seq1"), parentName="seq2")
            acc1.merge(acc2, sequenceName="seq1")
Exemple #16
0
    def runTest(self):
        # test if an algorithm (or sequence) can be controlled by more than one sequence

        accTop = ComponentAccumulator()

        recoSeq = seqAND("seqReco")
        recoAlg = TestAlgo("recoAlg")
        recoSeq.Members.append(recoAlg)

        acc1 = ComponentAccumulator()
        acc1.addSequence(seqAND("seq1"))
        acc1.addSequence(recoSeq, parentName="seq1")

        acc2 = ComponentAccumulator()
        acc2.addSequence(seqAND("seq2"))
        acc2.addSequence(recoSeq, parentName="seq2")

        accTop.merge(acc1)
        accTop.merge(acc2)

        accTop.printConfig()

        self.assertIsNotNone(
            findAlgorithm(accTop.getSequence("seq1"), "recoAlg"),
            "Algorithm missing in the first sequence")
        self.assertIsNotNone(
            findAlgorithm(accTop.getSequence("seq2"), "recoAlg"),
            "Algorithm missing in the second sequence")
        s = accTop.getSequence("seqReco")
        self.assertEqual(
            len(s.Members), 1,
            "Wrong number of algorithms in reco seq: %d " % len(s.Members))
        self.assertIs(findAlgorithm(accTop.getSequence("seq1"), "recoAlg"),
                      findAlgorithm(accTop.getSequence("seq2"), "recoAlg"),
                      "Algorithms are cloned")
        self.assertIs(findAlgorithm(accTop.getSequence("seq1"), "recoAlg"),
                      recoAlg, "Clone of the original inserted in sequence")

        fout = open("dummy.pkl", "wb")
        accTop.store(fout)
        fout.close()
Exemple #17
0
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
Exemple #18
0
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
Exemple #19
0
 def testMenu(flags):
     menuCA = ComponentAccumulator()
     menuCA.addSequence( seqAND("HLTAllSteps") )
     return menuCA
Exemple #20
0
def METAssociatorCfg(configFlags):
    sequencename = "METAssociation"

    components = ComponentAccumulator()
    from AthenaConfiguration.ComponentFactory import CompFactory
    AthSequencer = CompFactory.AthSequencer
    components.addSequence(AthSequencer(sequencename))

    modConstKey = ""
    modClusColls = {}
    if configFlags.MET.UseTracks:
        modConstKey = "OriginCorr"
        modClusColls = {
            'LCOriginCorrClusters': 'LCOriginTopoClusters',
            'EMOriginCorrClusters': 'EMOriginTopoClusters'
        }

    ############################################################################
    # AntiKt4LCTopo
    JetType = 'LCJet'
    associators = [
        AssocConfig(JetType),
        AssocConfig('Muon'),
        AssocConfig('Ele'),
        AssocConfig('Gamma'),
        AssocConfig('Tau'),
        AssocConfig('Soft')
    ]
    cfg_akt4lc = METAssocConfig('AntiKt4LCTopo',
                                configFlags,
                                associators,
                                doPFlow=False,
                                modConstKey=modConstKey,
                                modClusColls=modClusColls)
    components_akt4lc = getAssocCA(cfg_akt4lc,
                                   sequencename='METAssoc_AntiKt4LCTopo',
                                   METName='AntiKt4LCTopo')
    components.merge(components_akt4lc)

    ############################################################################
    # AntiKt4EMTopo
    JetType = 'EMJet'

    associators = [
        AssocConfig(JetType),
        AssocConfig('Muon'),
        AssocConfig('Ele'),
        AssocConfig('Gamma'),
        AssocConfig('Tau'),
        AssocConfig('Soft')
    ]
    cfg_akt4em = METAssocConfig('AntiKt4EMTopo',
                                configFlags,
                                associators,
                                doPFlow=False,
                                modConstKey=modConstKey,
                                modClusColls=modClusColls)
    components_akt4em = getAssocCA(cfg_akt4em,
                                   sequencename='METAssoc_AntiKt4EMTopo',
                                   METName='AntiKt4EMTopo')
    components.merge(components_akt4em)

    ############################################################################
    # PFlow
    if configFlags.MET.DoPFlow and configFlags.MET.UseTracks:
        JetType = 'PFlowJet'
        associators = [
            AssocConfig(JetType),
            AssocConfig('Muon'),
            AssocConfig('Ele'),
            AssocConfig('Gamma'),
            AssocConfig('Tau'),
            AssocConfig('Soft')
        ]
        cfg_akt4pf = METAssocConfig('AntiKt4EMPFlow',
                                    configFlags,
                                    associators,
                                    doPFlow=True)
        components_akt4pf = getAssocCA(cfg_akt4pf,
                                       sequencename='METAssoc_AntiKt4EMPFlow',
                                       METName='AntiKt4EMPFlow')
        components.merge(components_akt4pf)
    return components
Exemple #21
0
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
Exemple #22
0
def CaloTopoClusterCfg(configFlags,cellsname="AllCalo",clustersname="",doLCCalib=None,sequenceName='AthAlgSeq'):
    result=ComponentAccumulator()
    if (sequenceName != 'AthAlgSeq'):
        from AthenaCommon.CFElements import seqAND
        #result.mainSeq( seqAND( sequenceName ) )
        result.addSequence( seqAND(sequenceName) )

    if not clustersname:
        clustersname = "CaloTopoClusters"

    from LArGeoAlgsNV.LArGMConfig import LArGMCfg
    from TileGeoModel.TileGMConfig import TileGMCfg
    from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
    # Schedule total noise cond alg
    result.merge(CaloNoiseCondAlgCfg(configFlags,"totalNoise"))
    # Schedule electronic noise cond alg (needed for LC weights)
    result.merge(CaloNoiseCondAlgCfg(configFlags,"electronicNoise"))
    
    CaloTopoClusterMaker, CaloTopoClusterSplitter, CaloClusterMaker, CaloClusterSnapshot=CompFactory.getComps("CaloTopoClusterMaker","CaloTopoClusterSplitter","CaloClusterMaker","CaloClusterSnapshot",)

    result.merge(LArGMCfg(configFlags))

    from LArCalibUtils.LArHVScaleConfig import LArHVScaleCfg
    result.merge(LArHVScaleCfg(configFlags))

    result.merge(TileGMCfg(configFlags))

    if not doLCCalib:
        theCaloClusterSnapshot=CaloClusterSnapshot(OutputName=clustersname+"snapshot",SetCrossLinks=True)
    else:
        theCaloClusterSnapshot=CaloClusterSnapshot(OutputName=clustersname,SetCrossLinks=True)
         
    # maker tools
    TopoMaker = CaloTopoClusterMaker("TopoMaker")
        
    TopoMaker.CellsName = cellsname
    TopoMaker.CalorimeterNames=["LAREM",
                                "LARHEC",
                                "LARFCAL",
                                "TILE"]
    # cells from the following samplings will be able to form
    # seeds. By default no sampling is excluded
    TopoMaker.SeedSamplingNames = ["PreSamplerB", "EMB1", "EMB2", "EMB3",
                                   "PreSamplerE", "EME1", "EME2", "EME3",
                                   "HEC0", "HEC1","HEC2", "HEC3",
                                   "TileBar0", "TileBar1", "TileBar2",
                                   "TileExt0", "TileExt1", "TileExt2",
                                   "TileGap1", "TileGap2", "TileGap3",
                                   "FCAL0", "FCAL1", "FCAL2"] 
    TopoMaker.NeighborOption = "super3D"
    TopoMaker.RestrictHECIWandFCalNeighbors  = False
    TopoMaker.RestrictPSNeighbors  = True
    TopoMaker.CellThresholdOnEorAbsEinSigma     =    0.0
    TopoMaker.NeighborThresholdOnEorAbsEinSigma =    2.0
    TopoMaker.SeedThresholdOnEorAbsEinSigma     =    4.0
    
    # note E or AbsE 
    #
    # the following property must be set to TRUE in order to make double
    # sided cuts on the seed and the cluster level 
    #
    TopoMaker.SeedCutsInAbsE                 = True
    TopoMaker.ClusterEtorAbsEtCut            = 0.0*MeV
    # use 2-gaussian or single gaussian noise for TileCal
    TopoMaker.TwoGaussianNoise = configFlags.Calo.TopoCluster.doTwoGaussianNoise
        
    TopoSplitter = CaloTopoClusterSplitter("TopoSplitter")
    # cells from the following samplings will be able to form local
    # maxima. The excluded samplings are PreSamplerB, EMB1,
    # PreSamplerE, EME1, all Tile samplings, all HEC samplings and the
    # two rear FCal samplings.
    #
    TopoSplitter.SamplingNames = ["EMB2", "EMB3",
                                  "EME2", "EME3",
                                  "FCAL0"]
    # cells from the following samplings will also be able to form
    # local maxima but only if they are not overlapping in eta and phi
    # with local maxima in previous samplings from the primary list.
    #
    TopoSplitter.SecondarySamplingNames = ["EMB1","EME1",
                                           "TileBar0","TileBar1","TileBar2",
                                           "TileExt0","TileExt1","TileExt2",
                                           "HEC0","HEC1","HEC2","HEC3",
                                           "FCAL1","FCAL2"]
    TopoSplitter.ShareBorderCells = True
    TopoSplitter.RestrictHECIWandFCalNeighbors  = False
    TopoSplitter.WeightingOfNegClusters = configFlags.Calo.TopoCluster.doTreatEnergyCutAsAbsolute
    #
    # the following options are not set, since these are the default
    # values
    #
    # NeighborOption                = "super3D",
    # NumberOfCellsCut              = 4,
    # EnergyCut                     = 500*MeV,
        

    CaloTopoCluster=CaloClusterMaker(clustersname)
    CaloTopoCluster.ClustersOutputName=clustersname

    CaloTopoCluster.ClusterMakerTools = [TopoMaker, TopoSplitter]
    
    from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
    caloBadChanTool = result.popToolsAndMerge( CaloBadChanToolCfg(configFlags) )
    CaloClusterBadChannelList=CompFactory.CaloClusterBadChannelList
    BadChannelListCorr = CaloClusterBadChannelList(badChannelTool = caloBadChanTool)
    CaloTopoCluster.ClusterCorrectionTools += [BadChannelListCorr]

    CaloTopoCluster.ClusterCorrectionTools += [getTopoMoments(configFlags)]

    if doLCCalib is None:
        doLCCalib = configFlags.Calo.TopoCluster.doTopoClusterLocalCalib
    if doLCCalib:
        CaloTopoCluster.ClusterCorrectionTools += [theCaloClusterSnapshot]
        #if not clustersname:
        CaloTopoCluster.ClustersOutputName="CaloCalTopoClusters"
        CaloTopoCluster.ClusterCorrectionTools += getTopoClusterLocalCalibTools(configFlags)

        from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
        result.merge(caloTopoCoolFolderCfg(configFlags))

    result.addEventAlgo(CaloTopoCluster,primary=True,sequenceName=sequenceName)
    return result
Exemple #23
0
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
Exemple #24
0
    def skip_test_algorithms_merging(self):
        class MergeableAlgorithm(TestAlgo):
            def __init__(self, name, **kwargs):
                super(TestAlgo, self).__init__(name)
                #self._jobOptName = name
                for n, v in kwargs.items():
                    setattr(self, n, v)

                self._set_attributes = kwargs.keys()

            def getValuedProperties(self):
                d = {}
                for attrib in self._set_attributes:
                    d[attrib] = getattr(self, attrib)
                return d

            def __eq__(self, rhs):
                if self is rhs:
                    return True
                if not rhs or not isinstance(
                        rhs, Configurable
                ) or self.getFullName() != rhs.getFullName():
                    return False
                for attr, value in self.getValuedProperties().items():
                    if getattr(rhs, attr) != value:
                        return False
                return True

            def __ne__(self, rhs):
                return not self.__eq__(rhs)

        ca = ComponentAccumulator()

        seq1 = seqAND("seq1")
        innerSeq1 = seqAND("innerSeq1")
        level2Seq1 = seqAND("level2Seq1")

        seq2 = seqAND("seq2")
        innerSeq2 = seqAND("innerSeq2")

        firstAlg = MergeableAlgorithm("alg1",
                                      InputMakerInputDecisions=["input1"])

        ca.addSequence(seq1)
        ca.addSequence(innerSeq1, parentName=seq1.name())
        ca.addSequence(level2Seq1, parentName=innerSeq1.name())
        ca.addEventAlgo(firstAlg, sequenceName=level2Seq1.name())

        ca.addSequence(seq2)
        ca.addSequence(innerSeq2, parentName=seq2.name())

        innerSeqCopy = seqAND("innerSeq2")
        level2SeqCopy = seqAND("level2Seq2")

        secondAlg = MergeableAlgorithm("alg1",
                                       InputMakerInputDecisions=["input2"])

        secondCa = ComponentAccumulator()
        secondCa.addSequence(innerSeqCopy)
        secondCa.addSequence(level2SeqCopy, parentName=innerSeqCopy.name())
        secondCa.addEventAlgo(secondAlg, sequenceName=level2SeqCopy.name())

        ca.merge(secondCa)

        foundAlgs = findAllAlgorithms(ca.getSequence(), 'alg1')

        self.assertEqual(len(foundAlgs), 2)

        self.assertEqual(set(foundAlgs[0].InputMakerInputDecisions),
                         {"input1", "input2"})
        self.assertEqual(set(foundAlgs[1].InputMakerInputDecisions),
                         {"input1", "input2"})

        ca.printConfig()
        ca.wasMerged()
Exemple #25
0
def triggerRunCfg( flags, seqName = None, menu=None ):
    """
    top of the trigger config (for real triggering online or on MC)
    Returns: ca only
    """
    acc = ComponentAccumulator()

    # L1ConfigSvc needed for L1Decoder
    from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg

    acc.merge( L1ConfigSvcCfg(flags) )

    acc.addSequence( seqOR( "HLTTop") )
    
    acc.addSequence( parOR("HLTBeginSeq"), parentName="HLTTop" )
    # bit of a hack as for "legacy" type JO a seq name for cache creators has to be given,
    # in newJO realm the seqName will be removed as a comp fragment shoudl be unaware of where it will be attached
    acc.merge( triggerIDCCacheCreatorsCfg( flags, seqName="AthAlgSeq" ), sequenceName="HLTBeginSeq" )

    from L1Decoder.L1DecoderConfig import L1DecoderCfg
    l1DecoderAcc = L1DecoderCfg( flags, seqName =  "HLTBeginSeq")
    # TODO, once moved to newJO the algorithm can be added to l1DecoderAcc and merging will be sufficient here
    acc.merge( l1DecoderAcc )

    # detour to the menu here, (missing now, instead a temporary hack)
    if menu:
        menuAcc = menu( flags )
        HLTSteps = menuAcc.getSequence( "HLTAllSteps" )
        __log.info( "Configured menu with "+ str( len(HLTSteps.Members) ) +" steps" )
        acc.merge( menuAcc, sequenceName="HLTTop")

    # collect hypothesis algorithms from all sequence
    hypos = collectHypos( HLTSteps )
    filters = collectFilters( HLTSteps )
    acc.addSequence( parOR("HLTEndSeq"), parentName="HLTTop" )
    acc.addSequence( seqAND("HLTFinalizeSeq"), parentName="HLTEndSeq" )
    
    summaryAcc, summaryAlg = triggerSummaryCfg( flags, hypos )
    acc.merge( summaryAcc, sequenceName="HLTFinalizeSeq" )
    acc.addEventAlgo( summaryAlg, sequenceName="HLTFinalizeSeq" )

    #once menu is included we should configure monitoring here as below
    l1DecoderAlg = l1DecoderAcc.getEventAlgo("L1Decoder")

    monitoringAcc, monitoringAlg = triggerMonitoringCfg( flags, hypos, filters, l1DecoderAlg )
    acc.merge( monitoringAcc, sequenceName="HLTEndSeq" )
    acc.addEventAlgo( monitoringAlg, sequenceName="HLTEndSeq" )

    from TrigCostMonitorMT.TrigCostMonitorMTConfig import TrigCostMonitorMTCfg
    acc.merge( TrigCostMonitorMTCfg( flags ), sequenceName="HLTEndSeq" )

    decObj = collectDecisionObjects( hypos, filters, l1DecoderAlg, summaryAlg )
    decObjHypoOut = collectHypoDecisionObjects(hypos, inputs=False, outputs=True)
    __log.info( "Number of decision objects found in HLT CF %d", len( decObj ) )
    __log.info( "Of which, %d are the outputs of hypos", len( decObjHypoOut ) )
    __log.info( str( decObj ) )



    # configure components need to normalise output before writing out
    viewMakers = collectViewMakers( HLTSteps )

    outputAcc, edmSet = triggerOutputCfg( flags, decObj, decObjHypoOut, summaryAlg )
    acc.merge( outputAcc )

    if edmSet:
        mergingAlg = triggerMergeViewsAndAddMissingEDMCfg( [edmSet] , hypos, viewMakers, decObj, decObjHypoOut )
        acc.addEventAlgo( mergingAlg, sequenceName="HLTFinalizeSeq" )

    return acc
Exemple #26
0
def generateDecisionTreeOld(HLTNode, chains, allChainDicts):
    log.debug("Run generateDecisionTreeOld on %s", HLTNode.name())
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    acc = ComponentAccumulator()
    from collections import defaultdict
    from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import CFSequence

    chainStepsMatrix = defaultdict(lambda: defaultdict(lambda: list()))

    ## Fill chain steps matrix
    for chain in chains:
        chain.createHypoTools()  #allChainDicts)
        for stepNumber, chainStep in enumerate(chain.steps):
            chainName = chainStep.name.split('_')[0]
            chainStepsMatrix[stepNumber][chainName].append(chain)

    allSequences = []

    ## Matrix with steps lists generated. Creating filters for each cell
    for nstep in chainStepsMatrix:
        CFsequences = []
        stepDecisions = []
        stepAccs = []
        stepHypos = []

        for chainName in chainStepsMatrix[nstep]:
            chainsInCell = chainStepsMatrix[nstep][chainName]

            if not chainsInCell:
                continue

            stepCategoryAcc = ComponentAccumulator()

            stepHypo = None

            for chain in chainsInCell:
                for seq in chain.steps[nstep].sequences:
                    if seq.ca:
                        stepCategoryAcc.merge(seq.ca)

                    alg = seq.hypo.Alg
                    if stepHypo is None:
                        stepHypo = alg
                        stepHypos.append(alg)
                    stepCategoryAcc.addEventAlgo(alg)

            stepAccs.append(stepCategoryAcc)

            stepCategoryAcc.printConfig(True, True)
            firstChain = chainsInCell[0]

            if nstep == 0:
                filter_input = firstChain.L1decisions
            else:
                filter_input = []
                for sequence in firstChain.steps[nstep - 1].sequences:
                    filter_input += sequence.outputs

            # One aggregated filter per chain (one per column in matrix)
            filterName = 'Filter_{}'.format(firstChain.steps[nstep].name)
            filter_output = []
            for i in filter_input:
                filter_output.append(CFNaming.filterOutName(filterName, i))
            sfilter = buildFilter(filterName, filter_input)

            chainStep = firstChain.steps[nstep]

            CFseq = CFSequence(ChainStep=chainStep,
                               FilterAlg=sfilter,
                               connections=filter_output)
            CFsequences.append(CFseq)

            for sequence in chainStep.sequences:
                stepDecisions += sequence.outputs

            for chain in chainsInCell:
                sfilter.addChain(chain.name)

        allSequences.append(CFsequences)

        stepName = 'Step{}'.format(nstep)
        stepFilter = createStepFilterNode(stepName, CFsequences, dump=False)
        stepCF = createStepRecoNode('{}_{}'.format(HLTNode.name(), stepName),
                                    CFsequences,
                                    dump=False)

        from AthenaCommon.CFElements import findOwningSequence
        for oneAcc, cfseq, hypo in zip(stepAccs, CFsequences, stepHypos):
            owning = findOwningSequence(stepCF, hypo.getName())
            acc.addSequence(owning)
            acc.merge(oneAcc, sequenceName=owning.getName())
        summary = makeSummary('TriggerSummary{}'.format(stepName),
                              stepDecisions)

        HLTNode += stepFilter
        HLTNode += stepCF
        HLTNode += summary
        if create_dot():
            stepCF_DataFlow_to_dot('{}_{}'.format(HLTNode.name(), stepName),
                                   CFsequences)
            stepCF_ControlFlow_to_dot(stepCF)
            all_DataFlow_to_dot(HLTNode.name(), allSequences)

        matrixDisplay(allSequences)
    return acc
Exemple #27
0
def generateMenu(flags):
    """
    Using flags generate appropriate Control Flow Graph wiht all HLT algorithms
    """

    # convert to chainDefs
    from TriggerMenuMT.HLTMenuConfig.Menu.DictFromChainName import dictFromChainName

    counter = 0
    signatureToGenerator = {}
    menuChains = []
    allChainDicts = []

    menuAcc = ComponentAccumulator()
    mainSequenceName = 'HLTAllSteps'
    menuAcc.addSequence(seqAND(mainSequenceName))

    for name, cfgFlag in list(iteritems(flags._flagdict)):
        if 'Trigger.menu.' not in name:
            continue
        value = flags._get(name)
        if len(value) == 0:
            continue

        signatureName = name.split('.')[-1]
        signatures = []

        # fill the map[signature, generating function]
        if signatureName == 'combined':
            for chain in cfgFlag.get():
                signatures += dictFromChainName(chain)['signatures']
        else:
            signatures = [signatureName]

        for sig in signatures:
            fillGeneratorsMap(signatureToGenerator, sig.lower())

        # call generating function and pass to CF builder
        for chain in cfgFlag.get():
            # TODO topo threshold
            mainChainDict = dictFromChainName(chain)

            counter += 1
            mainChainDict['chainCounter'] = counter

            #set default chain prescale
            mainChainDict['prescale'] = 1

            allChainDicts.append(mainChainDict)

            chainDicts = splitInterSignatureChainDict(mainChainDict)
            listOfChainConfigs = []

            for chainDict in chainDicts:
                signature = chainDict['signature'].lower()

                if signature not in signatureToGenerator:
                    log.warning(
                        'Generator for {} is missing. Chain dict will not be built'
                        .format(signature))
                    continue

                chainConfig = signatureToGenerator[signature](flags, chainDict)
                listOfChainConfigs.append(chainConfig)

            if len(listOfChainConfigs) > 1:
                theChainConfig = mergeChainDefs(listOfChainConfigs,
                                                mainChainDict)

            else:
                theChainConfig = listOfChainConfigs[0]

            TriggerConfigHLT.registerChain(mainChainDict, theChainConfig)
            menuChains.append(theChainConfig)

    log.info('Obtained Menu Chain objects')

    # pass all menuChain to CF builder
    useReworked = True

    if useReworked:
        menuAcc.wasMerged()
        menuAcc = generateDecisionTree(menuChains)
    else:
        menuAcc.wasMerged()
        menuAcc = ComponentAccumulator()
        mainSequenceName = 'HLTAllSteps'
        menuAcc.addSequence(seqAND(mainSequenceName))
        chainsAcc = generateDecisionTreeOld(
            menuAcc.getSequence(mainSequenceName), menuChains, allChainDicts)
        menuAcc.merge(chainsAcc)

    menuAcc.printConfig()

    log.info('CF is built')

    # # generate JOSON representation of the config
    from TriggerMenuMT.HLTMenuConfig.Menu.HLTMenuJSON import generateJSON_newJO
    generateJSON_newJO(allChainDicts, menuChains,
                       menuAcc.getSequence("HLTAllSteps"))

    from TriggerMenuMT.HLTMenuConfig.Menu.HLTPrescaleJSON import generateJSON_newJO as generatePrescaleJSON_newJO
    generatePrescaleJSON_newJO(allChainDicts, menuChains)

    return menuAcc
Exemple #28
0
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
Exemple #29
0
class AthMonitorCfgHelper(object):
    '''
    This class is for the Run 3-style configuration framework. It is intended to be instantiated once
    per group of related monitoring algorithms.
    '''
    def __init__(self, inputFlags, monName):
        '''
        Create the configuration helper. Needs the global flags and the name of the set of
        monitoring algorithms.

        Arguments:
        inputFlags -- the global configuration flag object
        monName -- the name you want to assign the family of algorithms
        '''

        from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
        from AthenaConfiguration.ComponentFactory import CompFactory
        AthSequencer = CompFactory.AthSequencer
        self.inputFlags = inputFlags
        self.monName = monName
        self.monSeq = AthSequencer('AthMonSeq_' + monName)
        self.resobj = ComponentAccumulator()
        if inputFlags.DQ.useTrigger:
            from .TriggerInterface import getTrigDecisionTool
            self.resobj.merge(getTrigDecisionTool(inputFlags))

    def addAlgorithm(self, algClassOrObj, name=None, *args, **kwargs):
        '''
        Instantiate/add a monitoring algorithm

        Arguments:
        algClassOrObj -- the Configurable class object of the algorithm to create, or an instance
                         of the algorithm Configurable. The former is recommended.  In the former case,
                         the name argument is required.
        name -- the name of the algorithm to create. Required when passing a Configurable class object
                as algClassOrObj.  No effect if a Configurable instance is passed.
        *args, **kwargs -- additional arguments will be forwarded to the Configurable constructor if
                           a Configurable class object is passed. No effect if a Configurable instance
                           is passed.

        Returns:
        algObj -- an algorithm Configurable object
        '''
        from inspect import isclass
        if isclass(algClassOrObj):
            if name is None:
                raise TypeError(
                    'addAlgorithm with a class argument requires a name for the algorithm'
                )
            algObj = algClassOrObj(name, *args, **kwargs)
        else:
            algObj = algClassOrObj

        # configure these properties; users really should have no reason to override them
        algObj.Environment = self.inputFlags.DQ.Environment
        algObj.DataType = self.inputFlags.DQ.DataType
        if self.inputFlags.DQ.useTrigger:
            algObj.TrigDecisionTool = self.resobj.getPublicTool(
                "TrigDecisionTool")
            algObj.TriggerTranslatorTool = self.resobj.popToolsAndMerge(
                getTriggerTranslatorToolSimple(self.inputFlags))

        if not self.inputFlags.Input.isMC and self.inputFlags.DQ.enableLumiAccess:
            algObj.EnableLumi = True
            from LumiBlockComps.LuminosityCondAlgConfig import LuminosityCondAlgCfg
            from LumiBlockComps.LBDurationCondAlgConfig import LBDurationCondAlgCfg
            from LumiBlockComps.TrigLiveFractionCondAlgConfig import TrigLiveFractionCondAlgCfg
            self.resobj.merge(LuminosityCondAlgCfg(self.inputFlags))
            self.resobj.merge(LBDurationCondAlgCfg(self.inputFlags))
            self.resobj.merge(TrigLiveFractionCondAlgCfg(self.inputFlags))
        else:
            algObj.EnableLumi = False

        self.monSeq.Members.append(algObj)
        return algObj

    def addGroup(self, alg, name, topPath='', defaultDuration='run'):
        '''Add a group to an algorithm

        Technically, adding a GenericMonitoringTool instance. The name given here can be
        used to retrieve the group from within the algorithm when calling the fill()
        function. Note this is *not* the same thing as the Monitored::Group class. To
        avoid replication of code, this calls the more general case, getArray with an 1D
        array of length 1.

        Arguments:
        alg -- algorithm Configurable object (e.g. one returned from addAlgorithm)
        name -- name of the group
        topPath -- directory name in the output ROOT file under which histograms will be
                   produced
        defaultDuration -- default time between histogram reset for all histograms in
                           group; can be overridden for each specific histogram

        Returns:
        tool -- a GenericMonitoringTool Configurable object. This can be used to define
                histograms associated with that group (using defineHistogram).
        '''
        array = self.addArray([1],
                              alg,
                              name,
                              topPath=topPath,
                              defaultDuration=defaultDuration)
        return array[0]

    def addArray(self,
                 dimensions,
                 alg,
                 baseName,
                 topPath='',
                 defaultDuration='run'):
        '''Add many groups to an algorithm

        Arguments:
        dimensions -- list holding the size in each dimension [n1,n2,n3,n4,...]
        alg -- algorithm Configurable object
        baseName -- base name of the group. postfixes are added by GMT Array initialize
        topPath -- directory name in the output ROOT file under which histograms will be
                   produced
        duration -- default time between histogram reset for all histograms in group

        Returns:
        tool -- a GenericMonitoringToolArray object. This is used to define histograms
                associated with each group in the array.
        '''
        from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringArray
        array = GenericMonitoringArray(baseName, dimensions)

        if self.inputFlags.DQ.isReallyOldStyle:
            from AthenaCommon.AppMgr import ServiceMgr
            array.broadcast('THistSvc', ServiceMgr.THistSvc)
        else:
            acc = getDQTHistSvc(self.inputFlags)
            self.resobj.merge(acc)

        pathToSet = self.inputFlags.DQ.FileKey + ('/%s' %
                                                  topPath if topPath else '')
        array.broadcast('HistPath', pathToSet)
        # in the future, autodetect if we are online or not
        array.broadcast('convention', 'OFFLINE')
        array.broadcast('defaultDuration', defaultDuration)
        alg.GMTools += array.toolList()
        return array

    def result(self):
        '''
        Finalize the creation of the set of monitoring algorithms.

        Returns:
        (resobj, monSeq) -- a tuple with a ComponentAccumulator and an AthSequencer
        '''
        self.resobj.addSequence(self.monSeq)
        return self.resobj
Exemple #30
0
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