Beispiel #1
0
process.patPFMet.addGenMET = False

process.pfMetCHS = process.pfMet.clone()
process.pfMetCHS.src = cms.InputTag("chs")
process.pfMetCHS.alias = cms.string('pfMetCHS')
addMETCollection(process, labelName='patPFMetCHS', metSource='pfMetCHS') # RAW CHS MET
process.patPFMetCHS.addGenMET = False


## Slimmed METs
from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
#### CaloMET is not available in MiniAOD
del slimmedMETs.caloMET

### CHS
process.slimmedMETsCHS = slimmedMETs.clone()
if hasattr(process, "patPFMetCHS"):
    # Create MET from Type 1 PF collection
    process.patPFMetCHS.addGenMET = False
    process.slimmedMETsCHS.src = cms.InputTag("patPFMetCHS")
    process.slimmedMETsCHS.rawUncertainties = cms.InputTag("patPFMetCHS") # only central value
else:
    # Create MET from RAW PF collection
    process.patPFMetCHS.addGenMET = False
    process.slimmedMETsCHS.src = cms.InputTag("patPFMetCHS")
    del process.slimmedMETsCHS.rawUncertainties # not available
    
clean_met_(process.slimmedMETsCHS)
addMETCollection(process, labelName="slMETsCHS", metSource="slimmedMETsCHS")
process.slMETsCHS.addGenMET = False
Beispiel #2
0
def setup_jets_mets_(process, isData, bTagDiscriminators):
    """
    Create a new jets collection and a new MET collection with new JECs applied

    Return a tuple of newly created collections (jet, met)
    """

    # Jets

    add_ak4_chs_jets_(process, isData, bTagDiscriminators)

    # b-tagging information. From
    # https://github.com/cms-sw/cmssw/blob/CMSSW_7_4_X/PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py#L130
    process.patJetsAK4PFCHS.userData.userFunctions = cms.vstring(
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.M):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).numberOfSourceCandidatePtrs):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).value):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").flightDistance(0).significance):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.x):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.y):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).p4.z):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.x):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.y):(0)',
            '?(tagInfoCandSecondaryVertex("pfSecondaryVertex").nVertices()>0)?(tagInfoCandSecondaryVertex("pfSecondaryVertex").secondaryVertex(0).vertex.z):(0)',
            )
    process.patJetsAK4PFCHS.userData.userFunctionLabels = cms.vstring('vtxMass','vtxNtracks','vtx3DVal','vtx3DSig','vtxPx','vtxPy','vtxPz','vtxPosX','vtxPosY','vtxPosZ')
    process.patJetsAK4PFCHS.tagInfoSources = cms.VInputTag(cms.InputTag("pfSecondaryVertexTagInfosAK4PFCHS"))
    process.patJetsAK4PFCHS.addTagInfos = cms.bool(True)

    # Pile-up jet id
    process.load('RecoJets.JetProducers.PileupJetID_cfi')
    process.pileupJetId.applyJec = False
    process.pileupJetId.vertexes = cms.InputTag('offlineSlimmedPrimaryVertices')
    process.patJetsAK4PFCHS.userData.userFloats.src = [ cms.InputTag("pileupJetId:fullDiscriminant"), ]

    # MET
    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection

    ## Gen MET
    if not isData:
        process.genMetExtractor = cms.EDProducer("GenMETExtractor",
                metSource = cms.InputTag("slimmedMETs", "" , cms.InputTag.skipCurrentProcess())
                )

    # MET is done from all PF candidates, and Type-I corrections are computed from CHS ak4 PF jets
    # https://twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETRun2Corrections#type_1_PF_MET_recommended

    ## Raw PF METs
    process.load('RecoMET.METProducers.PFMET_cfi')

    process.pfMet.src = cms.InputTag('packedPFCandidates')
    addMETCollection(process, labelName='patPFMet', metSource='pfMet') # RAW MET
    process.patPFMet.addGenMET = False

    ## Type 1 corrections
    process.load('JetMETCorrections.Configuration.JetCorrectors_cff')
    from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType1
    from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1

    process.corrPfMetType1 = corrPfMetType1.clone(
        src = 'ak4PFJetsCHS',
        jetCorrLabel = 'ak4PFCHSL1FastL2L3Corrector' if not isData else 'ak4PFCHSL1FastL2L3ResidualCorrector',
        offsetCorrLabel = 'ak4PFCHSL1FastjetCorrector',
        type1JetPtThreshold = cms.double(15.0)
    )
    process.pfMetT1 = pfMetT1.clone(
        src = 'pfMet',
        srcCorrections = [cms.InputTag("corrPfMetType1", "type1")]
    )

    addMETCollection(process, labelName='patMET', metSource='pfMetT1') # T1 MET
    process.patMET.addGenMET = False

    ## Slimmed METs

    from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
    #### CaloMET is not available in MiniAOD
    del slimmedMETs.caloMET

    process.slimmedMETs = slimmedMETs.clone()

    process.patMET.addGenMET = not isData
    if not isData:
        process.patMET.genMETSource = cms.InputTag("genMetExtractor")
    process.slimmedMETs.src = cms.InputTag("patMET")
    process.slimmedMETs.rawVariation = cms.InputTag("patPFMet") # only central value

    # Only central values are available
    configure_slimmedmet_(process.slimmedMETs)

    process.slimmedJetsNewJEC = process.selectedPatJetsAK4PFCHS.clone()
    process.slimmedMETsNewJEC = process.slimmedMETs.clone()

    return ('slimmedJetsNewJEC', 'slimmedMETsNewJEC')
                           electronCollection="slimmedElectrons",
                           muonCollection="slimmedMuons",
                           tauCollection="slimmedTaus",
                           makeType1p2corrPFMEt=False)

