コード例 #1
0
ファイル: boostTools.py プロジェクト: hbakhshi/NTupleProducer
def clonePFTau(process,postfix="Boost"):
   process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
   from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
   cloneProcessingSnippet(process, process.PFTau, postfix)

   from PhysicsTools.PatAlgos.tools.pfTools import adaptPFTaus

#   adaptPFTaus(process,'hpsPFTau',postfix)

   getattr(process,"recoTauAK5PFJets08Region"+postfix).src = cms.InputTag('boostedTauSeeds')
   getattr(process,"recoTauAK5PFJets08Region"+postfix).pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
   getattr(process,"recoTauAK5PFJets08Region"+postfix).pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')

   getattr(process,"ak5PFJetsLegacyHPSPiZeros"+postfix).jetSrc = cms.InputTag('boostedTauSeeds')

   getattr(process,"ak5PFJetsRecoTauChargedHadrons"+postfix).jetSrc = cms.InputTag('boostedTauSeeds')
   getattr(process,"ak5PFJetsRecoTauChargedHadrons"+postfix).builders[1].dRcone = cms.double(0.3)
   getattr(process,"ak5PFJetsRecoTauChargedHadrons"+postfix).builders[1].dRconeLimitedToJetArea = cms.bool(True)

   getattr(process,"combinatoricRecoTaus"+postfix).jetSrc = cms.InputTag('boostedTauSeeds')
   getattr(process,"combinatoricRecoTaus"+postfix).builders[0].pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
   getattr(process,"combinatoricRecoTaus"+postfix).modifiers.remove(getattr(process,"combinatoricRecoTaus"+postfix).modifiers[3])

   getattr(process,"hpsPFTauDiscriminationByLooseMuonRejection3"+postfix).dRmuonMatch = cms.double(0.3)
   getattr(process,"hpsPFTauDiscriminationByLooseMuonRejection3"+postfix).dRmuonMatchLimitedToJetArea = cms.bool(True)
   getattr(process,"hpsPFTauDiscriminationByTightMuonRejection3"+postfix).dRmuonMatch = cms.double(0.3)
   getattr(process,"hpsPFTauDiscriminationByTightMuonRejection3"+postfix).dRmuonMatchLimitedToJetArea = cms.bool(True)
コード例 #2
0
def makeRecoJetCollection(process, pfCandCollection, coneSize, useCHSAlgo,
                          postfix):

    jetColName = "ak" + str(int(coneSize * 10)) + "PFJets"
    internalPfCandColl = pfCandCollection
    if useCHSAlgo:
        setattr(
            process, "tmpPFCandCollPtr" + postfix,
            cms.EDProducer("PFCandidateFwdPtrProducer",
                           src=cms.InputTag(pfCandCollection)))
        process.load("CommonTools.ParticleFlow.pfNoPileUpJME_cff")
        cloneProcessingSnippet(process,
                               getattr(process, "pfNoPileUpJMESequence"),
                               postfix)
        getattr(process, "pfPileUpJME" +
                postfix).PFCandidates = cms.InputTag("tmpPFCandCollPtr" +
                                                     postfix)
        getattr(process, "pfNoPileUpJME" +
                postfix).bottomCollection = cms.InputTag("tmpPFCandCollPtr" +
                                                         postfix)

        internalPfCandColl = "pfNoPileUpJME" + postfix
        jetColName += "CHS"

    setattr(
        process, jetColName + postfix,
        getattr(process,
                "ak4PFJets").clone(src=cms.InputTag(internalPfCandColl),
                                   rParam=cms.double(coneSize),
                                   doAreaFastjet=True))
コード例 #3
0
def makeRecoJetCollection(process, 
                          pfCandCollection,
                          coneSize,
                          useCHSAlgo,
                          postfix):

    jetColName="ak"+str(int(coneSize*10))+"PFJets"
    internalPfCandColl=pfCandCollection
    if useCHSAlgo:
        setattr( process, "tmpPFCandCollPtr"+postfix, 
                 cms.EDProducer("PFCandidateFwdPtrProducer",
                                src = cms.InputTag(pfCandCollection) ) 
                 )
        process.load("CommonTools.ParticleFlow.pfNoPileUpJME_cff")
        cloneProcessingSnippet(process, getattr(process,"pfNoPileUpJMESequence"), postfix )
        getattr(process, "pfPileUpJME"+postfix).PFCandidates = cms.InputTag("tmpPFCandCollPtr"+postfix)
        getattr(process, "pfNoPileUpJME"+postfix).bottomCollection = cms.InputTag("tmpPFCandCollPtr"+postfix) 
        
        internalPfCandColl = "pfNoPileUpJME"+postfix
        jetColName+="CHS"
 
    setattr(process, jetColName+postfix, getattr(process,"ak4PFJets").clone(
            src = cms.InputTag(internalPfCandColl),
            rParam=cms.double(coneSize),
            doAreaFastjet = True)
            )
コード例 #4
0
ファイル: myJetSequence_cff.py プロジェクト: YoungKwonJo/CMG
def myBaseJetSequence( process, postfix ): 

    patJet = 'selectedPatJets' + postfix
    baseJet = 'cmgBaseJet' + postfix
    baseLeadJet = 'cmgBaseLeadJet' + postfix
    baseFatJet = 'cmgBaseFatJet' + postfix
    baseDiJet = 'cmgBaseDiJet' + postfix
    baseTightDiJet = 'cmgBaseTightDiJet' + postfix


    cloneProcessingSnippet(process, process.baseJetSequence, postfix)

    getattr(process, "cmgBaseJet" + postfix).cfg.inputCollection = cms.InputTag(patJet)
    getattr(process, "cmgBaseLeadJet" + postfix).inputCollection = cms.InputTag(baseJet)
    getattr(process, "cmgBaseDiJet" + postfix).cfg.leg1Collection = cms.InputTag(baseLeadJet)
    getattr(process, "cmgBaseDiJet" + postfix).cfg.leg2Collection = cms.InputTag(baseLeadJet)

    # Histogramming
    
    getattr(process, "cmgBaseLorentzVector" + postfix).inputCollection = cms.InputTag(baseJet)
    getattr(process, "cmgBaseLeadLorentzVector" + postfix).inputCollection = cms.InputTag(baseLeadJet)
    
    getattr(process, "cmgBaseTightDiJet" + postfix).src = cms.InputTag(baseDiJet)        
    getattr(process, "cmgBaseDiJetLorentzVector" + postfix).inputCollection = cms.InputTag(baseTightDiJet)
    getattr(process, "cmgBaseDiJetHistograms" + postfix).inputCollection = cms.InputTag(baseTightDiJet)
コード例 #5
0
ファイル: tauTools.py プロジェクト: hbakhshi/NTupleProducer
def AddBoostedPATTaus(process,isPFBRECO=False,postfix="Boost",PFBRECOpostfix="PFlow",runOnMC=True):
    if hasattr(process,"PFTau"+postfix):
        print "Boosted tau sequence in path -> will be used by PAT "
        pfTauLabelOld="hpsPFTauProducer"
        pfTauLabelNew="hpsPFTauProducer"+postfix
        patTauLabel=""
        if hasattr(process,"makePatTaus"):
            print "pat Taus producer in path. It will be cloned to produce also boosted taus."
            cloneProcessingSnippet(process, process.makePatTaus, postfix)
            print "Replacing default producer by "+pfTauLabelNew
        else:
            print "standard pat taus are not produced. The default configuration of patTaus will be used to produce boosted patTaus."
            process.load("PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff")
            cloneProcessingSnippet(process, process.makePatTaus, postfix)
            print "Replacing default producer by "+pfTauLabelNew

        if runOnMC:
            getattr(process, "tauMatch" + patTauLabel+ postfix).src = pfTauLabelNew
            getattr(process, "tauGenJetMatch" + patTauLabel+ postfix).src = pfTauLabelNew
        else:
            getattr(process,"makePatTaus"+postfix).remove(getattr(process,"tauMatch" + patTauLabel+ postfix))
            getattr(process,"makePatTaus"+postfix).remove(getattr(process,"tauGenJetMatch" + patTauLabel+ postfix))
            getattr(process,"makePatTaus"+postfix).remove(getattr(process,"tauGenJets" + patTauLabel+ postfix))
            getattr(process,"makePatTaus"+postfix).remove(getattr(process,"tauGenJetsSelectorAllHadrons" + patTauLabel+ postfix))
            getattr(process,"patTaus"+postfix).genJetMatch=""
            getattr(process,"patTaus"+postfix).genParticleMatch=""
            getattr(process,"patTaus"+postfix).addGenJetMatch=False
            getattr(process,"patTaus"+postfix).embedGenJetMatch=False
            getattr(process,"patTaus"+postfix).addGenMatch=False
            getattr(process,"patTaus"+postfix).embedGenMatch=False
        getattr(process, "tauIsoDepositPFCandidates" + patTauLabel+ postfix).src = pfTauLabelNew
        getattr(process, "tauIsoDepositPFCandidates" + patTauLabel+ postfix).ExtractorPSet.tauSource = pfTauLabelNew
        getattr(process, "tauIsoDepositPFChargedHadrons" + patTauLabel+ postfix).src = pfTauLabelNew
        getattr(process, "tauIsoDepositPFChargedHadrons" + patTauLabel+ postfix).ExtractorPSet.tauSource = pfTauLabelNew
        getattr(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel+ postfix).src = pfTauLabelNew
        getattr(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel+ postfix).ExtractorPSet.tauSource = pfTauLabelNew
        getattr(process, "tauIsoDepositPFGammas" + patTauLabel+ postfix).src = pfTauLabelNew
        getattr(process, "tauIsoDepositPFGammas" + patTauLabel+ postfix).ExtractorPSet.tauSource = pfTauLabelNew
        getattr(process, "tauIsoDepositPFCandidates" + patTauLabel+ postfix).src = pfTauLabelNew
        getattr(process, "patTaus" + patTauLabel + postfix).tauSource = pfTauLabelNew
        getattr(process, "patTaus" + patTauLabel + postfix).tauIDSources = _buildIDSourcePSet('hpsPFTau', hpsTauIDSources, postfix)
        getattr(process, "patTaus" + patTauLabel + postfix).tauTransverseImpactParameterSource = "hpsPFTauTransverseImpactParameters"+postfix
        if isPFBRECO:
            getattr(process,"makePatTaus"+postfix).remove(getattr(process,"patPFCandidateIsoDepositSelection"+postfix))
            getattr(process, "tauIsoDepositPFChargedHadrons" + patTauLabel+ postfix).ExtractorPSet.candidateSource = "pfAllChargedHadrons"+PFBRECOpostfix
            getattr(process, "tauIsoDepositPFNeutralHadrons" + patTauLabel+ postfix).ExtractorPSet.candidateSource = "pfAllNeutralHadrons"+PFBRECOpostfix
            getattr(process, "tauIsoDepositPFGammas" + patTauLabel+ postfix).ExtractorPSet.candidateSource = "pfAllPhotons"+PFBRECOpostfix
            getattr(process, "hpsSelectionDiscriminator" + patTauLabel + postfix).PFTauProducer = "combinatoricRecoTaus"+postfix
            getattr(process, "hpsPFTauProducerSansRefs" + patTauLabel + postfix).src = "combinatoricRecoTaus"+postfix
        ## adapt cleanPatTaus

        if hasattr(process, "cleanPatTaus" + patTauLabel + postfix):
            getattr(process, "cleanPatTaus" + patTauLabel + postfix).preselection = \
                             'pt > 15 & abs(eta) < 2.3 & tauID("decayModeFinding") > 0.5 & tauID("byHPSloose") > 0.5' \
                             + ' & tauID("againstMuonTight") > 0.5 & tauID("againstElectronLoose") > 0.5'


    else:
        
        print "Boosted tau sequence not in path. Please include it."
コード例 #6
0
def myBaseJetSequence(process, postfix):

    patJet = 'selectedPatJets' + postfix
    baseJet = 'cmgBaseJet' + postfix
    baseLeadJet = 'cmgBaseLeadJet' + postfix
    baseFatJet = 'cmgBaseFatJet' + postfix
    baseDiJet = 'cmgBaseDiJet' + postfix
    baseTightDiJet = 'cmgBaseTightDiJet' + postfix

    cloneProcessingSnippet(process, process.baseJetSequence, postfix)

    getattr(process,
            "cmgBaseJet" + postfix).cfg.inputCollection = cms.InputTag(patJet)
    getattr(process,
            "cmgBaseLeadJet" + postfix).inputCollection = cms.InputTag(baseJet)
    getattr(process, "cmgBaseDiJet" +
            postfix).cfg.leg1Collection = cms.InputTag(baseLeadJet)
    getattr(process, "cmgBaseDiJet" +
            postfix).cfg.leg2Collection = cms.InputTag(baseLeadJet)

    # Histogramming

    getattr(process, "cmgBaseLorentzVector" +
            postfix).inputCollection = cms.InputTag(baseJet)
    getattr(process, "cmgBaseLeadLorentzVector" +
            postfix).inputCollection = cms.InputTag(baseLeadJet)

    getattr(process,
            "cmgBaseTightDiJet" + postfix).src = cms.InputTag(baseDiJet)
    getattr(process, "cmgBaseDiJetLorentzVector" +
            postfix).inputCollection = cms.InputTag(baseTightDiJet)
    getattr(process, "cmgBaseDiJetHistograms" +
            postfix).inputCollection = cms.InputTag(baseTightDiJet)
コード例 #7
0
def setup_MET_manually(process, cms, options, postfix="PFlow"):
    print '=' * 60
    print "Setting up PFMET from PAT manually"
    print '=' * 60
    
    #PFMET setup: following by-hand recipe from https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookMetAnalysis#Type_I_II_0_with_PF2PAT
    process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")
    getattr(process,'patPF2PATSequence'+postfix).remove(getattr(process,'patMETs'+postfix))

    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    cloneProcessingSnippet(process, process.producePatPFMETCorrections, postfix)

    getattr(process,'selectedPatJetsForMETtype1p2Corr'+postfix).src = cms.InputTag('selectedPatJets'+postfix)
    getattr(process,'selectedPatJetsForMETtype2Corr'+postfix).src = cms.InputTag('selectedPatJets'+postfix)
    getattr(process,'pfCandMETcorr'+postfix).src = cms.InputTag('pfNoJet'+postfix)
    getattr(process,'patPFJetMETtype1p2Corr'+postfix).type1JetPtThreshold = cms.double(10.0)
            
    if options.applyType0METcorrection:
        getattr(process,'patType1CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
                            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
                            cms.InputTag("patPFMETtype0Corr"+postfix)
                            )
        getattr(process,'patType1p2CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
                            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
                            cms.InputTag("patPFMETtype0Corr"+postfix)
                            )
    else:
        getattr(process,'patType1CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
                            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
                            )
        getattr(process,'patType1p2CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
                            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
                            )
            
    getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipEM = cms.bool(False)
    getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipMuons = cms.bool(False)
    getattr(process,'patPFJetMETtype2Corr'+postfix).skipEM = cms.bool(False)
    getattr(process,'patPFJetMETtype2Corr'+postfix).skipMuons = cms.bool(False)

    ##for type I+II corrections, switch this to patType1p2CorrectedPFMet
    getattr(process,'patMETs'+postfix).metSource = cms.InputTag('patType1CorrectedPFMet'+postfix)

    getattr(process,'patDefaultSequence'+postfix).remove(getattr(process,'patMETs'+postfix))

    if options.useData:
        getattr(process,'patPFJetMETtype1p2Corr'+postfix).jetCorrLabel = 'L2L3Residual'
        getattr(process,'patPFJetMETtype2Corr'+postfix).jetCorrLabel = 'L2L3Residual'
    
    getattr(process,'patPFMet'+postfix).addGenMET = cms.bool(not options.useData)
    process.patPFMet.addGenMET = cms.bool(not options.useData)
    
    process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
    process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
    
    #these flags are false for '+postfix' mets by default, but true for non-postfix ones!
    getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipEM = cms.bool(False)
    getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipMuons = cms.bool(False)
    
    setup_MET_uncertainties(process, cms, options, postfix)
コード例 #8
0
ファイル: rerunParticleFlow.py プロジェクト: nsahoo/cmssw-1
def rerunParticleFlow(process, inputProcess):

    # load event-setup definitions necessary to rerun particle-flow sequence
    loadIfNecessary(
        process, "TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi", "SteppingHelixPropagatorAny"
    )
    loadIfNecessary(
        process,
        "CalibTracker.SiPixelESProducers.SiPixelTemplateDBObjectESProducer_cfi",
        "siPixelTemplateDBObjectESProducer",
    )
    loadIfNecessary(process, "RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi", "MeasurementTracker")
    loadIfNecessary(process, "RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi", "ecalSeverityLevel")
    loadIfNecessary(
        process, "RecoEcal.EgammaCoreTools.EcalNextToDeadChannelESProducer_cff", "ecalNextToDeadChannelESProducer"
    )
    loadIfNecessary(process, "RecoLocalCalo.HcalRecAlgos.hcalRecAlgoESProd_cfi", "hcalRecAlgos")

    if not hasattr(process, "UpdaterService"):
        process.UpdaterService = cms.Service("UpdaterService")

    # load module definitions necessary to rerun particle-flow sequence
    loadIfNecessary(process, "RecoParticleFlow.PFClusterProducer.particleFlowCluster_cff", "particleFlowCluster")
    loadIfNecessary(
        process, "RecoEgamma.EgammaElectronProducers.gsfElectronSequence_cff", "gsfEcalDrivenElectronSequence"
    )
    loadIfNecessary(process, "RecoParticleFlow.Configuration.RecoParticleFlow_cff", "particleFlowReco")
    loadIfNecessary(process, "RecoMuon.MuonIsolation.muonPFIsolationValues_cff", "muonPFIsolationSequence")

    # define complete sequence of all modules necessary to rerun particle-flow algorithm
    process.rerunParticleFlowSequence = cms.Sequence(
        process.particleFlowCluster
        + process.particleFlowTrackWithDisplacedVertex
        + process.gsfEcalDrivenElectronSequence
        + process.particleFlowReco
        + process.particleFlowLinks
    )

    # CV: clone sequence and give it a different name so that particle-flow algorithm
    #     can be run using "official" module labels on embedded event later
    configtools.cloneProcessingSnippet(process, process.rerunParticleFlowSequence, "ForPFMuonCleaning")

    # CV: run particle-flow algorithm on final RECO muon collection
    #    (rather than running muon reconstruction sequence in steps)
    process.pfTrackForPFMuonCleaning.MuColl = cms.InputTag("muons")
    process.particleFlowBlockForPFMuonCleaning.RecMuons = cms.InputTag("muons")
    process.particleFlowTmpForPFMuonCleaning.muons = cms.InputTag("muons")
    process.particleFlowForPFMuonCleaning.FillMuonRefs = False

    # CV: make sure that all particle-flow based isolation is computed wrt. 'particleFlowTmp' collection
    #    (PAT may overwrite configuration parameters to refer to 'particleFlow' instead)
    configtools.massSearchReplaceAnyInputTag(
        process.rerunParticleFlowSequenceForPFMuonCleaning,
        cms.InputTag("particleFlow"),
        cms.InputTag("particleFlowTmp"),
    )

    return process.rerunParticleFlowSequenceForPFMuonCleaning
コード例 #9
0
def backupJetsFirstStep(process):
    """Take snapshots of the sequences before we change the PFCandidates"""
    process.originalAK4JetSequence = listDependencyChain(process, process.slimmedJets, ('particleFlow', 'muons'))
    backupAK4JetSequence = cloneProcessingSnippet(process, process.originalAK4JetSequence, "Backup")
    process.originalAK4PuppiJetSequence = listDependencyChain(process, process.slimmedJetsPuppi, ('particleFlow', 'muons'))
    backupAK4PuppiJetSequence = cloneProcessingSnippet(process, process.originalAK4PuppiJetSequence, "Backup")
    process.originalAK8JetSequence = listDependencyChain(process, process.slimmedJetsAK8, ('particleFlow', 'muons'))
    backupAK8JetSequence = cloneProcessingSnippet(process, process.originalAK8JetSequence, "Backup")
    return { 'AK4':backupAK4JetSequence, 'AK4Puppi':backupAK4PuppiJetSequence, 'AK8':backupAK8JetSequence }
コード例 #10
0
ファイル: pfTools.py プロジェクト: 12345ieee/cmg-cmssw
def switchToPFMET(process,input=cms.InputTag('pfMET'), type1=False, postfix=""):
    print 'MET: using ', input
    if( not type1 ):
        oldMETSource = applyPostfix(process, "patMETs",postfix).metSource
        applyPostfix(process, "patMETs",postfix).metSource = input
        applyPostfix(process, "patMETs",postfix).addMuonCorrections = False
        getattr(process, "patDefaultSequence"+postfix).remove(applyPostfix(process, "patMETCorrections",postfix))
    else:
        # type1 corrected MET
        # name of corrected MET hardcoded in PAT and meaningless
        print 'Apply TypeI corrections for MET'
        getattr(process, "patDefaultSequence"+postfix).remove(applyPostfix(process, "makePatMETs",postfix))
        jecLabel = getattr(process,'patJetCorrFactors'+postfix).levels

        if not hasattr(process,'producePatPFMETCorrections'):
            process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")
        #here add to the current path and give proper postfix
        if not hasattr(process,'producePatPFMETCorrections'+postfix):
            cloneProcessingSnippet(process,process.producePatPFMETCorrections,postfix)
        
        getattr(process,'patPFMet'+postfix).metSource = cms.InputTag('pfMET'+postfix)

        getattr(process,'selectedPatJetsForMETtype1p2Corr'+postfix).src = cms.InputTag('selectedPatJets'+postfix)
        getattr(process,'selectedPatJetsForMETtype2Corr'+postfix).src   = cms.InputTag('selectedPatJets'+postfix)

        getattr(process,'pfCandMETcorr'+postfix).src = cms.InputTag('pfNoJet'+postfix)

        getattr(process,'patPFJetMETtype1p2Corr'+postfix).offsetCorrLabel = cms.string(jecLabel[0])
        getattr(process,'patPFJetMETtype1p2Corr'+postfix).jetCorrLabel = cms.string(jecLabel[-1])
        getattr(process,'patPFJetMETtype1p2Corr'+postfix).type1JetPtThreshold = cms.double(10.0)
        getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipEM    = cms.bool(False)
        getattr(process,'patPFJetMETtype1p2Corr'+postfix).skipMuons = cms.bool(False)

        getattr(process,'patPFJetMETtype2Corr'+postfix).offsetCorrLabel = cms.string(jecLabel[0])
        getattr(process,'patPFJetMETtype2Corr'+postfix).jetCorrLabel = cms.string(jecLabel[-1])
        getattr(process,'patPFJetMETtype2Corr'+postfix).type1JetPtThreshold = cms.double(10.0)
        getattr(process,'patPFJetMETtype2Corr'+postfix).skipEM    = cms.bool(False)
        getattr(process,'patPFJetMETtype2Corr'+postfix).skipMuons = cms.bool(False)
        
        getattr(process,'patType1CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
            #cms.InputTag("patPFMETtype0Corr"+postfix),
            )
        getattr(process,'patType1p2CorrectedPFMet'+postfix).srcType1Corrections = cms.VInputTag(
            cms.InputTag("patPFJetMETtype1p2Corr"+postfix,"type1"),
            #cms.InputTag("patPFMETtype0Corr"+postfix),
            )
        
        getattr(process,'patMETs'+postfix).metSource = 'patType1CorrectedPFMet'+postfix

        getattr(process,"patDefaultSequence"+postfix).replace( getattr(process,'selectedPatJets'+postfix),
                                                               getattr(process,'selectedPatJets'+postfix)
                                                               *getattr(process,'producePatPFMETCorrections'+postfix)
                                                               *getattr(process,'patMETs'+postfix)
                                                              )
コード例 #11
0
def setupPFIso(process,
               leptonCollection,
               particleName,
               newpostfix='PFIso',
               postfix='',
               runPF2PAT=False):
    '''Generic function to setup particle-based isolation for a given lepton collection.
    Returns the isolation sequence.
    You are responsible for adding it to your path.

    leptonCollection could e.g. be "gsfElectrons" or "muons"
    particleName must be either "Electron" or "Muon".
    newpostfix can be specified to define several particle-flow isolation sequences
    '''
    lepshort = None
    if particleName == 'Electron':
        lepshort = 'el'
    elif particleName == 'Muon':
        lepshort = 'mu'
    else:
        raise ValueError(
            'particleName should be equal to "Electron" or "Muon"')

    if runPF2PAT != True:
        _loadPFBRECO(process)

    # ADD VETOES IN ENDCAPS!
    fullpostfix = postfix + newpostfix
    ga = _getattrGenerator(process, postfix)
    ganew = _getattrGenerator(process, fullpostfix)

    leptonSeq = cms.Sequence(
        ga('pf{lepton}IsolationSequence'.format(lepton=particleName)))
    setattr(
        process, 'std{lepton}Sequence{postfix}'.format(lepton=particleName,
                                                       postfix=postfix),
        leptonSeq)

    leptonSource = leptonCollection
    cloneProcessingSnippet(
        process, ga('std{lepton}Sequence'.format(lepton=particleName)),
        newpostfix)

    ganew("{lepshort}PFIsoDepositCharged".format(
        lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositChargedAll".format(
        lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositNeutral".format(
        lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositGamma".format(
        lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositPU".format(
        lepshort=lepshort)).src = leptonSource

    return ganew('std{lepton}Sequence'.format(lepton=particleName))
