コード例 #1
0
ファイル: custom_jme_cff.py プロジェクト: Presurvivor/cmssw
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName=""):
  """
  Setup modules to calculate PF jet ID 
  """

  isPUPPIJet = True if "Puppi" in jetName else False
  
  looseJetId = "looseJetId{}".format(jetName)
  setattr(proc, looseJetId, proc.looseJetId.clone(
      src = jetSrc,
      filterParams=proc.looseJetId.filterParams.clone(
        version ="WINTER16"
      ),
    )
  )

  tightJetId = "tightJetId{}".format(jetName)
  setattr(proc, tightJetId, proc.tightJetId.clone(
      src = jetSrc,
      filterParams=proc.tightJetId.filterParams.clone(
        version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "")
      ),
    )
  )
  
  tightJetIdLepVeto = "tightJetIdLepVeto{}".format(jetName)
  setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
      src = jetSrc,
      filterParams=proc.tightJetIdLepVeto.filterParams.clone(
        version = "SUMMER18{}".format("PUPPI" if isPUPPIJet else "")
      ),
    )
  )
  run2_jme_2016.toModify(getattr(proc, tightJetId) .filterParams,        version = "WINTER16" )
  run2_jme_2016.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version = "WINTER16" )
  run2_jme_2017.toModify(getattr(proc, tightJetId) .filterParams,        version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
  run2_jme_2017.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version = "WINTER17{}".format("PUPPI" if isPUPPIJet else ""))
  
  #
  # Save variables as userInts in each jet
  # 
  patJetWithUserData = "{}WithUserData".format(jetSrc)
  getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
  getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
  run2_jme_2016.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))

  #
  # Specfiy variables in the jetTable to save in NanoAOD
  #
  getattr(proc, jetTableName).variables.jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto")
  run2_jme_2016.toModify(getattr(proc, jetTableName).variables, jetId = Var("userInt('tightIdLepVeto')*4+userInt('tightId')*2+userInt('looseId')",int, doc="Jet ID flags bit1 is loose, bit2 is tight, bit3 is tightLepVeto"))

  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, jetSrc))+1, getattr(proc, tightJetId))
  getattr(proc,jetSequenceName).insert(getattr(proc,jetSequenceName).index(getattr(proc, tightJetId))+1, getattr(proc, tightJetIdLepVeto))
  
  setattr(proc,"_"+jetSequenceName+"_2016", getattr(proc,jetSequenceName).copy())
  getattr(proc,"_"+jetSequenceName+"_2016").insert(getattr(proc, "_"+jetSequenceName+"_2016").index(getattr(proc, tightJetId)), getattr(proc, looseJetId))
  run2_jme_2016.toReplaceWith(getattr(proc,jetSequenceName), getattr(proc, "_"+jetSequenceName+"_2016"))

  return proc