process.patMETs.addGenMET = cms.bool(False)
process.patJets.addGenJetMatch = cms.bool(False)
process.patJets.addGenPartonMatch = cms.bool(False)
process.patJets.addPartonJetMatch = cms.bool(False)

from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
addMETCollection(process, labelName='patMET', metSource='pfMetT1')  # T1
addMETCollection(process, labelName='patPFMet', metSource='pfMet')  # RAW

from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
process.mySlimmedMETs = slimmedMETs.clone()
process.mySlimmedMETs.src = cms.InputTag("patMET")
process.mySlimmedMETs.rawUncertainties = cms.InputTag(
    "patPFMet")  # only central value
process.mySlimmedMETs.type1Uncertainties = cms.InputTag(
    "patPFMetT1")  # only central value for now
del process.mySlimmedMETs.type1p2Uncertainties  # not available
del process.mySlimmedMETs.caloMET

####### Adding HEEP id ##########

from PhysicsTools.SelectorUtils.tools.vid_id_tools import *

dataFormat = DataFormat.MiniAOD
switchOnVIDElectronIdProducer(process, dataFormat)
Beispiel #4
0
process.patPFMet.addGenMET = False

process.pfMetCHS = process.pfMet.clone()
process.pfMetCHS.src = cms.InputTag("chs")
process.pfMetCHS.alias = cms.string('pfMetCHS')
addMETCollection(process, labelName='patPFMetCHS',
                 metSource='pfMetCHS')  # RAW CHS MET
process.patPFMetCHS.addGenMET = False

## Slimmed METs
from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
#### CaloMET is not available in MiniAOD
del slimmedMETs.caloMET

### CHS
process.slimmedMETsCHS = slimmedMETs.clone()
if hasattr(process, "patPFMetCHS"):
    # Create MET from Type 1 PF collection
    process.patPFMetCHS.addGenMET = False
    process.slimmedMETsCHS.src = cms.InputTag("patPFMetCHS")
    process.slimmedMETsCHS.rawUncertainties = cms.InputTag(
        "patPFMetCHS")  # only central value
else:
    # Create MET from RAW PF collection
    process.patPFMetCHS.addGenMET = False
    process.slimmedMETsCHS.src = cms.InputTag("patPFMetCHS")
    del process.slimmedMETsCHS.rawUncertainties  # not available