コード例 #12
0
ファイル: myJetSequence_cff.py プロジェクト: YoungKwonJo/CMG
def myPFJetSequence( process, postfix, doFat): 

    patJet = 'selectedPatJets' + postfix
    pfJet = 'cmgPFJet' + postfix
    pfDiJet = 'cmgPFDiJet' + postfix
    pfLeadJet = 'cmgPFLeadJet' + postfix
    pfFatJet = 'cmgPFFatJet' + postfix
    pfFatDiJet = 'cmgPFFatDiJet' + postfix
    pfTightDiJet = 'cmgPFTightDiJet' + postfix
    pfFatTightDiJet = 'cmgPFFatTightDiJet' + postfix
   
    cloneProcessingSnippet(process, process.pfJetSequence, postfix)

    getattr(process, "cmgPFJet" + postfix).cfg.inputCollection = cms.InputTag(patJet)
    getattr(process, "cmgPFLeadJet" + postfix).inputCollection = cms.InputTag(pfJet)
    getattr(process, "cmgPFDiJet" + postfix).cfg.leg1Collection = cms.InputTag(pfLeadJet)
    getattr(process, "cmgPFDiJet" + postfix).cfg.leg2Collection = cms.InputTag(pfLeadJet)

    getattr(process, "cmgPFFatJet" + postfix).cfg.inputCollection = cms.InputTag(pfJet)

    getattr(process, "cmgPFFatDiJet" + postfix).cfg.leg1Collection = cms.InputTag(pfFatJet)
    getattr(process, "cmgPFFatDiJet" + postfix).cfg.leg2Collection = cms.InputTag(pfFatJet)


    # Histogramming

    getattr(process, "cmgPFLorentzVector" + postfix).inputCollection = cms.InputTag(pfJet)
    getattr(process, "cmgPFLeadLorentzVector" + postfix).inputCollection = cms.InputTag(pfLeadJet)
    getattr(process, "cmgPFHistograms" + postfix).inputCollection = cms.InputTag(pfJet)
    getattr(process, "cmgPFLeadHistograms" + postfix).inputCollection = cms.InputTag(pfLeadJet)

    getattr(process, "cmgPFTightDiJet" + postfix).src = cms.InputTag(pfDiJet)
    getattr(process, "cmgPFDiJetLorentzVector" + postfix).inputCollection = cms.InputTag(pfTightDiJet)
    getattr(process, "cmgPFDiJetHistograms" + postfix).inputCollection = cms.InputTag(pfTightDiJet)

    
    getattr(process, "cmgPFFatTightDiJet" + postfix).src = cms.InputTag(pfFatDiJet)
    getattr(process, "cmgPFFatDiJetLorentzVector" + postfix).inputCollection = cms.InputTag(pfFatTightDiJet)
    getattr(process, "cmgPFFatDiJetHistograms" + postfix).inputCollection = cms.InputTag(pfFatTightDiJet)
    getattr(process, "cmgPFDiJetHistograms_FatJets" + postfix).inputCollection = cms.InputTag(pfFatTightDiJet)

    if (not doFat):
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFFatJet" + postfix))
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFFatDiJet" + postfix))
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFFatTightDiJet" + postfix))
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFFatDiJetLorentzVector" + postfix))
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFFatDiJetHistograms" + postfix))
        getattr(process, "pfJetSequence" + postfix).remove(getattr(process, "cmgPFDiJetHistograms_FatJets" + postfix))
コード例 #13
0
ファイル: boostedHPSPFTaus_cfi.py プロジェクト: p2l1pfp/cmssw
def addBoostedTaus(process):
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag

    process.load("RecoTauTag.Configuration.boostedHPSPFTaus_cff")
    patAlgosToolsTask = configtools.getPatAlgosToolsTask(process)
    patAlgosToolsTask.add(process.boostedHPSPFTausTask)

    process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
    process.ptau = cms.Path( process.PFTau )
    process.PATTauSequence = cms.Sequence(process.PFTau+process.makePatTaus+process.selectedPatTaus)
    process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted", addToTask = True)
    process.recoTauAK4PFJets08RegionBoosted.src = cms.InputTag('boostedTauSeeds')
    process.recoTauAK4PFJets08RegionBoosted.pfCandSrc = cms.InputTag('particleFlow')
    process.recoTauAK4PFJets08RegionBoosted.pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')
    process.ak4PFJetsLegacyHPSPiZerosBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRcone = cms.double(0.3)
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRconeLimitedToJetArea = cms.bool(True)
    process.combinatoricRecoTausBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('particleFlow')
    ## Note JetArea is not defined for subjets (-> do not switch to True in hpsPFTauDiscriminationByLooseMuonRejection3Boosted, False is default)
    ## The restiction to jetArea is turned to dRMatch=0.1 (-> use explicitly this modified value)
    process.hpsPFTauDiscriminationByMuonRejection3Boosted.dRmuonMatch = 0.1
    massSearchReplaceAnyInputTag(process.PATTauSequenceBoosted,cms.InputTag("ak4PFJets"),cms.InputTag("boostedTauSeeds"))  
    process.slimmedTausBoosted = process.slimmedTaus.clone(src = cms.InputTag("selectedPatTausBoosted"))
    patAlgosToolsTask.add(process.slimmedTausBoosted)

    return process
コード例 #14
0
def addBoostedTaus(process):
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
    process.load("RecoTauTag.Configuration.boostedHPSPFTaus_cff")
    process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
    process.ptau = cms.Path( process.PFTau )
    process.PATTauSequence = cms.Sequence(process.PFTau+process.makePatTaus+process.selectedPatTaus)
    process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted")
    process.recoTauAK4PFJets08RegionBoosted.src = cms.InputTag('boostedTauSeeds')
    process.recoTauAK4PFJets08RegionBoosted.pfCandSrc = cms.InputTag('particleFlow')
    process.recoTauAK4PFJets08RegionBoosted.pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')
    process.ak4PFJetsLegacyHPSPiZerosBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRcone = cms.double(0.3)
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRconeLimitedToJetArea = cms.bool(True)
    process.combinatoricRecoTausBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.combinatoricRecoTausBoosted.modifiers.remove(process.combinatoricRecoTausBoosted.modifiers[3])
    #process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
    process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('particleFlow')
    process.hpsPFTauDiscriminationByLooseMuonRejection3Boosted.dRmuonMatchLimitedToJetArea = cms.bool(True)
    process.hpsPFTauDiscriminationByTightMuonRejection3Boosted.dRmuonMatchLimitedToJetArea = cms.bool(True)
    massSearchReplaceAnyInputTag(process.PATTauSequenceBoosted,cms.InputTag("ak4PFJets"),cms.InputTag("boostedTauSeeds"))  
    process.slimmedTausBoosted = process.slimmedTaus.clone(src = cms.InputTag("selectedPatTausBoosted"))
    
    return process
コード例 #15
0
def addBoostedTaus(process):
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag

    process.load("RecoTauTag.Configuration.boostedHPSPFTaus_cff")
    patAlgosToolsTask = configtools.getPatAlgosToolsTask(process)
    patAlgosToolsTask.add(process.boostedHPSPFTausTask)

    process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
    process.ptau = cms.Path( process.PFTau )
    process.PATTauSequence = cms.Sequence(process.PFTau+process.makePatTaus+process.selectedPatTaus)
    process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted", addToTask = True)
    process.recoTauAK4PFJets08RegionBoosted.src = cms.InputTag('boostedTauSeeds')
    process.recoTauAK4PFJets08RegionBoosted.pfCandSrc = cms.InputTag('particleFlow')
    process.recoTauAK4PFJets08RegionBoosted.pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')
    process.ak4PFJetsLegacyHPSPiZerosBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRcone = cms.double(0.3)
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRconeLimitedToJetArea = cms.bool(True)
    process.combinatoricRecoTausBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.combinatoricRecoTausBoosted.modifiers.remove(process.combinatoricRecoTausBoosted.modifiers[3])
    #process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
    process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('particleFlow')
    #Note JetArea is not defined for subjets and restiction to jetArea is turned to dRMatch=0.1, so better use the latter explicitely
    #process.hpsPFTauDiscriminationByLooseMuonRejection3Boosted.dRmuonMatchLimitedToJetArea = cms.bool(True)
    #process.hpsPFTauDiscriminationByTightMuonRejection3Boosted.dRmuonMatchLimitedToJetArea = cms.bool(True)
    process.hpsPFTauDiscriminationByLooseMuonRejection3Boosted.dRmuonMatch = 0.1
    process.hpsPFTauDiscriminationByTightMuonRejection3Boosted.dRmuonMatch = 0.1
    massSearchReplaceAnyInputTag(process.PATTauSequenceBoosted,cms.InputTag("ak4PFJets"),cms.InputTag("boostedTauSeeds"))  
    process.slimmedTausBoosted = process.slimmedTaus.clone(src = cms.InputTag("selectedPatTausBoosted"))
    patAlgosToolsTask.add(process.slimmedTausBoosted)

    return process
コード例 #16
0
def cloneTagSequenceForEachSystematic(process,systlabels=[],phosystlabels=[],metsystlabels=[],jetsystlabels=[],jetSystematicsInputTags=None,ZPlusJetMode=False):
    #process,systlabels,phosystlabels,metsystlabels,jetsystlabels,jetSystematicsInputTags,ZPlusJetMode=False):
    if jetSystematicsInputTags is None:
        raise TypeError
    for systlabel in systlabels:
        if systlabel == "":
            continue
        from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet,massSearchReplaceAnyInputTag
        newseq = cloneProcessingSnippet(process,process.flashggTagSequence,systlabel)
        if systlabel in metsystlabels:
            massSearchReplaceAnyInputTag(newseq,cms.InputTag("flashggMetSystematics"),cms.InputTag("flashggMetSystematics",systlabel))
        if systlabel in phosystlabels:
            massSearchReplaceAnyInputTag(newseq,cms.InputTag("flashggDiPhotonSystematics"),cms.InputTag("flashggDiPhotonSystematics",systlabel))
        if systlabel in jetsystlabels:
            for i in range(len(jetSystematicsInputTags)):
                massSearchReplaceAnyInputTag(newseq,jetSystematicsInputTags[i],cms.InputTag(jetSystematicsInputTags[i].moduleLabel,systlabel))
        for name in newseq.moduleNames():
            module = getattr(process,name)
            if hasattr(module,"SystLabel"):
                module.SystLabel = systlabel
        process.systematicsTagSequences += newseq
        if ZPlusJetMode == 2:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggVBFTag" + systlabel))
        elif ZPlusJetMode:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggZPlusJetTag" + systlabel))
        else:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggTagSorter" + systlabel))
コード例 #17
0
def cloneTagSequenceForEachSystematic(process,systlabels=[],phosystlabels=[],metsystlabels=[],jetsystlabels=[],jetSystematicsInputTags=None,ZPlusJetMode=False):
    #process,systlabels,phosystlabels,metsystlabels,jetsystlabels,jetSystematicsInputTags,ZPlusJetMode=False):
    if jetSystematicsInputTags is None:
        raise TypeError
    for systlabel in systlabels:
        if systlabel == "":
            continue
        from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet,massSearchReplaceAnyInputTag
        newseq = cloneProcessingSnippet(process,process.flashggTagSequence,systlabel)
        if systlabel in metsystlabels:
            massSearchReplaceAnyInputTag(newseq,cms.InputTag("flashggMetSystematics"),cms.InputTag("flashggMetSystematics",systlabel))
        if systlabel in phosystlabels:
            massSearchReplaceAnyInputTag(newseq,cms.InputTag("flashggDiPhotonSystematics"),cms.InputTag("flashggDiPhotonSystematics",systlabel))
        if systlabel in jetsystlabels:
            for i in range(len(jetSystematicsInputTags)):
                massSearchReplaceAnyInputTag(newseq,jetSystematicsInputTags[i],cms.InputTag(jetSystematicsInputTags[i].moduleLabel,systlabel))
        for name in newseq.moduleNames():
            module = getattr(process,name)
            if hasattr(module,"SystLabel"):
                module.SystLabel = systlabel
        process.systematicsTagSequences += newseq
        if ZPlusJetMode == 2:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggVBFTag" + systlabel))
        elif ZPlusJetMode:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggZPlusJetTag" + systlabel))
        else:
            process.flashggSystTagMerger.src.append(cms.InputTag("flashggTagSorter" + systlabel))
コード例 #18
0
def setupPFIso(process, leptonCollection, particleName, newpostfix='PFIso'):

    '''Generic function to setup particle-based isolation for a given lepton collection.
    Returns the isolation sequence.
    You are responsible for adding it to your path.

    leptonCollection could e.g. be "gsfElectrons" or "muons"
    particleName must be either "Electron" or "Muon".
    newpostfix can be specified to define several particle-flow isolation sequences
    '''

    lepshort = None
    if particleName=='Electron':
        lepshort='el'
    elif particleName=='Muon':
        lepshort='mu'
    else:
        raise ValueError('particleName should be equal to "Electron" or "Muon"')
    
    postfix = ''
    # ADD VETOES IN ENDCAPS!
    fullpostfix = postfix+newpostfix
    
    ga = _getattrGenerator( process, postfix )
    ganew = _getattrGenerator( process, fullpostfix )

    leptonSeq = cms.Sequence(
        ga('pf{lepton}IsolationSequence'.format(lepton=particleName))  
        )



    
    setattr( process, 'std{lepton}Sequence{postfix}'.format(lepton=particleName,
                                                            postfix=postfix), leptonSeq)
    leptonSource = leptonCollection
    cloneProcessingSnippet(process,
                           ga('std{lepton}Sequence'.format(lepton=particleName)),
                           newpostfix)

    ganew("{lepshort}PFIsoDepositCharged".format(lepshort=lepshort) ).src = leptonSource
    ganew("{lepshort}PFIsoDepositChargedAll".format(lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositNeutral".format(lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositGamma".format(lepshort=lepshort)).src = leptonSource
    ganew("{lepshort}PFIsoDepositPU".format(lepshort=lepshort)).src = leptonSource

    return ganew('std{lepton}Sequence'.format(lepton=particleName))
コード例 #19
0
def backupJetsFirstStep(process):

    task = getPatAlgosToolsTask(process)

    """Take snapshots of the sequences before we change the PFCandidates"""
    process.originalAK4JetTask, process.originalAK4JetSequence = listDependencyChain(process, getattr(process,"slimmedJets"), ('particleFlow', 'muons'))
    backupAK4JetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK4JetSequence"), "Backup", addToTask = True )
    process.originalAK4PuppiJetTask, process.originalAK4PuppiJetSequence = listDependencyChain(process,getattr(process,"slimmedJetsPuppi"), ('particleFlow', 'muons'))
    backupAK4PuppiJetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK4PuppiJetSequence"), "Backup", addToTask = True )
    process.originalAK8JetTask,process.originalAK8JetSequence = listDependencyChain(process, getattr(process,"slimmedJetsAK8"), ('particleFlow', 'muons'))
    backupAK8JetSequence = cloneProcessingSnippet(process, getattr(process,"originalAK8JetSequence"), "Backup", addToTask = True )

    task.add(process.originalAK4JetTask)
    task.add(process.originalAK4PuppiJetTask)
    task.add(process.originalAK8JetTask)

    return { 'AK4':backupAK4JetSequence, 'AK4Puppi':backupAK4PuppiJetSequence, 'AK8':backupAK8JetSequence }
コード例 #20
0
def addLowPtTaus(process):
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag

    process.load("RecoTauTag.Configuration.LowPtHPSPFTaus_cff")
    patAlgosToolsTask = configtools.getPatAlgosToolsTask(process)
    patAlgosToolsTask.add(process.LowPtHPSPFTausTask)

    process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
    process.ptau = cms.Path(process.PFTau)
    process.PATTauSequence = cms.Sequence(process.PFTau + process.makePatTaus +
                                          process.selectedPatTaus)
    process.PATTauSequenceLowPt = cloneProcessingSnippet(
        process, process.PATTauSequence, "LowPt", addToTask=True)
    process.recoTauAK4PFJets08RegionLowPt.src = cms.InputTag('LowPtTauSeeds')
    process.recoTauAK4PFJets08RegionLowPt.pfCandSrc = cms.InputTag(
        'particleFlow')
    process.recoTauAK4PFJets08RegionLowPt.pfCandAssocMapSrc = cms.InputTag(
        'LowPtTauSeeds', 'pfCandAssocMapForIsolation')
    process.selectedPatTausLowPt.cut = cms.string(
        "pt > 1. && tauID(\'decayModeFindingNewDMs\')> 0.5"
    )  #tau pt> 1 GeV of threshold output
    process.ak4PFJetsLegacyHPSPiZerosLowPt.jetSrc = cms.InputTag(
        'LowPtTauSeeds')
    process.ak4PFJetsLegacyHPSPiZerosLowPt.minJetPt = cms.double(
        1)  #jet pt> 1 GeV of threshold in input
    process.ak4PFJetsRecoTauChargedHadronsLowPt.jetSrc = cms.InputTag(
        'LowPtTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsLowPt.builders[
        1].dRcone = cms.double(0.3)
    process.ak4PFJetsRecoTauChargedHadronsLowPt.builders[
        1].dRconeLimitedToJetArea = cms.bool(True)
    process.combinatoricRecoTausLowPt.jetSrc = cms.InputTag('LowPtTauSeeds')
    _allModifiers = cms.VPSet()
    for modifier in process.combinatoricRecoTausLowPt.modifiers:
        _allModifiers.append(modifier)
    process.combinatoricRecoTausLowPt.modifiers.remove(
        process.combinatoricRecoTausLowPt.modifiers[3])
    from Configuration.Eras.Modifier_run2_miniAOD_80XLegacy_cff import run2_miniAOD_80XLegacy
    from Configuration.Eras.Modifier_run2_miniAOD_94XFall17_cff import run2_miniAOD_94XFall17
    for era in [run2_miniAOD_80XLegacy, run2_miniAOD_94XFall17]:
        era.toModify(process.combinatoricRecoTausLowPt,
                     modifiers=_allModifiers)
    process.combinatoricRecoTausLowPt.builders[0].pfCandSrc = cms.InputTag(
        'particleFlow')
    ## Note JetArea is not defined for subjets (-> do not switch to True in hpsPFTauDiscriminationByLooseMuonRejection3LowPt, False is default)
    ## The restiction to jetArea is turned to dRMatch=0.1 (-> use explicitly this modified value)
    #process.hpsPFTauDiscriminationByLooseMuonRejection3LowPt.dRmuonMatch = 0.1
    #process.hpsPFTauDiscriminationByTightMuonRejection3LowPt.dRmuonMatch = 0.1
    massSearchReplaceAnyInputTag(process.PATTauSequenceLowPt,
                                 cms.InputTag("ak4PFJets"),
                                 cms.InputTag("LowPtTauSeeds"))
    process.slimmedTausLowPt = process.slimmedTaus.clone(
        src=cms.InputTag("selectedPatTausLowPt"))
    patAlgosToolsTask.add(process.slimmedTausLowPt)

    return process
コード例 #21
0
def rerunParticleFlow(process, inputProcess):

    # load event-setup definitions necessary to rerun particle-flow sequence
    loadIfNecessary(process, "TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi", "SteppingHelixPropagatorAny")
    loadIfNecessary(process, "CalibTracker.SiPixelESProducers.SiPixelTemplateDBObjectESProducer_cfi", "siPixelTemplateDBObjectESProducer")
    loadIfNecessary(process, "RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi", "MeasurementTracker")
    loadIfNecessary(process, "RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi", "ecalSeverityLevel")
    loadIfNecessary(process, "RecoEcal.EgammaCoreTools.EcalNextToDeadChannelESProducer_cff", "ecalNextToDeadChannelESProducer")
    loadIfNecessary(process, "RecoLocalCalo.HcalRecAlgos.hcalRecAlgoESProd_cfi", "hcalRecAlgos")

    if not hasattr(process, "UpdaterService"):
        process.UpdaterService = cms.Service("UpdaterService")

    # load module definitions necessary to rerun particle-flow sequence
    loadIfNecessary(process, "RecoParticleFlow.PFClusterProducer.particleFlowCluster_cff", "particleFlowCluster")    
    loadIfNecessary(process, "RecoEgamma.EgammaElectronProducers.gsfElectronSequence_cff", "gsfEcalDrivenElectronSequence")
    loadIfNecessary(process, "RecoParticleFlow.Configuration.RecoParticleFlow_cff", "particleFlowReco")
    loadIfNecessary(process, "RecoMuon.MuonIsolation.muonPFIsolationValues_cff", "muonPFIsolationSequence")

    # define complete sequence of all modules necessary to rerun particle-flow algorithm
    process.rerunParticleFlowSequence = cms.Sequence(
        process.particleFlowCluster 
       + process.particleFlowTrackWithDisplacedVertex
       + process.gsfEcalDrivenElectronSequence
       + process.particleFlowReco
       + process.particleFlowLinks
    )

    # CV: clone sequence and give it a different name so that particle-flow algorithm
    #     can be run using "official" module labels on embedded event later
    configtools.cloneProcessingSnippet(process, process.rerunParticleFlowSequence, "ForPFMuonCleaning")

    # CV: run particle-flow algorithm on final RECO muon collection
    #    (rather than running muon reconstruction sequence in steps)    
    process.pfTrackForPFMuonCleaning.MuColl = cms.InputTag('muons')
    process.particleFlowBlockForPFMuonCleaning.RecMuons = cms.InputTag('muons')
    process.particleFlowTmpForPFMuonCleaning.muons = cms.InputTag('muons')
    process.particleFlowForPFMuonCleaning.FillMuonRefs = False

    # CV: make sure that all particle-flow based isolation is computed wrt. 'particleFlowTmp' collection
    #    (PAT may overwrite configuration parameters to refer to 'particleFlow' instead)
    configtools.massSearchReplaceAnyInputTag(process.rerunParticleFlowSequenceForPFMuonCleaning, cms.InputTag('particleFlow'), cms.InputTag('particleFlowTmp'))

    return process.rerunParticleFlowSequenceForPFMuonCleaning
コード例 #22
0
def backupJetsFirstStep(process):
    """Take snapshots of the sequences before we change the PFCandidates"""
    process.originalAK4JetSequence = listDependencyChain(
        process, process.slimmedJets, ('particleFlow', 'muons'))
    backupAK4JetSequence = cloneProcessingSnippet(
        process, process.originalAK4JetSequence, "Backup")
    process.originalAK4PuppiJetSequence = listDependencyChain(
        process, process.slimmedJetsPuppi, ('particleFlow', 'muons'))
    backupAK4PuppiJetSequence = cloneProcessingSnippet(
        process, process.originalAK4PuppiJetSequence, "Backup")
    process.originalAK8JetSequence = listDependencyChain(
        process, process.slimmedJetsAK8, ('particleFlow', 'muons'))
    backupAK8JetSequence = cloneProcessingSnippet(
        process, process.originalAK8JetSequence, "Backup")
    return {
        'AK4': backupAK4JetSequence,
        'AK4Puppi': backupAK4PuppiJetSequence,
        'AK8': backupAK8JetSequence
    }
コード例 #23
0
def cloneTtFullHadEvent(process):

    ## search highest already existing clone of ttFullHadEvent
    ## to get the needed index for the new ttFullHadEvent
    i = 2
    while ("ttFullHadEvent" + str(i) in process.producerNames()):
        i = i + 1
    ## clone the ttFullHadEvent including all hypotheses
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    process.makeTtFullHadEvent += cloneProcessingSnippet(
        process, process.makeTtFullHadEventBase, str(i))
コード例 #24
0
def cloneTtFullHadEvent(process
                        ):

    ## search highest already existing clone of ttFullHadEvent
    ## to get the needed index for the new ttFullHadEvent
    i=2
    while ("ttFullHadEvent"+str(i) in process.producerNames()):
        i = i+1
    ## clone the ttFullHadEvent including all hypotheses
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    process.makeTtFullHadEvent += cloneProcessingSnippet(process, process.makeTtFullHadEventBase, str(i))
コード例 #25
0
def addBoostedTaus(process):
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
    process.load("RecoTauTag.Configuration.boostedHPSPFTaus_cff")
    process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
    process.ptau = cms.Path( process.PFTau )
    process.PATTauSequence = cms.Sequence(process.PFTau+process.makePatTaus+process.selectedPatTaus)
    process.PATTauSequenceBoosted = cloneProcessingSnippet(process,process.PATTauSequence, "Boosted")
    process.recoTauAK4PFJets08RegionBoosted.src = cms.InputTag('boostedTauSeeds')
    process.recoTauAK4PFJets08RegionBoosted.pfCandSrc = cms.InputTag('particleFlow')
    process.recoTauAK4PFJets08RegionBoosted.pfCandAssocMapSrc = cms.InputTag('boostedTauSeeds', 'pfCandAssocMapForIsolation')
    process.ak4PFJetsLegacyHPSPiZerosBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRcone = cms.double(0.3)
    process.ak4PFJetsRecoTauChargedHadronsBoosted.builders[1].dRconeLimitedToJetArea = cms.bool(True)
    process.combinatoricRecoTausBoosted.jetSrc = cms.InputTag('boostedTauSeeds')
    process.combinatoricRecoTausBoosted.modifiers.remove(process.combinatoricRecoTausBoosted.modifiers[3])
    #process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('pfNoPileUpForBoostedTaus')
    process.combinatoricRecoTausBoosted.builders[0].pfCandSrc = cms.InputTag('particleFlow')
    massSearchReplaceAnyInputTag(process.PATTauSequenceBoosted,cms.InputTag("ak4PFJets"),cms.InputTag("boostedTauSeeds"))  
    process.slimmedTausBoosted = process.slimmedTaus.clone(src = cms.InputTag("selectedPatTausBoosted"))
    
    return process
コード例 #26
0
    filter=cms.bool(False))
process.recoTauHPSTancSequence += process.hpsTancTausPassingDecayMode

# Add selectors for the different decay modes
for decayMode in [0, 1, 2, 10]:
    selectorName = "selectedHpsTancTrainTausDecayMode%i" % decayMode
    setattr(
        process, selectorName,
        cms.EDFilter("PFTauViewRefSelector",
                     src=cms.InputTag("hpsTancTausPassingDecayMode"),
                     cut=cms.string("decayMode = %i" % decayMode),
                     filter=cms.bool(False)))
    process.recoTauHPSTancSequence += getattr(process, selectorName)

# Make copies of the signal and background tau production sequences
configtools.cloneProcessingSnippet(process, process.recoTauHPSTancSequence,
                                   "Signal")
configtools.massSearchReplaceAnyInputTag(process.recoTauHPSTancSequenceSignal,
                                         cms.InputTag("ak5PFJets"),
                                         cms.InputTag("preselectedSignalJets"))
configtools.cloneProcessingSnippet(process, process.recoTauHPSTancSequence,
                                   "Background")
configtools.massSearchReplaceAnyInputTag(
    process.recoTauHPSTancSequenceBackground, cms.InputTag("ak5PFJets"),
    cms.InputTag("preselectedBackgroundJets"))
process.buildTaus += process.recoTauHPSTancSequenceSignal
process.buildTaus += process.recoTauHPSTancSequenceBackground