コード例 #2
0
def setupAK15(process, runOnMC=False, path=None, runParticleNetMD=True):
    # recluster Puppi jets
    bTagDiscriminators = [
        'pfJetProbabilityBJetTags',
        'pfCombinedInclusiveSecondaryVertexV2BJetTags',
        'pfDeepCSVJetTags:probb',
        'pfDeepCSVJetTags:probbb',
    ]
    subjetBTagDiscriminators = [
        'pfJetProbabilityBJetTags',
        'pfCombinedInclusiveSecondaryVertexV2BJetTags',
        'pfDeepCSVJetTags:probb',
        'pfDeepCSVJetTags:probbb',
    ]
    JETCorrLevels = ['L2Relative', 'L3Absolute', 'L2L3Residual']

    from PhysicsTools.PFNano.jetToolbox_cff import jetToolbox
    jetToolbox(process,
               'ak15',
               'dummySeqAK15',
               'noOutput',
               PUMethod='Puppi',
               JETCorrPayload='AK8PFPuppi',
               JETCorrLevels=JETCorrLevels,
               Cut='pt > 160.0 && abs(rapidity()) < 2.4',
               runOnMC=runOnMC,
               addNsub=True,
               maxTau=3,
               addSoftDrop=True,
               addSoftDropSubjets=True,
               subJETCorrPayload='AK4PFPuppi',
               subJETCorrLevels=JETCorrLevels,
               bTagDiscriminators=bTagDiscriminators,
               subjetBTagDiscriminators=subjetBTagDiscriminators)

    if runOnMC:
        process.ak15GenJetsNoNu.jetPtMin = 100
        process.ak15GenJetsNoNuSoftDrop.jetPtMin = 100

    from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
    from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetJetTagsProbs as pfParticleNetJetTagsProbs
    from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfMassDecorrelatedParticleNetJetTagsProbs as pfMassDecorrelatedParticleNetJetTagsProbs
    bTagDiscriminators += pfParticleNetJetTagsProbs
    if runParticleNetMD:
        bTagDiscriminators += pfMassDecorrelatedParticleNetJetTagsProbs

    #from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsProbs, _pfMassDecorrelatedDeepBoostedJetTagsProbs, _pfDeepBoostedJetTagsMetaDiscrs, _pfMassDecorrelatedDeepBoostedJetTagsMetaDiscrs
    #bTagDiscriminators += _pfDeepBoostedJetTagsProbs + _pfMassDecorrelatedDeepBoostedJetTagsProbs + _pfDeepBoostedJetTagsMetaDiscrs + _pfMassDecorrelatedDeepBoostedJetTagsMetaDiscrs

    updateJetCollection(
        process,
        jetSource=cms.InputTag('packedPatJetsAK15PFPuppiSoftDrop'),
        rParam=1.5,
        jetCorrections=('AK8PFPuppi', cms.vstring(JETCorrLevels), 'None'),
        btagDiscriminators=bTagDiscriminators,
        postfix='AK15ParticleNet',
    )

    from RecoBTag.ONNXRuntime.pfParticleNet_cff import pfMassDecorrelatedParticleNetJetTags
    if runParticleNetMD:
        process.pfParticleNetTagInfosAK15ParticleNet.jet_radius = 1.5
        process.pfMassDecorrelatedParticleNetJetTagsAK15ParticleNet = pfMassDecorrelatedParticleNetJetTags.clone(
            src=process.pfMassDecorrelatedParticleNetJetTagsAK15ParticleNet.
            src,
            preprocess_json=
            'PhysicsTools/PFNano/data/ParticleNet-MD/ak15/preprocess.json',
            model_path=
            'PhysicsTools/PFNano/data/ParticleNet-MD/ak15/particle-net.onnx',
        )

    # src
    srcJets = cms.InputTag('selectedUpdatedPatJetsAK15ParticleNet')

    # jetID
    process.looseJetIdAK15Puppi = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('WINTER16'),
            quality=cms.string('LOOSE'),
        ),
        src=srcJets)

    process.tightJetIdAK15Puppi = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('SUMMER18PUPPI'),
            quality=cms.string('TIGHT'),
        ),
        src=srcJets)

    process.tightJetIdLepVetoAK15Puppi = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('SUMMER18PUPPI'),
            quality=cms.string('TIGHTLEPVETO'),
        ),
        src=srcJets)

    run2_jme_2016.toModify(process.tightJetIdAK15Puppi.filterParams,
                           version="WINTER16")
    run2_jme_2016.toModify(process.tightJetIdLepVetoAK15Puppi.filterParams,
                           version="WINTER16")
    run2_jme_2017.toModify(process.tightJetIdAK15Puppi.filterParams,
                           version="WINTER17PUPPI")
    run2_jme_2017.toModify(process.tightJetIdLepVetoAK15Puppi.filterParams,
                           version="WINTER17PUPPI")

    process.ak15WithUserData = cms.EDProducer(
        "PATJetUserDataEmbedder",
        src=srcJets,
        userFloats=cms.PSet(),
        userInts=cms.PSet(
            tightId=cms.InputTag("tightJetIdAK15Puppi"),
            tightIdLepVeto=cms.InputTag("tightJetIdLepVetoAK15Puppi"),
        ),
    )
    run2_jme_2016.toModify(
        process.ak15WithUserData.userInts,
        looseId=cms.InputTag("looseJetIdAK15Puppi"),
        tightIdLepVeto=None,
    )

    process.ak15Table = cms.EDProducer(
        "SimpleCandidateFlatTableProducer",
        src=cms.InputTag("ak15WithUserData"),
        name=cms.string("FatJetAK15"),  # AK15Puppi
        cut=cms.string(""),
        doc=cms.string("ak15 puppi jets"),
        singleton=cms.bool(False),  # the number of entries is variable
        extension=cms.bool(False),  # this is the main table for the jets
        variables=cms.PSet(
            P4Vars,
            jetId=Var(
                "userInt('tightId')*2+4*userInt('tightIdLepVeto')",
                int,
                doc=
                "Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"
            ),
            area=Var("jetArea()",
                     float,
                     doc="jet catchment area, for JECs",
                     precision=10),
            rawFactor=Var("1.-jecFactor('Uncorrected')",
                          float,
                          doc="1 - Factor to get back to raw pT",
                          precision=6),
            nPFConstituents=Var("numberOfDaughters()",
                                int,
                                doc="Number of PF candidate constituents"),
            tau1=Var("userFloat('NjettinessAK15Puppi:tau1')",
                     float,
                     doc="Nsubjettiness (1 axis)",
                     precision=10),
            tau2=Var("userFloat('NjettinessAK15Puppi:tau2')",
                     float,
                     doc="Nsubjettiness (2 axis)",
                     precision=10),
            tau3=Var("userFloat('NjettinessAK15Puppi:tau3')",
                     float,
                     doc="Nsubjettiness (3 axis)",
                     precision=10),
            msoftdrop=Var("groomedMass()",
                          float,
                          doc="Corrected soft drop mass with PUPPI",
                          precision=10),
            btagCSVV2=Var(
                "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",
                float,
                doc=
                "pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",
                precision=10),
            btagDeepB=Var(
                "bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",
                float,
                doc="DeepCSV b+bb tag discriminator",
                precision=10),
            btagJP=Var(
                "bDiscriminator('pfJetProbabilityBJetTags')",
                float,
                doc="pfJetProbabilityBJetTags b-tag discriminator (aka JP)",
                precision=10),
            nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
                          int,
                          doc="number of b-hadrons"),
            nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
                          int,
                          doc="number of c-hadrons"),
            subJetIdx1=Var(
                "?nSubjetCollections()>0 && subjets().size()>0?subjets()[0].key():-1",
                int,
                doc="index of first subjet"),
            subJetIdx2=Var(
                "?nSubjetCollections()>0 && subjets().size()>1?subjets()[1].key():-1",
                int,
                doc="index of second subjet"),
        ))
    run2_jme_2016.toModify(
        process.ak15Table.variables,
        jetId=Var("userInt('tightId')*2+userInt('looseId')",
                  int,
                  doc="Jet ID flags bit1 is loose, bit2 is tight"))
    process.ak15Table.variables.pt.precision = 10

    # add mass-decorelated taggers
    for prob in pfParticleNetJetTagsProbs:
        name = 'ParticleNet_' + prob.split(':')[1]
        setattr(
            process.ak15Table.variables, name,
            Var("bDiscriminator('%s')" % prob, float, doc=prob, precision=-1))

    if runParticleNetMD:
        for prob in pfMassDecorrelatedParticleNetJetTagsProbs:
            name = 'ParticleNetMD_' + prob.split(':')[1]
            name = name.replace('QCDothers', 'QCD')  # FIXME
            setattr(
                process.ak15Table.variables, name,
                Var("bDiscriminator('%s')" % prob,
                    float,
                    doc=prob,
                    precision=-1))

    process.ak15SubJetTable = cms.EDProducer(
        "SimpleCandidateFlatTableProducer",
        src=cms.InputTag("selectedPatJetsAK15PFPuppiSoftDropPacked",
                         "SubJets"),
        cut=cms.string(""),
        name=cms.string("FatJetAK15SubJet"),  # AK15PuppiSubJet
        doc=cms.string("ak15 puppi subjets"),
        singleton=cms.bool(False),  # the number of entries is variable
        extension=cms.bool(False),  # this is the main table for the jets
        variables=cms.PSet(
            P4Vars,
            area=Var("jetArea()",
                     float,
                     doc="jet catchment area, for JECs",
                     precision=10),
            rawFactor=Var("1.-jecFactor('Uncorrected')",
                          float,
                          doc="1 - Factor to get back to raw pT",
                          precision=6),
            btagDeepB=Var(
                "bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",
                float,
                doc="DeepCSV b+bb tag discriminator",
                precision=10),
            btagCSVV2=Var(
                "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",
                float,
                doc=
                " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",
                precision=10),
            btagJP=Var(
                "bDiscriminator('pfJetProbabilityBJetTags')",
                float,
                doc="pfJetProbabilityBJetTags b-tag discriminator (aka JP)",
                precision=10),
            nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
                          int,
                          doc="number of b-hadrons"),
            nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
                          int,
                          doc="number of c-hadrons"),
        ))
    process.ak15SubJetTable.variables.pt.precision = 10

    process.ak15Task = cms.Task(
        process.tightJetIdAK15Puppi,
        process.tightJetIdLepVetoAK15Puppi,
        process.ak15WithUserData,
        process.ak15Table,
        process.ak15SubJetTable,
    )

    if runOnMC:
        process.genJetAK15Table = cms.EDProducer(
            "SimpleCandidateFlatTableProducer",
            src=cms.InputTag("ak15GenJetsNoNu"),
            cut=cms.string("pt > 100."),
            name=cms.string("GenJetAK15"),
            doc=cms.string("AK15 GenJets made with visible genparticles"),
            singleton=cms.bool(False),  # the number of entries is variable
            extension=cms.bool(
                False),  # this is the main table for the genjets
            variables=cms.PSet(P4Vars, ))
        process.genJetAK15Table.variables.pt.precision = 10

        process.genSubJetAK15Table = cms.EDProducer(
            "SimpleCandidateFlatTableProducer",
            src=cms.InputTag("ak15GenJetsNoNuSoftDrop", "SubJets"),
            cut=cms.string(""),
            name=cms.string("GenSubJetAK15"),
            doc=cms.string("AK15 Gen-SubJets made with visible genparticles"),
            singleton=cms.bool(False),  # the number of entries is variable
            extension=cms.bool(
                False),  # this is the main table for the genjets
            variables=cms.PSet(P4Vars, ))
        process.genSubJetAK15Table.variables.pt.precision = 10

        process.ak15Task.add(process.genJetAK15Table)
        process.ak15Task.add(process.genSubJetAK15Table)

        ###### hack to avoid circular dependency ######
        process.jetMC.remove(process.patJetPartons)
        process.ak15Task.add(process.patJetPartons)
        ###############################################

    _ak15Task_2016 = process.ak15Task.copy()
    _ak15Task_2016.replace(process.tightJetIdLepVetoAK15Puppi,
                           process.looseJetIdAK15Puppi)
    run2_jme_2016.toReplaceWith(process.ak15Task, _ak15Task_2016)

    if path is None:
        process.schedule.associate(process.ak15Task)
    else:
        getattr(process, path).associate(process.ak15Task)
