コード例 #1
0
def addCorrectedPFMet(process, isMC, doApplyType0corr, doApplySysShiftCorr, runPeriod, doSmearJets, jecUncertaintyTag, doApplyUnclEnergyResidualCorr):

    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.inputFileNames = cms.PSet(
        DPhi = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbrmetphi_53_June2013_type1.root'),
        CovU2 = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbru2cov_53_Dec2012.root'),
        U = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbrmet_53_June2013_type1.root'),
        CovU1 = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbru1cov_53_Dec2012.root')
    )
    process.pfMEtMVA.loadMVAfromDB = cms.bool(False)
    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.noPileUpPFchsMEtSequence + process.patPFchsMetNoPileUp)
    ##process.patMEtNoPileUpSequence = cms.Sequence(process.noPileUpPFMEtSequence + process.patPFMetNoPileUp)
    
    process.makeCorrectedPatPFMETs = cms.Sequence()

    if isMC:
        import PhysicsTools.PatAlgos.tools.helpers as configtools
        process.type0PFMEtCorrection.remove(process.type0PFMEtCorrectionPFCandToVertexAssociation)
        process.makeCorrectedPatPFMETs += process.type0PFMEtCorrectionPFCandToVertexAssociation
        configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, "NoSmearing")        
        process.selectedPatJetsForMETtype1p2CorrNoSmearing.src = cms.InputTag('patJetsNotOverlappingWithLeptonsForJetMEtUncertainty')
        process.selectedPatJetsForMETtype2CorrNoSmearing.src = process.selectedPatJetsForMETtype1p2CorrNoSmearing.src
        configtools.cloneProcessingSnippet(process, process.patMEtMVAsequence, "NoSmearing")
        process.makeCorrectedPatPFMETs += process.patMEtMVAsequenceNoSmearing
        ##process.patMEtNoPileUpSequence.remove(process.type0PFMEtCorrection)
        configtools.cloneProcessingSnippet(process, process.patMEtNoPileUpSequence, "NoSmearing")
        ##process.printEventContentForNoPileUpPFMEtNoSmearing = cms.EDAnalyzer("EventContentAnalyzer")
        ##process.patMEtNoPileUpSequenceNoSmearing.replace(process.noPileUpPFMEtDataNoSmearing, process.printEventContentForNoPileUpPFMEtNoSmearing + process.noPileUpPFMEtDataNoSmearing)
        process.makeCorrectedPatPFMETs += process.patMEtNoPileUpSequenceNoSmearing
    else:
        doSmearJets = False
        
    sysShiftCorrParameter = None
    if doApplySysShiftCorr:
        process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
        if runPeriod == "2012RunABCD":
            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,
        jecUncertaintyTag = jecUncertaintyTag,
        makeType1corrPFMEt = True,
        makeType1p2corrPFMEt = True,
        doApplyType0corr = doApplyType0corr,
        sysShiftCorrParameter = sysShiftCorrParameter,
        doApplySysShiftCorr = doApplySysShiftCorr,
        doApplyUnclEnergyCalibration = (doApplyUnclEnergyResidualCorr & isMC),
        addToPatDefaultSequence = False
    )
    from PhysicsTools.PatUtils.tools.runMVAMEtUncertainties import runMVAMEtUncertainties
    runMVAMEtUncertainties(
        process,
        electronCollection = '',
        photonCollection = '',
        muonCollection = cms.InputTag('patMuons'),        
        tauCollection = '',        
        jetCollection = cms.InputTag('patJets'),   
        doSmearJets = doSmearJets,
        jecUncertaintyTag = jecUncertaintyTag,
        addToPatDefaultSequence = False
    )
    from PhysicsTools.PatUtils.tools.runNoPileUpMEtUncertainties import runNoPileUpMEtUncertainties
    runNoPileUpMEtUncertainties(
        process,
        electronCollection = '',
        photonCollection = '',
        muonCollection = cms.InputTag('patMuons'),
        tauCollection = '',
        jetCollection = cms.InputTag('patJets'),    
        doApplyChargedHadronSubtraction = False,
        doSmearJets = doSmearJets,
        jecUncertaintyTag = jecUncertaintyTag,
        doApplyUnclEnergyCalibration = (doApplyUnclEnergyResidualCorr & isMC),
        addToPatDefaultSequence = False
    )
    runNoPileUpMEtUncertainties(
        process,
        electronCollection = '',
        photonCollection = '',
        muonCollection = cms.InputTag('patMuons'),
        tauCollection = '',
        jetCollection = cms.InputTag('patJetsAK5PFchs'),    
        doApplyChargedHadronSubtraction = True,
        doSmearJets = doSmearJets,
        jecUncertaintyFile = "PhysicsTools/PatUtils/data/Summer13_V1_DATA_UncertaintySources_AK5PFchs.txt",
        jecUncertaintyTag = jecUncertaintyTag,
        addToPatDefaultSequence = False
    )

    if isMC:
        process.makeCorrectedPatPFMETs += process.pfType1MEtUncertaintySequence
        process.makeCorrectedPatPFMETs += process.pfNoPileUpMEtUncertaintySequence
        process.makeCorrectedPatPFMETs += process.pfchsNoPileUpMEtUncertaintySequence
        process.makeCorrectedPatPFMETs += process.pfMVAMEtUncertaintySequence
        process.patPFMet.addGenMET = cms.bool(True)
        process.patPFMetMVA.addGenMET = cms.bool(True)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L3Absolute")
        process.patPFJetMETtype1p2CorrNoSmearing.jetCorrLabel = cms.string("L3Absolute")
    else:
        process.patPFMet.addGenMET = cms.bool(False)
        process.patPFMetMVA.addGenMET = cms.bool(False)
        process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string("L2L3Residual")
    
        process.makeCorrectedPatPFMETs += process.patJetsNotOverlappingWithLeptonsForJetMEtUncertainty
        if hasattr(process, "pfMEtSysShiftCorrSequence"):
            process.makeCorrectedPatPFMETs += process.pfMEtSysShiftCorrSequence
        process.makeCorrectedPatPFMETs += process.producePatPFMETCorrections
        process.makeCorrectedPatPFMETs += process.patMEtMVAsequence
        process.makeCorrectedPatPFMETs += 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_June2013_type1.root'), # CV: same for unity and non-unity response training
                    CovU2 = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbru2cov_53_Dec2012.root'),
                    U = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbrmet_53_June2013_type1_UnityResponse.root'),
                    CovU1 = cms.FileInPath('JetMETCorrections/METPUSubtraction/data/gbru1cov_53_Dec2012.root')
                ),
                loadMVAfromDB = cms.bool(False)
            )
            moduleName_unity = moduleName.replace("pfMEtMVA", "pfMEtMVAunityResponse")
            setattr(process, moduleName_unity, module_unity)
            process.makeCorrectedPatPFMETs += 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.makeCorrectedPatPFMETs += module_unity

    return process.makeCorrectedPatPFMETs