################################################################################
#  Define signal path
################################################################################
コード例 #27
0
def redoPFTauDiscriminators(process,
                            oldPFTauLabel=cms.InputTag('hpsPFTauProducer'),
                            newPFTauLabel=cms.InputTag('hpsPFTauProducer'),
                            tauType='hpsPFTau',
                            postfix=""):
    print 'Tau discriminators: ', oldPFTauLabel, '->', newPFTauLabel
    print 'Tau type: ', tauType
    #oldPFTauLabel.setModuleLabel(oldPFTauLabel.getModuleLabel()+postfix)
    tauSrc = 'PFTauProducer'

    tauDiscriminationSequence = None

    if tauType == 'hpsPFTau':
        process.patHPSPFTauDiscrimination = process.produceAndDiscriminateHPSPFTaus.copy(
        )
        # remove producers
        for iname in process.patHPSPFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy") > -1
                    or iname.find("DiscriminationAgainst") > -1):
                process.patHPSPFTauDiscrimination.remove(
                    getattr(process, iname))
        tauDiscriminationSequence = cloneProcessingSnippet(
            process, process.patHPSPFTauDiscrimination, postfix)

    elif tauType == 'hpsTancTaus':  #to be checked if correct
        process.patHPSTaNCPFTauDiscrimination = process.hpsTancTauInitialSequence.copy(
        )
        process.patHPSTaNCPFTauDiscrimination *= process.hpsTancTauDiscriminantSequence
        # remove producers
        for iname in process.patHPSTaNCPFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy") > -1
                    or iname.find("DiscriminationAgainst") > -1):
                process.patHPSTaNCPFTauDiscrimination.remove(
                    getattr(process, iname))
        tauDiscriminationSequence = cloneProcessingSnippet(
            process, process.patHPSTaNCPFTauDiscrimination, postfix)

    elif tauType == 'fixedConePFTau':
        process.patFixedConePFTauDiscrimination = process.produceAndDiscriminateFixedConePFTaus.copy(
        )
        # remove producers
        for iname in process.patFixedConePFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy") > -1
                    or iname.find("DiscriminationAgainst") > -1):
                process.patFixedConePFTauDiscrimination.remove(
                    getattr(process, iname))
        tauDiscriminationSequence = cloneProcessingSnippet(
            process, process.patFixedConePFTauDiscrimination, postfix)

    elif tauType == 'shrinkingConePFTau':  #shr cone with TaNC
        process.patShrinkingConePFTauDiscrimination = process.produceAndDiscriminateShrinkingConePFTaus.copy(
        )
        process.patShrinkingConePFTauDiscrimination *= process.produceShrinkingConeDiscriminationByTauNeuralClassifier
        # remove producers
        for iname in process.patShrinkingConePFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy") > -1
                    or iname.find("DiscriminationAgainst") > -1):
                process.patShrinkingConePFTauDiscrimination.remove(
                    getattr(process, iname))
        tauDiscriminationSequence = cloneProcessingSnippet(
            process, process.patShrinkingConePFTauDiscrimination, postfix)

    elif tauType == 'caloTau':
        # fill calo sequence by discriminants
        process.patCaloTauDiscrimination = process.tautagging.copy()
        # remove producers
        for iname in process.patCaloTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy") > -1
                    or iname.find("DiscriminationAgainst") > -1):
                process.patCaloTauDiscrimination.remove(getattr(
                    process, iname))
        tauDiscriminationSequence = cloneProcessingSnippet(
            process, process.patCaloTauDiscrimination, postfix)
        tauSrc = 'CaloTauProducer'
    else:
        raise StandardError, "Unkown tauType: '%s'" % tauType

    applyPostfix(process, "patDefaultSequence", postfix).replace(
        applyPostfix(process, "patTaus", postfix),
        tauDiscriminationSequence * applyPostfix(process, "patTaus", postfix))

    massSearchReplaceParam(tauDiscriminationSequence, tauSrc, oldPFTauLabel,
                           newPFTauLabel)
# getattr(process,"pfNoElectron"+postfix).enable = False
# getattr(process,"pfNoTau"+postfix).enable = False
# getattr(process,"pfNoJet"+postfix).enable = True
# getattr(process,"pfIsolatedMuons"+postfix).isolationCut = 999999
# getattr(process,"pfIsolatedElectrons"+postfix).isolationCut = 999999

################################################################
#### Clone the PF2PAT sequence for data-driven QCD estimate ####
################################################################

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet

postfixNoLeptonCleaning = "NoLeptonCleaning"

# just cloning the first sequence, and enabling lepton cleaning
cloneProcessingSnippet(process, getattr(process, "patPF2PATSequencePF2PAT"), postfixNoLeptonCleaning)

getattr(process, "pfNoMuonPF2PATNoLeptonCleaning").enable = False
getattr(process, "pfNoElectronPF2PATNoLeptonCleaning").enable = False
getattr(process, "pfIsolatedMuonsPF2PATNoLeptonCleaning").combinedIsolationCut = cms.double(999999)
getattr(process, "pfIsolatedMuonsPF2PATNoLeptonCleaning").isolationCut = cms.double(999999)
getattr(process, "pfIsolatedElectronsPF2PATNoLeptonCleaning").combinedIsolationCut = cms.double(999999)
getattr(process, "pfIsolatedElectronsPF2PATNoLeptonCleaning").isolationCut = cms.double(999999)

###############################
### TagInfo and Matching Setup#
###############################

# process.patJetsPF2PAT.embedGenJetMatch = True
# process.patJetsPF2PAT.getJetMCFlavour = True
# process.patJetsPF2PAT.addGenPartonMatch = True
コード例 #29
0
    )


# ---------------- Sequence AK5NoPUSub, pfNoPileUp switched off ---------------

# PFBRECO+PAT sequence 2:
# pfNoPileUp switched off, AK5PFJets. This sequence is a clone of the AK5 sequence defined previously.

if runAK5NoPUSub:
    print 'Preparing AK5NoPUSub sequence...',

    postfixNoPUSub = 'NoPUSub'
    postfixAK5NoPUSub = postfixAK5+postfixNoPUSub

    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    cloneProcessingSnippet(process, getattr(process, 'patPF2PATSequence'+postfixAK5), postfixNoPUSub)

    getattr(process,"pfNoPileUp"+postfixAK5NoPUSub).enable = False
    getattr(process,"patJetCorrFactors"+postfixAK5NoPUSub).payload = "AK5PF"

    print 'Done'

    process.customPFJetsNoPUSub = cms.EDProducer(
        'PFJetUserData',
        JetInputCollection=cms.untracked.InputTag("selectedPatJetsAK5NoPUSub"),
        Verbosity=cms.untracked.bool(False)
        )

# Jet cleaning for patJets NoPUSub
    process.cleanPatJetsNoPUIsoLept = cms.EDProducer(
        "PATJetCleaner",
コード例 #30
0
            if pset.Label.value().count("Scale"):
                pset.NoCentralShift = cms.bool(False) # Turn on central shift for data (it is off for MC)
                pset.NSigmas = cms.vint32() # Do not perform shift
            newvpset += [pset]
        process.flashggDiPhotonSystematics.SystMethods = newvpset
    else:
        for direction in ["Up","Down"]:
            jetsystlabels.append("JEC%s01sigma" % direction)
            jetsystlabels.append("JER%s01sigma" % direction)
        systlabels += jetsystlabels
        for pset in process.flashggDiPhotonSystematics.SystMethods:
            pset.NSigmas = cms.vint32() # Central value only
    for systlabel in systlabels:
        if systlabel == "":
            continue
        newseq = cloneProcessingSnippet(process,process.flashggTagSequence,systlabel)
        if systlabel in jetsystlabels:    
            for i in range(len(jetSystematicsInputTags)):
                massSearchReplaceAnyInputTag(newseq,jetSystematicsInputTags[i],cms.InputTag(jetSystematicsInputTags[i].moduleLabel,systlabel))
        for name in newseq.moduleNames():
            module = getattr(process,name)
            if hasattr(module,"SystLabel"):
                module.SystLabel = systlabel
        process.systematicsTagSequences += newseq
        process.flashggVBFTagMerger.src.append(cms.InputTag("flashggVBFTag" + systlabel))
        
        
# set the VBF dumper
process.vbfTagDumper = createTagDumper("VBFTag")
process.vbfTagDumper.dumpTrees     = True
process.vbfTagDumper.dumpHistos    = True
コード例 #31
0
import FWCore.ParameterSet.Config as cms
import Validation.RecoTau.ValidationUtils as Utils
from Validation.RecoTau.RecoTauValidation_cfi import ApplyFunctionToSequence, SetValidationExtention
import PhysicsTools.PatAlgos.tools.helpers as helpers

proc = cms.Process('helper')

proc.load('Validation.RecoTau.dataTypes.ValidateTausOnZTT_cff')  # import *

procAttributes = dir(proc)  #Takes a snapshot of what there in the process
helpers.cloneProcessingSnippet(
    proc, proc.TauValNumeratorAndDenominatorZTT,
    'FastSim')  #clones the sequence inside the process with ZTT postfix
helpers.cloneProcessingSnippet(
    proc, proc.TauEfficienciesZTT,
    'FastSim')  #clones the sequence inside the process with ZTT postfix
proc.produceDenominatorZTTFastSim = helpers.cloneProcessingSnippet(
    proc, proc.produceDenominatorZTT, 'FastSim')

#adds to TauValNumeratorAndDenominator modules in the sequence FastSim to the extention name
zttLabeler = lambda module: SetValidationExtention(module, 'FastSim')
zttModifier = ApplyFunctionToSequence(zttLabeler)
proc.TauValNumeratorAndDenominatorZTTFastSim.visit(zttModifier)

#Sets the correct naming to efficiency histograms
proc.efficienciesZTTFastSim.plots = Utils.SetPlotSequence(
    proc.TauValNumeratorAndDenominatorZTTFastSim)

#checks what's new in the process (the cloned sequences and modules in them)
newProcAttributes = filter(
    lambda x: (x not in procAttributes) and (x.find('FastSim') != -1),
コード例 #32
0
# top projections in PF2PAT:
getattr(process, "pfNoPileUp" + postfix).enable = True
getattr(process, "pfNoMuon" + postfix).enable = True
getattr(process, "pfNoElectron" + postfix).enable = True
getattr(process, "pfNoTau" + postfix).enable = False
getattr(process, "pfNoJet" + postfix).enable = False

#####################################################################################################
#### Clone the PF2PAT sequence for data-driven QCD estimate, and for Stijn's JetMET service work ####
#####################################################################################################

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
postfixNoLeptonCleaning = 'NoLeptonCleaning'

# just cloning the first sequence, and enabling lepton cleaning
cloneProcessingSnippet(process, getattr(process, 'patPF2PATSequencePF2PAT'),
                       postfixNoLeptonCleaning)

getattr(process, "pfNoMuonPF2PATNoLeptonCleaning").enable = False
getattr(process, "pfNoElectronPF2PATNoLeptonCleaning").enable = False
getattr(
    process,
    "pfIsolatedMuonsPF2PATNoLeptonCleaning").combinedIsolationCut = cms.double(
        999999)
getattr(
    process,
    "pfIsolatedMuonsPF2PATNoLeptonCleaning").isolationCut = cms.double(999999)
getattr(process, "pfIsolatedElectronsPF2PATNoLeptonCleaning"
        ).combinedIsolationCut = cms.double(999999)
getattr(process,
        "pfIsolatedElectronsPF2PATNoLeptonCleaning").isolationCut = cms.double(
            999999)
コード例 #33
0
def produce_final_states(process, collections, output_commands,
                         sequence, puTag, buildFSAEvent=True,
                         noTracks=False, noPhotons=False):

    muonsrc = collections['muons']
    esrc = collections['electrons']
    tausrc = collections['taus']
    jetsrc = collections['jets']
    pfmetsrc = collections['pfmet']
    mvametsrc = collections['mvamet']
    phosrc = collections['photons']

    # Build the PATFinalStateEventObject
    if buildFSAEvent:
        process.load("FinalStateAnalysis.PatTools."
                     "finalStates.patFinalStateEventProducer_cfi")
        process.patFinalStateEventProducer.electronSrc = cms.InputTag(esrc)
        process.patFinalStateEventProducer.muonSrc = cms.InputTag(muonsrc)
        process.patFinalStateEventProducer.tauSrc = cms.InputTag(tausrc)
        process.patFinalStateEventProducer.jetSrc = cms.InputTag(jetsrc)
        process.patFinalStateEventProducer.phoSrc = cms.InputTag(phosrc)
        process.patFinalStateEventProducer.metSrc = pfmetsrc
        process.patFinalStateEventProducer.puTag = cms.string(puTag)
        process.patFinalStateEventProducer.mets.pfmet = pfmetsrc
        process.patFinalStateEventProducer.mets.mvamet = mvametsrc
        sequence += process.patFinalStateEventProducer

    # Always keep
    output_commands.append('*_patFinalStateEventProducer_*_*')

    # Apply some loose PT cuts on the objects we use to create the final states
    # so the combinatorics don't blow up
    process.muonsForFinalStates = cms.EDFilter(
        "PATMuonRefSelector",
        src=cms.InputTag(muonsrc),
        cut=cms.string('max(pt, userFloat("maxCorPt")) > 4 '
                       '& (isGlobalMuon | isTrackerMuon)'),
        filter=cms.bool(False),
    )

    process.electronsForFinalStates = cms.EDFilter(
        "PATElectronRefSelector",
        src=cms.InputTag(esrc),
        cut=cms.string('abs(superCluster().eta) < 3.0 '
                       '& max(pt, userFloat("maxCorPt")) > 7'),
        filter=cms.bool(False),
    )

    process.photonsForFinalStates = cms.EDFilter(
        "PATPhotonRefSelector",
        src=cms.InputTag(phosrc),
        cut=cms.string('abs(superCluster().eta()) < 3.0 & pt > 10'),
        filter=cms.bool(False),
    )

    # Require that the PT of the jet (either corrected jet or tau)
    # to be greater than 17
    process.tausForFinalStates = cms.EDFilter(
        "PATTauRefSelector",
        src=cms.InputTag(tausrc),
        cut=cms.string('abs(eta) < 2.5 & pt > 17 & tauID("decayModeFinding")'),
        filter=cms.bool(False),
    )


    process.jetsForFinalStates = cms.EDProducer("PATJetCleaner",
        src = cms.InputTag(jetsrc),
        # preselection (any string-based cut on pat::Jet)
        preselection = cms.string("pt>20 & abs(eta) < 2.5 & userFloat('idLoose') & userFloat('fullDiscriminant')"),
        # overlap checking configurables
        checkOverlaps = cms.PSet(
         muons = cms.PSet(
          src = cms.InputTag("muonsForFinalStates"),
          algorithm = cms.string("byDeltaR"),
          preselection = cms.string("pt>10&&isGlobalMuon&&isTrackerMuon&&(chargedHadronIso()+max(photonIso+neutralHadronIso(),0.0))/pt()<0.3"),
          deltaR = cms.double(0.3),
          checkRecoComponents = cms.bool(False),
          pairCut = cms.string(""),
          requireNoOverlaps = cms.bool(True),
        ),
        electrons = cms.PSet(
           src = cms.InputTag("electronsForFinalStates"),
           algorithm = cms.string("byDeltaR"),
           preselection = cms.string("pt>10&&(chargedHadronIso()+max(photonIso()+neutralHadronIso(),0.0))/pt()<0.3"),
           deltaR = cms.double(0.3),
           checkRecoComponents = cms.bool(False),
           pairCut = cms.string(""),
           requireNoOverlaps = cms.bool(True),
         ),
         ),
         # finalCut (any string-based cut on pat::Jet)
         finalCut = cms.string('')
    )

    process.selectObjectsForFinalStates = cms.Sequence(
        process.muonsForFinalStates
        + process.electronsForFinalStates
        + process.tausForFinalStates
	+ process.jetsForFinalStates
    )
    if not noPhotons:
        process.selectObjectsForFinalStates += process.photonsForFinalStates

    sequence += process.selectObjectsForFinalStates

    # Now build all combinatorics for E/Mu/Tau/Photon
    object_types = [('Elec', cms.InputTag("electronsForFinalStates")),
                    ('Mu', cms.InputTag("muonsForFinalStates")),
                    ('Tau', cms.InputTag("tausForFinalStates")),
			('Jet', cms.InputTag("jetsForFinalStates"))]

    if not noPhotons:
        object_types.append(('Pho', cms.InputTag("photonsForFinalStates")))

    process.buildDiObjects = cms.Sequence()

    process.load("FinalStateAnalysis.PatTools."
                 "finalStates.patFinalStatesEmbedExtraCollections_cfi")
    # If we don't have tracks, don't fit the FS vertices
    if noTracks:
        process.patFinalStateVertexFitter.enable = False

    # Build di-object pairs
    for diobject in _combinatorics(object_types, 2):
        # Don't build two jet states
        if (diobject[0][0], diobject[1][0]) == ('Tau', 'Tau'):
            continue
        if (diobject[0][0], diobject[1][0]) == ('Tau', 'Pho'):
            continue
        if (diobject[0][0], diobject[1][0]) == ('Tau', 'Jet'):
            continue
        if (diobject[0][0], diobject[1][0]) == ('Jet', 'Pho'):
            continue
        if (diobject[0][0], diobject[1][0]) == ('Jet', 'Jet'):
            continue

        # Define some basic selections for building combinations
        cuts = ['smallestDeltaR() > 0.3']  # basic x-cleaning

        producer = cms.EDProducer(
            "PAT%s%sFinalStateProducer" % (diobject[0][0], diobject[1][0]),
            evtSrc=cms.InputTag("patFinalStateEventProducer"),
            leg1Src=diobject[0][1],
            leg2Src=diobject[1][1],
            # X-cleaning
            cut=cms.string(' & '.join(cuts))
        )
        producer_name = "finalState%s%s" % (diobject[0][0], diobject[1][0])
        setattr(process, producer_name + "Raw", producer)
        process.buildDiObjects += producer
        # Embed the other collections
        embedder_seq = helpers.cloneProcessingSnippet(
            process, process.patFinalStatesEmbedObjects, producer_name)
        process.buildDiObjects += embedder_seq
        # Do some trickery so the final module has a nice output name
        final_module_name = chain_sequence(embedder_seq, producer_name + "Raw")
        final_module = cms.EDProducer(
            "PATFinalStateCopier", src=final_module_name)
        setattr(process, producer_name, final_module)
        process.buildDiObjects += final_module
        setattr(process, producer_name, final_module)
        output_commands.append("*_%s_*_*" % producer_name)
    sequence += process.buildDiObjects

    # Build tri-lepton pairs
    process.buildTriObjects = cms.Sequence()
    for triobject in _combinatorics(object_types, 3):
        # Don't build three jet states
        if (triobject[0][0], triobject[1][0], triobject[2][0]) == \
           ('Tau', 'Tau', 'Tau'):
            continue

        n_taus = [x[0] for x in triobject].count('Tau')
        n_phos = [x[0] for x in triobject].count('Pho')
        n_muons = [x[0] for x in triobject].count('Mu')
        n_jets = [x[0] for x in triobject].count('Jet')

        if n_taus > 2:
            continue
        if n_phos > 2:
            continue
        if n_taus and n_phos:
            continue
	if n_jets > 0 and not (n_jets == 2 and n_muons == 1):
	    continue 


        # Define some basic selections for building combinations
        cuts = ['smallestDeltaR() > 0.3']  # basic x-cleaning

        producer = cms.EDProducer(
            "PAT%s%s%sFinalStateProducer" %
            (triobject[0][0], triobject[1][0], triobject[2][0]),
            evtSrc=cms.InputTag("patFinalStateEventProducer"),
            leg1Src=triobject[0][1],
            leg2Src=triobject[1][1],
            leg3Src=triobject[2][1],
            # X-cleaning
            cut=cms.string(' & '.join(cuts))
        )
        producer_name = "finalState%s%s%s" % (
            triobject[0][0], triobject[1][0], triobject[2][0])
        #setattr(process, producer_name, producer)
        #process.buildTriLeptons += producer
        setattr(process, producer_name + "Raw", producer)
        process.buildTriObjects += producer
        # Embed the other collections
        embedder_seq = helpers.cloneProcessingSnippet(
            process, process.patFinalStatesEmbedObjects, producer_name)
        process.buildTriObjects += embedder_seq
        # Do some trickery so the final module has a nice output name
        final_module_name = chain_sequence(embedder_seq, producer_name + "Raw")
        final_module = cms.EDProducer(
            "PATFinalStateCopier", src=final_module_name)
        setattr(process, producer_name, final_module)
        process.buildTriObjects += final_module
        output_commands.append("*_%s_*_*" % producer_name)
    sequence += process.buildTriObjects

    # Build 4 lepton final states
    process.buildQuadObjects = cms.Sequence()
    for quadobject in _combinatorics(object_types, 4):
        # Don't build states with more than 2 hadronic taus or phos
        n_taus = [x[0] for x in quadobject].count('Tau')
        n_phos = [x[0] for x in quadobject].count('Pho')
        n_jets = [x[0] for x in quadobject].count('Jet')

        if n_taus > 2:
            continue
        if n_phos > 2:
            continue
        if n_taus and n_phos:
            continue
	if n_jets> 0:
            continue


        # Define some basic selections for building combinations
        cuts = ['smallestDeltaR() > 0.3']  # basic x-cleaning

        producer = cms.EDProducer(
            "PAT%s%s%s%sFinalStateProducer" %
            (quadobject[0][0], quadobject[1][0], quadobject[2][0],
             quadobject[3][0]),
            evtSrc=cms.InputTag("patFinalStateEventProducer"),
            leg1Src=quadobject[0][1],
            leg2Src=quadobject[1][1],
            leg3Src=quadobject[2][1],
            leg4Src=quadobject[3][1],
            # X-cleaning
            cut=cms.string(' & '.join(cuts))
        )
        producer_name = "finalState%s%s%s%s" % (
            quadobject[0][0], quadobject[1][0], quadobject[2][0],
            quadobject[3][0]
        )
        #setattr(process, producer_name, producer)
        #process.buildTriLeptons += producer
        setattr(process, producer_name + "Raw", producer)
        process.buildQuadObjects += producer
        # Embed the other collections
        embedder_seq = helpers.cloneProcessingSnippet(
            process, process.patFinalStatesEmbedObjects, producer_name)
        process.buildQuadObjects += embedder_seq
        # Do some trickery so the final module has a nice output name
        final_module_name = chain_sequence(embedder_seq, producer_name + "Raw")
        final_module = cms.EDProducer(
            "PATFinalStateCopier", src=final_module_name)
        setattr(process, producer_name, final_module)
        process.buildQuadObjects += final_module
        output_commands.append("*_%s_*_*" % producer_name)
    sequence += process.buildQuadObjects
コード例 #34
0
import FWCore.ParameterSet.Config as cms
from Validation.RecoTau.RecoTauValidation_cfi import ApplyFunctionToSequence, SetValidationExtention
import PhysicsTools.PatAlgos.tools.helpers as helpers

proc = cms.Process('helper')

proc.load('Validation.RecoTau.dataTypes.ValidateTausOnZEE_cff')  # import *

procAttributes = dir(proc)  #Takes a snapshot of what there in the process
helpers.cloneProcessingSnippet(
    proc, proc.runTauValidation,
    'FastSim')  #clones the sequence inside the process with ZTT postfix
#helpers.cloneProcessingSnippet( proc, proc.TauEfficienciesZTT, 'FastSim') #clones the sequence inside the process with ZTT postfix
#proc.produceDenominatorZTTFastSim = helpers.cloneProcessingSnippet( proc, proc.produceDenominatorZTT, 'FastSim')

#adds to TauValNumeratorAndDenominator modules in the sequence FastSim to the extention name
zttLabeler = lambda module: SetValidationExtention(module, 'FastSim')
zttModifier = ApplyFunctionToSequence(zttLabeler)
proc.TauValNumeratorAndDenominatorZEEFastSim.visit(zttModifier)

#Sets the correct naming to efficiency histograms
proc.efficienciesZEEFastSim.streamTag = cms.InputTag("ZEEFastSim")

#checks what's new in the process (the cloned sequences and modules in them)
newProcAttributes = filter(
    lambda x: (x not in procAttributes) and (x.find('FastSim') != -1),
    dir(proc))

#spawns a local variable with the same name as the proc attribute, needed for future process.load
for newAttr in newProcAttributes:
    locals()[newAttr] = getattr(proc, newAttr)
コード例 #35
0
process.p1 = cms.Path(process.emulationSequence * process.scalersRawToDigi *
                      process.tauL1Rate * process.isoEGL1Rate *
                      process.rlxEGL1Rate * process.jetL1Rate *
                      process.sumsL1Rates * process.sumsUCTRates)

if options.stage1:
    print "Building stage1 trees"
    process.p1 += process.uctLeptonRates
    process.p1 += process.uctHadronicRates

if options.stage1B:
    print "Building Stage1B trees"
    # Make a copy of the lepton efficiency trees using stage 1B inputs.
    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    process.uctLeptonRatesStage1B = cloneProcessingSnippet(
        process, process.uctLeptonRates, 'Stage1B')
    # Update input tags to the stage 1B producer
    for stage1BTreeMaker in [
            process.rlxTauUCTRateStage1B,
            #process.isoTauUCTRateStage1B,
            process.rlxEGUCTRateStage1B,
            #process.isoEGUCTRateStage1B
    ]:
        stage1BTreeMaker.src[0].setModuleLabel("UCTStage1BProducer")
    # add the computation of stage1b trees
    process.p1 += process.uctLeptonRatesStage1B

# Make the framework shut up.
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 100
コード例 #36
0
    def _addPFMEtByMVA(self, process, metUncertaintySequence,
                       shiftedParticleCollections, pfCandCollection,
                       collectionsToKeep, doSmearJets, jecUncertaintyFile,
                       jecUncertaintyTag, varyByNsigmas, postfix):

        if not hasattr(process, "pfMEtMVA"):
            process.load("JetMETCorrections.METPUSubtraction.mvaPFMET_cff")

        lastUncorrectedJetCollection = 'ak5PFJets'
        lastCorrectedJetCollection = 'calibratedAK5PFJetsForPFMEtMVA'
        if postfix != "":
            configtools.cloneProcessingSnippet(process,
                                               process.pfMEtMVAsequence,
                                               postfix)
            lastCorrectedJetCollection += postfix

        if doSmearJets:
            process.load("RecoJets.Configuration.GenJetParticles_cff")
            metUncertaintySequence += process.genParticlesForJetsNoNu
            process.load("RecoJets.Configuration.RecoGenJets_cff")
            metUncertaintySequence += process.ak5GenJetsNoNu
            setattr(
                process,
                "smearedUncorrectedJetsForPFMEtByMVA" + postfix,
                cms.EDProducer(
                    "SmearedPFJetProducer",
                    src=cms.InputTag('ak5PFJets'),
                    jetCorrLabel=cms.string("ak5PFL1FastL2L3"),
                    dRmaxGenJetMatch=cms.string(
                        'TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'
                    ),
                    sigmaMaxGenJetMatch=cms.double(5.),
                    inputFileName=cms.FileInPath(
                        'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'
                    ),
                    lutName=cms.string('pfJetResolutionMCtoDataCorrLUT'),
                    jetResolutions=jetResolutions.METSignificance_params,
                    skipRawJetPtThreshold=cms.double(10.),  # GeV
                    skipCorrJetPtThreshold=cms.double(1.e-2),
                    srcGenJets=cms.InputTag('ak5GenJetsNoNu')))
            metUncertaintySequence += getattr(
                process, "smearedUncorrectedJetsForPFMEtByMVA" + postfix)
            getattr(process, "calibratedAK5PFJetsForPFMEtMVA" +
                    postfix).src = cms.InputTag(
                        'smearedUncorrectedJetsForPFMEtByMVA' + postfix)
            getattr(process,
                    "pfMEtMVA" + postfix).srcUncorrJets = cms.InputTag(
                        'smearedUncorrectedJetsForPFMEtByMVA' + postfix)
            metUncertaintySequence += getattr(
                process, "calibratedAK5PFJetsForPFMEtMVA" + postfix)
            setattr(
                process, "smearedCorrectedJetsForPFMEtByMVA" + postfix,
                getattr(process,
                        "smearedUncorrectedJetsForPFMEtByMVA" + postfix).clone(
                            src=cms.InputTag('calibratedAK5PFJetsForPFMEtMVA' +
                                             postfix),
                            jetCorrLabel=cms.string("")))
            metUncertaintySequence += getattr(
                process, "smearedCorrectedJetsForPFMEtByMVA" + postfix)
            getattr(process, "pfMEtMVA" + postfix).srcCorrJets = cms.InputTag(
                'smearedCorrectedJetsForPFMEtByMVA' + postfix)
            metUncertaintySequence += getattr(process, "pfMEtMVA" + postfix)
        else:
            metUncertaintySequence += getattr(process,
                                              "pfMEtMVAsequence" + postfix)
        self._addPATMEtProducer(process, metUncertaintySequence,
                                'pfMEtMVA' + postfix, 'patPFMetMVA',
                                collectionsToKeep, postfix)

        for leptonCollection in [['Electron', 'En', 'electronCollection', 0.3],
                                 ['Photon', 'En', 'photonCollection', 0.3],
                                 ['Muon', 'En', 'muonCollection', 0.3],
                                 ['Tau', 'En', 'tauCollection', 0.3]]:
            if self._isValidInputTag(
                    shiftedParticleCollections[leptonCollection[2]]):
                pfCandCollectionLeptonShiftUp, pfCandCollectionLeptonShiftDown = \
                  self._addPFCandidatesForPFMEtInput(
                    process, metUncertaintySequence,
                    shiftedParticleCollections['%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
                    shiftedParticleCollections['%s%sUp' % (leptonCollection[2], leptonCollection[1])],
                    shiftedParticleCollections['%s%sDown' % (leptonCollection[2], leptonCollection[1])],
                    leptonCollection[3],
                    pfCandCollection, postfix)
                modulePFMEtLeptonShiftUp = getattr(
                    process, "pfMEtMVA" + postfix).clone(
                        srcPFCandidates=cms.InputTag(
                            pfCandCollectionLeptonShiftUp),
                        srcLeptons=cms.VInputTag(
                            self._getLeptonsForPFMEtInput(
                                shiftedParticleCollections,
                                leptonCollection[2],
                                '%s%sUp' %
                                (leptonCollection[2], leptonCollection[1]),
                                postfix=postfix)))
                modulePFMEtLeptonShiftUpName = "pfMEtMVA%s%sUp" % (
                    leptonCollection[0], leptonCollection[1])
                modulePFMEtLeptonShiftUpName += postfix
                setattr(process, modulePFMEtLeptonShiftUpName,
                        modulePFMEtLeptonShiftUp)
                metUncertaintySequence += modulePFMEtLeptonShiftUp
                self._addPATMEtProducer(
                    process, metUncertaintySequence,
                    modulePFMEtLeptonShiftUpName, 'patPFMetMVA%s%sUp' %
                    (leptonCollection[0], leptonCollection[1]),
                    collectionsToKeep, postfix)
                modulePFMEtLeptonShiftDown = getattr(
                    process, "pfMEtMVA" + postfix).clone(
                        srcPFCandidates=cms.InputTag(
                            pfCandCollectionLeptonShiftDown),
                        srcLeptons=cms.VInputTag(
                            self._getLeptonsForPFMEtInput(
                                shiftedParticleCollections,
                                leptonCollection[2],
                                '%s%sDown' %
                                (leptonCollection[2], leptonCollection[1]),
                                postfix=postfix)))
                modulePFMEtLeptonShiftDownName = "pfMEtMVA%s%sDown" % (
                    leptonCollection[0], leptonCollection[1])
                modulePFMEtLeptonShiftDownName += postfix
                setattr(process, modulePFMEtLeptonShiftDownName,
                        modulePFMEtLeptonShiftDown)
                metUncertaintySequence += modulePFMEtLeptonShiftDown
                self._addPATMEtProducer(
                    process, metUncertaintySequence,
                    modulePFMEtLeptonShiftDownName, 'patPFMetMVA%s%sDown' %
                    (leptonCollection[0], leptonCollection[1]),
                    collectionsToKeep, postfix)

        if self._isValidInputTag(shiftedParticleCollections['jetCollection']):
            setattr(
                process, "uncorrectedJetsEnUpForPFMEtByMVA" + postfix,
                cms.EDProducer(
                    "ShiftedPFJetProducer",
                    src=cms.InputTag(lastUncorrectedJetCollection),
                    jetCorrInputFileName=cms.FileInPath(jecUncertaintyFile),
                    jetCorrUncertaintyTag=cms.string(jecUncertaintyTag),
                    addResidualJES=cms.bool(True),
                    jetCorrLabelUpToL3=cms.string("ak5PFL1FastL2L3"),
                    jetCorrLabelUpToL3Res=cms.string(
                        "ak5PFL1FastL2L3Residual"),
                    shiftBy=cms.double(+1. * varyByNsigmas)))
            metUncertaintySequence += getattr(
                process, "uncorrectedJetsEnUpForPFMEtByMVA" + postfix)
            setattr(
                process, "uncorrectedJetsEnDownForPFMEtByMVA" + postfix,
                getattr(process,
                        "uncorrectedJetsEnUpForPFMEtByMVA" + postfix).clone(
                            shiftBy=cms.double(-1. * varyByNsigmas)))
            metUncertaintySequence += getattr(
                process, "uncorrectedJetsEnDownForPFMEtByMVA" + postfix)
            setattr(
                process, "correctedJetsEnUpForPFMEtByMVA" + postfix,
                getattr(process,
                        "uncorrectedJetsEnUpForPFMEtByMVA" + postfix).clone(
                            src=cms.InputTag(lastCorrectedJetCollection),
                            addResidualJES=cms.bool(False),
                            shiftBy=cms.double(+1. * varyByNsigmas)))
            metUncertaintySequence += getattr(
                process, "correctedJetsEnUpForPFMEtByMVA" + postfix)
            setattr(
                process, "correctedJetsEnDownForPFMEtByMVA" + postfix,
                getattr(process,
                        "correctedJetsEnUpForPFMEtByMVA" + postfix).clone(
                            shiftBy=cms.double(-1. * varyByNsigmas)))
            metUncertaintySequence += getattr(
                process, "correctedJetsEnDownForPFMEtByMVA" + postfix)
            pfCandCollectionJetEnUp, pfCandCollectionJetEnDown = \
              self._addPFCandidatesForPFMEtInput(
                process, metUncertaintySequence,
                shiftedParticleCollections['lastJetCollection'], "Jet", "En",
                shiftedParticleCollections['jetCollectionEnUpForCorrMEt'], shiftedParticleCollections['jetCollectionEnDownForCorrMEt'],
                0.5,
                pfCandCollection, postfix)
            setattr(
                process, "pfMEtMVAJetEnUp" + postfix,
                getattr(process, "pfMEtMVA").clone(
                    srcCorrJets=cms.InputTag('correctedJetsEnUpForPFMEtByMVA' +
                                             postfix),
                    srcUncorrJets=cms.InputTag(
                        'uncorrectedJetsEnUpForPFMEtByMVA' + postfix),
                    srcPFCandidates=cms.InputTag(pfCandCollectionJetEnUp),
                    srcLeptons=cms.VInputTag(
                        self._getLeptonsForPFMEtInput(
                            shiftedParticleCollections, postfix=postfix))))
            metUncertaintySequence += getattr(process,
                                              "pfMEtMVAJetEnUp" + postfix)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    'pfMEtMVAJetEnUp' + postfix,
                                    'patPFMetMVAJetEnUp', collectionsToKeep,
                                    postfix)
            setattr(
                process, "pfMEtMVAJetEnDown" + postfix,
                getattr(process, "pfMEtMVA" + postfix).clone(
                    srcCorrJets=cms.InputTag(
                        'correctedJetsEnDownForPFMEtByMVA' + postfix),
                    srcUncorrJets=cms.InputTag(
                        'uncorrectedJetsEnDownForPFMEtByMVA' + postfix),
                    srcPFCandidates=cms.InputTag(pfCandCollectionJetEnDown),
                    srcLeptons=cms.VInputTag(
                        self._getLeptonsForPFMEtInput(
                            shiftedParticleCollections, postfix=postfix))))
            metUncertaintySequence += getattr(process,
                                              "pfMEtMVAJetEnDown" + postfix)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    'pfMEtMVAJetEnDown' + postfix,
                                    'patPFMetMVAJetEnDown', collectionsToKeep,
                                    postfix)

            if hasattr(process,
                       "smearedUncorrectedJetsForPFMEtByMVA" + postfix):
                setattr(
                    process, "uncorrectedJetsResUpForPFMEtByMVA" + postfix,
                    getattr(process, "smearedUncorrectedJetsForPFMEtByMVA" +
                            postfix).clone(shiftBy=cms.double(-1. *
                                                              varyByNsigmas)))
                metUncertaintySequence += getattr(
                    process, "uncorrectedJetsResUpForPFMEtByMVA" + postfix)
                setattr(
                    process, "uncorrectedJetsResDownForPFMEtByMVA" + postfix,
                    getattr(process, "smearedUncorrectedJetsForPFMEtByMVA" +
                            postfix).clone(shiftBy=cms.double(+1. *
                                                              varyByNsigmas)))
                metUncertaintySequence += getattr(
                    process, "uncorrectedJetsResDownForPFMEtByMVA" + postfix)
                setattr(
                    process, "correctedJetsResUpForPFMEtByMVA" + postfix,
                    getattr(process, "smearedCorrectedJetsForPFMEtByMVA" +
                            postfix).clone(shiftBy=cms.double(-1. *
                                                              varyByNsigmas)))
                metUncertaintySequence += getattr(
                    process, "correctedJetsResUpForPFMEtByMVA" + postfix)
                setattr(
                    process, "correctedJetsResDownForPFMEtByMVA" + postfix,
                    getattr(process, "smearedCorrectedJetsForPFMEtByMVA" +
                            postfix).clone(shiftBy=cms.double(+1. *
                                                              varyByNsigmas)))
                metUncertaintySequence += getattr(
                    process, "correctedJetsResDownForPFMEtByMVA" + postfix)
                pfCandCollectionJetResUp, pfCandCollectionJetResDown = \
                  self._addPFCandidatesForPFMEtInput(
                    process, metUncertaintySequence,
                    shiftedParticleCollections['jetCollection'], "Jet", "Res",
                    shiftedParticleCollections['jetCollectionResUp'], shiftedParticleCollections['jetCollectionResDown'],
                    0.5,
                    pfCandCollection, postfix)
                setattr(
                    process, "pfMEtMVAJetResUp" + postfix,
                    getattr(process, "pfMEtMVA" + postfix).clone(
                        srcCorrJets=cms.InputTag(
                            'correctedJetsResUpForPFMEtByMVA' + postfix),
                        srcUncorrJets=cms.InputTag(
                            'uncorrectedJetsResUpForPFMEtByMVA' + postfix),
                        srcPFCandidates=cms.InputTag(pfCandCollectionJetResUp),
                        srcLeptons=cms.VInputTag(
                            self._getLeptonsForPFMEtInput(
                                shiftedParticleCollections, postfix=postfix))))
                metUncertaintySequence += getattr(process,
                                                  "pfMEtMVAJetResUp" + postfix)
                self._addPATMEtProducer(process, metUncertaintySequence,
                                        'pfMEtMVAJetResUp' + postfix,
                                        'patPFMetMVAJetResUp',
                                        collectionsToKeep, postfix)
                setattr(
                    process, "pfMEtMVAJetResDown" + postfix,
                    getattr(process, "pfMEtMVA" + postfix).clone(
                        srcCorrJets=cms.InputTag(
                            'correctedJetsResDownForPFMEtByMVA' + postfix),
                        srcUncorrJets=cms.InputTag(
                            'uncorrectedJetsResDownForPFMEtByMVA' + postfix),
                        srcPFCandidates=cms.InputTag(
                            pfCandCollectionJetResDown),
                        srcLeptons=cms.VInputTag(
                            self._getLeptonsForPFMEtInput(
                                shiftedParticleCollections, postfix=postfix))))
                metUncertaintySequence += getattr(
                    process, "pfMEtMVAJetResDown" + postfix)
                self._addPATMEtProducer(process, metUncertaintySequence,
                                        'pfMEtMVAJetResDown' + postfix,
                                        'patPFMetMVAJetResDown',
                                        collectionsToKeep, postfix)

            setattr(
                process,
                "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA" + postfix,
                cms.EDProducer("ShiftedPFCandidateProducer",
                               src=cms.InputTag('pfCandsNotInJet'),
                               shiftBy=cms.double(+1. * varyByNsigmas),
                               uncertainty=cms.double(0.10)))
            metUncertaintySequence += getattr(
                process,
                "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA" + postfix)
            setattr(
                process,
                "pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA" + postfix,
                getattr(
                    process, "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA" +
                    postfix).clone(shiftBy=cms.double(-1. * varyByNsigmas)))
            metUncertaintySequence += getattr(
                process,
                "pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA" + postfix)
            pfCandCollectionUnclusteredEnUp, pfCandCollectionUnclusteredEnDown = \
              self._addPFCandidatesForPFMEtInput(
                process, metUncertaintySequence,
                pfCandCollection, "Unclustered", "En",
                'pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA' + postfix, 'pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA' + postfix, #fixme MM
                0.01,
                pfCandCollection, postfix)
            setattr(
                process, "pfMEtMVAUnclusteredEnUp" + postfix,
                getattr(process, "pfMEtMVA" + postfix).clone(
                    srcPFCandidates=cms.InputTag(
                        pfCandCollectionUnclusteredEnUp),
                    srcLeptons=cms.VInputTag(
                        self._getLeptonsForPFMEtInput(
                            shiftedParticleCollections, postfix=postfix))))
            metUncertaintySequence += getattr(
                process, "pfMEtMVAUnclusteredEnUp" + postfix)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    'pfMEtMVAUnclusteredEnUp' + postfix,
                                    'patPFMetMVAUnclusteredEnUp',
                                    collectionsToKeep, postfix)
            setattr(
                process, "pfMEtMVAUnclusteredEnDown" + postfix,
                getattr(process, "pfMEtMVA" + postfix).clone(
                    srcPFCandidates=cms.InputTag(
                        pfCandCollectionUnclusteredEnDown),
                    srcLeptons=cms.VInputTag(
                        self._getLeptonsForPFMEtInput(
                            shiftedParticleCollections, postfix=postfix))))
            metUncertaintySequence += getattr(
                process, "pfMEtMVAUnclusteredEnDown" + postfix)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    'pfMEtMVAUnclusteredEnDown' + postfix,
                                    'patPFMetMVAUnclusteredEnDown',
                                    collectionsToKeep, postfix)
    process.patTaus.addGenJetMatch = False
    process.patTaus.addGenMatch = False

    process.patMETs.addGenMET = False 
    process.patMETsRaw.addGenMET = False 

    # adding L2L3Residual corrections
    process.patJetCorrFactors.levels.append('L2L3Residual')
    if isNewerThan('CMSSW_5_2_0'):
        process.patJetCorrFactorsCHSpruned.levels.append('L2L3Residual')