コード例 #3
0
def setupCustomizedAK8(process, runOnMC=False, path=None):
    # recluster Puppi jets
    bTagDiscriminators = [
        'pfCombinedInclusiveSecondaryVertexV2BJetTags',
        'pfBoostedDoubleSecondaryVertexAK8BJetTags',
    ]
    subjetBTagDiscriminators = [
        'pfCombinedInclusiveSecondaryVertexV2BJetTags',
        'pfDeepCSVJetTags:probb',
        'pfDeepCSVJetTags:probbb',
    ]
    JETCorrLevels = ['L2Relative', 'L3Absolute', 'L2L3Residual']

    from PhysicsTools.NanoTuples.jetToolbox_cff import jetToolbox
    jetToolbox(process,
               'ak8',
               'dummySeqAK8',
               'noOutput',
               PUMethod='Puppi',
               JETCorrPayload='AK8PFPuppi',
               JETCorrLevels=JETCorrLevels,
               Cut='pt > 170.0 && abs(rapidity()) < 2.4',
               runOnMC=runOnMC,
               addNsub=True,
               maxTau=3,
               addSoftDrop=True,
               addSoftDropSubjets=True,
               subJETCorrPayload='AK4PFPuppi',
               subJETCorrLevels=JETCorrLevels,
               bTagDiscriminators=bTagDiscriminators,
               subjetBTagDiscriminators=subjetBTagDiscriminators)

    if runOnMC:
        process.ak8GenJetsNoNu.jetPtMin = 100
        process.ak8GenJetsNoNuSoftDrop.jetPtMin = 100

    from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
    from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsProbs, _pfMassDecorrelatedDeepBoostedJetTagsProbs
    from RecoBTag.MXNet.pfParticleNet_cff import _pfParticleNetJetTagsProbs, _pfMassDecorrelatedParticleNetJetTagsProbs
    updateJetCollection(
        process,
        jetSource=cms.InputTag('packedPatJetsAK8PFPuppiSoftDrop'),
        rParam=0.8,
        jetCorrections=('AK8PFPuppi', cms.vstring(JETCorrLevels), 'None'),
        btagDiscriminators=bTagDiscriminators + _pfDeepBoostedJetTagsProbs +
        _pfMassDecorrelatedDeepBoostedJetTagsProbs +
        _pfParticleNetJetTagsProbs +
        _pfMassDecorrelatedParticleNetJetTagsProbs,
        postfix='AK8WithPuppiDaughters',
    )

    # src
    srcJets = cms.InputTag('selectedUpdatedPatJetsAK8WithPuppiDaughters')

    # jetID
    process.looseJetIdCustomAK8 = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('WINTER16'),
            quality=cms.string('LOOSE'),
        ),
        src=srcJets)

    process.tightJetIdCustomAK8 = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('SUMMER18PUPPI'),
            quality=cms.string('TIGHT'),
        ),
        src=srcJets)

    process.tightJetIdLepVetoCustomAK8 = cms.EDProducer(
        "PatJetIDValueMapProducer",
        filterParams=cms.PSet(
            version=cms.string('SUMMER18PUPPI'),
            quality=cms.string('TIGHTLEPVETO'),
        ),
        src=srcJets)

    run2_jme_2016.toModify(process.tightJetIdCustomAK8.filterParams,
                           version="WINTER16")
    run2_jme_2016.toModify(process.tightJetIdLepVetoCustomAK8.filterParams,
                           version="WINTER16")
    run2_jme_2017.toModify(process.tightJetIdCustomAK8.filterParams,
                           version="WINTER17PUPPI")
    run2_jme_2017.toModify(process.tightJetIdLepVetoCustomAK8.filterParams,
                           version="WINTER17PUPPI")

    process.customAK8WithUserData = cms.EDProducer(
        "PATJetUserDataEmbedder",
        src=srcJets,
        userFloats=cms.PSet(),
        userInts=cms.PSet(
            tightId=cms.InputTag("tightJetIdCustomAK8"),
            tightIdLepVeto=cms.InputTag("tightJetIdLepVetoCustomAK8"),
        ),
    )

    run2_jme_2016.toModify(
        process.customAK8WithUserData.userInts,
        looseId=cms.InputTag("looseJetIdCustomAK8"),
        tightIdLepVeto=None,
    )

    process.customAK8Table = cms.EDProducer(
        "SimpleCandidateFlatTableProducer",
        src=cms.InputTag("customAK8WithUserData"),
        name=cms.string("CustomAK8Puppi"),
        cut=cms.string(""),
        doc=cms.string("reclustered ak8 puppi jets"),
        singleton=cms.bool(False),  # the number of entries is variable
        extension=cms.bool(False),  # this is the main table for the jets
        variables=cms.PSet(
            P4Vars,
            jetId=Var(
                "userInt('tightId')*2+4*userInt('tightIdLepVeto')",
                int,
                doc=
                "Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto"
            ),
            area=Var("jetArea()",
                     float,
                     doc="jet catchment area, for JECs",
                     precision=10),
            rawFactor=Var("1.-jecFactor('Uncorrected')",
                          float,
                          doc="1 - Factor to get back to raw pT",
                          precision=6),
            nPFConstituents=Var("numberOfDaughters()",
                                int,
                                doc="Number of PF candidate constituents"),
            tau1=Var("userFloat('NjettinessAK8Puppi:tau1')",
                     float,
                     doc="Nsubjettiness (1 axis)",
                     precision=10),
            tau2=Var("userFloat('NjettinessAK8Puppi:tau2')",
                     float,
                     doc="Nsubjettiness (2 axis)",
                     precision=10),
            tau3=Var("userFloat('NjettinessAK8Puppi:tau3')",
                     float,
                     doc="Nsubjettiness (3 axis)",
                     precision=10),
            msoftdrop=Var("groomedMass()",
                          float,
                          doc="Corrected soft drop mass with PUPPI",
                          precision=10),
            btagCSVV2=Var(
                "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",
                float,
                doc=
                " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",
                precision=10),
            btagHbb=Var(
                "bDiscriminator('pfBoostedDoubleSecondaryVertexAK8BJetTags')",
                float,
                doc="Higgs to BB tagger discriminator",
                precision=10),
            nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
                          int,
                          doc="number of b-hadrons"),
            nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
                          int,
                          doc="number of c-hadrons"),
            subJetIdx1=Var(
                "?nSubjetCollections()>0 && subjets().size()>0?subjets()[0].key():-1",
                int,
                doc="index of first subjet"),
            subJetIdx2=Var(
                "?nSubjetCollections()>0 && subjets().size()>1?subjets()[1].key():-1",
                int,
                doc="index of second subjet"),
        ))
    run2_jme_2016.toModify(
        process.customAK8Table.variables,
        jetId=Var("userInt('tightId')*2+userInt('looseId')",
                  int,
                  doc="Jet ID flags bit1 is loose, bit2 is tight"))
    process.customAK8Table.variables.pt.precision = 10

    # add DeepAK8 scores: nominal
    for prob in _pfDeepBoostedJetTagsProbs:
        name = 'DeepAK8_' + prob.split(':')[1]
        setattr(
            process.customAK8Table.variables, name,
            Var("bDiscriminator('%s')" % prob, float, doc=prob, precision=-1))

    # add DeepAK8 scores: mass decorrelated
    for prob in _pfMassDecorrelatedDeepBoostedJetTagsProbs:
        name = 'DeepAK8MD_' + prob.split(':')[1]
        setattr(
            process.customAK8Table.variables, name,
            Var("bDiscriminator('%s')" % prob, float, doc=prob, precision=-1))

    # add ParticleNet nominal taggers
    for prob in _pfParticleNetJetTagsProbs:
        name = 'ParticleNet_' + prob.split(':')[1]
        setattr(
            process.customAK8Table.variables, name,
            Var("bDiscriminator('%s')" % prob, float, doc=prob, precision=-1))

    # add ParticleNet mass-decorelated taggers
    for prob in _pfMassDecorrelatedParticleNetJetTagsProbs:
        name = 'ParticleNetMD_' + prob.split(':')[1]
        setattr(
            process.customAK8Table.variables, name,
            Var("bDiscriminator('%s')" % prob, float, doc=prob, precision=-1))

    process.customAK8SubJetTable = cms.EDProducer(
        "SimpleCandidateFlatTableProducer",
        src=cms.InputTag("selectedPatJetsAK8PFPuppiSoftDropPacked", "SubJets"),
        cut=cms.string(""),
        name=cms.string("CustomAK8PuppiSubJet"),
        doc=cms.string("reculstered ak8 puppi subjets"),
        singleton=cms.bool(False),  # the number of entries is variable
        extension=cms.bool(False),  # this is the main table for the jets
        variables=cms.PSet(
            P4Vars,
            area=Var("jetArea()",
                     float,
                     doc="jet catchment area, for JECs",
                     precision=10),
            rawFactor=Var("1.-jecFactor('Uncorrected')",
                          float,
                          doc="1 - Factor to get back to raw pT",
                          precision=6),
            btagDeepB=Var(
                "bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')",
                float,
                doc="DeepCSV b+bb tag discriminator",
                precision=10),
            btagCSVV2=Var(
                "bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",
                float,
                doc=
                " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",
                precision=10),
            nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
                          int,
                          doc="number of b-hadrons"),
            nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
                          int,
                          doc="number of c-hadrons"),
        ))
    process.customAK8SubJetTable.variables.pt.precision = 10

    process.customizedAK8Task = cms.Task(process.tightJetIdCustomAK8,
                                         process.tightJetIdLepVetoCustomAK8,
                                         process.customAK8WithUserData,
                                         process.customAK8Table,
                                         process.customAK8SubJetTable)

    if runOnMC:
        process.customGenJetAK8Table = cms.EDProducer(
            "SimpleCandidateFlatTableProducer",
            src=cms.InputTag("ak8GenJetsNoNu"),
            cut=cms.string("pt > 100."),
            name=cms.string("CustomGenJetAK8"),
            doc=cms.string("AK8 GenJets made with visible genparticles"),
            singleton=cms.bool(False),  # the number of entries is variable
            extension=cms.bool(
                False),  # this is the main table for the genjets
            variables=cms.PSet(P4Vars, ))
        process.customGenJetAK8Table.variables.pt.precision = 10

        process.customGenSubJetAK8Table = cms.EDProducer(
            "SimpleCandidateFlatTableProducer",
            src=cms.InputTag("ak8GenJetsNoNuSoftDrop", "SubJets"),
            cut=cms.string(""),
            name=cms.string("CustomGenSubJetAK8"),
            doc=cms.string("AK8 Gen-SubJets made with visible genparticles"),
            singleton=cms.bool(False),  # the number of entries is variable
            extension=cms.bool(
                False),  # this is the main table for the genjets
            variables=cms.PSet(P4Vars, ))
        process.customGenSubJetAK8Table.variables.pt.precision = 10

        process.customizedAK8Task.add(process.customGenJetAK8Table)
        process.customizedAK8Task.add(process.customGenSubJetAK8Table)

    _customizedAK8Task_80X = process.customizedAK8Task.copy()
    _customizedAK8Task_80X.replace(process.tightJetIdLepVetoCustomAK8,
                                   process.looseJetIdCustomAK8)
    run2_jme_2016.toReplaceWith(process.customizedAK8Task,
                                _customizedAK8Task_80X)

    if path is None:
        process.schedule.associate(process.customizedAK8Task)
    else:
        getattr(process, path).associate(process.customizedAK8Task)