コード例 #2
0
                               makeType1p2corrPFMEt = False,
                               doApplyType0corr = True,
                               doSmearJets = False,
                               addToPatDefaultSequence = False,
                               postfix = ''
                                               )
    process.patPFJetMETtype1p2Corr.jetCorrLabel = cms.string('L2L3Residual')
    process.patPFJetMETtype2Corr.jetCorrLabel = cms.string('L2L3Residual')
                                    
    from PhysicsTools.PatUtils.tools.runMVAMEtUncertainties         import runMVAMEtUncertainties
    runMVAMEtUncertainties(process,
                           electronCollection = '',
                           photonCollection = cms.InputTag('goodPhotonsHighPtCut'),
                           muonCollection = '',
                           tauCollection = '',
                           jetCollection = cms.InputTag('patJets'),
                           jecUncertaintyFile = "PhysicsTools/PatUtils/data/Summer13_V1_DATA_UncertaintySources_AK5PF.txt",
                           doSmearJets = False,
                           addToPatDefaultSequence = False,
                           postfix = ''
                           )
    process.calibratedAK5PFJetsForPFMEtMVA.correctors = cms.vstring("ak5PFL1FastL2L3Residual")
    process.pfMEtMVA.srcLeptons = cms.VInputTag('goodPhotonsHighPtCut')

else:
    from PhysicsTools.PatUtils.tools.runType1PFMEtUncertainties     import runType1PFMEtUncertainties
    runType1PFMEtUncertainties(process,
                               electronCollection = '',
                               photonCollection = cms.InputTag('goodPhotonsHighPtCut'),
                               muonCollection = '',
                               tauCollection = '',
コード例 #3
0
ファイル: patMET.py プロジェクト: yhshin11/devMet
        doApplyType0corr = True,
        doSmearJets =isSmear,
        postfix = i
        )

if produceMVAPFMET:
     for i in smearing:
        isSmear=False
        if i == "Smeared":
            isSmear=True
        runMVAMEtUncertainties(
            process,
            electronCollection = cms.InputTag('selectedPatElectrons'),
            photonCollection = '',
            muonCollection = '',#cms.InputTag('selectedPatMuons'),
            tauCollection = '',
            jetCollection = cms.InputTag('patJets'),    
            doSmearJets =isSmear,
            addToPatDefaultSequence = False,
            postfix = i
            )

if produceNoPUPFMET:
     for i in smearing:
        isSmear=False
        if i == "Smeared":
            isSmear=True
        runNoPileUpMEtUncertainties(
            process,
            electronCollection = cms.InputTag('selectedPatElectrons'),
            photonCollection = '',
コード例 #4
0
  muonCollection = cms.InputTag('selectedPatMuons'),
  tauCollection = '',
  jetCollection = cms.InputTag('patJets'),
  makeType1corrPFMEt = True,
  makeType1p2corrPFMEt = True,
  doApplyType0corr = True,
  doSmearJets =isMC,
  postfix = ''
)

runMVAMEtUncertainties(
  process,
  electronCollection = '',
  photonCollection = '',
  muonCollection = cms.InputTag('selectedPatMuons'),
  tauCollection = '',
  jetCollection = cms.InputTag('patJets'),
  doSmearJets =isMC,
  addToPatDefaultSequence = False,
  postfix = ''
  )

runNoPileUpMEtUncertainties(
  process,
  electronCollection = '',
  photonCollection = '',
  muonCollection = cms.InputTag('selectedPatMuons'),
  tauCollection = '',
  jetCollection = cms.InputTag('patJets'),
  addToPatDefaultSequence = False,
  doApplyChargedHadronSubtraction = False,