print 'cloning the jet sequence to build PU chs jets'

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
process.PATCMGJetCHSSequence = cloneProcessingSnippet(process, process.PATCMGJetSequence, 'CHS')
process.PATCMGJetCHSSequence.insert( 0, process.ak5PFJetsCHS )
from CMGTools.Common.Tools.visitorUtils import replaceSrc
replaceSrc( process.PATCMGJetCHSSequence, 'ak5PFJets', 'ak5PFJetsCHS')
replaceSrc( process.PATCMGJetCHSSequence, 'particleFlow', 'pfNoPileUp')
process.patJetCorrFactorsCHS.payload = 'AK5PFchs'
process.selectedPatJetsCHS.cut = 'pt()>10'


########################################################
## Path definition
########################################################
process.PATCMGSequence.remove(process.PATCMGTauSequence)


process.dump = cms.EDAnalyzer('EventContentAnalyzer')
コード例 #38
0
ファイル: tauTools.py プロジェクト: fabozzi/ST_44
def redoPFTauDiscriminators(process,
                            oldPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
                            newPFTauLabel = cms.InputTag('shrinkingConePFTauProducer'),
                            tauType = 'shrinkingConePFTau', postfix = ""):
    print 'Tau discriminators: ', oldPFTauLabel, '->', newPFTauLabel
    print 'Tau type: ', tauType
    #oldPFTauLabel.setModuleLabel(oldPFTauLabel.getModuleLabel()+postfix)
    tauSrc = 'PFTauProducer'

    tauDiscriminationSequence = None

    if tauType == 'hpsPFTau':
        process.patHPSPFTauDiscrimination = process.produceAndDiscriminateHPSPFTaus.copy()
        # remove producers
        for iname in process.patHPSPFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
                process.patHPSPFTauDiscrimination.remove(getattr(process,iname) )
        tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSPFTauDiscrimination, postfix)

    elif tauType == 'hpsTancTaus': #to be checked if correct
        process.patHPSTaNCPFTauDiscrimination = process.hpsTancTauInitialSequence.copy()
        process.patHPSTaNCPFTauDiscrimination *= process.hpsTancTauDiscriminantSequence
        # remove producers
        for iname in process.patHPSTaNCPFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
                process.patHPSTaNCPFTauDiscrimination.remove(getattr(process,iname) )
        tauDiscriminationSequence = cloneProcessingSnippet(process, process.patHPSTaNCPFTauDiscrimination, postfix)

    elif tauType == 'fixedConePFTau':
        process.patFixedConePFTauDiscrimination = process.produceAndDiscriminateFixedConePFTaus.copy()
        # remove producers
        for iname in process.patFixedConePFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
                process.patFixedConePFTauDiscrimination.remove(getattr(process,iname) )
        tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patFixedConePFTauDiscrimination, postfix)

    elif tauType == 'shrinkingConePFTau': #shr cone with TaNC
        process.patShrinkingConePFTauDiscrimination = process.produceAndDiscriminateShrinkingConePFTaus.copy()
        process.patShrinkingConePFTauDiscrimination *= process.produceShrinkingConeDiscriminationByTauNeuralClassifier
        # remove producers
        for iname in process.patShrinkingConePFTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
                process.patShrinkingConePFTauDiscrimination.remove(getattr(process,iname) )
        tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patShrinkingConePFTauDiscrimination, postfix)

    elif tauType == 'caloTau':
        # fill calo sequence by discriminants
        process.patCaloTauDiscrimination = process.tautagging.copy()
        # remove producers
        for iname in process.patCaloTauDiscrimination.moduleNames():
            if not (iname.find("DiscriminationBy")>-1 or iname.find("DiscriminationAgainst")>-1):
                process.patCaloTauDiscrimination.remove(getattr(process,iname) )
        tauDiscriminationSequence =  cloneProcessingSnippet(process, process.patCaloTauDiscrimination, postfix)
        tauSrc = 'CaloTauProducer'
    else:
        raise StandardError, "Unkown tauType: '%s'"%tauType

    applyPostfix(process,"patDefaultSequence",postfix).replace(
        applyPostfix(process,"patTaus",postfix),
        tauDiscriminationSequence*applyPostfix(process,"patTaus",postfix)
    )

    massSearchReplaceParam(tauDiscriminationSequence, tauSrc, oldPFTauLabel, newPFTauLabel)
コード例 #39
0
import FWCore.ParameterSet.Config as cms
import Validation.RecoTau.ValidationUtils as Utils
from Validation.RecoTau.RecoTauValidation_cfi import ApplyFunctionToSequence, SetValidationExtention
import PhysicsTools.PatAlgos.tools.helpers as helpers

proc = cms.Process('helper')

proc.load('Validation.RecoTau.dataTypes.ValidateTausOnZTT_cff')# import *

procAttributes = dir(proc) #Takes a snapshot of what there in the process
helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominatorZTT, 'FastSim') #clones the sequence inside the process with ZTT postfix
helpers.cloneProcessingSnippet( proc, proc.TauEfficienciesZTT, 'FastSim') #clones the sequence inside the process with ZTT postfix
proc.produceDenominatorZTTFastSim = helpers.cloneProcessingSnippet( proc, proc.produceDenominatorZTT, 'FastSim')

#adds to TauValNumeratorAndDenominator modules in the sequence FastSim to the extention name
zttLabeler = lambda module : SetValidationExtention(module, 'FastSim')
zttModifier = ApplyFunctionToSequence(zttLabeler)
proc.TauValNumeratorAndDenominatorZTTFastSim.visit(zttModifier)

#Sets the correct naming to efficiency histograms
proc.efficienciesZTTFastSim.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorZTTFastSim)

#checks what's new in the process (the cloned sequences and modules in them)
newProcAttributes = filter( lambda x: (x not in procAttributes) and (x.find('FastSim') != -1), dir(proc) )

#spawns a local variable with the same name as the proc attribute, needed for future process.load
for newAttr in newProcAttributes:
    locals()[newAttr] = getattr(proc,newAttr)

produceDenominator = produceDenominatorZTTFastSim
コード例 #40
0
    def _addCorrCaloMEt(self, process, metUncertaintySequence,
                        shiftedParticleCollections, caloTowerCollection,
                        collectionsToKeep,
                        jetCorrLabelUpToL3, jetCorrLabelUpToL3Res,
                        jecUncertaintyFile, jecUncertaintyTag,
                        varyByNsigmas,
                        type1JetPtThreshold,
                        postfix):

        if not hasattr(process, 'produceCaloMETCorrections'):
            process.load("JetMETCorrections.Type1MET.caloMETCorrections_cff")
        process.caloJetMETcorr.type1JetPtThreshold = cms.double(type1JetPtThreshold)

        # If with empty postfix, make a backup of
        # process.producePatPFMETCorrections, because the original
        # sequence will be modified later in this function
        if postfix == "":
            configtools.cloneProcessingSnippet(process, process.produceCaloMETCorrections, "OriginalReserved")
        else:
            if postfix == "OriginalReserved":
                raise ValueError("Postfix label '%s' is reserved for internal usage !!" % postfix)

            if hasattr(process, "produceCaloMETCorrectionsOriginalReserved"):
                configtools.cloneProcessingSnippet(process, process.produceCaloMETCorrectionsOriginalReserved, postfix, removePostfix="OriginalReserved")
            else:
                configtools.cloneProcessingSnippet(process, process.produceCaloMETCorrections, postfix)

        metUncertaintySequence += getattr(process, "produceCaloMETCorrections")

        metCollectionsUp_DownForCorrMEt = \
            self._propagateMEtUncertainties(
              process, shiftedParticleCollections['lastJetCollection'], "Jet", "En",
              shiftedParticleCollections['jetCollectionEnUpForCorrMEt'], shiftedParticleCollections['jetCollectionEnDownForCorrMEt'],
              process.caloType1CorrectedMet, "Calo", metUncertaintySequence, postfix)
        #getattr(process, "patCaloMETcorrJetEnUp").verbosity = cms.int32(1)
        #getattr(process, metCollectionsUp_DownForCorrMEt[0]).verbosity = cms.int32(1)
        #getattr(process, "patCaloMETcorrJetEnDown").verbosity = cms.int32(1)
        #getattr(process, metCollectionsUp_DownForCorrMEt[1]).verbosity = cms.int32(1)

        self._addPATMEtProducer(process, metUncertaintySequence,
                                metCollectionsUp_DownForCorrMEt[0], 'patType1CorrectedCaloMetJetEnUp', collectionsToKeep, postfix)
        self._addPATMEtProducer(process, metUncertaintySequence,
                                metCollectionsUp_DownForCorrMEt[1], 'patType1CorrectedCaloMetJetEnDown', collectionsToKeep, postfix)

        if caloTowerCollection.value() != "":
            process.caloJetMETcorr.srcMET = cms.InputTag('')
            process.caloTowersNotInJetsForMEtUncertainty = cms.EDProducer("TPCaloJetsOnCaloTowers",
                enable = cms.bool(True),
                verbose = cms.untracked.bool(False),
                name = cms.untracked.string("caloTowersNotInJetsForMEtUncertainty"),
                topCollection = cms.InputTag('ak5CaloJets'),
                bottomCollection = caloTowerCollection
            )
            metUncertaintySequence += process.caloTowersNotInJetsForMEtUncertainty
            process.caloTowerMETcorr = cms.EDProducer("CaloTowerMETcorrInputProducer",
                src = cms.InputTag('caloTowersNotInJetsForMEtUncertainty'),
                residualCorrLabel = cms.string(""),
                residualCorrEtaMax = cms.double(9.9),
                residualCorrOffset = cms.double(0.),
                globalThreshold = cms.double(0.3), # NOTE: this value need to match met.globalThreshold, defined in RecoMET/METProducers/python/CaloMET_cfi.py
                noHF = cms.bool(False),
                #verbosity = cms.int32(1)
            )
            metUncertaintySequence += process.caloTowerMETcorr
            moduleCaloType1CorrectedMetUnclusteredEnUp = getattr(process, "caloType1CorrectedMet" + postfix).clone(
                applyType2Corrections = cms.bool(True),
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('caloJetMETcorr', 'type2'),
                    cms.InputTag('caloTowerMETcorr')
                ),
                type2CorrFormula = cms.string("A"),
                type2CorrParameter = cms.PSet(
                    A = cms.double(1.0 + 0.1*varyByNsigmas)
                ),
                #verbosity = cms.int32(1)
            )
            moduleCaloType1CorrectedMetUnclusteredEnUpName = "caloType1CorrectedMetUnclusteredEnUp%s" % postfix
            setattr(process, moduleCaloType1CorrectedMetUnclusteredEnUpName, moduleCaloType1CorrectedMetUnclusteredEnUp)
            metUncertaintySequence += getattr(process, moduleCaloType1CorrectedMetUnclusteredEnUpName)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    moduleCaloType1CorrectedMetUnclusteredEnUpName, 'patType1CorrectedCaloMetUnclusteredEnUp', collectionsToKeep, postfix)
            moduleCaloType1CorrectedMetUnclusteredEnDown = moduleCaloType1CorrectedMetUnclusteredEnUp.clone(
                type2CorrParameter = cms.PSet(
                    A = cms.double(1.0 - 0.1*varyByNsigmas)
                )
            )
            moduleCaloType1CorrectedMetUnclusteredEnDownName = "caloType1CorrectedMetUnclusteredEnDown%s" % postfix
            setattr(process, moduleCaloType1CorrectedMetUnclusteredEnDownName, moduleCaloType1CorrectedMetUnclusteredEnDown)
            metUncertaintySequence += getattr(process, moduleCaloType1CorrectedMetUnclusteredEnDownName)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    moduleCaloType1CorrectedMetUnclusteredEnDownName, 'patType1CorrectedCaloMetUnclusteredEnDown', collectionsToKeep, postfix)
        else:            
            moduleCaloType1CorrectedMetUnclusteredEnUp = getattr(process, "caloType1CorrectedMet" + postfix).clone(
                applyType2Corrections = cms.bool(True),
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('caloJetMETcorr', 'type2fromMEt')
                ),
                type2CorrFormula = cms.string("A"),
                type2CorrParameter = cms.PSet(
                    A = cms.double(1.0 + 0.1*varyByNsigmas)
                )
            )
            moduleCaloType1CorrectedMetUnclusteredEnUpName = "caloType1CorrectedMetUnclusteredEnUp%s" % postfix
            setattr(process, moduleCaloType1CorrectedMetUnclusteredEnUpName, moduleCaloType1CorrectedMetUnclusteredEnUp)
            metUncertaintySequence += getattr(process, moduleCaloType1CorrectedMetUnclusteredEnUpName)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    moduleCaloType1CorrectedMetUnclusteredEnUp, 'patType1CorrectedCaloMetUnclusteredEnUp', collectionsToKeep, postfix)
            moduleCaloType1CorrectedMetUnclusteredEnDown = moduleCaloType1CorrectedMetUnclusteredEnUp.clone(
                type2CorrParameter = cms.PSet(
                    A = cms.double(1.0 - 0.1*varyByNsigmas)
                )
            )
            moduleCaloType1CorrectedMetUnclusteredEnDownName = "caloType1CorrectedMetUnclusteredEnDown%s" % postfix
            setattr(process, moduleCaloType1CorrectedMetUnclusteredEnDownName, moduleCaloType1CorrectedMetUnclusteredEnDown)
            metUncertaintySequence += getattr(process, moduleCaloType1CorrectedMetUnclusteredEnDownName)
            self._addPATMEtProducer(process, metUncertaintySequence,
                                    moduleCaloType1CorrectedMetUnclusteredEnDown, 'patType1CorrectedCaloMetUnclusteredEnDown', collectionsToKeep, postfix)