clean_met_(process.slimmedMETsCHS)
addMETCollection(process, labelName="slMETsCHS", metSource="slimmedMETsCHS")
process.slMETsCHS.addGenMET = False
Beispiel #5
0
def setup_met_(process, isData):
    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection

    ## Gen MET
    if not isData:
        process.genMetExtractor = cms.EDProducer("GenMETExtractor",
                metSource = cms.InputTag("slimmedMETs", "" , cms.InputTag.skipCurrentProcess())
                )

    # MET is done from all PF candidates, and Type-I corrections are computed from CHS ak4 PF jets
    # https://twiki.cern.ch/twiki/bin/viewauth/CMS/MissingETRun2Corrections#type_1_PF_MET_recommended

    ## Raw PF METs
    process.load('RecoMET.METProducers.PFMET_cfi')

    process.pfMet.src = cms.InputTag('packedPFCandidates')
    addMETCollection(process, labelName='patPFMet', metSource='pfMet') # RAW MET
    process.patPFMet.addGenMET = False

    ## Type 1 corrections
    process.load('JetMETCorrections.Configuration.JetCorrectors_cff')
    from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType1
    from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1

    if not hasattr(process, 'ak4PFJetsCHS'):
        print("WARNING: No AK4 CHS jets produced. Type 1 corrections for MET are not available.")
    else:
        process.corrPfMetType1 = corrPfMetType1.clone(
            src = 'ak4PFJetsCHS',
            jetCorrLabel = 'ak4PFCHSL1FastL2L3Corrector' if not isData else 'ak4PFCHSL1FastL2L3ResidualCorrector',
            offsetCorrLabel = 'ak4PFCHSL1FastjetCorrector'
        )
        process.pfMetT1 = pfMetT1.clone(
            src = 'pfMet',
            srcCorrections = [cms.InputTag("corrPfMetType1", "type1")]
        )

        addMETCollection(process, labelName='patMET', metSource='pfMetT1') # T1 MET
        process.patMET.addGenMET = False

    ## Slimmed METs

    from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
    #### CaloMET is not available in MiniAOD
    del slimmedMETs.caloMET

    process.slimmedMETs = slimmedMETs.clone()
    if hasattr(process, "patMET"):
        # Create MET from Type 1 PF collection
        process.patMET.addGenMET = not isData
        if not isData:
            process.patMET.genMETSource = cms.InputTag("genMetExtractor")
        process.slimmedMETs.src = cms.InputTag("patMET")
        process.slimmedMETs.rawUncertainties = cms.InputTag("patPFMet") # only central value
    else:
        # Create MET from RAW PF collection
        process.patPFMet.addGenMET = not isData
        if not isData:
            process.patPFMet.genMETSource = cms.InputTag("genMetExtractor")
        process.slimmedMETs.src = cms.InputTag("patPFMet")
        del process.slimmedMETs.rawUncertainties # not available

    del process.slimmedMETs.type1Uncertainties # not available
    del process.slimmedMETs.type1p2Uncertainties # not available
