Exemple #1
0
def nanoAOD_customizeCommon(process):
    #    makePuppiesFromMiniAOD(process,True) # call this here as it calls switchOnVIDPhotonIdProducer
    process = nanoAOD_activateVID(process)
    nanoAOD_addDeepInfo_switch = cms.PSet(
        nanoAOD_addDeepBTag_switch=cms.untracked.bool(False),
        nanoAOD_addDeepFlavourTag_switch=cms.untracked.bool(False),
    )
    run2_miniAOD_80XLegacy.toModify(
        nanoAOD_addDeepInfo_switch,
        nanoAOD_addDeepBTag_switch=cms.untracked.bool(True))
    for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
        modifier.toModify(
            nanoAOD_addDeepInfo_switch,
            nanoAOD_addDeepFlavourTag_switch=cms.untracked.bool(True))
    process = nanoAOD_addDeepInfo(
        process,
        addDeepBTag=nanoAOD_addDeepInfo_switch.nanoAOD_addDeepBTag_switch,
        addDeepFlavour=nanoAOD_addDeepInfo_switch.
        nanoAOD_addDeepFlavourTag_switch)
    nanoAOD_addDeepInfoAK8_switch = cms.PSet(
        nanoAOD_addDeepBTag_switch=cms.untracked.bool(False),
        nanoAOD_addDeepBoostedJet_switch=cms.untracked.bool(False),
        nanoAOD_addDeepDoubleX_switch=cms.untracked.bool(False),
        nanoAOD_addParticleNet_switch=cms.untracked.bool(False),
        jecPayload=cms.untracked.string('AK8PFPuppi'))
    # deepAK8 should not run on 80X, that contains ak8PFJetsCHS jets
    run2_miniAOD_80XLegacy.toModify(nanoAOD_addDeepInfoAK8_switch,
                                    nanoAOD_addDeepBTag_switch=True,
                                    jecPayload='AK8PFchs')
    # for 94X and 102X samples: needs to run DeepAK8, DeepDoubleX and ParticleNet
    (run2_nanoAOD_94X2016 | run2_nanoAOD_94XMiniAODv1
     | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1).toModify(
         nanoAOD_addDeepInfoAK8_switch,
         nanoAOD_addDeepBoostedJet_switch=True,
         nanoAOD_addDeepDoubleX_switch=True,
         nanoAOD_addParticleNet_switch=True,
     )
    # for 106Xv1: only needs to run ParticleNet; DeepAK8, DeepDoubleX are already in MiniAOD
    run2_nanoAOD_106Xv1.toModify(
        nanoAOD_addDeepInfoAK8_switch,
        nanoAOD_addParticleNet_switch=True,
    )
    process = nanoAOD_addDeepInfoAK8(
        process,
        addDeepBTag=nanoAOD_addDeepInfoAK8_switch.nanoAOD_addDeepBTag_switch,
        addDeepBoostedJet=nanoAOD_addDeepInfoAK8_switch.
        nanoAOD_addDeepBoostedJet_switch,
        addDeepDoubleX=nanoAOD_addDeepInfoAK8_switch.
        nanoAOD_addDeepDoubleX_switch,
        addParticleNet=nanoAOD_addDeepInfoAK8_switch.
        nanoAOD_addParticleNet_switch,
        jecPayload=nanoAOD_addDeepInfoAK8_switch.jecPayload)
    (run2_nanoAOD_94XMiniAODv1 | run2_nanoAOD_94X2016
     | run2_nanoAOD_94XMiniAODv2 | run2_nanoAOD_102Xv1
     | run2_nanoAOD_106Xv1).toModify(process, lambda p: nanoAOD_addTauIds(p))
    return process