コード例 #41
0
    def _addCorrPFMEt(self, process, metUncertaintySequence,
                      shiftedParticleCollections, pfCandCollection,
                      collectionsToKeep,
                      doSmearJets,
                      makeType1corrPFMEt,
                      makeType1p2corrPFMEt,
                      doApplyType0corr,
                      sysShiftCorrParameter,
                      doApplySysShiftCorr,
                      jetCorrLabel,
                      varyByNsigmas,
                      postfix):

        if not (makeType1corrPFMEt or makeType1p2corrPFMEt):
            return

        if not hasattr(process, 'producePatPFMETCorrections'):
            process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")

        # If with empty postfix, make a backup of
        # process.producePatPFMETCorrections, because the original
        # sequence will be modified later in this function
        if postfix == "":
            configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, "OriginalReserved")
        else:
            if postfix == "OriginalReserved":
                raise ValueError("Postfix label '%s' is reserved for internal usage !!" % postfix)

            if hasattr(process, "producePatPFMETCorrectionsOriginalReserved"):
                configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrectionsOriginalReserved, postfix, removePostfix="OriginalReserved")
            else:
                configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, postfix)
        
        # add "nominal" (unshifted) pat::MET collections        
        getattr(process, "pfCandsNotInJet" + postfix).bottomCollection = pfCandCollection        
        getattr(process, "selectedPatJetsForMETtype1p2Corr" + postfix).src = shiftedParticleCollections['lastJetCollection']
        getattr(process, "selectedPatJetsForMETtype2Corr" + postfix).src = shiftedParticleCollections['lastJetCollection']
        
        if doApplySysShiftCorr:
            if not hasattr(process, 'pfMEtSysShiftCorrSequence'):
                process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
            if postfix != "":
                configtools.cloneProcessingSnippet(process, process.pfMEtSysShiftCorrSequence, postfix)

            getattr(process, "pfMEtSysShiftCorr" + postfix).parameter = sysShiftCorrParameter
            metUncertaintySequence += getattr(process, "pfMEtSysShiftCorrSequence" + postfix)

        metUncertaintySequence += getattr(process, "producePatPFMETCorrections" + postfix)
        
        patType1correctionsCentralValue = [ cms.InputTag('patPFJetMETtype1p2Corr' + postfix, 'type1') ]
        if doApplyType0corr:
            patType1correctionsCentralValue.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])
        if doApplySysShiftCorr:
            patType1correctionsCentralValue.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])
        getattr(process, "patType1CorrectedPFMet" + postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
        getattr(process, "patType1p2CorrectedPFMet" + postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
        
        collectionsToKeep.extend([
            'patPFMet' + postfix,
            'patType1CorrectedPFMet' + postfix,
            'patType1p2CorrectedPFMet' + postfix])

        setattr(process, "selectedPatJetsForMETtype1p2CorrEnUp" + postfix, 
          getattr(process, shiftedParticleCollections['jetCollectionEnUpForCorrMEt']).clone(
            src = cms.InputTag('selectedPatJetsForMETtype1p2Corr' + postfix)
        ))
        metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrEnUp" + postfix)
        setattr(process, "selectedPatJetsForMETtype1p2CorrEnDown" + postfix,
          getattr(process, shiftedParticleCollections['jetCollectionEnDownForCorrMEt']).clone(
            src = cms.InputTag('selectedPatJetsForMETtype1p2Corr' + postfix)
        ))
        metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrEnDown" + postfix)
        if makeType1p2corrPFMEt:
            setattr(process, "selectedPatJetsForMETtype2CorrEnUp" + postfix,
              getattr(process, shiftedParticleCollections['jetCollectionEnUpForCorrMEt']).clone(
                src = cms.InputTag('selectedPatJetsForMETtype2Corr' + postfix)
            ))
            metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrEnUp" + postfix)
            setattr(process, "selectedPatJetsForMETtype2CorrEnDown" + postfix,
              getattr(process, shiftedParticleCollections['jetCollectionEnDownForCorrMEt']).clone(
                src = cms.InputTag('selectedPatJetsForMETtype2Corr' + postfix)
            ))
            metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrEnDown" + postfix)

        if doSmearJets:
            setattr(process, "selectedPatJetsForMETtype1p2CorrResUp" + postfix,
              getattr(process, shiftedParticleCollections['jetCollectionResUp']).clone(
                src = cms.InputTag('selectedPatJetsForMETtype1p2Corr' + postfix)
            ))
            metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrResUp" + postfix)
            setattr(process, "selectedPatJetsForMETtype1p2CorrResDown" + postfix,
              getattr(process, shiftedParticleCollections['jetCollectionResDown']).clone(
                src = cms.InputTag('selectedPatJetsForMETtype1p2Corr' + postfix)
            ))
            metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrResDown" + postfix)
            if makeType1p2corrPFMEt:            
                setattr(process, "selectedPatJetsForMETtype2CorrResUp" + postfix,
                  getattr(process, shiftedParticleCollections['jetCollectionResUp']).clone(
                    src = cms.InputTag('selectedPatJetsForMETtype2Corr' + postfix)
                ))
                metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrResUp" + postfix)
                setattr(process, "selectedPatJetsForMETtype2CorrResDown" + postfix,
                  getattr(process, shiftedParticleCollections['jetCollectionResDown']).clone(
                    src = cms.InputTag('selectedPatJetsForMETtype2Corr' + postfix)
                ))
                metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrResDown" + postfix)

        if doSmearJets:
            # apply MET smearing to "raw" (uncorrected) MET
            smearedPatPFMetSequence = cms.Sequence()
            setattr(process, "smearedPatPFMetSequence" + postfix, smearedPatPFMetSequence)
            if not hasattr(process, "patPFMetORIGINAL"):
                setattr(process, "patPFMetORIGINAL" + postfix, getattr(process, "patPFMet").clone())
            setattr(process, "patPFMetForMEtUncertainty" + postfix, getattr(process, "patPFMetORIGINAL" + postfix).clone())
            smearedPatPFMetSequence += getattr(process, "patPFMetForMEtUncertainty" + postfix)
            setattr(process, "patPFMETcorrJetSmearing" + postfix, cms.EDProducer("ShiftedParticleMETcorrInputProducer",
                srcOriginal = cms.InputTag(shiftedParticleCollections['cleanedJetCollection']),
                srcShifted = cms.InputTag(shiftedParticleCollections['lastJetCollection'])                                           
            ))
            smearedPatPFMetSequence += getattr(process, "patPFMETcorrJetSmearing" + postfix)
            getattr(process, "producePatPFMETCorrections" + postfix).replace(getattr(process, "patPFMet" + postfix), smearedPatPFMetSequence)
            setattr(process, "patPFMet" + postfix, getattr(process, "patType1CorrectedPFMet" + postfix).clone(
                src = cms.InputTag('patPFMetForMEtUncertainty' + postfix),
                srcType1Corrections = cms.VInputTag(
                    cms.InputTag('patPFMETcorrJetSmearing' + postfix)
                )
            ))
            smearedPatPFMetSequence += getattr(process, "patPFMet" + postfix)
            metUncertaintySequence += smearedPatPFMetSequence 

        # propagate shifts in jet energy to "raw" (uncorrected) and Type 1 corrected MET
        metCollectionsUp_DownForRawMEt = \
            self._propagateMEtUncertainties(
              process, shiftedParticleCollections['lastJetCollection'], "Jet", "En",
              shiftedParticleCollections['jetCollectionEnUpForRawMEt'], shiftedParticleCollections['jetCollectionEnDownForRawMEt'],
              getattr(process, "patPFMet" + postfix), "PF", metUncertaintySequence, postfix)
        collectionsToKeep.extend(metCollectionsUp_DownForRawMEt)

        metCollectionsUp_DownForCorrMEt = \
            self._propagateMEtUncertainties(
              process, shiftedParticleCollections['lastJetCollection'], "Jet", "En",
              shiftedParticleCollections['jetCollectionEnUpForCorrMEt'], shiftedParticleCollections['jetCollectionEnDownForCorrMEt'],
              getattr(process, "patType1CorrectedPFMet" + postfix), "PF", metUncertaintySequence, postfix)
        collectionsToKeep.extend(metCollectionsUp_DownForCorrMEt)

        # propagate shifts in jet energy to Type 1 + 2 corrected MET
        if makeType1p2corrPFMEt:   
            setattr(process, "patPFJetMETtype1p2CorrEnUp" + postfix, getattr(process, "patPFJetMETtype1p2Corr" + postfix).clone(
                src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrEnUp" + postfix).label()),
                jetCorrLabel = cms.string(jetCorrLabel)
            ))
            metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrEnUp" + postfix)
            setattr(process, "patPFJetMETtype1p2CorrEnDown" + postfix, getattr(process, "patPFJetMETtype1p2CorrEnUp" + postfix).clone(
                src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrEnDown" + postfix).label())
            ))
            metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrEnDown" + postfix)
            setattr(process, "patPFJetMETtype2CorrEnUp" + postfix, getattr(process, "patPFJetMETtype2Corr" + postfix).clone(
                src = cms.InputTag('selectedPatJetsForMETtype2CorrEnUp' + postfix)
            ))
            metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrEnUp" + postfix)
            setattr(process, "patPFJetMETtype2CorrEnDown" + postfix,  getattr(process, "patPFJetMETtype2Corr" + postfix).clone(
                src = cms.InputTag('selectedPatJetsForMETtype2CorrEnDown' + postfix)
            ))
            metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrEnDown" + postfix)

            patType1correctionsJetEnUp = [ cms.InputTag('patPFJetMETtype1p2CorrEnUp' + postfix, 'type1') ]        
            if doApplyType0corr:
                patType1correctionsJetEnUp.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])
            if doApplySysShiftCorr:
                patType1correctionsJetEnUp.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])            
            setattr(process, "patType1p2CorrectedPFMetJetEnUp" + postfix, getattr(process, "patType1p2CorrectedPFMet" + postfix).clone(
                srcType1Corrections = cms.VInputTag(patType1correctionsJetEnUp),
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('patPFJetMETtype1p2CorrEnUp' + postfix, 'type2' ),
                    cms.InputTag('patPFJetMETtype2CorrEnUp' + postfix,   'type2' ),
                    cms.InputTag('patPFJetMETtype1p2CorrEnUp' + postfix, 'offset'),
                    cms.InputTag('pfCandMETcorr' + postfix)
                )
            ))
            metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetEnUp" + postfix)
            collectionsToKeep.append('patType1p2CorrectedPFMetJetEnUp' + postfix)
            patType1correctionsJetEnDown = [ cms.InputTag('patPFJetMETtype1p2CorrEnDown' + postfix, 'type1') ]
            if doApplyType0corr:
                patType1correctionsJetEnDown.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])
            if doApplySysShiftCorr:
                patType1correctionsJetEnDown.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])    
            setattr(process, "patType1p2CorrectedPFMetJetEnDown" + postfix, getattr(process, "patType1p2CorrectedPFMetJetEnUp" + postfix).clone(
                srcType1Corrections = cms.VInputTag(patType1correctionsJetEnDown),
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('patPFJetMETtype1p2CorrEnDown' + postfix, 'type2' ),
                    cms.InputTag('patPFJetMETtype2CorrEnDown' + postfix,   'type2' ),
                    cms.InputTag('patPFJetMETtype1p2CorrEnDown' + postfix, 'offset'),
                    cms.InputTag('pfCandMETcorr' + postfix)
                )
            ))
            metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetEnDown" + postfix)
            collectionsToKeep.append('patType1p2CorrectedPFMetJetEnDown' + postfix)

        if doSmearJets:
            # propagate shifts in jet resolution to "raw" (uncorrected) MET and Type 1 corrected MET
            for metProducer in [ getattr(process, "patPFMet" + postfix),
                                 getattr(process, "patType1CorrectedPFMet" + postfix) ]:

                metCollectionsUp_Down = \
                    self._propagateMEtUncertainties(
                      process, shiftedParticleCollections['lastJetCollection'], "Jet", "Res",
                      shiftedParticleCollections['jetCollectionResUp'], shiftedParticleCollections['jetCollectionResDown'],
                      metProducer, "PF", metUncertaintySequence, postfix)
                collectionsToKeep.extend(metCollectionsUp_Down)
            
            # propagate shifts in jet resolution to Type 1 + 2 corrected MET
            if makeType1p2corrPFMEt:  
                setattr(process, "patPFJetMETtype1p2CorrResUp" + postfix, getattr(process, "patPFJetMETtype1p2Corr" + postfix).clone(
                    src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrResUp" + postfix).label()),
                    jetCorrLabel = cms.string(jetCorrLabel)
                ))
                metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrResUp" + postfix)
                setattr(process, "patPFJetMETtype1p2CorrResDown" + postfix, getattr(process, "patPFJetMETtype1p2CorrResUp" + postfix).clone(
                    src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrResDown" + postfix).label())
                ))
                metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrResDown" + postfix)
                setattr(process, "patPFJetMETtype2CorrResUp" + postfix, getattr(process, "patPFJetMETtype2Corr" + postfix).clone(
                    src = cms.InputTag('selectedPatJetsForMETtype2CorrResUp' + postfix)
                ))
                metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrResUp" + postfix)
                setattr(process, "patPFJetMETtype2CorrResDown" + postfix, getattr(process, "patPFJetMETtype2Corr" + postfix).clone(
                    src = cms.InputTag('selectedPatJetsForMETtype2CorrResDown' + postfix)
                ))
                metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrResDown" + postfix)

                patType1correctionsJetResUp = [ cms.InputTag('patPFJetMETtype1p2CorrResUp' + postfix, 'type1') ]
                if doApplyType0corr:
                    patType1correctionsJetResUp.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])
                if doApplySysShiftCorr:
                    patType1correctionsJetResUp.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])
                setattr(process, "patType1p2CorrectedPFMetJetResUp" + postfix,  getattr(process, "patType1p2CorrectedPFMet" + postfix).clone(
                    srcType1Corrections = cms.VInputTag(patType1correctionsJetResUp),
                    srcUnclEnergySums = cms.VInputTag(
                        cms.InputTag('patPFJetMETtype1p2CorrResUp' + postfix, 'type2' ),
                        cms.InputTag('patPFJetMETtype2CorrResUp' + postfix,   'type2' ),
                        cms.InputTag('patPFJetMETtype1p2CorrResUp' + postfix, 'offset'),
                        cms.InputTag('pfCandMETcorr' + postfix)
                    )
                ))
                metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetResUp" + postfix)
                collectionsToKeep.append('patType1p2CorrectedPFMetJetResUp' + postfix)
                patType1correctionsJetResDown = [ cms.InputTag('patPFJetMETtype1p2CorrResDown' + postfix, 'type1') ]
                if doApplyType0corr:
                    patType1correctionsJetResDown.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])
                if doApplySysShiftCorr:
                    patType1correctionsJetResDown.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])
                setattr(process, "patType1p2CorrectedPFMetJetResDown" + postfix, getattr(process, "patType1p2CorrectedPFMetJetResUp" + postfix).clone(
                    srcType1Corrections = cms.VInputTag(patType1correctionsJetResDown),
                    srcUnclEnergySums = cms.VInputTag(
                        cms.InputTag('patPFJetMETtype1p2CorrResDown' + postfix, 'type2' ),
                        cms.InputTag('patPFJetMETtype2CorrResDown' + postfix,   'type2' ),
                        cms.InputTag('patPFJetMETtype1p2CorrResDown' + postfix, 'offset'),
                        cms.InputTag('pfCandMETcorr' + postfix)
                    )
                ))
                metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetResDown" + postfix)
                collectionsToKeep.append('patType1p2CorrectedPFMetJetResDown' + postfix)

        #--------------------------------------------------------------------------------------------
        # shift "unclustered energy" (PFJets of Pt < 10 GeV plus PFCandidates not within jets)
        # and propagate effect of shift to (Type 1 as well as Type 1 + 2 corrected) MET
        #--------------------------------------------------------------------------------------------

        unclEnMETcorrections = [
            [ 'pfCandMETcorr' + postfix, [ '' ] ],
            [ 'patPFJetMETtype1p2Corr' + postfix, [ 'type2', 'offset' ] ],
            [ 'patPFJetMETtype2Corr' + postfix, [ 'type2' ] ],
        ]
        unclEnMETcorrectionsUp = []
        unclEnMETcorrectionsDown = []
        for srcUnclEnMETcorr in unclEnMETcorrections:
            moduleUnclEnMETcorrUp = cms.EDProducer("ShiftedMETcorrInputProducer",
                src = cms.VInputTag(
                    [ cms.InputTag(srcUnclEnMETcorr[0], instanceLabel) for instanceLabel in srcUnclEnMETcorr[1] ]
                ),
                uncertainty = cms.double(0.10),
                shiftBy = cms.double(+1.*varyByNsigmas)
            )
            baseName = srcUnclEnMETcorr[0]
            if postfix != "":
                if baseName[-len(postfix):] == postfix:
                    baseName = baseName[0:-len(postfix)]
                else:
                    raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (postfix, baseName))
            moduleUnclEnMETcorrUpName = "%sUnclusteredEnUp%s" % (baseName, postfix)
            setattr(process, moduleUnclEnMETcorrUpName, moduleUnclEnMETcorrUp)
            metUncertaintySequence += moduleUnclEnMETcorrUp
            unclEnMETcorrectionsUp.extend([ cms.InputTag(moduleUnclEnMETcorrUpName, instanceLabel)
                                            for instanceLabel in srcUnclEnMETcorr[1] ] )
            moduleUnclEnMETcorrDown = moduleUnclEnMETcorrUp.clone(
                shiftBy = cms.double(-1.*varyByNsigmas)
            )
            moduleUnclEnMETcorrDownName = "%sUnclusteredEnDown%s" % (baseName, postfix)
            setattr(process, moduleUnclEnMETcorrDownName, moduleUnclEnMETcorrDown)
            metUncertaintySequence += moduleUnclEnMETcorrDown
            unclEnMETcorrectionsDown.extend([ cms.InputTag(moduleUnclEnMETcorrDownName, instanceLabel)
                                              for instanceLabel in srcUnclEnMETcorr[1] ] )

        # propagate shifts in jet energy/resolution to "raw" (uncorrected) MET    
        setattr(process, "patPFMetUnclusteredEnUp" + postfix, getattr(process, "patType1CorrectedPFMet" + postfix).clone(
            src = cms.InputTag('patPFMet' + postfix),
            srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
        ))
        metUncertaintySequence += getattr(process, "patPFMetUnclusteredEnUp" + postfix)
        collectionsToKeep.append('patPFMetUnclusteredEnUp' + postfix)
        setattr(process, "patPFMetUnclusteredEnDown" + postfix, getattr(process, "patPFMetUnclusteredEnUp" + postfix).clone(
            srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
        ))
        metUncertaintySequence += getattr(process, "patPFMetUnclusteredEnDown" + postfix)
        collectionsToKeep.append('patPFMetUnclusteredEnDown' + postfix)

        # propagate shifts in jet energy/resolution to Type 1 corrected MET
        setattr(process, "patType1CorrectedPFMetUnclusteredEnUp" + postfix, getattr(process, "patType1CorrectedPFMet" + postfix).clone(
            src = cms.InputTag('patType1CorrectedPFMet' + postfix),
            srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
        ))
        metUncertaintySequence += getattr(process, "patType1CorrectedPFMetUnclusteredEnUp" + postfix)
        collectionsToKeep.append('patType1CorrectedPFMetUnclusteredEnUp' + postfix)
        setattr(process, "patType1CorrectedPFMetUnclusteredEnDown" + postfix, getattr(process, "patType1CorrectedPFMetUnclusteredEnUp" + postfix).clone(
            srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
        ))
        metUncertaintySequence += getattr(process, "patType1CorrectedPFMetUnclusteredEnDown" + postfix)
        collectionsToKeep.append('patType1CorrectedPFMetUnclusteredEnDown' + postfix)
        
        # propagate shifts in jet energy/resolution to Type 1 + 2 corrected MET
        if makeType1p2corrPFMEt: 
            setattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp" + postfix, getattr(process, "patType1p2CorrectedPFMet" + postfix).clone(
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('patPFJetMETtype1p2Corr' + postfix,                'type2' ),
                    cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnUp' + postfix, 'type2' ),
                    cms.InputTag('patPFJetMETtype2Corr' + postfix,                  'type2' ),   
                    cms.InputTag('patPFJetMETtype2CorrUnclusteredEnUp' + postfix,   'type2' ),
                    cms.InputTag('patPFJetMETtype1p2Corr' + postfix,                'offset'),
                    cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnUp' + postfix, 'offset'),
                    cms.InputTag('pfCandMETcorr' + postfix),
                    cms.InputTag('pfCandMETcorrUnclusteredEnUp' + postfix)
                )
            ))
            metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp" + postfix)
            collectionsToKeep.append('patType1p2CorrectedPFMetUnclusteredEnUp' + postfix)
            setattr(process, "patType1p2CorrectedPFMetUnclusteredEnDown" + postfix, getattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp" + postfix).clone(
                srcUnclEnergySums = cms.VInputTag(
                    cms.InputTag('patPFJetMETtype1p2Corr' + postfix,                  'type2' ),
                    cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnDown' + postfix, 'type2' ),
                    cms.InputTag('patPFJetMETtype2Corr' + postfix,                    'type2' ),  
                    cms.InputTag('patPFJetMETtype2CorrUnclusteredEnDown' + postfix,   'type2' ),
                    cms.InputTag('patPFJetMETtype1p2Corr' + postfix,                  'offset'),
                    cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnDown' + postfix, 'offset'),
                    cms.InputTag('pfCandMETcorr' + postfix),
                    cms.InputTag('pfCandMETcorrUnclusteredEnDown' + postfix)
                )
            ))
            metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetUnclusteredEnDown" + postfix)
            collectionsToKeep.append('patType1p2CorrectedPFMetUnclusteredEnDown' + postfix)

        #--------------------------------------------------------------------------------------------    
        # propagate shifted electron/photon, muon and tau-jet energies to MET
        #--------------------------------------------------------------------------------------------

        metProducers = [ getattr(process, "patPFMet" + postfix),
                         getattr(process, "patType1CorrectedPFMet" + postfix) ]
        if makeType1p2corrPFMEt:
            metProducers.append( getattr(process, "patType1p2CorrectedPFMet" + postfix) )
        for metProducer in metProducers:
            
            if self._isValidInputTag(shiftedParticleCollections['electronCollection']):
                metCollectionsUp_Down = \
                    self._propagateMEtUncertainties(
                      process, shiftedParticleCollections['electronCollection'].value(), "Electron", "En",
                      shiftedParticleCollections['electronCollectionEnUp'], shiftedParticleCollections['electronCollectionEnDown'],
                      metProducer, "PF", metUncertaintySequence, postfix)
                collectionsToKeep.extend(metCollectionsUp_Down)

            if self._isValidInputTag(shiftedParticleCollections['photonCollection']):
                metCollectionsUp_Down = \
                    self._propagateMEtUncertainties(
                      process, shiftedParticleCollections['photonCollection'].value(), "Photon", "En",
                      shiftedParticleCollections['photonCollectionEnUp'], shiftedParticleCollections['photonCollectionEnDown'],
                      metProducer, "PF", metUncertaintySequence, postfix)
                collectionsToKeep.extend(metCollectionsUp_Down)
                
            if self._isValidInputTag(shiftedParticleCollections['muonCollection']):
                metCollectionsUp_Down = \
                    self._propagateMEtUncertainties(
                      process, shiftedParticleCollections['muonCollection'].value(), "Muon", "En",
                      shiftedParticleCollections['muonCollectionEnUp'], shiftedParticleCollections['muonCollectionEnDown'],
                      metProducer, "PF", metUncertaintySequence, postfix)
                collectionsToKeep.extend(metCollectionsUp_Down)

            if self._isValidInputTag(shiftedParticleCollections['tauCollection']):
                metCollectionsUp_Down = \
                    self._propagateMEtUncertainties(
                      process, shiftedParticleCollections['tauCollection'].value(), "Tau", "En",
                      shiftedParticleCollections['tauCollectionEnUp'], shiftedParticleCollections['tauCollectionEnDown'],
                      metProducer, "PF", metUncertaintySequence, postfix)
                collectionsToKeep.extend(metCollectionsUp_Down)