Beispiel #6
0
def setup_nohf_met_(process, isData):
    from PhysicsTools.PatAlgos.tools.metTools import addMETCollection

    process.noHFCands = cms.EDFilter("CandPtrSelector",
            src=cms.InputTag("packedPFCandidates"),
            cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
            )

    if not isData and not hasattr(process, 'genMetExtractor'):
        process.genMetExtractor = cms.EDProducer("GenMETExtractor",
                metSource = cms.InputTag("slimmedMETs", "" , cms.InputTag.skipCurrentProcess())
                )

    if not hasattr(process, 'pfMet'):
        from RecoMET.METProducers.PFMET_cfi import pfMet
        process.pfMetNoHF = pfMet.clone()
    else:
        process.pfMetNoHF = process.pfMet.clone()

    process.pfMetNoHF.calculateSignificance = False
    process.pfMetNoHF.src = cms.InputTag('noHFCands')
    addMETCollection(process, labelName='patPFMetNoHF', metSource='pfMetNoHF') # RAW MET
    process.patPFMetNoHF.addGenMET = False

    ## Type 1 corrections
    if not hasattr(process, 'ak4PFCHSL1FastL2L3Corrector'):
        process.load('JetMETCorrections.Configuration.JetCorrectors_cff')

    from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType1
    from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1

    if not hasattr(process, 'ak4PFJetsCHS'):
        print("WARNING: No AK4 CHS jets produced. Type 1 corrections for MET are not available.")
    else:
        if not hasattr(process, 'corrPfMetType1'):
            process.corrPfMetType1 = corrPfMetType1.clone(
                src = 'ak4PFJetsCHS',
                jetCorrLabel = 'ak4PFCHSL1FastL2L3Corrector' if not isData else 'ak4PFCHSL1FastL2L3ResidualCorrector',
                offsetCorrLabel = 'ak4PFCHSL1FastjetCorrector'
            )

        process.pfMetT1NoHF = pfMetT1.clone(
            src = 'pfMetNoHF',
            srcCorrections = [cms.InputTag("corrPfMetType1", "type1")]
        )

        addMETCollection(process, labelName='patMETNoHF', metSource='pfMetT1NoHF') # T1 MET
        process.patMETNoHF.addGenMET = False

    ## Slimmed METs

    from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
    #### CaloMET is not available in MiniAOD
    if hasattr(slimmedMETs, 'caloMET'):
        del slimmedMETs.caloMET

    process.slimmedMETsNoHF = slimmedMETs.clone()
    if hasattr(process, "patMETNoHF"):
        # Create MET from Type 1 PF collection
        process.patMETNoHF.addGenMET = not isData
        if not isData:
            process.patMETNoHF.genMETSource = cms.InputTag("genMetExtractor")
        process.slimmedMETsNoHF.src = cms.InputTag("patMETNoHF")
        process.slimmedMETsNoHF.rawUncertainties = cms.InputTag("patPFMetNoHF") # only central value
    else:
        # Create MET from RAW PF collection
        process.patPFMetNoHF.addGenMET = not isData
        if not isData:
            process.patPFMetNoHF.genMETSource = cms.InputTag("genMetExtractor")
        process.slimmedMETsNoHF.src = cms.InputTag("patPFMetNoHF")
        del process.slimmedMETsNoHF.rawUncertainties # not available

    del process.slimmedMETsNoHF.type1Uncertainties # not available
    del process.slimmedMETsNoHF.type1p2Uncertainties # not available