Exemple #2
0
def nanoAOD_recalibrateMETs(process, isData):
    # add DeepMETs
    nanoAOD_DeepMET_switch = cms.PSet(
        nanoAOD_addDeepMET_switch=cms.untracked.bool(
            True),  # decide if DeeMET should be included in Nano
        nanoAOD_produceDeepMET_switch=cms.untracked.bool(
            False),  # decide if DeepMET should be computed on the fly
        ResponseTune_Graph=cms.untracked.string(
            'RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2018.pb'))
    for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1, run2_nanoAOD_106Xv1:
        # compute DeepMETs in these eras (before 111X)
        modifier.toModify(
            nanoAOD_DeepMET_switch,
            nanoAOD_produceDeepMET_switch=cms.untracked.bool(True))
    for modifier in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
        modifier.toModify(
            nanoAOD_DeepMET_switch,
            ResponseTune_Graph=cms.untracked.string(
                "RecoMET/METPUSubtraction/data/deepmet/deepmet_resp_v1_2016.pb"
            ))
    if nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch:
        process = nanoAOD_addDeepMET(
            process,
            addDeepMETProducer=nanoAOD_DeepMET_switch.
            nanoAOD_produceDeepMET_switch,
            ResponseTune_Graph=nanoAOD_DeepMET_switch.ResponseTune_Graph)

    # if included in Nano, and not computed in the fly, then it should be extracted from minAOD
    extractDeepMETs = nanoAOD_DeepMET_switch.nanoAOD_addDeepMET_switch and not nanoAOD_DeepMET_switch.nanoAOD_produceDeepMET_switch

    runMetCorAndUncFromMiniAOD(process,
                               isData=isData,
                               extractDeepMETs=extractDeepMETs)
    process.nanoSequenceCommon.insert(
        process.nanoSequenceCommon.index(process.jetSequence),
        cms.Sequence(process.fullPatMetSequence))
    process.basicJetsForMetForT1METNano = process.basicJetsForMet.clone(
        src=process.updatedJetsWithUserData.src,
        skipEM=False,
        type1JetPtThreshold=0.0,
        calcMuonSubtrRawPtAsValueMap=cms.bool(True),
    )
    process.jetSequence.insert(
        process.jetSequence.index(process.updatedJetsWithUserData),
        cms.Sequence(process.basicJetsForMetForT1METNano))
    process.updatedJetsWithUserData.userFloats.muonSubtrRawPt = cms.InputTag(
        "basicJetsForMetForT1METNano:MuonSubtrRawPt")
    process.corrT1METJetTable.src = process.finalJets.src
    process.corrT1METJetTable.cut = "pt<15 && abs(eta)<9.9"
    for table in process.jetTable, process.corrT1METJetTable:
        table.variables.muonSubtrFactor = Var(
            "1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",
            float,
            doc="1-(muon-subtracted raw pt)/(raw pt)",
            precision=6)
    process.metTables += process.corrT1METJetTable
    #    makePuppiesFromMiniAOD(process,True) # call this before in the global customizer otherwise it would reset photon IDs in VID
    nanoAOD_PuppiV15_switch = cms.PSet(
        recoMetFromPFCs=cms.untracked.bool(False),
        reclusterJets=cms.untracked.bool(False),
    )
    run2_nanoAOD_106Xv1.toModify(nanoAOD_PuppiV15_switch,
                                 recoMetFromPFCs=True,
                                 reclusterJets=True)
    if nanoAOD_PuppiV15_switch.reclusterJets:
        from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets
        from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
        task = getPatAlgosToolsTask(process)
        addToProcessAndTask(
            'ak4PuppiJets',
            ak4PFJets.clone(src='puppi', doAreaFastjet=True, jetPtMin=10.),
            process, task)
        from PhysicsTools.PatAlgos.tools.jetTools import addJetCollection
        addJetCollection(
            process,
            labelName='Puppi',
            jetSource=cms.InputTag('ak4PuppiJets'),
            algo='AK',
            rParam=0.4,
            genJetCollection=cms.InputTag('slimmedGenJets'),
            jetCorrections=('AK4PFPuppi', [
                'L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual'
            ], 'None'),
            pfCandidates=cms.InputTag('packedPFCandidates'),
            pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
            svSource=cms.InputTag('slimmedSecondaryVertices'),
            muSource=cms.InputTag('slimmedMuons'),
            elSource=cms.InputTag('slimmedElectrons'),
            genParticles=cms.InputTag('prunedGenParticles'),
            getJetMCFlavour=False)

        process.patJetsPuppi.addGenPartonMatch = cms.bool(False)
        process.patJetsPuppi.addGenJetMatch = cms.bool(False)

    runMetCorAndUncFromMiniAOD(
        process,
        isData=isData,
        metType="Puppi",
        postfix="Puppi",
        jetFlavor="AK4PFPuppi",
        recoMetFromPFCs=bool(nanoAOD_PuppiV15_switch.recoMetFromPFCs),
        reclusterJets=bool(nanoAOD_PuppiV15_switch.reclusterJets))
    process.nanoSequenceCommon.insert(
        process.nanoSequenceCommon.index(process.jetSequence),
        cms.Sequence(process.puppiMETSequence +
                     process.fullPatMetSequencePuppi))
    return process
Exemple #3
0
# this below is used only in some eras
slimmedElectronsUpdated = cms.EDProducer("PATElectronUpdater",
    src = cms.InputTag("slimmedElectronsTo106X"),
    vertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
    computeMiniIso = cms.bool(False),
    fixDxySign = cms.bool(True),
    pfCandsForMiniIso = cms.InputTag("packedPFCandidates"),
    miniIsoParamsB = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsB, # so they're in sync
    miniIsoParamsE = PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi.patElectrons.miniIsoParamsE, # so they're in sync
)
run2_miniAOD_80XLegacy.toModify( slimmedElectronsUpdated, computeMiniIso = True )
# bypass the update to 106X in 106X to only pick up the IP sign fix
run2_egamma_2017.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
run2_egamma_2018.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
run2_nanoAOD_106Xv1.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectrons"))
####because run2_egamma_2017 and run2_egamma_2018 can modify things further, need the following line to resort back
for modifier in run2_miniAOD_80XLegacy,run2_nanoAOD_94X2016,run2_nanoAOD_94XMiniAODv1,run2_nanoAOD_94XMiniAODv2,run2_nanoAOD_102Xv1:
    modifier.toModify(slimmedElectronsUpdated, src = cms.InputTag("slimmedElectronsTo106X"))


electron_id_modules_WorkingPoints_nanoAOD = cms.PSet(
    modules = cms.vstring(
        'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V1_cff',
        'RecoEgamma.ElectronIdentification.Identification.cutBasedElectronID_Fall17_94X_V2_cff',
        'RecoEgamma.ElectronIdentification.Identification.heepElectronID_HEEPV70_cff',
        'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
        'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
        'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
        'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
    ),