コード例 #42
0
ファイル: example.py プロジェクト: syuvivida/DelPanjTree_8TeV
if runOnMC is False:
    process.PATCMGSequence.replace(
        process.patMuons,
        process.tunePmuons + process.muonTrackError + process.patMuons)

if runOnMC is True:
    process.PATCMGSequence.replace(
        process.muonMatch,
        process.tunePmuons + process.muonTrackError + process.muonMatch)
    process.muonMatch.src = "tunePmuons"

print 'cloning the jet sequence to build PU chs jets'

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet

process.PATCMGJetCHSSequence = cloneProcessingSnippet(
    process, process.PATCMGJetSequence, 'CHS')
process.PATCMGJetCHSSequence.insert(0, process.ak5PFJetsCHS)
from CMGTools.Common.Tools.visitorUtils import replaceSrc

replaceSrc(process.PATCMGJetCHSSequence, 'ak5PFJets', 'ak5PFJetsCHS')
replaceSrc(process.PATCMGJetCHSSequence, 'particleFlow', 'pfNoPileUp')
jecPayload = 'AK5PFchs'
process.patJetsWithVarCHS.payload = jecPayload
process.patJetCorrFactorsCHS.payload = jecPayload
process.puJetIdCHS.jec = jecPayload
process.cmgPUJetMvaCHS.jec = jecPayload
process.selectedPatJetsCHS.cut = 'pt()>10'

# Change the soft muons? Change the MET?
###
### WW ANALYSIS - PAY ATTENTION TO THIS
コード例 #43
0
    process.p1 = cms.Path(
        reco_object_step *
        process.emulationSequence *
        process.corrjetEfficiency
    )

if options.stage1:
    print "Building Stage1 trees"
    process.p1 += process.leptonEfficiencies

if options.stage1B:
    if options.isTAvg:
        print "Building Stage1B trees"
        # Make a copy of the lepton efficiency trees using stage 1B inputs.
        from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
        process.leptonEfficienciesStage1B = cloneProcessingSnippet(
            process, process.leptonEfficiencies, 'Stage1B')
        # Update input tags to the stage 1B producer
        for stage1BTreeMaker in [#process.isoTauEfficiencyStage1B,
            process.rlxTauEfficiencyStage1B,
            #process.isoEGEfficiencyStage1B,
            process.rlxEGEfficiencyStage1B,
            process.rlxUCTisoL1EGEfficiencyStage1B]:
            stage1BTreeMaker.l1GSrc[0].setModuleLabel("UCTStage1BEfficiencyProducer")
            for branch in stage1b_branches.parameterNames_():
                setattr(stage1BTreeMaker.ntuple, branch,
                        getattr(stage1b_branches, branch))
                # add the computation of stage1b trees
                process.p1 += process.leptonEfficienciesStage1B
    else:
        print "Building Stage1B trees"
        # Make a copy of the lepton efficiency trees using stage 1B inputs.
コード例 #44
0
def addExtraMETCollections(process, unCleanPFCandidateCollection,
                           cleanElectronCollection,
                           cleanPhotonCollection,
                           unCleanElectronCollection,
                           unCleanPhotonCollection ):

    # Muon/EGamma un/corrected pfMET ============
    from PhysicsTools.PatUtils.tools.corMETFromMuonAndEG import corMETFromMuonAndEG
    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncForMiniAODProduction
    
    # uncorrected MET
    cloneProcessingSnippet(process, getattr(process,"makePatJets"),"BackupAllEvents")
    massSearchReplaceAnyInputTag(getattr(process,"makePatJetsBackupAllEvents"), "ak4PFJetsCHS", "ak4PFJetsCHSBackupAllEvents")
    massSearchReplaceAnyInputTag(getattr(process,"makePatJetsBackupAllEvents"), "pfCandidatesBadMuonsCleaned", "particleFlow")
    del process.patJetsBackupAllEvents.userData
    process.patJetsBackupAllEvents.addAssociatedTracks = cms.bool(False)
    process.patJetsBackupAllEvents.addBTagInfo = cms.bool(False)
    process.patJetsBackupAllEvents.addDiscriminators = cms.bool(False)
    process.patJetsBackupAllEvents.addGenJetMatch = cms.bool(False)
    process.patJetsBackupAllEvents.addGenPartonMatch = cms.bool(False)
    process.patJetsBackupAllEvents.addJetCharge = cms.bool(False)
    process.patJetsBackupAllEvents.addJetCorrFactors = cms.bool(True)
    process.patJetsBackupAllEvents.addJetFlavourInfo = cms.bool(False)
    process.patJetsBackupAllEvents.addJetID = cms.bool(False)
    process.patJetsBackupAllEvents.addPartonJetMatch = cms.bool(False)
    process.patJetsBackupAllEvents.addResolutions = cms.bool(False)
    process.patJetsBackupAllEvents.addTagInfos = cms.bool(False)
    process.patJetsBackupAllEvents.discriminatorSources = cms.VInputTag()
    process.patJetsBackupAllEvents.embedGenJetMatch = cms.bool(False)
  
    runMetCorAndUncForMiniAODProduction(process,
                                        metType="PF",
                                        pfCandColl=cms.InputTag(unCleanPFCandidateCollection),
                                        recoMetFromPFCs=True,
                                        jetCollUnskimmed="patJetsBackupAllEvents",
                                        postfix="Uncorrected"
                                        )

    if not hasattr(process, "slimmedMETs"):
        process.load('PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi')
        
    process.slimmedMETsUncorrected = process.slimmedMETs.clone()
    process.slimmedMETsUncorrected.src = cms.InputTag("patPFMetT1Uncorrected")
    process.slimmedMETsUncorrected.rawVariation =  cms.InputTag("patPFMetUncorrected")
    process.slimmedMETsUncorrected.t1Uncertainties = cms.InputTag("patPFMetT1%sUncorrected") 
    process.slimmedMETsUncorrected.t01Variation = cms.InputTag("patPFMetT0pcT1Uncorrected")
    process.slimmedMETsUncorrected.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sUncorrected")
    process.slimmedMETsUncorrected.tXYUncForRaw = cms.InputTag("patPFMetTxyUncorrected")
    process.slimmedMETsUncorrected.tXYUncForT1 = cms.InputTag("patPFMetT1TxyUncorrected")
    process.slimmedMETsUncorrected.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyUncorrected")
    process.slimmedMETsUncorrected.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyUncorrected")
    process.slimmedMETsUncorrected.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyUncorrected")
    del process.slimmedMETsUncorrected.caloMET
    
    # EG corrected MET
    corMETFromMuonAndEG(process,
                        pfCandCollection="", #not needed
                        electronCollection=unCleanElectronCollection,
                        photonCollection=unCleanPhotonCollection,
                        corElectronCollection=cleanElectronCollection,
                        corPhotonCollection=cleanPhotonCollection,
                        allMETEGCorrected=True,
                        muCorrection=False,
                        eGCorrection=True,
                        runOnMiniAOD=False,
                        eGPFix="Uncorrected",
                        postfix="EGOnly"
                        )
    process.slimmedMETsEGClean = process.slimmedMETs.clone()
    process.slimmedMETsEGClean.src = cms.InputTag("patPFMetT1UncorrectedEGOnly")
    process.slimmedMETsEGClean.rawVariation =  cms.InputTag("patPFMetRawUncorrectedEGOnly")
    process.slimmedMETsEGClean.t1Uncertainties = cms.InputTag("patPFMetT1%sUncorrectedEGOnly") 
    process.slimmedMETsEGClean.t01Variation = cms.InputTag("patPFMetT0pcT1UncorrectedEGOnly")
    process.slimmedMETsEGClean.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sUncorrectedEGOnly")
    process.slimmedMETsEGClean.tXYUncForRaw = cms.InputTag("patPFMetTxyUncorrectedEGOnly")
    process.slimmedMETsEGClean.tXYUncForT1 = cms.InputTag("patPFMetT1TxyUncorrectedEGOnly")
    process.slimmedMETsEGClean.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyUncorrectedEGOnly")
    process.slimmedMETsEGClean.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyUncorrectedEGOnly")
    process.slimmedMETsEGClean.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyUncorrectedEGOnly")
    del process.slimmedMETsEGClean.caloMET
 
    # fully corrected MET
    corMETFromMuonAndEG(process,
                        pfCandCollection="", #not needed
                        electronCollection=unCleanElectronCollection,
                        photonCollection=unCleanPhotonCollection,
                        corElectronCollection=cleanElectronCollection,
                        corPhotonCollection=cleanPhotonCollection,
                        allMETEGCorrected=True,
                        muCorrection=False,
                        eGCorrection=True,
                        runOnMiniAOD=False,
                        postfix="MuEGClean"
                        )
    process.slimmedMETsMuEGClean = process.slimmedMETs.clone()
    process.slimmedMETsMuEGClean.src = cms.InputTag("patPFMetT1MuEGClean")
    process.slimmedMETsMuEGClean.rawVariation =  cms.InputTag("patPFMetRawMuEGClean")
    process.slimmedMETsMuEGClean.t1Uncertainties = cms.InputTag("patPFMetT1%sMuEGClean") 
    process.slimmedMETsMuEGClean.t01Variation = cms.InputTag("patPFMetT0pcT1MuEGClean")
    process.slimmedMETsMuEGClean.t1SmearedVarsAndUncs = cms.InputTag("patPFMetT1Smear%sMuEGClean")
    process.slimmedMETsMuEGClean.tXYUncForRaw = cms.InputTag("patPFMetTxyMuEGClean")
    process.slimmedMETsMuEGClean.tXYUncForT1 = cms.InputTag("patPFMetT1TxyMuEGClean")
    process.slimmedMETsMuEGClean.tXYUncForT01 = cms.InputTag("patPFMetT0pcT1TxyMuEGClean")
    process.slimmedMETsMuEGClean.tXYUncForT1Smear = cms.InputTag("patPFMetT1SmearTxyMuEGClean")
    process.slimmedMETsMuEGClean.tXYUncForT01Smear = cms.InputTag("patPFMetT0pcT1SmearTxyMuEGClean")
    del process.slimmedMETsMuEGClean.caloMET

    addKeepStatement(process, "keep *_slimmedMETs_*_*",
                    ["keep *_slimmedMETsUncorrected_*_*", "keep *_slimmedMETsEGClean_*_*", "keep *_slimmedMETsMuEGClean_*_*"])
コード例 #45
0
PFJetsId = cms.EDFilter(
    "TauValPFJetSelector",
    src = cms.InputTag('kinematicSelectedPFJets'),
    cut = cms.string("chargedHadronEnergyFraction > 0.0 & neutralHadronEnergyFraction < 0.99 & neutralHadronEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & neutralEmEnergyFraction < 0.99 & chargedMultiplicity > 0 & nConstituents > 1"),
    filter = cms.bool(False)
	)

CleanedPFJets = cms.EDProducer("TauValJetViewCleaner",
    srcObject            = cms.InputTag( "kinematicSelectedPFJets" ),
    srcObjectsToRemove   = cms.VInputTag( cms.InputTag("muons"), cms.InputTag("gedGsfElectrons") ),
    deltaRMin            = cms.double(0.15)
)

procAttributes = dir(proc) #Takes a snapshot of what there in the process
helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealData') #clones the sequence inside the process with RealData postfix
helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealData') #clones the sequence inside the process with RealData postfix
helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealData, 'kinematicSelectedTauValDenominator', 'CleanedPFJets') #sets the correct input tag

#adds to TauValNumeratorAndDenominator modules in the sequence RealData to the extention name
zttLabeler = lambda module : SetValidationExtention(module, 'RealData')
zttModifier = ApplyFunctionToSequence(zttLabeler)
proc.TauValNumeratorAndDenominatorRealData.visit(zttModifier)

binning = cms.PSet(
	pt = cms.PSet( nbins = cms.int32(25), min = cms.double(0.), max = cms.double(250.) ), #hinfo(75, 0., 150.)
	eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
	phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
	pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
	)
zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
コード例 #46
0
addMETSig(process, postfixAK5)

# ---------------- Sequence AK5LC, lepton x-cleaning ---------------

# PF2PAT+PAT sequence 2:
# lepton cleaning, AK5PFJets. This sequence is a clone of the AK5 sequence defined previously.
# just modifying the x-cleaning parameters, and the isolation cut for x-cleaning