コード例 #4
0
#before cross linking
jetSequence = cms.Sequence(jetCorrFactorsNano + updatedJets + tightJetId +
                           tightJetIdLepVeto + bJetVars + qgtagger + jercVars +
                           pileupJetId94X + pileupJetId102X +
                           updatedJetsWithUserData + jetCorrFactorsAK8 +
                           updatedJetsAK8 + tightJetIdAK8 +
                           tightJetIdLepVetoAK8 + updatedJetsAK8WithUserData +
                           chsForSATkJets + softActivityJets +
                           softActivityJets2 + softActivityJets5 +
                           softActivityJets10 + finalJets + finalJetsAK8)

_jetSequence_2016 = jetSequence.copy()
_jetSequence_2016.insert(_jetSequence_2016.index(tightJetId), looseJetId)
_jetSequence_2016.insert(_jetSequence_2016.index(tightJetIdAK8), looseJetIdAK8)
run2_jme_2016.toReplaceWith(jetSequence, _jetSequence_2016)

#after lepton collections have been run
jetLepSequence = cms.Sequence(lepInJetVars)

#after cross linkining
jetTables = cms.Sequence(bjetNN + cjetNN + jetTable + fatJetTable +
                         subJetTable + saJetTable + saTable)

#MC only producers and tables
jetMC = cms.Sequence(jetMCTable + genJetTable + patJetPartons +
                     genJetFlavourTable + genJetAK8Table +
                     genJetAK8FlavourAssociation + genJetAK8FlavourTable +
                     fatJetMCTable + genSubJetAK8Table + subjetMCTable)