Beispiel #7
0
def makeMET(process, isData, pfCandidates, jetSource, jetFlavor, postfix=''):
    """
    @jetFlavor: e.g. 'ak4PFchs'

    Additional information (such as gen and calo mets) are added only if postfix is empty.
    """

    sequence = cms.Sequence()
    # postfix is automatically added to the module names
    addattr = AddAttr(process, sequence, postfix)

    if postfix == '':
        # default MET - extract from input slimmedMETs
        pfMet = addattr(
            'pfMet',
            cms.EDProducer("RecoMETExtractor",
                           metSource=cms.InputTag(
                               "slimmedMETs",
                               processName=cms.InputTag.skipCurrentProcess()),
                           correctionLevel=cms.string('raw')))
    else:
        pfMet = addattr(
            'pfMet',
            PFMET_cfi.pfMet.clone(
                src=pfCandidates,
                calculateSignificance=False  # done in PAT
            ))

    cleanedJets = addattr(
        'cleanedJetsForMET',
        cms.EDProducer(
            "PATJetCleanerForType1MET",
            src=cms.InputTag(jetSource),
            jetCorrEtaMax=cms.double(9.9),
            jetCorrLabel=cms.InputTag("L3Absolute"),
            jetCorrLabelRes=cms.InputTag("L2L3Residual"),
            offsetCorrLabel=cms.InputTag("L1FastJet"),
            skipEM=cms.bool(True),
            skipEMfractionThreshold=cms.double(0.9),
            skipMuonSelection=cms.string('isGlobalMuon | isStandAloneMuon'),
            skipMuons=cms.bool(True),
            type1JetPtThreshold=cms.double(15.0)))

    selectedJets = addattr(
        'selectedJetsForMET',
        selectedPatJets.clone(src=cleanedJets,
                              cut='pt > 15 && abs(eta) < 9.9'))

    crossCleanedJets = addattr('crossCleanedJetsForMET',
                               cleanPatJets.clone(src=selectedJets))
    ccJetsMod = addattr.last
    ccJetsMod.checkOverlaps.muons.src = muons
    ccJetsMod.checkOverlaps.electrons.src = electrons
    del ccJetsMod.checkOverlaps.photons
    del ccJetsMod.checkOverlaps.taus
    # not used at all and electrons are already cleaned
    del ccJetsMod.checkOverlaps.tkIsoElectrons

    patPFMet = addattr(
        'patPFMet',
        patMET_cff.patPFMet.clone(
            metSource=pfMet,
            genMETSource='genMetTrue',
            srcPFCands=pfCandidates,
            computeMETSignificance=True,
            parameters=(METSignificanceParams_Data
                        if isData else METSignificanceParams),
            srcJets=crossCleanedJets,
            srcLeptons=[electrons, muons, photons],
            addGenMET=(not isData and postfix == '')))

    patPFMetT1Corr = addattr(
        'patPFMetT1Corr',
        patMET_cff.patPFMetT1T2Corr.clone(src=crossCleanedJets))

    patPFMetT1 = addattr(
        'patPFMetT1',
        patMET_cff.patPFMetT1.clone(src=patPFMet,
                                    srcCorrections=[
                                        cms.InputTag(
                                            patPFMetT1Corr.getModuleLabel(),
                                            'type1')
                                    ]))

    pfCandsNoEle = addattr(
        'pfCandsNoEle',
        cms.EDProducer("CandPtrProjector",
                       src=cms.InputTag(pfCandidates),
                       veto=electrons))

    pfCandsNoEleMu = addattr(
        'pfCandsNoEleMu',
        cms.EDProducer("CandPtrProjector", src=pfCandsNoEle, veto=muons))

    pfCandsNoEleMuTau = addattr(
        'pfCandsNoEleMuTau',
        cms.EDProducer("CandPtrProjector", src=pfCandsNoEleMu, veto=taus))

    pfCandsNoEleMuTauGamma = addattr(
        'pfCandsNoEleMuTauGamma',
        cms.EDProducer("CandPtrProjector", src=pfCandsNoEleMuTau,
                       veto=photons))

    pfCandsForUnclusteredUnc = addattr(
        'pfCandsForUnclusteredUnc',
        cms.EDProducer("CandPtrProjector",
                       src=pfCandsNoEleMuTauGamma,
                       veto=crossCleanedJets))

    for vsign, vname in [(1, 'Up'), (-1, 'Down')]:
        shiftConf = [('MuonEn', muons.value(),
                      '((x<100)?(0.002+0*y):(0.05+0*y))'),
                     ('ElectronEn', electrons.value(),
                      '((abs(y)<1.479)?(0.006+0*x):(0.015+0*x))'),
                     ('PhotonEn', photons.value(),
                      '((abs(y)<1.479)?(0.01+0*x):(0.025+0*x))'),
                     ('TauEn', taus.value(), '0.03+0*x*y'),
                     ('UnclusteredEn', pfCandsForUnclusteredUnc.value(), ''),
                     ('JetEn', crossCleanedJets.value(), '')]

        for part, coll, formula in shiftConf:
            if part == 'UnclusteredEn':
                shifted = addattr(
                    'shifted' + part + vname,
                    cms.EDProducer(
                        "ShiftedParticleProducer",
                        src=pfCandsForUnclusteredUnc,
                        binning=cms.VPSet(
                            # charged PF hadrons - tracker resolution
                            cms.PSet(
                                binSelection=cms.string('charge!=0'),
                                binUncertainty=cms.string(
                                    'sqrt(pow(0.00009*x,2)+pow(0.0085/sqrt(sin(2*atan(exp(-y)))),2))'
                                )),
                            # neutral PF hadrons - HCAL resolution
                            cms.PSet(
                                binSelection=cms.string('pdgId==130'),
                                energyDependency=cms.bool(True),
                                binUncertainty=cms.string(
                                    '((abs(y)<1.3)?(min(0.25,sqrt(0.64/x+0.0025))):(min(0.30,sqrt(1.0/x+0.0016))))'
                                )),
                            # photon - ECAL resolution
                            cms.PSet(binSelection=cms.string('pdgId==22'),
                                     energyDependency=cms.bool(True),
                                     binUncertainty=cms.string(
                                         'sqrt(0.0009/x+0.000001)+0*y')),
                            # HF particules - HF resolution
                            cms.PSet(binSelection=cms.string(
                                'pdgId==1 || pdgId==2'),
                                     energyDependency=cms.bool(True),
                                     binUncertainty=cms.string(
                                         'sqrt(1./x+0.0025)+0*y')),
                        ),
                        shiftBy=cms.double(float(vsign))))

            elif part == 'JetEn':
                shifted = addattr(
                    'shifted' + part + vname,
                    cms.EDProducer(
                        'SUEPShiftedPATJetProducer',
                        src=crossCleanedJets,
                        jetCorrPayloadName=cms.string(jetFlavor),
                        jetCorrUncertaintyTag=cms.string('Uncertainty'),
                        addResidualJES=cms.bool(isData),
                        jetCorrLabelUpToL3=cms.InputTag(
                            'L3Absolute'),  # use embedded correction factors
                        jetCorrLabelUpToL3Res=cms.InputTag('L2L3Residual'),
                        shiftBy=cms.double(float(vsign))))

            else:
                shifted = addattr(
                    'shifted' + part + vname,
                    cms.EDProducer("ShiftedParticleProducer",
                                   src=cms.InputTag(coll),
                                   uncertainty=cms.string(formula),
                                   shiftBy=cms.double(float(vsign))))

            metCorrShifted = addattr(
                'metCorrShifted' + part + vname,
                cms.EDProducer("ShiftedParticleMETcorrInputProducer",
                               srcOriginal=cms.InputTag(coll),
                               srcShifted=shifted))
            addattr(
                'patPFMetT1' + part + vname,
                patMET_cff.patPFMetT1.clone(src=patPFMetT1,
                                            srcCorrections=[metCorrShifted]))

    # Dummy JetResUp and JetResDown modules because PATJetSlimmer requires them
    # Jet smearing should be propagated to MET simply by using ptSmear(|Up|Down) branches at the ntuples level
    addattr('patPFMetT1JetResUp',
            getattr(process, 'patPFMetT1JetEnUp' + postfix).clone())
    addattr('patPFMetT1JetResDown',
            getattr(process, 'patPFMetT1JetEnDown' + postfix).clone())

    addattr(
        'slimmedMETs',
        slimmedMETs.clone(src=patPFMetT1,
                          rawVariation=patPFMet,
                          t1Uncertainties="patPFMetT1%s" + postfix,
                          runningOnMiniAOD=True))

    slimmed = addattr.last

    if postfix == '':  # default MET
        slimmed.caloMET = 'patCaloMet'
    else:
        del slimmed.caloMET

    del slimmed.t01Variation
    del slimmed.t1SmearedVarsAndUncs
    del slimmed.tXYUncForT1
    del slimmed.tXYUncForRaw
    del slimmed.tXYUncForT01
    del slimmed.tXYUncForT1Smear
    del slimmed.tXYUncForT01Smear

    return sequence
                           electronCollection="slimmedElectrons",
                           muonCollection="slimmedMuons",
                           tauCollection="slimmedTaus",
			   makeType1p2corrPFMEt=False)
			   
process.patMETs.addGenMET  = cms.bool(False)
process.patJets.addGenJetMatch = cms.bool(False) 
process.patJets.addGenPartonMatch = cms.bool(False) 
process.patJets.addPartonJetMatch = cms.bool(False) 
			       
from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
addMETCollection(process, labelName = 'patMET'    , metSource = 'pfMetT1'  ) # T1
addMETCollection(process, labelName = 'patPFMet'  , metSource = 'pfMet'    ) # RAW
		     
from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
process.mySlimmedMETs = slimmedMETs.clone()
process.mySlimmedMETs.src = cms.InputTag("patMET")
process.mySlimmedMETs.rawUncertainties   = cms.InputTag("patPFMet") # only central value
process.mySlimmedMETs.type1Uncertainties = cms.InputTag("patPFMetT1")    # only central value for now
del process.mySlimmedMETs.type1p2Uncertainties # not available
del process.mySlimmedMETs.caloMET
        
####### Adding HEEP id ##########

from PhysicsTools.SelectorUtils.tools.vid_id_tools import *

dataFormat=DataFormat.MiniAOD
switchOnVIDElectronIdProducer(process,dataFormat)

process.egmGsfElectronIDSequence = cms.Sequence(process.egmGsfElectronIDs)