if runAK5LC:
    print 'cloning AK5 sequence to prepare AK5LC sequence...'

    from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
    postfixLC = 'LC'
    # just cloning the first sequence, and enabling lepton cleaning
    cloneProcessingSnippet(process,
                           getattr(process, 'patPF2PATSequence' + postfixAK5),
                           postfixLC)

    postfixAK5LC = postfixAK5 + postfixLC
    getattr(process, "pfNoMuon" + postfixAK5LC).enable = True
    getattr(process, "pfNoElectron" + postfixAK5LC).enable = True
    getattr(process, "pfIsolatedMuons" + postfixAK5LC).isolationCut = 0.2
    getattr(process, "pfIsolatedElectrons" + postfixAK5LC).isolationCut = 0.2

    #COLIN : need to add the VBTF e and mu id

    # configure MET significance
    getattr(process, "PFMETSignificance" +
            postfixAK5LC).inputPATElectrons = cms.InputTag('patElectrons' +
                                                           postfixAK5LC)
    getattr(process, "PFMETSignificance" +
def configurePatTupleProduction(process,
                                patSequenceBuilder=buildGenericTauSequence,
                                patPFTauCleanerPrototype=None,
                                patCaloTauCleanerPrototype=None,
                                addSVfitInfo=False,
                                hltProcess="HLT",
                                isMC=False,
                                applyTauVertexMatch=True):

    # check that patSequenceBuilder and patTauCleanerPrototype are defined and non-null
    if patSequenceBuilder is None:
        raise ValueError("Undefined 'patSequenceBuilder' Parameter !!")
    if patPFTauCleanerPrototype is None or patCaloTauCleanerPrototype is None:
        raise ValueError("Undefined 'patTauCleanerPrototype' Parameter !!")

    #--------------------------------------------------------------------------------
    # produce PAT objects
    #--------------------------------------------------------------------------------

    process.load("PhysicsTools.PatAlgos.patSequences_cff")
    process.load("PhysicsTools.PatAlgos.producersLayer1.tauProducer_cff")
    process.load("PhysicsTools.PatAlgos.producersLayer1.muonProducer_cff")
    process.load("PhysicsTools.PatAlgos.producersLayer1.metProducer_cff")
    process.load("TauAnalysis.CandidateTools.muTauPairProduction_cff")

    # per default, do **not** run SVfit algorithm
    if not addSVfitInfo:
        process.allMuTauPairs.doSVreco = cms.bool(False)
        process.allMuTauPairs.doPFMEtSign = cms.bool(False)
        process.allMuTauPairsLooseMuonIsolation.doSVreco = cms.bool(False)
        process.allMuTauPairsLooseMuonIsolation.doPFMEtSign = cms.bool(False)

    if not isMC:
        removeMCMatching(process, ["All"], outputModules=[])
    else:
        # match pat::Taus to all genJets
        # (including to genJets build from electrons/muons produced in tau --> e/mu decays)
        process.tauGenJetMatch.matched = cms.InputTag("tauGenJets")

    #--------------------------------------------------------------------------------
    # configure PAT trigger matching
    switchOnTrigger(process, hltProcess=hltProcess, outputModule='')
    # CV: disable L1Algos in MC for now, to prevent error messages
    #
    #     %MSG-e L1GlobalTriggerObjectMapRecord:  PATTriggerProducer:patTrigger
    #
    #       ERROR: The requested algorithm name = L1_DoubleEG1
    #       does not exists in the trigger menu.
    #       Returning zero pointer for getObjectMap
    #
    #     to be printed for every event (06/05/2011)
    #
    #     for Data the L1Algos flag needs to be enabled,
    #     in order for the prescale computation/correction for Data
    #     implemented in TauAnalysis/TauIdEfficiency/bin/FWLiteTauIdEffAnalyzer.cc to work
    if isMC:
        process.patTrigger.addL1Algos = cms.bool(False)
    else:
        process.patTrigger.addL1Algos = cms.bool(True)

    process.patTauTriggerMatchHLTprotoType = cms.EDProducer(
        "PATTriggerMatcherDRLessByR",
        src=cms.InputTag("cleanLayer1Taus"),
        matched=cms.InputTag("patTrigger"),
        matchedCuts=cms.string('path("HLT_Jet30_v*")'),
        maxDPtRel=cms.double(1.e+3),
        maxDeltaR=cms.double(0.5),
        resolveAmbiguities=cms.bool(True),
        resolveByMatchQuality=cms.bool(True))
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    # compute Pt sum of charged + neutral hadrons and photons within isolation cones of size dR = 0.4/0.6

    process.load("RecoMuon/MuonIsolation/muonPFIsolation_cff")
    patutils.massSearchReplaceAnyInputTag(
        process.muonPFIsolationDepositsSequence, cms.InputTag('muons1stStep'),
        cms.InputTag('muons'))
    process.patMuons.isoDeposits = cms.PSet(
        # CV: strings for IsoDeposits defined in PhysicsTools/PatAlgos/plugins/PATMuonProducer.cc
        pfChargedHadrons=cms.InputTag("muPFIsoDepositCharged"),
        pfNeutralHadrons=cms.InputTag("muPFIsoDepositNeutral"),
        pfPhotons=cms.InputTag("muPFIsoDepositGamma"),
        user=cms.VInputTag(cms.InputTag("muPFIsoDepositChargedAll"),
                           cms.InputTag("muPFIsoDepositPU")))

    process.patMuons.userIsolation = cms.PSet(
        # CV: strings for Isolation values defined in PhysicsTools/PatAlgos/src/MultiIsolator.cc
        pfChargedHadron=cms.PSet(
            deltaR=cms.double(0.4),
            src=process.patMuons.isoDeposits.pfChargedHadrons,
            vetos=process.muPFIsoValueCharged04.deposits[0].vetos,
            skipDefaultVeto=process.muPFIsoValueCharged04.deposits[0].
            skipDefaultVeto),
        pfNeutralHadron=cms.PSet(
            deltaR=cms.double(0.4),
            src=process.patMuons.isoDeposits.pfNeutralHadrons,
            vetos=process.muPFIsoValueNeutral04.deposits[0].vetos,
            skipDefaultVeto=process.muPFIsoValueNeutral04.deposits[0].
            skipDefaultVeto),
        pfGamma=cms.PSet(deltaR=cms.double(0.4),
                         src=process.patMuons.isoDeposits.pfPhotons,
                         vetos=process.muPFIsoValueGamma04.deposits[0].vetos,
                         skipDefaultVeto=process.muPFIsoValueGamma04.
                         deposits[0].skipDefaultVeto),
        user=cms.VPSet(
            cms.PSet(deltaR=cms.double(0.4),
                     src=process.patMuons.isoDeposits.user[0],
                     vetos=process.muPFIsoValueChargedAll04.deposits[0].vetos,
                     skipDefaultVeto=process.muPFIsoValueChargedAll04.
                     deposits[0].skipDefaultVeto),
            cms.PSet(deltaR=cms.double(0.4),
                     src=process.patMuons.isoDeposits.user[1],
                     vetos=process.muPFIsoValuePU04.deposits[0].vetos,
                     skipDefaultVeto=process.muPFIsoValuePU04.deposits[0].
                     skipDefaultVeto)))

    process.patMuonsWithinAcc = cms.EDFilter(
        "PATMuonSelector",
        src=cms.InputTag('patMuons'),
        cut=cms.string("pt > 15. & abs(eta) < 2.1"),
        filter=cms.bool(False))
    process.selectedPatMuonsVBTFid = cms.EDFilter(
        "PATMuonIdSelector",
        src=cms.InputTag('patMuonsWithinAcc'),
        vertexSource=cms.InputTag('selectedPrimaryVertexPosition'),
        beamSpotSource=cms.InputTag('offlineBeamSpot'),
        filter=cms.bool(False))
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # produce collections of pat::Jets for CaloJets and PFJets
    #
    # NOTE: needed for evaluating jetId for Calo/TCTaus and PFTaus
    #
    jec = ['L1FastJet', 'L2Relative', 'L3Absolute']
    if not isMC:
        jec.extend(['L2L3Residual'])

    addJetCollection(process,
                     cms.InputTag('ak5PFJets'),
                     'AK5',
                     'PF',
                     doJTA=False,
                     doBTagging=False,
                     jetCorrLabel=('AK5PF', cms.vstring(jec)),
                     doType1MET=False,
                     genJetCollection=cms.InputTag("ak5GenJets"),
                     doJetID=True,
                     jetIdLabel="ak5",
                     outputModules=[])

    addJetCollection(process,
                     cms.InputTag('ak5CaloJets'),
                     'AK5',
                     'Calo',
                     doJTA=False,
                     doBTagging=False,
                     jetCorrLabel=('AK5Calo', cms.vstring(jec)),
                     doType1MET=False,
                     genJetCollection=cms.InputTag("ak5GenJets"),
                     doJetID=True,
                     jetIdLabel="ak5",
                     outputModules=[])
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # configure Jet Energy Corrections
    #
    process.load("TauAnalysis.Configuration.jetCorrectionParameters_cfi")
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    # add pfMET
    process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")
    if isMC:
        import PhysicsTools.PatAlgos.tools.helpers as configtools
        configtools.cloneProcessingSnippet(process,
                                           process.producePatPFMETCorrections,
                                           "NoSmearing")
        process.selectedPatJetsForMETtype1p2CorrNoSmearing.src = cms.InputTag(
            'patJetsNotOverlappingWithLeptonsForMEtUncertainty')
        process.selectedPatJetsForMETtype2CorrNoSmearing.src = process.selectedPatJetsForMETtype1p2CorrNoSmearing.src

    process.patMEtProductionSequence = cms.Sequence()
    process.patMEtProductionSequence += process.patDefaultSequence

    from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties
    doSmearJets = None
    if isMC:
        doSmearJets = True
    else:
        doSmearJets = False
    runMEtUncertainties(
        process,
        electronCollection='',
        photonCollection='',
        muonCollection=cms.InputTag('selectedPatMuonsVBTFid'),
        tauCollection='',
        jetCollection=cms.InputTag('patJetsAK5PF'),
        doSmearJets=doSmearJets,
        doApplyType0corr=True,
        sysShiftCorrParameter=None,
        doApplySysShiftCorr=False,
        # CV: shift Jet energy by 3 standard-deviations,
        #     so that template morphing remains an interpolation and no extrapolation is needed
        varyByNsigmas=3.0,
        addToPatDefaultSequence=False)

    if isMC:
        process.patPFMet.addGenMET = cms.bool(True)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L3Absolute")

        process.patMEtProductionSequence += process.metUncertaintySequence
    else:
        process.patPFMet.addGenMET = cms.bool(False)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string(
            "L2L3Residual")

        process.patMEtProductionSequence += process.patJetsAK5PFnotOverlappingWithLeptonsForMEtUncertainty
        process.patMEtProductionSequence += process.producePatPFMETCorrections
    #--------------------------------------------------------------------------------

    pfJetCollection = 'patJetsAK5PFnotOverlappingWithLeptonsForMEtUncertainty'
    pfMEtCollection = 'patType1CorrectedPFMet'
    if isMC:
        pfJetCollection = 'smearedPatJetsAK5PF'

    #--------------------------------------------------------------------------------
    #
    # produce combinations of muon + tau-jet pairs
    # for collection of pat::Tau objects representing CaloTaus
    #
    switchToCaloTau(process)
    process.patCaloTauProducer = copy.deepcopy(process.patTaus)

    retVal_caloTau = patSequenceBuilder(
        process,
        collectionName=["patCaloTaus", ""],
        jetCollectionName="patJetsAK5Calo",
        patTauProducerPrototype=process.patCaloTauProducer,
        patTauCleanerPrototype=patCaloTauCleanerPrototype,
        triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType,
        addGenInfo=isMC,
        applyTauJEC=False,
        applyTauVertexMatch=applyTauVertexMatch)
    process.caloTauSequence = retVal_caloTau["sequence"]

    process.patMuonCaloTauPairs = process.allMuTauPairs.clone(
        srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'),
        srcLeg2=cms.InputTag(retVal_caloTau["collection"]),
        srcMET=cms.InputTag('patMETs'),
        srcGenParticles=cms.InputTag(''),
        doSVreco=cms.bool(False),
        doPFMEtSign=cms.bool(False))
    if hasattr(process.patMuonCaloTauPairs, "nSVfit"):
        delattr(process.patMuonCaloTauPairs, "nSVfit")
    if hasattr(process.patMuonCaloTauPairs, "pfMEtSign"):
        delattr(process.patMuonCaloTauPairs, "pfMEtSign")
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # produce collection of pat::Tau objects representing PFTaus
    # reconstructed by fixed signal cone algorithm
    # (plus combinations of muon + tau-jet pairs)
    #
    #switchToPFTauFixedCone(process)
    #process.patPFTauProducerFixedCone = copy.deepcopy(process.patTaus)
    #
    #retVal_pfTauFixedCone = patSequenceBuilder(
    #    process,
    #    collectionName = [ "patPFTaus", "FixedCone" ],
    #    jetCollectionName = pfJetCollection,
    #    patTauProducerPrototype = process.patPFTauProducerFixedCone,
    #    patTauCleanerPrototype = patPFTauCleanerPrototype,
    #    triggerMatcherProtoType = process.patTauTriggerMatchHLTprotoType,
    #    addGenInfo = isMC,
    #    applyTauJEC = False,
    #    applyTauVertexMatch = applyTauVertexMatch
    #)
    #process.pfTauSequenceFixedCone = retVal_pfTauFixedCone["sequence"]
    #
    #process.patMuonPFTauPairsFixedCone = process.allMuTauPairs.clone(
    #    srcLeg1 = cms.InputTag('selectedPatMuonsVBTFid'),
    #    srcLeg2 = cms.InputTag(retVal_pfTauFixedCone["collection"]),
    #    srcMET = cms.InputTag(pfMEtCollection),
    #    srcGenParticles = cms.InputTag(''),
    #    doSVreco = cms.bool(False)
    #)
    #if hasattr(process.patMuonPFTauPairsFixedCone, "nSVfit"):
    #    delattr(process.patMuonPFTauPairsFixedCone, "nSVfit")
    #if hasattr(process.patMuonPFTauPairsFixedCone, "pfMEtSign"):
    #    delattr(process.patMuonPFTauPairsFixedCone, "pfMEtSign")
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # produce collection of pat::Tau objects representing PFTaus
    # reconstructed by shrinking signal cone algorithm
    # (plus combinations of muon + tau-jet pairs)
    #
    #switchToPFTauShrinkingCone(process)
    #process.patPFTauProducerShrinkingCone = copy.deepcopy(process.patTaus)
    #
    #retVal_pfTauShrinkingCone = patSequenceBuilder(
    #    process,
    #    collectionName = [ "patPFTaus", "ShrinkingCone" ],
    #    jetCollectionName = pfJetCollection,
    #    patTauProducerPrototype = process.patPFTauProducerShrinkingCone,
    #    patTauCleanerPrototype = patPFTauCleanerPrototype,
    #    triggerMatcherProtoType = process.patTauTriggerMatchHLTprotoType,
    #    addGenInfo = isMC,
    #    applyTauJEC = False,
    #    applyTauVertexMatch = applyTauVertexMatch
    #)
    #process.pfTauSequenceShrinkingCone = retVal_pfTauShrinkingCone["sequence"]
    #
    #process.patMuonPFTauPairsShrinkingCone = process.allMuTauPairs.clone(
    #    srcLeg1 = cms.InputTag('selectedPatMuonsVBTFid'),
    #    srcLeg2 = cms.InputTag(retVal_pfTauShrinkingCone["collection"]),
    #    srcMET = cms.InputTag(pfMEtCollection),
    #    srcGenParticles = cms.InputTag(''),
    #    doSVreco = cms.bool(False)
    #)
    #if hasattr(process.patMuonPFTauPairsShrinkingCone, "nSVfit"):
    #    delattr(process.patMuonPFTauPairsShrinkingCone, "nSVfit")
    #if hasattr(process.patMuonPFTauPairsShrinkingCone, "pfMEtSign"):
    #    delattr(process.patMuonPFTauPairsShrinkingCone, "pfMEtSign")
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # produce collection of pat::Tau objects representing PFTaus
    # reconstructed by hadron + strips (HPS) algorithm
    # (plus combinations of muon + tau-jet pairs)
    #
    # NOTE: switchToPFTauHPS function overwrites process.cleanPatTaus.preselection using HPS specific discriminators;
    #       undo overwriting, in order to prevent run-time errors in case of subsequence _switchToPFTau call,
    #       arising from the fact that HPS specific discriminators are not available for all tau types
    #
    switchToPFTauHPS(process)
    process.cleanPatTaus.preselection = cms.string('')
    process.patPFTauProducerHPS = copy.deepcopy(process.patTaus)

    retVal_pfTauHPS = patSequenceBuilder(
        process,
        collectionName=["patPFTaus", "HPS"],
        jetCollectionName=pfJetCollection,
        patTauProducerPrototype=process.patPFTauProducerHPS,
        patTauCleanerPrototype=patPFTauCleanerPrototype,
        triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType,
        addGenInfo=isMC,
        applyTauJEC=True,
        applyTauVertexMatch=applyTauVertexMatch)
    process.pfTauSequenceHPS = retVal_pfTauHPS["sequence"]

    process.patMuonPFTauPairsHPS = process.allMuTauPairs.clone(
        srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'),
        srcLeg2=cms.InputTag(retVal_pfTauHPS["collection"]),
        srcMET=cms.InputTag(pfMEtCollection),
        srcGenParticles=cms.InputTag(''),
        doSVreco=cms.bool(False))
    if hasattr(process.patMuonPFTauPairsHPS, "nSVfit"):
        delattr(process.patMuonPFTauPairsHPS, "nSVfit")
    if hasattr(process.patMuonPFTauPairsHPS, "pfMEtSign"):
        delattr(process.patMuonPFTauPairsHPS, "pfMEtSign")
    #--------------------------------------------------------------------------------

    #--------------------------------------------------------------------------------
    #
    # produce collection of pat::Tau objects representing PFTaus
    # reconstructed by HPS + TaNC combined tau id. algorithm
    # (plus combinations of muon + tau-jet pairs)
    #
    switchToPFTauHPSpTaNC(process)
    process.cleanPatTaus.preselection = cms.string('')
    process.patPFTauProducerHPSpTaNC = copy.deepcopy(process.patTaus)

    retVal_pfTauHPSpTaNC = patSequenceBuilder(
        process,
        collectionName=["patPFTaus", "HPSpTaNC"],
        jetCollectionName=pfJetCollection,
        patTauProducerPrototype=process.patPFTauProducerHPSpTaNC,
        patTauCleanerPrototype=patPFTauCleanerPrototype,
        triggerMatcherProtoType=process.patTauTriggerMatchHLTprotoType,
        addGenInfo=isMC,
        applyTauJEC=True,
        applyTauVertexMatch=applyTauVertexMatch)
    process.pfTauSequenceHPSpTaNC = retVal_pfTauHPSpTaNC["sequence"]

    process.patMuonPFTauPairsHPSpTaNC = process.allMuTauPairs.clone(
        srcLeg1=cms.InputTag('selectedPatMuonsVBTFid'),
        srcLeg2=cms.InputTag(retVal_pfTauHPSpTaNC["collection"]),
        srcMET=cms.InputTag(pfMEtCollection),
        srcGenParticles=cms.InputTag(''),
        doSVreco=cms.bool(False))
    if hasattr(process.patMuonPFTauPairsHPSpTaNC, "nSVfit"):
        delattr(process.patMuonPFTauPairsHPSpTaNC, "nSVfit")
    if hasattr(process.patMuonPFTauPairsHPSpTaNC, "pfMEtSign"):
        delattr(process.patMuonPFTauPairsHPSpTaNC, "pfMEtSign")
    #--------------------------------------------------------------------------------

    process.patTupleProductionSequence = cms.Sequence(
        process.muonPFIsolationSequence + process.patDefaultSequence
        ##+ process.patTrigger + process.patTriggerEvent
        + process.patMuonsWithinAcc + process.selectedPatMuonsVBTFid +
        process.patMEtProductionSequence + process.caloTauSequence
        # store TaNC inputs as discriminators
        #+ process.produceTancMVAInputDiscriminators
        #+ process.pfTauSequenceFixedCone
        #+ process.pfTauSequenceShrinkingCone
        + process.pfTauSequenceHPS + process.pfTauSequenceHPSpTaNC +
        process.patMuonCaloTauPairs
        #+ process.patMuonPFTauPairsFixedCone
        #+ process.patMuonPFTauPairsShrinkingCone
        + process.patMuonPFTauPairsHPS + process.patMuonPFTauPairsHPSpTaNC)

    # return names of "final" collections of CaloTaus/different types of PFTaus
    # to be used as InputTag for further processing
    retVal = {}
    retVal["caloTauCollection"] = retVal_caloTau["collection"]
    retVal["muonCaloTauCollection"] = process.patMuonCaloTauPairs.label()
    #retVal["pfTauCollectionFixedCone"] = retVal_pfTauFixedCone["collection"]
    #retVal["muonPFTauCollectionFixedCone"] = process.patMuonPFTauPairsFixedCone.label()
    #retVal["pfTauCollectionShrinkingCone"] = retVal_pfTauShrinkingCone["collection"]
    #retVal["muonPFTauCollectionShrinkingCone"] = process.patMuonPFTauPairsShrinkingCone.label()
    retVal["pfTauCollectionHPS"] = retVal_pfTauHPS["collection"]
    retVal["muonPFTauCollectionHPS"] = process.patMuonPFTauPairsHPS.label()
    retVal["pfTauCollectionHPSpTaNC"] = retVal_pfTauHPSpTaNC["collection"]
    retVal[
        "muonPFTauCollectionHPSpTaNC"] = process.patMuonPFTauPairsHPSpTaNC.label(
        )
    return retVal
コード例 #48
0
def reconfigurePF2PATTaus(
        process,
        tauType='shrinkingConePFTau',
        pf2patSelection=[
            "DiscriminationByIsolation", "DiscriminationByLeadingPionPtCut"
        ],
        selectionDependsOn=["DiscriminationByLeadingTrackFinding"],
        producerFromType=lambda producer: producer + "Producer",
        postfix=""):
    print "patTaus will be produced from taus of type: %s that pass %s" \
   % (tauType, pf2patSelection)

    #get baseSequence
    baseSequence = getattr(process, "pfTausBaseSequence" + postfix)
    #clean baseSequence from old modules
    for oldBaseModuleName in baseSequence.moduleNames():
        oldBaseModule = getattr(process, oldBaseModuleName)
        baseSequence.remove(oldBaseModule)

    # Get the prototype of tau producer to make, i.e. fixedConePFTauProducer
    producerName = producerFromType(tauType)
    # Set as the source for the pf2pat taus (pfTaus) selector
    applyPostfix(process, "pfTaus", postfix).src = producerName + postfix
    # Start our pf2pat taus base sequence
    oldTauSansRefs = getattr(process, 'pfTausProducerSansRefs' + postfix)
    oldTau = getattr(process, 'pfTausProducer' + postfix)
    ## copy tau and setup it properly
    newTauSansRefs = None
    newTau = getattr(process, producerName).clone()
    ## adapted to new structure in RecoTauProducers PLEASE CHECK!!!
    if tauType == 'shrinkingConePFTau':
        newTauSansRefs = getattr(process, producerName + "SansRefs").clone()
        newTauSansRefs.modifiers[1] = cms.PSet(
            pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix),
            name=cms.string('pfTauTTIworkaround' + postfix),
            plugin=cms.string('RecoTauTagInfoWorkaroundModifer'))
        newTau.modifiers[1] = newTauSansRefs.modifiers[1]
        newTauSansRefs.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix
        newTau.piZeroSrc = newTauSansRefs.piZeroSrc
        newTauSansRefs.builders[0].pfCandSrc = oldTauSansRefs.builders[
            0].pfCandSrc
        newTauSansRefs.jetRegionSrc = oldTauSansRefs.jetRegionSrc
        newTauSansRefs.jetSrc = oldTauSansRefs.jetSrc
    elif tauType == 'fixedConePFTau':
        newTau.piZeroSrc = "pfJetsLegacyTaNCPiZeros" + postfix
    elif tauType == 'hpsPFTau':
        newTau = process.combinatoricRecoTaus.clone()
        newTau.piZeroSrc = "pfJetsLegacyHPSPiZeros" + postfix
        newTau.modifiers[3] = cms.PSet(
            pfTauTagInfoSrc=cms.InputTag("pfTauTagInfoProducer" + postfix),
            name=cms.string('pfTauTTIworkaround' + postfix),
            plugin=cms.string('RecoTauTagInfoWorkaroundModifer'))
        from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
        cloneProcessingSnippet(process, process.produceHPSPFTaus, postfix)
        massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix),
                               "PFTauProducer",
                               cms.InputTag("combinatoricRecoTaus"),
                               cms.InputTag("pfTausBase" + postfix))
        massSearchReplaceParam(getattr(process, "produceHPSPFTaus" + postfix),
                               "src", cms.InputTag("combinatoricRecoTaus"),
                               cms.InputTag("pfTausBase" + postfix))

    newTau.builders[0].pfCandSrc = oldTau.builders[0].pfCandSrc
    newTau.jetRegionSrc = oldTau.jetRegionSrc
    newTau.jetSrc = oldTau.jetSrc

    # replace old tau producer by new one put it into baseSequence
    setattr(process, "pfTausBase" + postfix, newTau)
    if tauType == 'shrinkingConePFTau':
        setattr(process, "pfTausBaseSansRefs" + postfix, newTauSansRefs)
        getattr(process,
                "pfTausBase" + postfix).src = "pfTausBaseSansRefs" + postfix
        baseSequence += getattr(process, "pfTausBaseSansRefs" + postfix)
    baseSequence += getattr(process, "pfTausBase" + postfix)
    if tauType == 'hpsPFTau':
        baseSequence += getattr(process, "produceHPSPFTaus" + postfix)
    #make custom mapper to take postfix into account (could have gone with lambda of lambda but... )
    def producerIsTauTypeMapperWithPostfix(tauProducer):
        return lambda x: producerIsTauTypeMapper(tauProducer) + x.group(
            1) + postfix

    def recoTauTypeMapperWithGroup(tauProducer):
        return "%s(.*)" % recoTauTypeMapper(tauProducer)

    # Get our prediscriminants
    for predisc in selectionDependsOn:
        # Get the prototype
        originalName = tauType + predisc  # i.e. fixedConePFTauProducerDiscriminationByLeadingTrackFinding
        clonedName = "pfTausBase" + predisc + postfix
        clonedDisc = getattr(process, originalName).clone()
        # Register in our process
        setattr(process, clonedName, clonedDisc)
        baseSequence += getattr(process, clonedName)

        tauCollectionToSelect = None
        if tauType != 'hpsPFTau':
            tauCollectionToSelect = "pfTausBase" + postfix
            #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
        else:
            tauCollectionToSelect = "hpsPFTauProducer" + postfix
        # Adapt this discriminator for the cloned prediscriminators
        adaptTauDiscriminator(
            clonedDisc,
            newTauProducer="pfTausBase",
            oldTauTypeMapper=recoTauTypeMapperWithGroup,
            newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
            preservePFTauProducer=True)
        clonedDisc.PFTauProducer = tauCollectionToSelect

    # Reconfigure the pf2pat PFTau selector discrimination sources
    applyPostfix(process, "pfTaus", postfix).discriminators = cms.VPSet()
    for selection in pf2patSelection:
        # Get our discriminator that will be used to select pfTaus
        originalName = tauType + selection
        clonedName = "pfTausBase" + selection + postfix
        clonedDisc = getattr(process, originalName).clone()
        # Register in our process
        setattr(process, clonedName, clonedDisc)

        tauCollectionToSelect = None

        if tauType != 'hpsPFTau':
            tauCollectionToSelect = cms.InputTag("pfTausBase" + postfix)
            #cms.InputTag(clonedDisc.PFTauProducer.value()+postfix)
        else:
            tauCollectionToSelect = cms.InputTag("hpsPFTauProducer" + postfix)
        #Adapt our cloned discriminator to the new prediscriminants
        adaptTauDiscriminator(
            clonedDisc,
            newTauProducer="pfTausBase",
            oldTauTypeMapper=recoTauTypeMapperWithGroup,
            newTauTypeMapper=producerIsTauTypeMapperWithPostfix,
            preservePFTauProducer=True)
        clonedDisc.PFTauProducer = tauCollectionToSelect
        baseSequence += clonedDisc
        # Add this selection to our pfTau selectors
        applyPostfix(process, "pfTaus", postfix).discriminators.append(
            cms.PSet(discriminator=cms.InputTag(clonedName),
                     selectionCut=cms.double(0.5)))
        # Set the input of the final selector.
        if tauType != 'hpsPFTau':
            applyPostfix(process, "pfTaus",
                         postfix).src = "pfTausBase" + postfix
        else:
            # If we are using HPS taus, we need to take the output of the clenaed
            # collection
            applyPostfix(process, "pfTaus",
                         postfix).src = "hpsPFTauProducer" + postfix
コード例 #49
0
def createPatMETModules(process, metType, metPatSequence, applyT1Cor=False, 
                        applyT2Cor=False, applyT0pcCor=False, applyXYShiftCor=False, 
                        applyUncEnCalib=False,sysShiftCorrParameter=cms.VPSet(), postfix=""):

    ##FIXME: postfix is set to null as the whoelsequence receive it later
    postfix=""

    if applyUncEnCalib :
        applyT2Cor = True

    ## standard naming convention
    metModName = "pat"+metType+"Met"
    metModNameT1=metModName
    metModNameT1T2=metModName
    if applyT0pcCor :
        metModNameT1 += "T0pc"
        metModNameT1T2 += "T0pc"
    metModNameT1 += "T1"
    metModNameT1T2 += "T1T2"
    if applyXYShiftCor :
        metModNameT1 += "Txy"
        metModNameT1T2 += "Txy"
    # disabled spec. name for the moment as it just modifies the type2 MET
  #  if applyUncEnCalib :
  #      metModNameT1 += "UEC"
  #      metModNameT1T2 += "UEC"


    #plug the MET modules in to the sequence
    setattr(process, metModName,  getattr(process, metModName ) )
    if applyT1Cor :
        setattr(process, metModNameT1+postfix, getattr(process, metModNameT1 ).clone(
                src = cms.InputTag(metModName + postfix) 
                ))
        metPatSequence += getattr(process, metModNameT1+postfix)
    if applyT2Cor :
        setattr(process, metModNameT1T2+postfix, getattr(process, metModNameT1T2 ).clone(
                src = cms.InputTag(metModName + postfix) 
                ) )
        metPatSequence += getattr(process, metModNameT1T2+postfix)

    patMetCorrectionsCentralValue = []


    #Type0 for pfT1 and pfT1T2 MET
    if metType == "PF":
        patMetCorrectionsCentralValue = [ cms.InputTag('patPFJetMETtype1p2Corr' + postfix, 'type1') ]
        if applyT0pcCor :
            patMetCorrectionsCentralValue.extend([ cms.InputTag('patPFMETtype0Corr' + postfix) ])


    # compute XY shift correction if asked, and configure the tool accordingly
    if applyXYShiftCor :
        if not hasattr(process, 'pfMEtSysShiftCorrSequence'):
            process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
        if postfix != "":
            configtools.cloneProcessingSnippet(process, process.pfMEtSysShiftCorrSequence, postfix)

        getattr(process, "pfMEtSysShiftCorr" + postfix).parameter = sysShiftCorrParameter
        metPatSequence += getattr(process, "pfMEtSysShiftCorrSequence" + postfix)

        patMetCorrectionsCentralValue.extend([ cms.InputTag('pfMEtSysShiftCorr' + postfix) ])
        

    #finalize T1/T2 correction process
    if applyT1Cor :
        getattr(process, metModNameT1 + postfix).srcType1Corrections = cms.VInputTag(patMetCorrectionsCentralValue)
    if applyT2Cor :
        getattr(process, metModNameT1T2 + postfix).srcType1Corrections = cms.VInputTag(patMetCorrectionsCentralValue)


    # Apply unclustered energy calibration on pfMET T1T2 if asked -> discard type2 and replace it with 
    # calibration computed with the jet residual correction
    if metType == "PF":
        if applyUncEnCalib:
            applyUnclEnergyCalibrationOnPfT1T2Met(process, postfix)
            patPFMetT1T2 = getattr(process, metModNameT1T2)
            patPFMetT1T2.applyType2Corrections = cms.bool(True)
            patPFMetT1T2.srcUnclEnergySums = cms.VInputTag(
                cms.InputTag('pfCandMETresidualCorr' + postfix),
                cms.InputTag("patPFJetMETtype1p2Corr" + postfix, "type2")
                )
            patPFMetT1T2.type2CorrFormula = cms.string("A")
            patPFMetT1T2.type2CorrParameter = cms.PSet(A = cms.double(2.))


    collectionsToKeep = [ 'patPFMet' + postfix ]
    if applyT1Cor:
        collectionsToKeep.append( metModNameT1 + postfix )
    if applyT2Cor:
        collectionsToKeep.append( metModNameT1T2 + postfix )

    return (metModName, metModNameT1, metModNameT1T2, collectionsToKeep)
コード例 #50
0
def switchToPFMET(process,
                  input=cms.InputTag('pfMET'),
                  type1=False,
                  postfix=""):
    print 'MET: using ', input
    if (not type1):
        oldMETSource = applyPostfix(process, "patMETs", postfix).metSource
        applyPostfix(process, "patMETs", postfix).metSource = input
        applyPostfix(process, "patMETs", postfix).addMuonCorrections = False
        getattr(process, "patDefaultSequence" + postfix).remove(
            applyPostfix(process, "patMETCorrections", postfix))
    else:
        # type1 corrected MET
        # name of corrected MET hardcoded in PAT and meaningless
        print 'Apply TypeI corrections for MET'
        getattr(process, "patDefaultSequence" + postfix).remove(
            applyPostfix(process, "makePatMETs", postfix))
        jecLabel = getattr(process, 'patJetCorrFactors' + postfix).levels

        if not hasattr(process, 'producePatPFMETCorrections'):
            process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")
        #here add to the current path and give proper postfix
        if not hasattr(process, 'producePatPFMETCorrections' + postfix):
            cloneProcessingSnippet(process, process.producePatPFMETCorrections,
                                   postfix)

        getattr(process, 'patPFMet' +
                postfix).metSource = cms.InputTag('pfMET' + postfix)

        getattr(process, 'selectedPatJetsForMETtype1p2Corr' +
                postfix).src = cms.InputTag('selectedPatJets' + postfix)
        getattr(process, 'selectedPatJetsForMETtype2Corr' +
                postfix).src = cms.InputTag('selectedPatJets' + postfix)

        getattr(process, 'pfCandMETcorr' +
                postfix).src = cms.InputTag('pfNoJet' + postfix)

        getattr(process, 'patPFJetMETtype1p2Corr' +
                postfix).offsetCorrLabel = cms.string(jecLabel[0])
        getattr(process, 'patPFJetMETtype1p2Corr' +
                postfix).jetCorrLabel = cms.string(jecLabel[-1])
        getattr(process, 'patPFJetMETtype1p2Corr' +
                postfix).type1JetPtThreshold = cms.double(10.0)
        getattr(process,
                'patPFJetMETtype1p2Corr' + postfix).skipEM = cms.bool(False)
        getattr(process,
                'patPFJetMETtype1p2Corr' + postfix).skipMuons = cms.bool(False)

        getattr(process, 'patPFJetMETtype2Corr' +
                postfix).offsetCorrLabel = cms.string(jecLabel[0])
        getattr(process, 'patPFJetMETtype2Corr' +
                postfix).jetCorrLabel = cms.string(jecLabel[-1])
        getattr(process, 'patPFJetMETtype2Corr' +
                postfix).type1JetPtThreshold = cms.double(10.0)
        getattr(process,
                'patPFJetMETtype2Corr' + postfix).skipEM = cms.bool(False)
        getattr(process,
                'patPFJetMETtype2Corr' + postfix).skipMuons = cms.bool(False)

        getattr(process, 'patType1CorrectedPFMet' +
                postfix).srcType1Corrections = cms.VInputTag(
                    cms.InputTag("patPFJetMETtype1p2Corr" + postfix, "type1"),
                    #cms.InputTag("patPFMETtype0Corr"+postfix),
                )
        getattr(process, 'patType1p2CorrectedPFMet' +
                postfix).srcType1Corrections = cms.VInputTag(
                    cms.InputTag("patPFJetMETtype1p2Corr" + postfix, "type1"),
                    #cms.InputTag("patPFMETtype0Corr"+postfix),
                )

        getattr(process, 'patMETs' +
                postfix).metSource = 'patType1CorrectedPFMet' + postfix

        getattr(process, "patDefaultSequence" + postfix).replace(
            getattr(process, 'selectedPatJets' + postfix),
            getattr(process, 'selectedPatJets' + postfix) *
            getattr(process, 'producePatPFMETCorrections' + postfix) *
            getattr(process, 'patMETs' + postfix))
コード例 #51
0
    process.PATCMGSequence.replace( process.patMuons,
                                    process.tunePmuons +
                                    process.muonTrackError +
                                    process.patMuons )

if runOnMC is True:
        process.PATCMGSequence.replace( process.muonMatch,
                                        process.tunePmuons +
                                        process.muonTrackError +
                                        process.muonMatch )
        process.muonMatch.src = "tunePmuons"

print 'cloning the jet sequence to build PU chs jets'

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
process.PATCMGJetCHSSequence = cloneProcessingSnippet(process, process.PATCMGJetSequence, 'CHS')
process.PATCMGJetCHSSequence.insert( 0, process.ak5PFJetsCHS )
from CMGTools.Common.Tools.visitorUtils import replaceSrc
replaceSrc( process.PATCMGJetCHSSequence, 'ak5PFJets', 'ak5PFJetsCHS')
replaceSrc( process.PATCMGJetCHSSequence, 'particleFlow', 'pfNoPileUp')
jecPayload = 'AK5PFchs'
process.patJetsWithVarCHS.payload = jecPayload
process.patJetCorrFactorsCHS.payload = jecPayload
process.puJetIdCHS.jec = jecPayload
process.cmgPUJetMvaCHS.jec = jecPayload
process.selectedPatJetsCHS.cut = 'pt()>10'

# Change the soft muons? Change the MET?
###
### WW ANALYSIS - PAY ATTENTION TO THIS
###
コード例 #52
0
def usePF2PAT(process,
              runPF2PAT=True,
              jetAlgo='AK5',
              runOnMC=True,
              postfix="",
              jetCorrections=('AK5PFchs',
                              ['L1FastJet', 'L2Relative', 'L3Absolute']),
              pvCollection=cms.InputTag('offlinePrimaryVertices'),
              typeIMetCorrections=False,
              outputModules=['out']):
    # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT.
    # CREATE ADDITIONAL FUNCTIONS IF NEEDED.
    """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence"""

    # -------- CORE ---------------
    if runPF2PAT:
        process.load("CommonTools.ParticleFlow.PF2PAT_cff")
        #add Pf2PAT *before* cloning so that overlapping modules are cloned too
        #process.patDefaultSequence.replace( process.patCandidates, process.PF2PAT+process.patCandidates)
        process.patPF2PATSequence = cms.Sequence(process.PF2PAT +
                                                 process.patDefaultSequence)
    else:
        process.patPF2PATSequence = cms.Sequence(process.patDefaultSequence)

    if not postfix == "":
        from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
        cloneProcessingSnippet(process, process.patPF2PATSequence, postfix)
        #delete everything pat PF2PAT modules! if you want to test the postfixing for completeness
        #from PhysicsTools.PatAlgos.tools.helpers import listModules,listSequences
        #for module in listModules(process.patDefaultSequence):
        #    if not module.label() is None: process.__delattr__(module.label())
        #for sequence in listSequences(process.patDefaultSequence):
        #    if not sequence.label() is None: process.__delattr__(sequence.label())
        #del process.patDefaultSequence

    removeCleaning(process, postfix=postfix, outputModules=outputModules)

    # -------- OBJECTS ------------
    # Muons
    adaptPFMuons(process, applyPostfix(process, "patMuons", postfix), postfix)

    # Electrons
    adaptPFElectrons(process, applyPostfix(process, "patElectrons", postfix),
                     postfix)

    # Photons
    print "Temporarily switching off photons completely"

    removeSpecificPATObjects(process,
                             names=['Photons'],
                             outputModules=outputModules,
                             postfix=postfix)
    removeIfInSequence(process, "patPhotonIsolation", "patDefaultSequence",
                       postfix)

    # Jets
    if runOnMC:
        switchToPFJets(process,
                       cms.InputTag('pfNoTau' + postfix),
                       jetAlgo,
                       postfix=postfix,
                       jetCorrections=jetCorrections,
                       type1=typeIMetCorrections,
                       outputModules=outputModules)
        applyPostfix(process, "patDefaultSequence", postfix).replace(
            applyPostfix(process, "patJetGenJetMatch", postfix),
            getattr(process, "genForPF2PATSequence") *
            applyPostfix(process, "patJetGenJetMatch", postfix))
    else:
        if not 'L2L3Residual' in jetCorrections[1]:
            print '#################################################'
            print 'WARNING! Not using L2L3Residual but this is data.'
            print 'If this is okay with you, disregard this message.'
            print '#################################################'
        switchToPFJets(process,
                       cms.InputTag('pfNoTau' + postfix),
                       jetAlgo,
                       postfix=postfix,
                       jetCorrections=jetCorrections,
                       type1=typeIMetCorrections,
                       outputModules=outputModules)

    # Taus
    #adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix )
    #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix )
    adaptPFTaus(process, tauType='hpsPFTau', postfix=postfix)

    # MET
    switchToPFMET(process,
                  cms.InputTag('pfMET' + postfix),
                  type1=typeIMetCorrections,
                  postfix=postfix)
    if not runOnMC:
        if hasattr(process, 'patPFMet' + postfix):
            getattr(process, 'patPFMet' + postfix).addGenMET = cms.bool(False)

    # Unmasked PFCandidates
    addPFCandidates(process,
                    cms.InputTag('pfNoJet' + postfix),
                    patLabel='PFParticles' + postfix,
                    cut="",
                    postfix=postfix)

    # adapt primary vertex collection
    adaptPVs(process, pvCollection=pvCollection, postfix=postfix)

    if runOnMC:
        process.load("CommonTools.ParticleFlow.genForPF2PAT_cff")
        getattr(process, "patDefaultSequence" + postfix).replace(
            applyPostfix(process, "patCandidates",
                         postfix), process.genForPF2PATSequence +
            applyPostfix(process, "patCandidates", postfix))
    else:
        removeMCMatchingPF2PAT(process,
                               postfix=postfix,
                               outputModules=outputModules)

    print "Done: PF2PAT interfaced to PAT, postfix=", postfix