_jetMC_pre94X = jetMC.copy()
_jetMC_pre94X.insert(_jetMC_pre94X.index(genJetFlavourTable),
コード例 #5
0
ファイル: metFilters_cff.py プロジェクト: p2l1pfp/cmssw
## The muon bad track filter (2016) ________________________________________________||
from RecoMET.METFilters.BadPFMuonFilter_cfi import *

## The muon bad track filter with Dz cut (2020) _____________________________________||
from RecoMET.METFilters.BadPFMuonDzFilter_cfi import *

#HF noise filter
from RecoMET.METFilters.hfNoisyHitsFilter_cfi import *

metFilters = cms.Sequence(
    goodVertices * globalSuperTightHalo2016Filter *
    HBHENoiseFilterResultProducer * HBHENoiseFilter * HBHENoiseIsoFilter *
    EcalDeadCellTriggerPrimitiveFilter * BadPFMuonFilter * BadPFMuonDzFilter *
    hfNoisyHitsFilter * eeBadScFilter * ecalBadCalibFilter)

from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal
phase2_hgcal.toReplaceWith(
    metFilters,
    metFilters.copyAndExclude([
        HBHENoiseFilterResultProducer,
        HBHENoiseFilter,
        HBHENoiseIsoFilter,  # No hcalnoise for hgcal
        eeBadScFilter  # No EE
    ]))

from Configuration.Eras.Modifier_run2_jme_2016_cff import run2_jme_2016
run2_jme_2016.toReplaceWith(
    metFilters,
    metFilters.copyAndExclude([ecalBadCalibFilter, hfNoisyHitsFilter]))