Пример #1
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
Пример #2
0
def getConstitModAlg(constit,
                     suffix="",
                     tvaKey="JetTrackVtxAssoc",
                     vtxKey="PrimaryVertices",
                     monTool=None):
    inputtype = constit.basetype

    # Need to extend to TCC
    if inputtype not in [xAODType.CaloCluster, xAODType.ParticleFlow]:
        constmodlog.error(
            "Only ParticleFlow and CaloCluster currently supported!")
        raise TypeError("Unsupported input type {0}".format(inputtype))

    sequence = list(constit.modifiers)  # Copy, as we may make some additions
    typename = {
        xAODType.CaloCluster: "TopoCluster",
        xAODType.ParticleFlow: "EMPFlow"
    }[inputtype]

    if inputtype == xAODType.ParticleFlow:
        # Always do 4mom corrections first and CHS last
        sequence = ["CorrectPFO"] + sequence + ["CHS"]

    # If no mods are needed, don't give back a tool
    if sequence == []: return None

    modlist = []
    for step in sequence:
        if step == "LC":
            continue  # Nothing to do for LC clusters
        tool = None

        toolname = "ConstitMod{0}_{1}{2}".format(typename, step, suffix)
        tool = ConstModTools[step](toolname, **ConstModConfigs[step])

        # May want to set also for cluster origin correction
        # but so far unused
        if step == "CorrectPFO":
            tool.VertexContainerKey = vtxKey
        if step == "CHS":
            tool.TrackVertexAssociation = tvaKey
            tool.VertexContainerKey = vtxKey

        if inputtype == xAODType.ParticleFlow and step not in [
                "CorrectPFO", "CHS"
        ]:
            tool.IgnoreChargedPFO = True
            tool.ApplyToChargedPFO = False
        tool.InputType = inputtype
        modlist.append(tool)

    sequenceshort = "".join(sequence)
    seqname = "ConstitMod{0}_{1}{2}".format(sequenceshort, typename, suffix)
    inputcontainer = str(constit.rawname)
    outputcontainer = str(constit.inputname)
    if inputtype == xAODType.ParticleFlow:
        # Tweak PF names because ConstModSequence needs to work with
        # up to 4 containers
        def chopPFO(thestring):
            pfostr = "ParticleFlowObjects"
            if thestring.endswith(pfostr):
                return thestring[:-len(pfostr)]
            return thestring

        inputcontainer = chopPFO(inputcontainer)
        outputcontainer = chopPFO(outputcontainer)

    modseq = CompFactory.JetConstituentModSequence(
        seqname,
        InputType=inputtype,
        OutputContainer=outputcontainer,
        InputContainer=inputcontainer,
        Modifiers=modlist,
        MonTool=monTool)

    constitmodalg = CompFactory.JetAlgorithm("jetalg_{0}".format(
        modseq.getName()))
    constitmodalg.Tools = [modseq]

    return constitmodalg