コード例 #53
0
    process.PATCMGSequence.replace( process.patMuons,
                                    process.tunePmuons +
                                    process.muonTrackError +
                                    process.patMuons )

if runOnMC is True:
        process.PATCMGSequence.replace( process.muonMatch,
                                        process.tunePmuons +
                                        process.muonTrackError +
                                        process.muonMatch )
        process.muonMatch.src = "tunePmuons"

print 'cloning the jet sequence to build PU chs jets'

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
process.PATCMGJetCHSSequence = cloneProcessingSnippet(process, process.PATCMGJetSequence, 'CHS')
process.PATCMGJetCHSSequence.insert( 0, process.ak5PFJetsCHS )
from CMGTools.Common.Tools.visitorUtils import replaceSrc
replaceSrc( process.PATCMGJetCHSSequence, 'ak5PFJets', 'ak5PFJetsCHS')
replaceSrc( process.PATCMGJetCHSSequence, 'particleFlow', 'pfNoPileUp')
jecPayload = 'AK5PFchs'
process.patJetsWithVarCHS.payload = jecPayload
process.patJetCorrFactorsCHS.payload = jecPayload
process.puJetIdCHS.jec = jecPayload
process.cmgPUJetMvaCHS.jec = jecPayload
process.selectedPatJetsCHS.cut = 'pt()>10'

# Change the soft muons? Change the MET?
###
### WW ANALYSIS - PAY ATTENTION TO THIS
###
コード例 #54
0
                                        process.goodVertices +
                                        process.seqMultProd)

#----GlobalTag ------------------------

process.load(
    "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag

process.GlobalTag = GlobalTag(process.GlobalTag, options.globalTag, '')

process.siStripQualityESProducer.ListOfRecordToMerge = cms.VPSet(
    #    cms.PSet( record = cms.string("SiStripDetVOffRcd"),    tag    = cms.string("") ),
    cms.PSet(record=cms.string("SiStripDetCablingRcd"), tag=cms.string("")),
    cms.PSet(record=cms.string("RunInfoRcd"), tag=cms.string("")),
    cms.PSet(record=cms.string("SiStripBadChannelRcd"), tag=cms.string("")),
    cms.PSet(record=cms.string("SiStripBadFiberRcd"), tag=cms.string("")),
    cms.PSet(record=cms.string("SiStripBadModuleRcd"), tag=cms.string("")))

process.TFileService = cms.Service('TFileService',
                                   fileName=cms.string('OccupancyPlotsTest_' +
                                                       options.tag + '.root'))

cloneProcessingSnippet(process, process.seqAnalyzers, "All")

process.p0 = cms.Path(process.seqRECO + process.seqProducers +
                      process.seqAnalyzersAll + process.seqHLTSelection +
                      process.seqAnalyzers)

#print process.dumpPython()
コード例 #55
0
        "MuonsFromPV@+ MuTrackCands@-"
    ),  # it takes opposite sign collection, no matter if +- or -+
    cut=cms.string("60 < mass < 120"))

BestZmm = cms.EDProducer(
    "BestMassZArbitrationProducer",  # returns the Z with mass closer to 91.18 GeV
    ZCandidateCollection=cms.InputTag("ZmmCandMuonTrack"))

MuZLegs = cms.EDProducer(
    "CollectionFromZLegProducer",
    ZCandidateCollection=cms.InputTag("BestZmm"),
)

procAttributes = dir(proc)  #Takes a snapshot of what there in the process
helpers.cloneProcessingSnippet(
    proc, proc.TauValNumeratorAndDenominator, 'RealMuonsData'
)  #clones the sequence inside the process with RealMuonsData postfix
helpers.cloneProcessingSnippet(
    proc, proc.TauEfficiencies, 'RealMuonsData'
)  #clones the sequence inside the process with RealMuonsData postfix
helpers.massSearchReplaceAnyInputTag(
    proc.TauValNumeratorAndDenominatorRealMuonsData,
    'kinematicSelectedTauValDenominator',
    cms.InputTag("MuZLegs", "theProbeLeg"))  #sets the correct input tag

#adds to TauValNumeratorAndDenominator modules in the sequence RealMuonsData to the extention name
zttLabeler = lambda module: SetValidationExtention(module, 'RealMuonsData')
zttModifier = ApplyFunctionToSequence(zttLabeler)
proc.TauValNumeratorAndDenominatorRealMuonsData.visit(zttModifier)

binning = cms.PSet(
コード例 #56
0
#---------------------------------------------------------------------------------
dzCuts = [0.05 ,0.10 , 0.15 , 0.2]
for dzCut in dzCuts:
   # Make a loose-DZ copy
   #print 'creating '+addedLabel
   process.hpsPFTauDiscriminationByVLooseIsolation.qualityCuts.signalQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByVLooseIsolation.qualityCuts.isolationQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByMediumIsolation.qualityCuts.signalQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByMediumIsolation.qualityCuts.isolationQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByLooseIsolation.qualityCuts.signalQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByLooseIsolation.qualityCuts.isolationQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByTightIsolation.qualityCuts.signalQualityCuts.maxDeltaZ = dzCut
   process.hpsPFTauDiscriminationByTightIsolation.qualityCuts.isolationQualityCuts.maxDeltaZ = dzCut

   addedLabel = 'DZCut%i'%(int(dzCut*100))
   configtools.cloneProcessingSnippet( process, process.validation, addedLabel)
   #checking we did everything correctly
   assert( hasattr(process,'validation%s'%(addedLabel) ) )
   assert( getattr(process,'hpsPFTauDiscriminationByVLooseIsolation%s'%(addedLabel) ).qualityCuts.signalQualityCuts.maxDeltaZ  == dzCut )
   assert( getattr(process,'hpsPFTauDiscriminationByMediumIsolation%s'%(addedLabel) ).qualityCuts.signalQualityCuts.maxDeltaZ  == dzCut )
   assert( getattr(process,'hpsPFTauDiscriminationByLooseIsolation%s'%(addedLabel) ).qualityCuts.signalQualityCuts.maxDeltaZ  == dzCut )
   assert( getattr(process,'hpsPFTauDiscriminationByTightIsolation%s'%(addedLabel) ).qualityCuts.signalQualityCuts.maxDeltaZ  == dzCut )
   process.vtxStudy += getattr(process,'validation%s'%(addedLabel) )
   assert( hasattr(process, 'RunHPSValidation%s'%(addedLabel))  )
   for entry in getattr(process, 'RunHPSValidation%s'%(addedLabel)).discriminators:
      entry.discriminator = entry.discriminator.value() + addedLabel
      #print addedLabel+' created'



#process.validation *= process.saveTauEff #save the output
コード例 #57
0
# Put the new modules in the sequence
if runOnMC is False:
    process.PATCMGSequence.replace(
        process.patMuons,
        process.tunePmuons + process.muonTrackError + process.patMuons)

if runOnMC is True:
    process.PATCMGSequence.replace(
        process.muonMatch,
        process.tunePmuons + process.muonTrackError + process.muonMatch)
    process.muonMatch.src = "tunePmuons"

print 'cloning the jet sequence to build PU chs jets'

from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
process.PATCMGJetCHSSequence = cloneProcessingSnippet(
    process, process.PATCMGJetSequence, 'CHS')
process.PATCMGJetCHSSequence.insert(0, process.ak5PFJetsCHS)
from CMGTools.Common.Tools.visitorUtils import replaceSrc
replaceSrc(process.PATCMGJetCHSSequence, 'ak5PFJets', 'ak5PFJetsCHS')
replaceSrc(process.PATCMGJetCHSSequence, 'particleFlow', 'pfNoPileUp')
jecPayload = 'AK5PFchs'
process.patJetsWithVarCHS.payload = jecPayload
process.patJetCorrFactorsCHS.payload = jecPayload
process.puJetIdCHS.jec = jecPayload
process.cmgPUJetMvaCHS.jec = jecPayload
process.selectedPatJetsCHS.cut = 'pt()>10'

# Change the soft muons? Change the MET?
###
### WW ANALYSIS - PAY ATTENTION TO THIS
###
コード例 #58
0
ファイル: metTools.py プロジェクト: EricBAdamsUMDCP/cmssw-1
def addCorrectedPFMet(process, isMC, doApplyType0corr, doApplySysShiftCorr,
                      runPeriod, doSmearJets):

    process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")

    process.load("JetMETCorrections.METPUSubtraction.mvaPFMET_cff")
    if isMC:
        process.calibratedAK5PFJetsForPFMEtMVA.correctors = cms.vstring(
            "ak5PFL1FastL2L3")
    else:
        process.calibratedAK5PFJetsForPFMEtMVA.correctors = cms.vstring(
            "ak5PFL1FastL2L3Residual")
    process.pfMEtMVA.srcCorrJets = cms.InputTag(
        'calibratedAK5PFJetsForPFMEtMVA')
    process.pfMEtMVA.srcLeptons = cms.VInputTag('goodMuons')
    process.pfMEtMVA.verbosity = cms.int32(0)
    process.patPFMetMVA = process.patMETs.clone(
        metSource=cms.InputTag('pfMEtMVA'),
        addMuonCorrections=cms.bool(False),
        genMETSource=cms.InputTag('genMetTrue'))
    process.patMEtMVAsequence = cms.Sequence(process.pfMEtMVAsequence +
                                             process.patPFMetMVA)

    process.load("JetMETCorrections.METPUSubtraction.noPileUpPFMET_cff")
    process.load("JetMETCorrections.METPUSubtraction.noPileUpPFchsMET_cff")
    if isMC:
        process.calibratedAK5PFJetsForNoPileUpPFMEt.correctors = cms.vstring(
            "ak5PFL1FastL2L3")
        process.calibratedAK5PFchsJetsForNoPileUpPFchsMEt.correctors = cms.vstring(
            "ak5PFchsL1FastL2L3")
    else:
        process.calibratedAK5PFJetsForNoPileUpPFMEt.correctors = cms.vstring(
            "ak5PFL1FastL2L3Residual")
        process.calibratedAK5PFchsJetsForNoPileUpPFchsMEt.correctors = cms.vstring(
            "ak5PFchsL1FastL2L3Residual")

    process.noPileUpPFMEt.srcLeptons = cms.VInputTag('patMuons')
    process.noPileUpPFMEtData.verbosity = cms.int32(0)
    process.noPileUpPFMEt.verbosity = cms.int32(0)
    process.patPFMetNoPileUp = process.patMETs.clone(
        metSource=cms.InputTag('noPileUpPFMEt'),
        addMuonCorrections=cms.bool(False),
        genMETSource=cms.InputTag('genMetTrue'))
    process.noPileUpPFchsMEt.srcLeptons = cms.VInputTag('patMuons')
    process.noPileUpPFchsMEtData.verbosity = cms.int32(0)
    process.noPileUpPFchsMEt.verbosity = cms.int32(0)
    process.patPFchsMetNoPileUp = process.patMETs.clone(
        metSource=cms.InputTag('noPileUpPFchsMEt'),
        addMuonCorrections=cms.bool(False),
        genMETSource=cms.InputTag('genMetTrue'))
    process.patMEtNoPileUpSequence = cms.Sequence(
        process.noPileUpPFMEtSequence + process.patPFMetNoPileUp +
        process.patPFchsMetNoPileUp)

    process.makeCorrectedPatMETs = cms.Sequence()

    if isMC:
        import PhysicsTools.PatAlgos.tools.helpers as configtools
        process.type0PFMEtCorrection.remove(
            process.type0PFMEtCorrectionPFCandToVertexAssociation)
        process.makeCorrectedPatMETs += process.type0PFMEtCorrectionPFCandToVertexAssociation
        configtools.cloneProcessingSnippet(process,
                                           process.producePatPFMETCorrections,
                                           "NoSmearing")
        process.selectedPatJetsForMETtype1p2CorrNoSmearing.src = cms.InputTag(
            'patJetsNotOverlappingWithLeptonsForMEtUncertainty')
        process.selectedPatJetsForMETtype2CorrNoSmearing.src = process.selectedPatJetsForMETtype1p2CorrNoSmearing.src
        configtools.cloneProcessingSnippet(process, process.patMEtMVAsequence,
                                           "NoSmearing")
        process.patMEtNoPileUpSequence.remove(process.type0PFMEtCorrection)
        configtools.cloneProcessingSnippet(process,
                                           process.patMEtNoPileUpSequence,
                                           "NoSmearing")
    else:
        doSmearJets = False

    sysShiftCorrParameter = None
    if doApplySysShiftCorr:
        process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
        if runPeriod == "2012RunABC":
            if isMC:
                sysShiftCorrParameter = process.pfMEtSysShiftCorrParameters_2012runABCvsNvtx_mc
            else:
                sysShiftCorrParameter = process.pfMEtSysShiftCorrParameters_2012runABCvsNvtx_data
        else:
            raise ValueError("Invalid runPeriod = %s !!" % runPeriod)

    from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties import runType1PFMEtUncertainties
    runType1PFMEtUncertainties(process,
                               electronCollection='',
                               photonCollection='',
                               muonCollection=cms.InputTag('patMuons'),
                               tauCollection='',
                               jetCollection=cms.InputTag('patJets'),
                               doSmearJets=doSmearJets,
                               makeType1corrPFMEt=True,
                               makeType1p2corrPFMEt=True,
                               doApplyType0corr=doApplyType0corr,
                               sysShiftCorrParameter=sysShiftCorrParameter,
                               doApplySysShiftCorr=doApplySysShiftCorr,
                               addToPatDefaultSequence=False)
    from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties import runMVAMEtUncertainties
    runMVAMEtUncertainties(process,
                           electronCollection='',
                           photonCollection='',
                           muonCollection=cms.InputTag('patMuons'),
                           tauCollection='',
                           doSmearJets=doSmearJets,
                           addToPatDefaultSequence=False)
    from PhysicsTools.PatUtils.tools.runNoPileUpMEtUncertainties import runNoPileUpMEtUncertainties
    runNoPileUpMEtUncertainties(process,
                                electronCollection='',
                                photonCollection='',
                                muonCollection=cms.InputTag('patMuons'),
                                tauCollection='',
                                doApplyChargedHadronSubtraction=False,
                                doSmearJets=doSmearJets,
                                addToPatDefaultSequence=False)
    runNoPileUpMEtUncertainties(process,
                                electronCollection='',
                                photonCollection='',
                                muonCollection=cms.InputTag('patMuons'),
                                tauCollection='',
                                doApplyChargedHadronSubtraction=True,
                                doSmearJets=doSmearJets,
                                addToPatDefaultSequence=False)

    if isMC:
        process.patPFMet.addGenMET = cms.bool(True)
        process.patPFMetMVA.addGenMET = cms.bool(True)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L3Absolute")
        process.patPFJetMETtype1p2CorrNoSmearing.jetCorrLabel = cms.string(
            "L3Absolute")

        process.makeCorrectedPatMETs += process.metUncertaintySequence
        process.makeCorrectedPatMETs += process.producePatPFMETCorrectionsNoSmearing
        process.makeCorrectedPatMETs += process.patMEtMVAsequenceNoSmearing
        process.makeCorrectedPatMETs += process.patMEtNoPileUpSequenceNoSmearing
    else:
        process.patPFMet.addGenMET = cms.bool(False)
        process.patPFMetMVA.addGenMET = cms.bool(False)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string(
            "L2L3Residual")

        process.makeCorrectedPatMETs += process.patJetsNotOverlappingWithLeptonsForMEtUncertainty
        if hasattr(process, "pfMEtSysShiftCorrSequence"):
            process.makeCorrectedPatMETs += process.pfMEtSysShiftCorrSequence
        process.makeCorrectedPatMETs += process.producePatPFMETCorrections
        process.makeCorrectedPatMETs += process.patMEtMVAsequence
        process.makeCorrectedPatMETs += process.patMEtNoPileUpSequence

    # add MVA MEt with unity response training
    for moduleName in dir(process):
        if (moduleName.endswith("Up")
                or moduleName.endswith("Down")) and not isMC:
            continue
        module = getattr(process, moduleName)
        if isinstance(module,
                      cms.EDProducer) and module.type_() == "PFMETProducerMVA":
            module_unity = module.clone(inputFileNames=cms.PSet(
                DPhi=cms.FileInPath(
                    'JetMETCorrections/METPUSubtraction/data/gbrmetphi_53.root'
                ),  # CV: same for unity and non-unity response training
                CovU2=cms.FileInPath(
                    'JetMETCorrections/METPUSubtraction/data/gbru2cov_53_UnityResponse.root'
                ),
                U=cms.FileInPath(
                    'JetMETCorrections/METPUSubtraction/data/gbrmet_53_UnityResponse.root'
                ),
                CovU1=cms.FileInPath(
                    'JetMETCorrections/METPUSubtraction/data/gbru1cov_53_UnityResponse.root'
                )))
            moduleName_unity = moduleName.replace("pfMEtMVA",
                                                  "pfMEtMVAunityResponse")
            setattr(process, moduleName_unity, module_unity)
            process.makeCorrectedPatMETs += module_unity
    for moduleName in dir(process):
        if (moduleName.endswith("Up")
                or moduleName.endswith("Down")) and not isMC:
            continue
        module = getattr(process, moduleName)
        if isinstance(module, cms.EDProducer) and module.type_(
        ) == "PATMETProducer" and moduleName.find("patPFMetMVA") != -1:
            module_unity = module.clone(
                metSource=cms.InputTag(module.metSource.value().replace(
                    "pfMEtMVA", "pfMEtMVAunityResponse")))
            moduleName_unity = moduleName.replace("patPFMetMVA",
                                                  "patPFMetMVAunityResponse")
            setattr(process, moduleName_unity, module_unity)
            process.makeCorrectedPatMETs += module_unity

    # add No-PU MEt without L1Fastjet jet energy corrections
    for moduleName in dir(process):
        if ((moduleName.endswith("Up") or moduleName.endswith("Down"))
                and not moduleName.endswith("NoPileUp")) and not isMC:
            continue
        module = getattr(process, moduleName)
        if isinstance(module, cms.EDProducer) and module.type_(
        ) == "NoPileUpPFMEtDataProducer":
            moduleName_calib_or_corrJets = module.srcJets.value()
            module_calib_or_corrJets = getattr(process,
                                               moduleName_calib_or_corrJets)
            moduleName_calibJets = None
            moduleName_corrJets = None
            moduleName_smearedJets = None
            ##print "%s: %s" % (moduleName_calib_or_corrJets, module_calib_or_corrJets.type_())
            if module_calib_or_corrJets.type_() == "ShiftedPFJetProducer":
                moduleName_corrJets = moduleName_calib_or_corrJets
                module_corrJets = getattr(process, moduleName_corrJets)
                moduleName_calibJets = module_corrJets.src.value()
            elif module_calib_or_corrJets.type_() == "PFJetCorrectionProducer":
                moduleName_calibJets = moduleName_calib_or_corrJets
            elif module_calib_or_corrJets.type_() == "SmearedPFJetProducer":
                moduleName_smearedJets = moduleName_calib_or_corrJets
                module_smearedJets = getattr(process, moduleName_smearedJets)
                moduleName_calibJets = module_smearedJets.src.value()
            else:
                raise ValueError("Module = %s is of unsupported type = %s !!" %
                                 (moduleName_calib_or_corrJets,
                                  module_calib_or_corrJets.type_()))
            if moduleName_calibJets:
                module_calibJets = getattr(process, moduleName_calibJets)
                module_calibJets_woL1FastJet = module_calibJets.clone(
                    correctors=cms.vstring(
                        module_calibJets.correctors[0].replace("L1Fast", "")))
                moduleName_calibJets_woL1FastJet = moduleName_calibJets.replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")
                setattr(process, moduleName_calibJets_woL1FastJet,
                        module_calibJets_woL1FastJet)
                ##print "adding module %s: %s" % (moduleName_calibJets_woL1FastJet, module_calibJets_woL1FastJet.type_())
                process.makeCorrectedPatMETs += module_calibJets_woL1FastJet
            if moduleName_corrJets:
                module_corrJets = getattr(process, moduleName_corrJets)
                module_corrJets_woL1FastJet = module_corrJets.clone(
                    src=cms.InputTag(module_corrJets.src.value().replace(
                        "ForNoPileUpPFMEt",
                        "ForNoPileUpPFMEtWithoutL1FastJet")),
                    jetCorrLabelUpToL3Res=cms.string(
                        module_corrJets.jetCorrLabelUpToL3Res.value().replace(
                            "L1Fast", "")),
                    jetCorrLabelUpToL3=cms.string(
                        module_corrJets.jetCorrLabelUpToL3.value().replace(
                            "L1Fast", "")))
                moduleName_corrJets_woL1FastJet = moduleName_corrJets.replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")
                setattr(process, moduleName_corrJets_woL1FastJet,
                        module_corrJets_woL1FastJet)
                ##print "adding module %s: %s" % (moduleName_corrJets_woL1FastJet, module_corrJets_woL1FastJet.type_())
                process.makeCorrectedPatMETs += module_corrJets_woL1FastJet
            if moduleName_smearedJets:
                module_smearedJets = getattr(process, moduleName_smearedJets)
                module_smearedJets_woL1FastJet = module_smearedJets.clone(
                    src=cms.InputTag(module_smearedJets.src.value().replace(
                        "ForNoPileUpPFMEt",
                        "ForNoPileUpPFMEtWithoutL1FastJet")),
                    jetCorrLabel=cms.string('ak5PFL1Fastjet'))
                moduleName_smearedJets_woL1FastJet = moduleName_smearedJets.replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")
                setattr(process, moduleName_smearedJets_woL1FastJet,
                        module_smearedJets_woL1FastJet)
                ##print "adding module %s: %s" % (moduleName_smearedJets_woL1FastJet, module_smearedJets_woL1FastJet.type_())
                process.makeCorrectedPatMETs += module_smearedJets_woL1FastJet
            moduleName_jetId = module.srcJetIds.getModuleLabel()
            module_jetId = getattr(process, moduleName_jetId)
            module_jetId_woL1FastJet = module_jetId.clone(
                jets=cms.InputTag(module_jetId.jets.value().replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")))
            moduleName_jetId_woL1FastJet = moduleName_jetId.replace(
                "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")
            setattr(process, moduleName_jetId_woL1FastJet,
                    module_jetId_woL1FastJet)
            ##print "adding module %s: %s" % (moduleName_jetId_woL1FastJet, module_jetId_woL1FastJet.type_())
            process.makeCorrectedPatMETs += module_jetId_woL1FastJet
            module_woL1FastJet = module.clone(
                jetEnOffsetCorrLabel=cms.string(""),
                srcJets=cms.InputTag(module.srcJets.value().replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")),
                srcJetIds=cms.InputTag(module.srcJetIds.value().replace(
                    "ForNoPileUpPFMEt", "ForNoPileUpPFMEtWithoutL1FastJet")))
            moduleName_woL1FastJet = moduleName.replace(
                "noPileUpPFMEtData", "noPileUpPFMEtDataWithoutL1FastJet")
            setattr(process, moduleName_woL1FastJet, module_woL1FastJet)
            process.makeCorrectedPatMETs += module_woL1FastJet
    for moduleName in dir(process):
        if ((moduleName.endswith("Up") or moduleName.endswith("Down"))
                and not moduleName.endswith("NoPileUp")) and not isMC:
            continue
        module = getattr(process, moduleName)
        if isinstance(
                module,
                cms.EDProducer) and module.type_() == "NoPileUpPFMEtProducer":
            module_woL1FastJet = module.clone(srcMVAMEtData=cms.InputTag(
                module.srcMVAMEtData.value().replace(
                    "noPileUpPFMEtData", "noPileUpPFMEtDataWithoutL1FastJet")))
            moduleName_woL1FastJet = moduleName.replace(
                "noPileUpPFMEt", "noPileUpPFMEtWithoutL1FastJet")
            setattr(process, moduleName_woL1FastJet, module_woL1FastJet)
            process.makeCorrectedPatMETs += module_woL1FastJet
    for moduleName in dir(process):
        if ((moduleName.endswith("Up") or moduleName.endswith("Down"))
                and not moduleName.endswith("NoPileUp")) and not isMC:
            continue
        module = getattr(process, moduleName)
        if isinstance(module, cms.EDProducer) and module.type_(
        ) == "PATMETProducer" and moduleName.find("patPFMetNoPileUp") != -1:
            module_woL1FastJet = module.clone(
                metSource=cms.InputTag(module.metSource.value().replace(
                    "noPileUpPFMEt", "noPileUpPFMEtWithoutL1FastJet")))
            moduleName_woL1FastJet = moduleName.replace(
                "patPFMetNoPileUp", "patPFMetNoPileUpWithoutL1FastJet")
            setattr(process, moduleName_woL1FastJet, module_woL1FastJet)
            process.makeCorrectedPatMETs += module_woL1FastJet

    return process.makeCorrectedPatMETs