Example #1
0
def toolJetQuarkLabel(name, useBTagFlagsDefaults = True, **options):
    """Sets up a JetQuarkLabel tool and returns it.

    input:             name: The name of the tool (should be unique).
      useBTagFlagsDefaults : Whether to use BTaggingFlags defaults for options that are not specified.
                             Note however that this tool has no BTaggingFlags defaults; the option is
                             here only for consistency.
                  **options: Python dictionary with options for the tool.
    output: The actual tool, which can then be added to ToolSvc via ToolSvc += output."""
    options['name'] = name
    from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQuarkLabel
    return Analysis__JetQuarkLabel(**options)
                    jetC = jetC1.replace("Jets", "")
                    if jetC in BTaggingFlags.Jets:
                        BTaggingFlags.RetagJets += [jetC]
        except Exception, err:
            print "#BTAG# - b-tagging: automatic inspection of input file failed (file too old?)"
print "#BTAG# --> b-tagging: using ", TheTruthCollectionKey, " as truth key"
print "#BTAG# --> b-tagging: re-tagging those jet collections: ", BTaggingFlags.RetagJets


# -- Truth labeling tool:
from JetRec.JetRecFlags import jetFlags

if jetFlags.useTruth():
    from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQuarkLabel

    BTagJetTruthMatching = Analysis__JetQuarkLabel(name="BTagJetTruthMatching")
    BTagJetTruthMatching.McEventCollection = TheTruthCollectionKey
    ToolSvc += BTagJetTruthMatching
    if BTaggingFlags.OutputLevel < 3:
        print BTagJetTruthMatching

    from BTagging.BTaggingConf import Analysis__BTagLabeling

    thisBTagLabeling = Analysis__BTagLabeling(
        name="thisBTagLabeling",
        JetTruthMatchTool=BTagJetTruthMatching
        # JetQGPartonTruthMatchTool = BTagJetQGPartonTruthMatching,  #MANU??
        # LeptonTruthTool   = BTagLeptonTruthTool
    )
    ToolSvc += thisBTagLabeling
    if BTaggingFlags.OutputLevel < 3:
def declareDefaultTools():

    from JetRecConfig.JetRecFlags import jetFlags
    from JetRecConfig.JetRecStandardToolManager import jtm
    from MCTruthClassifier.MCTruthClassifierConf import MCTruthClassifier
    from JetRec.JetRecConf import PseudoJetGetter

    try:
        from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQuarkLabel
        jtm.haveParticleJetTools = True
    except:
        jtm.haveParticleJetTools = False
    if jtm.haveParticleJetTools:
        from ParticleJetTools.ParticleJetToolsConf import Analysis__JetConeLabeling
        from ParticleJetTools.ParticleJetToolsConf import Analysis__JetPartonTruthLabel
        from ParticleJetTools.ParticleJetToolsConf import CopyTruthJetParticles
        from ParticleJetTools.ParticleJetToolsConf import ParticleJetDeltaRLabelTool

    ghostScaleFactor = 1e-40

    #--------------------------------------------------------------
    # Truth selection.
    #--------------------------------------------------------------

    if jetFlags.useTruth:
        truthClassifier = MCTruthClassifier(name="JetMCTruthClassifier",
                                            ParticleCaloExtensionTool="")
        jtm += truthClassifier

        jtm += CopyTruthJetParticles("truthpartcopy",
                                     OutputName="JetInputTruthParticles",
                                     MCTruthClassifier=truthClassifier)
        jtm += CopyTruthJetParticles("truthpartcopywz",
                                     OutputName="JetInputTruthParticlesNoWZ",
                                     MCTruthClassifier=truthClassifier,
                                     IncludePromptLeptons=False,
                                     IncludeMuons=True,
                                     IncludeNeutrinos=True)

    # Truth.
    if jetFlags.useTruth and jtm.haveParticleJetTools:
        # ParticleJetTools tools may be omitted in analysi releases.
        #ift jtm.haveParticleJetTools:
        # Delta-R truth parton label: truthpartondr.
        jtm += Analysis__JetQuarkLabel("jetquarklabel",
                                       McEventCollection="TruthEvents")
        jtm += Analysis__JetConeLabeling("truthpartondr",
                                         JetTruthMatchTool=jtm.jetquarklabel)

        # Parton truth label.
        jtm += Analysis__JetPartonTruthLabel("partontruthlabel")

        # Cone matching for B, C and tau truth for all but track jets.
        jtm += ParticleJetDeltaRLabelTool(
            "jetdrlabeler",
            LabelName="HadronConeExclTruthLabelID",
            DoubleLabelName="HadronConeExclExtendedTruthLabelID",
            BLabelName="ConeExclBHadronsFinal",
            CLabelName="ConeExclCHadronsFinal",
            TauLabelName="ConeExclTausFinal",
            BParticleCollection="TruthLabelBHadronsFinal",
            CParticleCollection="TruthLabelCHadronsFinal",
            TauParticleCollection="TruthLabelTausFinal",
            PartPtMin=5000.0,
            JetPtMin=0.0,
            DRMax=0.3,
            MatchMode="MinDR")

        # Cone matching for B, C and tau truth for track jets.
        jtm += ParticleJetDeltaRLabelTool(
            "trackjetdrlabeler",
            LabelName="HadronConeExclTruthLabelID",
            DoubleLabelName="HadronConeExclExtendedTruthLabelID",
            BLabelName="ConeExclBHadronsFinal",
            CLabelName="ConeExclCHadronsFinal",
            TauLabelName="ConeExclTausFinal",
            BParticleCollection="TruthLabelBHadronsFinal",
            CParticleCollection="TruthLabelCHadronsFinal",
            TauParticleCollection="TruthLabelTausFinal",
            PartPtMin=5000.0,
            JetPtMin=4500.0,
            DRMax=0.3,
            MatchMode="MinDR")

        jtm += PseudoJetGetter(
            "truthget",
            Label="Truth",
            InputContainer=jtm.truthpartcopy.OutputName,
            OutputContainer="PseudoJetTruth",
            GhostScale=0.0,
            SkipNegativeEnergy=True,
        )
        jtm += PseudoJetGetter(
            "truthwzget",
            Label="TruthWZ",
            InputContainer=jtm.truthpartcopywz.OutputName,
            OutputContainer="PseudoJetTruthWZ",
            GhostScale=0.0,
            SkipNegativeEnergy=True,
        )
        jtm += PseudoJetGetter(
            "gtruthget",
            Label="GhostTruth",
            InputContainer=jtm.truthpartcopy.OutputName,
            OutputContainer="PseudoJetGhostTruth",
            GhostScale=ghostScaleFactor,
            SkipNegativeEnergy=True,
        )

        # Truth flavor tags.
        for ptype in jetFlags.truthFlavorTags():
            jtm += PseudoJetGetter(
                "gtruthget_" + ptype,
                InputContainer="TruthLabel" + ptype,
                Label="Ghost" + ptype,
                OutputContainer="PseudoJetGhost" + ptype,
                SkipNegativeEnergy=True,
                GhostScale=ghostScaleFactor,
            )
