Beispiel #1
0
def PrepJMECustomNanoAOD(process, runOnMC):

    ############################################################################
    # Remove all default jet pt cuts from jets_cff.py
    ############################################################################
    process = RemoveAllJetPtCuts(process)

    ###########################################################################
    #
    # Gen-level jets related functions. Only for MC.
    #
    ###########################################################################
    genJA = GenJetAdder()
    if runOnMC:
        ############################################################################
        # Save additional variables for AK8 GEN jets
        ############################################################################
        process = AddVariablesForAK8GenJets(process)
        ###########################################################################
        # Recluster AK4 GEN jets
        ###########################################################################
        process = ReclusterAK4GenJets(process, genJA)
        process = AddVariablesForAK4GenJets(process)
        ###########################################################################
        # Add additional GEN jets to NanoAOD
        ###########################################################################
        for jetConfig in config_genjets:
            cfg = {k: v for k, v in jetConfig.items() if k != "enabled"}
            genJetInfo = genJA.addGenJetCollection(process, **cfg)
            AddNewGenJets(process, genJetInfo)

    ###########################################################################
    #
    # Reco-level jets related functions. For both MC and data.
    #
    ###########################################################################
    recoJA = RecoJetAdder(runOnMC=runOnMC)
    ###########################################################################
    # Save additional variables for AK8Puppi jets
    ###########################################################################
    process = AddVariablesForAK8PuppiJets(process)
    ###########################################################################
    # Recluster AK4 CHS jets and replace "slimmedJets"
    ###########################################################################
    process = ReclusterAK4CHSJets(process, recoJA, runOnMC)
    ###########################################################################
    # Add additional Reco jets to NanoAOD
    ###########################################################################
    for jetConfig in config_recojets:
        cfg = {k: v for k, v in jetConfig.items() if k != "enabled"}
        recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
        AddNewPatJets(process, recoJetInfo, runOnMC)

    ###########################################################################
    # Save Maximum of Pt Hat Max
    ###########################################################################
    if runOnMC:
        process.puTable.savePtHatMax = True

    return process
Beispiel #2
0
def PrepJMECustomNanoAOD(process, runOnMC):
    #
    # Additional variables to AK4GenJets
    #
    process.genJetTable.variables.area = JETVARS.area
    #
    # Additional variables to AK8GenJets
    #
    process.genJetAK8Table.variables.area = JETVARS.area
    #
    # Additional variables for AK4PFCHS
    #
    process.jetTable.variables.HFHEF = JETVARS.HFHEF
    process.jetTable.variables.HFEMEF = JETVARS.HFEMEF
    #
    # Additional variables to AK8PFPUPPI
    #
    # These variables are not stored for AK8PFCHS (slimmedJetsAK8)
    # in MiniAOD if their pt < 170 GeV. Hence the conditional fill.
    #
    process.fatJetTable.variables.chHEF = Var(
        "?isPFJet()?chargedHadronEnergyFraction():-1",
        float,
        doc="charged Hadron Energy Fraction",
        precision=6)
    process.fatJetTable.variables.neHEF = Var(
        "?isPFJet()?neutralHadronEnergyFraction():-1",
        float,
        doc="neutral Hadron Energy Fraction",
        precision=6)
    process.fatJetTable.variables.chEmEF = Var(
        "?isPFJet()?chargedEmEnergyFraction():-1",
        float,
        doc="charged Electromagnetic Energy Fraction",
        precision=6)
    process.fatJetTable.variables.neEmEF = Var(
        "?isPFJet()?neutralEmEnergyFraction():-1",
        float,
        doc="neutral Electromagnetic Energy Fraction",
        precision=6)
    process.fatJetTable.variables.muEF = Var(
        "?isPFJet()?muonEnergyFraction():-1",
        float,
        doc="muon Energy Fraction",
        precision=6)
    process.fatJetTable.variables.HFHEF = Var(
        "?isPFJet()?HFHadronEnergyFraction():-1",
        float,
        doc="energy fraction in forward hadronic calorimeter",
        precision=6)
    process.fatJetTable.variables.HFEMEF = Var(
        "?isPFJet()?HFEMEnergyFraction():-1",
        float,
        doc="energy fraction in forward EM calorimeter",
        precision=6)
    #
    #
    #
    process.jercVarsFatJet = process.jercVars.clone(
        srcJet="updatedJetsAK8",
        maxDR=0.8,
    )
    process.jetSequence.insert(
        process.jetSequence.index(process.updatedJetsAK8WithUserData),
        process.jercVarsFatJet)

    process.updatedJetsAK8WithUserData.userFloats = cms.PSet(
        chFPV0EF=cms.InputTag("%s:chargedFromPV0EnergyFraction" %
                              process.jercVarsFatJet.label()),
        chFPV1EF=cms.InputTag("%s:chargedFromPV1EnergyFraction" %
                              process.jercVarsFatJet.label()),
        chFPV2EF=cms.InputTag("%s:chargedFromPV2EnergyFraction" %
                              process.jercVarsFatJet.label()),
        chFPV3EF=cms.InputTag("%s:chargedFromPV3EnergyFraction" %
                              process.jercVarsFatJet.label()),
    )

    process.fatJetTable.variables.chFPV0EF = JETVARS.chFPV0EF
    process.fatJetTable.variables.chFPV1EF = JETVARS.chFPV1EF
    process.fatJetTable.variables.chFPV2EF = JETVARS.chFPV2EF
    process.fatJetTable.variables.chFPV3EF = JETVARS.chFPV3EF

    #
    #
    #
    process.finalJets.cut = ""  # 15 -> 10
    process.finalJetsAK8.cut = ""  # 170 -> 170
    process.genJetTable.cut = ""  # 10 -> 8
    process.genJetFlavourTable.cut = ""  # 10 -> 8
    process.genJetAK8Table.cut = ""  # 100 -> 80
    process.genJetAK8FlavourTable.cut = ""  # 100 -> 80
    #
    # Add variables for pileup jet ID studies.
    #
    AddPileUpJetIDVars(process)
    #
    # Add variables for quark guon likelihood tagger studies.
    #
    AddQGLTaggerVars(process)

    ######################################################################################################################

    #
    # Add GenJets to NanoAOD
    #
    genJA = GenJetAdder()
    tableGenJA = TableGenJetAdder()

    for jetConfig in config_genjets:
        cfg = {k: v for k, v in jetConfig.items() if k != "enabled"}
        genJetInfo = genJA.addGenJetCollection(process, **cfg)
        tableGenJA.addTable(process, genJetInfo)

    #
    # Add RecoJets to NanoAOD
    #
    recoJA = RecoJetAdder(runOnMC=runOnMC)
    tableRecoJA = TableRecoJetAdder()

    for jetConfig in config_recojets:
        cfg = {k: v for k, v in jetConfig.items() if k != "enabled"}
        recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
        tableRecoJA.addTable(process, recoJetInfo)

    if runOnMC:
        process.nanoSequenceMC += genJA.getSequence(process)
        process.nanoSequenceMC += recoJA.getSequence(process)
        process.nanoSequenceMC += tableGenJA.getSequence(process)
        process.nanoSequenceMC += tableRecoJA.getSequence(process)
    else:
        process.nanoSequence += recoJA.getSequence(process)
        process.nanoSequence += tableRecoJA.getSequence(process)

    return process