Example #4
0
    )

    # Truth flavor tags.
    for ptype in jetFlags.truthFlavorTags():
        jtm += PseudoJetAlgorithm(
            "gtruthget_" + ptype,
            InputContainer="TruthLabel" + ptype,
            Label="Ghost" + ptype,
            OutputContainer="PseudoJetGhost" + ptype,
            SkipNegativeEnergy=True,
        )

    # ParticleJetTools tools may be omitted in analysi releases.
    #ift jtm.haveParticleJetTools:
    # Delta-R truth parton label: truthpartondr.
    jtm += Analysis__JetQuarkLabel("jetquarklabel",
                                   McEventCollection="TruthEvents")
    jtm += Analysis__JetConeLabeling("truthpartondr",
                                     JetTruthMatchTool=jtm.jetquarklabel)

    # Parton truth label.
    jtm += Analysis__JetPartonTruthLabel("partontruthlabel")

    # Cone matching for B, C and tau truth for all but track jets.
    jtm += ParticleJetDeltaRLabelTool(
        "jetdrlabeler",
        LabelName="HadronConeExclTruthLabelID",
        DoubleLabelName="HadronConeExclExtendedTruthLabelID",
        BLabelName="ConeExclBHadronsFinal",
        CLabelName="ConeExclCHadronsFinal",
        TauLabelName="ConeExclTausFinal",
        BParticleCollection="TruthLabelBHadronsFinal",
Example #5
0
    #
    # ========== Add tools now
    #
    from AthenaCommon.AppMgr import ToolSvc

    # -- for calibration from COOL
    include("JetTagCalibration/BTagCalibrationBroker_jobOptions.py")

    # -- to label jets with truth information
    from RecExConfig.RecFlags import rec
    if rec.doTruth:
        # Jet Label
        if BTaggingFlags.jetTruthMatching == 'matchQuark' or BTaggingFlags.jetTruthMatching == 'jetTrackTruthMatching':
            if BTaggingFlags.jetTruthMatching == 'matchQuark':  # this is default!
                from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQuarkLabel
                BTagJetTruthMatching = Analysis__JetQuarkLabel(
                    name="BTagJetTruthMatching")
            elif BTaggingFlags.jetTruthMatching == 'jetTrackTruthMatching':
                from ParticleJetTools.ParticleJetToolsConf import Analysis__JetTrackTruthMatching
                BTagJetTruthMatching = Analysis__JetTrackTruthMatching(
                    name="BTagJetTruthMatching",
                    TrackParticlesName=BTaggingFlags.
                    TrackParticleCollectionName,
                    TrackParticleTruthMapName=BTaggingFlags.
                    TrackParticleTruthCollectionName)
        BTagJetTruthMatching.McEventCollection = TheTruthCollectionKey
        ToolSvc += BTagJetTruthMatching
        if BTaggingFlags.OutputLevel < 3:
            print BTagJetTruthMatching

        if BTaggingFlags.QGTag:
            from ParticleJetTools.ParticleJetToolsConf import Analysis__JetQGPartonLabel