Пример #1
0
    def toolCode(self, process):
        """
        Tool code implementation
        """
        ## initialize parameters
        labelName = "patJets" + self._parameters["labelName"].value
        postfix = self._parameters["postfix"].value
        jetSource = self._parameters["jetSource"].value
        algo = self._parameters["algo"].value
        jetCorrections = self._parameters["jetCorrections"].value
        btagDiscriminators = list(self._parameters["btagDiscriminators"].value)
        btagInfos = list(self._parameters["btagInfos"].value)
        jetTrackAssociation = self._parameters["jetTrackAssociation"].value
        outputModules = list(self._parameters["outputModules"].value)

        ## a list of all producer modules, which are already known to process
        knownModules = process.producerNames().split()
        ## determine whether btagging information is required or not
        if btagDiscriminators.count("None") > 0:
            btagDiscriminators.remove("None")
        if btagInfos.count("None") > 0:
            btagInfos.remove("None")
        bTagging = len(btagDiscriminators) > 0 or len(btagInfos) > 0
        ## construct postfix label for auxiliary modules; this postfix
        ## label will start with a capitalized first letter following
        ## the CMS nameing conventions and for improved readablility
        _labelName = labelName[:1].upper() + labelName[1:]
        # _labelName=labelName
        ## determine jet algorithm from jetSource; supported algo types
        ## are ak, kt, sc, ic. This loop expects that the algo type is
        ## followed by a single integer corresponding to the opening
        ## angle parameter dR times 10 (examples ak5, kt4, kt6, ...)
        _algo = algo
        # jetSource=cms.InputTag("ak5PFJets")
        for x in ["ak", "kt", "sc", "ic"]:
            if jetSource.getModuleLabel().lower().find(x) > -1:
                _algo = jetSource.getModuleLabel()[
                    jetSource.getModuleLabel().lower().find(x) : jetSource.getModuleLabel().lower().find(x) + 3
                ]
        # print _algo
        ## add new patJets to process (keep instance for later further modifications)
        from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets

        if labelName in knownModules:
            _newPatJets = getattr(process, labelName + postfix)
            _newPatJets.jetSource = jetSource
        else:
            # setattr(process, labelName, patJets.clone(jetSource=jetSource))
            setattr(process, labelName + postfix, patJets.clone(jetSource=jetSource))
            _newPatJets = getattr(process, labelName + postfix)
            knownModules.append(labelName + postfix)
        ## add new selectedPatJets to process
        from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets

        if "selected" + _labelName + postfix in knownModules:
            _newSelectedPatJets = getattr(process, "selected" + _labelName + postfix)
            _newSelectedPatJets.src = labelName + postfix
        else:
            setattr(process, "selected" + _labelName + postfix, selectedPatJets.clone(src=labelName + postfix))
            knownModules.append("selected" + _labelName + postfix)

        ## set postfix label to '' if there is no labelName given. In this case all
        ## modules should keep there names w/o postfixes. This will cover the case
        ## of switchJectCollection
        if self._parameters["labelName"].value == "":
            _labelName = ""

        ## add new patJetPartonMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch

        if "patJetPartonMatch" + _labelName + postfix in knownModules:
            _newPatJetPartonMatch = getattr(process, "patJetPartonMatch" + _labelName + postfix)
            _newPatJetPartonMatch.src = jetSource
        else:
            setattr(process, "patJetPartonMatch" + _labelName + postfix, patJetPartonMatch.clone(src=jetSource))
            knownModules.append("patJetPartonMatch" + _labelName + postfix)
        ## add new patJetGenJetMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch

        if "patJetGenJetMatch" + _labelName + postfix in knownModules:
            _newPatJetGenJetMatch = getattr(process, "patJetGenJetMatch" + _labelName + postfix)
            _newPatJetGenJetMatch.src = jetSource
            _newPatJetGenJetMatch.matched = _algo.lower() + "GenJets" + postfix
        else:
            setattr(
                process,
                "patJetGenJetMatch" + _labelName + postfix,
                patJetGenJetMatch.clone(src=jetSource, matched=_algo + "GenJets"),
            )
            knownModules.append("patJetGenJetMatch" + _labelName + postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociation

        if "patJetPartonAssociation" + _labelName + postfix in knownModules:
            _newPatJetPartonAssociation = getattr(
                process, "patJetPartonAssociation" + _labelName + postfix, patJetPartonAssociation.clone(jets=jetSource)
            )
            _newPatJetPartonAssociation.jets = jetSource
        else:
            setattr(
                process, "patJetPartonAssociation" + _labelName + postfix, patJetPartonAssociation.clone(jets=jetSource)
            )
            knownModules.append("patJetPartonAssociation" + _labelName + postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation

        if "patJetFlavourAssociation" + _labelName + postfix in knownModules:
            _newPatJetFlavourAssociation = getattr(
                process,
                "patJetFlavourAssociation" + _labelName + postfix,
                patJetFlavourAssociation.clone(srcByReference="patJetPartonAssociation" + _labelName + postfix),
            )
            _newPatJetFlavourAssociation.srcByReference = "patJetPartonAssociation" + _labelName + postfix
        else:
            setattr(
                process,
                "patJetFlavourAssociation" + _labelName + postfix,
                patJetFlavourAssociation.clone(srcByReference="patJetPartonAssociation" + _labelName + postfix),
            )
            knownModules.append("patJetFlavourAssociation" + _labelName + postfix)
        ## modify new patJets collection accordingly
        _newPatJets.genJetMatch.setModuleLabel("patJetGenJetMatch" + _labelName + postfix)
        _newPatJets.genPartonMatch.setModuleLabel("patJetPartonMatch" + _labelName + postfix)
        _newPatJets.JetPartonMapSource.setModuleLabel("patJetFlavourAssociation" + _labelName + postfix)

        ## add jetTrackAssociation for btagging (or jetTracksAssociation only) if required by user
        if jetTrackAssociation or bTagging:
            ## add new jetTracksAssociationAtVertex to process
            from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex

            if "jetTracksAssociationAtVertex" + _labelName + postfix in knownModules:
                _newJetTracksAssociationAtVertex = getattr(
                    process, "jetTracksAssociatorAtVertex" + _labelName + postfix
                )
                _newJetTracksAssociationAtVertex.jets = jetSource
            else:
                setattr(
                    process,
                    "jetTracksAssociatorAtVertex" + _labelName + postfix,
                    ak5JetTracksAssociatorAtVertex.clone(jets=jetSource),
                )
                knownModules.append("jetTracksAssociationAtVertex" + _labelName + postfix)
            ## add new patJetCharge to process
            from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge

            if "patJetCharge" + _labelName + postfix in knownModules:
                _newPatJetCharge = getattr(process, "patJetCharge" + _labelName + postfix)
                _newPatJetCharge.src = "jetTracksAssociatorAtVertex" + _labelName + postfix
            else:
                setattr(
                    process,
                    "patJetCharge" + _labelName + postfix,
                    patJetCharge.clone(src="jetTracksAssociatorAtVertex" + _labelName + postfix),
                )
                knownModules.append("patJetCharge" + _labelName + postfix)
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks = True
            _newPatJets.trackAssociationSource = cms.InputTag("jetTracksAssociatorAtVertex" + _labelName + postfix)
            _newPatJets.addJetCharge = True
            _newPatJets.jetChargeSource = cms.InputTag("patJetCharge" + _labelName + postfix)
        else:
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks = False
            _newPatJets.trackAssociationSource = ""
            _newPatJets.addJetCharge = False
            _newPatJets.jetChargeSource = ""
        ## run btagging if required by user
        if bTagging:
            ## expand tagInfos to what is explicitely required by user + implicit
            ## requirements that come in from one or the other discriminator
            requiredTagInfos = list(btagInfos)
            for btagDiscr in btagDiscriminators:
                for requiredTagInfo in supportedBtagDiscr[btagDiscr]:
                    tagInfoCovered = False
                    for tagInfo in requiredTagInfos:
                        if requiredTagInfo == tagInfo:
                            tagInfoCovered = True
                            break
                    if not tagInfoCovered:
                        requiredTagInfos.append(requiredTagInfo)
            ## load sequences and setups needed fro btagging
            ## This loads all available btagger, but the ones we need are added to the process by hand lader. Only needed to get the ESProducer. Needs improvement
            # loadWithPostFix(process,"RecoBTag.Configuration.RecoBTag_cff",postfix)
            process.load("RecoBTag.Configuration.RecoBTag_cff")
            # addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
            import RecoBTag.Configuration.RecoBTag_cff as btag

            ## prepare setups for simple secondary vertex infos
            setattr(process, "simpleSecondaryVertex2Trk", simpleSecondaryVertex2Trk)
            ## prepare setups for transient tracks
            setattr(process, "TransientTrackBuilderESProducer", TransientTrackBuilderESProducer)
            ## setup all required btagInfos : we give a dedicated treatment for all five different
            ## types of tagINfos here. A common treatment is possible but might require a more
            ## general approach anyway in coordination with the btaggin POG.
            for btagInfo in requiredTagInfos:
                if "impactParameterTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.impactParameterTagInfos.clone(
                            jetTracks=cms.InputTag("jetTracksAssociatorAtVertex" + _labelName + postfix)
                        ),
                    )
                if "secondaryVertexTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.secondaryVertexTagInfos.clone(
                            trackIPTagInfos=cms.InputTag("impactParameterTagInfos" + _labelName + postfix)
                        ),
                    )
                if "secondaryVertexNegativeTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.secondaryVertexNegativeTagInfos.clone(
                            trackIPTagInfos=cms.InputTag("impactParameterTagInfos" + _labelName + postfix)
                        ),
                    )
                if "softElectronTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.softElectronTagInfos.clone(jets=cms.InputTag(_newJetCollection)),
                    )
                if "softMuonTagInfos" in btagInfo:
                    setattr(
                        process,
                        btagInfo + _labelName + postfix,
                        btag.softMuonTagInfos.clone(jets=cms.InputTag(_newJetCollection)),
                    )
            ## setup all required btagDiscriminators
            for btagDiscr in btagDiscriminators:
                setattr(
                    process,
                    btagDiscr + _labelName + postfix,
                    getattr(btag, btagDiscr).clone(
                        tagInfos=cms.VInputTag(
                            *[cms.InputTag(x + _labelName + postfix) for x in supportedBtagDiscr[btagDiscr]]
                        )
                    ),
                )
            ## replace corresponding tags for pat jet production
            _newPatJets.tagInfoSources = cms.VInputTag(*[cms.InputTag(x + _labelName + postfix) for x in btagInfos])
            _newPatJets.discriminatorSources = cms.VInputTag(
                *[cms.InputTag(x + _labelName + postfix) for x in btagDiscriminators]
            )
        else:
            _newPatJets.addBTagInfo = False
            ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
            for outputModule in outputModules:
                if hasattr(process, outputModule):
                    getattr(process, outputModule).outputCommands.append(
                        "drop *_" + "selected" + _labelName + postfix + "_tagInfos_*"
                    )

        ## add jet correction factors if required by user
        if jetCorrections != None:
            ## check for the correct format
            if type(jetCorrections) != type(
                ("PAYLOAD-LABEL", ["CORRECTION-LEVEL-A", "CORRECTION-LEVEL-B"], "MET-LABEL")
            ):
                raise ValueError, "In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
                'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
                corrections."
            ## determine type of jet constituents from jetSource; supported
            ## jet constituent types are calo, pf, jpt, for pf also particleflow
            ## is aloowed as part of the jetSource label, which might be used
            ## in CommonTools.ParticleFlow
            _type = "NONE"
            if jetCorrections[0].count("PF") > 0:
                _type = "PF"
            elif jetCorrections[0].count("Calo") > 0:
                _type = "Calo"
            elif jetCorrections[0].count("JPT") > 0:
                _type = "JPT"
            else:
                raise TypeError, "In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets."
            from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors

            if "patJetCorrFactors" + _labelName + postfix in knownModules:
                _newPatJetCorrFactors = getattr(process, "patJetCorrFactors" + _labelName + postfix)
                _newPatJetCorrFactors.src = jetSource
            else:

                setattr(process, "patJetCorrFactors" + _labelName + postfix, patJetCorrFactors.clone(src=jetSource))
                _newPatJetCorrFactors = getattr(process, "patJetCorrFactors" + _labelName + postfix)
            _newPatJetCorrFactors.payload = jetCorrections[0]
            _newPatJetCorrFactors.levels = jetCorrections[1]
            ## check whether L1Offset or L1FastJet is part of levels
            error = False
            for x in jetCorrections[1]:
                if x == "L1Offset":
                    if not error:
                        _newPatJetCorrFactors.useNPV = True
                        _newPatJetCorrFactors.primaryVertices = "offlinePrimaryVertices"
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error = True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[
                            1
                        ]
                if x == "L1FastJet":
                    if not error:
                        if _type == "JPT":
                            raise TypeError, "In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets."
                        ## configure module
                        _newPatJetCorrFactors.useRho = True
                        _newPatJetCorrFactors.rho = cms.InputTag("kt6" + _type + "Jets", "rho")
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error = True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[
                            1
                        ]
            _newPatJets.jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactors" + _labelName + postfix))
            ## configure MET(Type1) corrections
            if jetCorrections[2].lower() != "none" and jetCorrections[2] != "":
                if not jetCorrections[2].lower() == "type-1" and not jetCorrections[2].lower() == "type-2":
                    raise valueError, "In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\
                    Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: ", jetCorrections[
                        2
                    ]
                if _type == "JPT":
                    raise ValueError, 'In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to "None" (as string in quatiation \
                    marks) and use raw tcMET together with JPTJets.'
                ## set up jet correctors for MET corrections
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Fastjet
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Offset
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL2Relative
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL3Absolute
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFResidual

                setattr(
                    process,
                    jetCorrections[0] + "L1FastJet",
                    ak5PFL1Fastjet.clone(
                        algorithm=jetCorrections[0], srcRho=cms.InputTag("kt6" + _type + "Jets", "rho")
                    ),
                )
                setattr(process, jetCorrections[0] + "L1Offset", ak5PFL1Offset.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L2Relative", ak5PFL2Relative.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L3Absolute", ak5PFL3Absolute.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0] + "L2L3Residual", ak5PFResidual.clone(algorithm=jetCorrections[0]))
                setattr(
                    process,
                    jetCorrections[0] + "CombinedCorrector",
                    cms.ESProducer("JetCorrectionESChain", correctors=cms.vstring()),
                )
                for x in jetCorrections[1]:
                    if (
                        x != "L1FastJet"
                        and x != "L1Offset"
                        and x != "L2Relative"
                        and x != "L3Absolute"
                        and x != "L2L3Residual"
                    ):
                        raise ValueError, "In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, \
                        L3Asolute, L2L3Residual. Requested was:", x
                    else:
                        getattr(process, jetCorrections[0] + "CombinedCorrector").correctors.append(
                            jetCorrections[0] + x
                        )

                ## set up MET(Type1) correction modules
                if _type == "Calo":
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloJetMETcorr
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1CorrectedMet
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1p2CorrectedMet

                    setattr(
                        process,
                        jetCorrections[0] + "JetMETcorr" + postfix,
                        caloJetMETcorr.clone(
                            src=jetSource,
                            srcMET="corMetGlobalMuons",
                            jetCorrections=cms.string(jetCorrections[0] + "CombinedCorrector" + postfix),
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1CorMet" + postfix,
                        caloType1CorrectedMet.clone(
                            src="corMetGlobalMuons" + postfix,
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1p2CorMet" + postfix,
                        caloType1p2CorrectedMet.clone(
                            src="corMetGlobalMuons" + postfix,
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                            srcUnclEnergySums=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type2"),
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "offset"),
                                cms.InputTag("muonCaloMETcorr" + postfix),
                            ),
                        ),
                    )

                elif _type == "PF":
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandsNotInJet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1p2CorrectedMet

                    setattr(
                        process,
                        jetCorrections[0] + "CandsNotInJet" + postfix,
                        pfCandsNotInJet.clone(topCollection=jetSource),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "CandMETcorr" + postfix,
                        pfCandMETcorr.clone(src=cms.InputTag(jetCorrections[0] + "CandsNotInJet" + postfix)),
                    )
                    setattr(process, jetCorrections[0] + "JetMETcorr" + postfix, pfJetMETcorr.clone(src=jetSource))
                    setattr(
                        process,
                        jetCorrections[0] + "Type1CorMet" + postfix,
                        pfType1CorrectedMet.clone(
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            )
                        ),
                    )
                    setattr(
                        process,
                        jetCorrections[0] + "Type1p2CorMet" + postfix,
                        pfType1p2CorrectedMet.clone(
                            srcType1Corrections=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type1")
                            ),
                            srcUnclEnergySums=cms.VInputTag(
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "type2"),
                                cms.InputTag(jetCorrections[0] + "JetMETcorr" + postfix, "offset"),
                                cms.InputTag(jetCorrections[0] + "CandMETcorr" + postfix),
                            ),
                        ),
                    )

                ## common configuration for Calo and PF
                if "L1FastJet" in jetCorrections[1] or "L1Fastjet" in jetCorrections[1]:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string(
                        jetCorrections[0] + "L1FastJet"
                    )
                elif "L1Offset" in jetCorrections[1]:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string(
                        jetCorrections[0] + "L1Offset"
                    )
                else:
                    getattr(process, jetCorrections[0] + "JetMETcorr" + postfix).offsetCorrLabel = cms.string("")

                from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs

                if jetCorrections[2].lower() == "type-1":
                    setattr(
                        process,
                        "patMETs" + _labelName + postfix,
                        patMETs.clone(
                            metSource=cms.InputTag(jetCorrections[0] + "Type1CorMet" + postfix),
                            addMuonCorrections=False,
                        ),
                    )
                elif jetCorrections[2].lower() == "type-1":
                    setattr(
                        process,
                        "patMETs" + _labelName + postfix,
                        patMETs.clone(
                            metSource=cms.InputTag(jetCorrections[0] + "Type1p2CorMet" + postfix),
                            addMuonCorrections=False,
                        ),
                    )
        else:
            ## switch jetCorrFactors off
            _newPatJets.addJetCorrFactors = False
Пример #2
0
###### Jet MET corrections
process.load('RecoJets.Configuration.RecoPFJets_cff')
process.kt6PFJets.doRhoFastjet = True
process.kt6PFJets.doAreaFastjet = True
process.kt6PFJets.voronoiRfact = 0.9

process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
process.load('JetMETCorrections.Configuration.JetCorrectionServices_cff')
process.load("JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi")
process.load('JetMETCorrections.Type1MET.pfMETCorrections_cff')
process.pfJetMETcorr.jetCorrLabel = cms.string("ak5PFL1FastL2L3")
from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
process.pfType0Type1CorrectedMet = pfType1CorrectedMet.clone(
applyType0Corrections = cms.bool(False),
srcType1Corrections = cms.VInputTag(
    cms.InputTag('pfMETcorrType0'),
    cms.InputTag('pfJetMETcorr', 'type1')
)
)
process.metAnalysisSequence=cms.Sequence(process.type0PFMEtCorrection*process.producePFMETCorrections*process.pfType0Type1CorrectedMet)
process.jet_step = cms.Path(process.kt6PFJets*process.metAnalysisSequence)

######PF ISO calculation for Electrons
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFPhotonIso
process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons')
#process.phoIsoSequence = setupPFPhotonIso(process, 'photons')
#process.pfiso_step = cms.Path( process.pfParticleSelectionSequence + process.eleIsoSequence + process.phoIsoSequence)
process.pfiso_step = cms.Path( process.pfParticleSelectionSequence + process.eleIsoSequence)

######Electron ID
process.load("RecoEgamma.ElectronIdentification.cutsInCategoriesElectronIdentificationV06_cfi")
Пример #3
0
from Validation.RecoMET.METValidation_cfi import *

#Removed the MET collections that we no longer monitor
#in an attempt to reduce the number of histograms produced
# as requested by DQM group to reduce the load on server.
# -Samantha Hewamanage ([email protected]) - 04-27-2012

from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr, pfchsMETcorr, pfType1CorrectedMet

from JetMETCorrections.Configuration.JetCorrectionServices_cff import ak4PFL1FastL2L3, ak4PFL1Fastjet, ak4PFL2Relative, ak4PFL3Absolute

newAk5PFL1FastL2L3 = ak4PFL1FastL2L3.clone()
pfJetMETcorr.jetCorrLabel = cms.string('newAk5PFL1FastL2L3')

pfType0CorrectedMet = pfType1CorrectedMet.clone(
    applyType0Corrections=cms.bool(True),
    applyType1Corrections=cms.bool(False))
pfType01CorrectedMet = pfType1CorrectedMet.clone(
    applyType0Corrections=cms.bool(True), applyType1Corrections=cms.bool(True))

METRelValSequence = cms.Sequence(
    metAnalyzer *
    #metHOAnalyzer*
    #metNoHFAnalyzer*
    #metNoHFHOAnalyzer*
    #metOptAnalyzer*
    #metOptHOAnalyzer*
    #metOptNoHFAnalyzer*
    #metOptNoHFHOAnalyzer
    pfMetAnalyzer *
    #tcMetAnalyzer*
Пример #4
0
    doBTagging = False,
    jetCorrLabel = _jetCorrections,
    doType1MET = False,
    doJetID = True,
    jetIdLabel = "ak5"
)

# apply type I/type I + II PFMEt corrections to pat::MET object 
# and estimate systematic uncertainties on MET
from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties
runMEtUncertainties(process,doApplyType0corr=False)

process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
 
process.pfMETType0 = pfType1CorrectedMet.clone()
process.pfMETType0.applyType1Corrections = cms.bool(True)
process.pfMETType0.applyType0Corrections = cms.bool(True)

if tauSwitch:
    tausequence = cms.Sequence( process.PFTau)
else:
    tausequence = cms.Sequence()
if IsPythiaShowered:
    filtersequence = cms.Sequence( process.totalKinematicsFilter )
else:
    filtersequence = cms.Sequence()

# photon
# the isolation has to be reprocessed, cf. https://twiki.cern.ch/twiki/bin/view/CMS/EgammaPFBasedIsolation#The_25th_May_update
# which require the EGammaAnalysisTools photonIsoProducer from:
Пример #5
0
    def toolCode(self, process):
        """
        Tool code implementation
        """
        ## initialize parameters
        labelName='patJets'+self._parameters['labelName'].value
        postfix=self._parameters['postfix'].value
        jetSource=self._parameters['jetSource'].value
        algo=self._parameters['algo'].value
        jetCorrections=self._parameters['jetCorrections'].value
        btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
        btagInfos=list(self._parameters['btagInfos'].value)
        jetTrackAssociation=self._parameters['jetTrackAssociation'].value
        outputModules=list(self._parameters['outputModules'].value)

        ## a list of all producer modules, which are already known to process
        knownModules = process.producerNames().split()
        ## determine whether btagging information is required or not
        if btagDiscriminators.count('None')>0:
            btagDiscriminators.remove('None')
        if btagInfos.count('None')>0:
            btagInfos.remove('None')
        bTagging=(len(btagDiscriminators)>0 or len(btagInfos)>0)
        ## construct postfix label for auxiliary modules; this postfix
        ## label will start with a capitalized first letter following
        ## the CMS nameing conventions and for improved readablility
        _labelName=labelName[:1].upper()+labelName[1:]
	#_labelName=labelName
        ## determine jet algorithm from jetSource; supported algo types
        ## are ak, kt, sc, ic. This loop expects that the algo type is
        ## followed by a single integer corresponding to the opening
        ## angle parameter dR times 10 (examples ak5, kt4, kt6, ...)
        _algo=algo
	#jetSource=cms.InputTag("ak5PFJets")
        for x in ["ak", "kt", "sc", "ic"]:
            if jetSource.getModuleLabel().lower().find(x)>-1:
                _algo=jetSource.getModuleLabel()[jetSource.getModuleLabel().lower().find(x):jetSource.getModuleLabel().lower().find(x)+3]
	#print _algo
        ## add new patJets to process (keep instance for later further modifications)
        from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import patJets
        if labelName in knownModules :
            _newPatJets=getattr(process, labelName+postfix)
            _newPatJets.jetSource=jetSource
        else :
            #setattr(process, labelName, patJets.clone(jetSource=jetSource))
            setattr(process, labelName+postfix, patJets.clone(jetSource=jetSource))
            _newPatJets=getattr(process, labelName+postfix)
            knownModules.append(labelName+postfix)
        ## add new selectedPatJets to process
        from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
        if 'selected'+_labelName+postfix in knownModules :
            _newSelectedPatJets=getattr(process, 'selected'+_labelName+postfix)
            _newSelectedPatJets.src=labelName+postfix
        else :
            setattr(process, 'selected'+_labelName+postfix, selectedPatJets.clone(src=labelName+postfix))
            knownModules.append('selected'+_labelName+postfix)

        ## set postfix label to '' if there is no labelName given. In this case all
        ## modules should keep there names w/o postfixes. This will cover the case
        ## of switchJectCollection
        if self._parameters['labelName'].value == '' :
            _labelName = ''

	## add new patJetPartonMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
        if 'patJetPartonMatch'+_labelName+postfix in knownModules :
            _newPatJetPartonMatch=getattr(process, 'patJetPartonMatch'+_labelName+postfix)
            _newPatJetPartonMatch.src=jetSource
        else :
            setattr(process, 'patJetPartonMatch'+_labelName+postfix, patJetPartonMatch.clone(src=jetSource))
            knownModules.append('patJetPartonMatch'+_labelName+postfix)
        ## add new patJetGenJetMatch to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
        if 'patJetGenJetMatch'+_labelName+postfix in knownModules :
            _newPatJetGenJetMatch=getattr(process, 'patJetGenJetMatch'+_labelName+postfix)
            _newPatJetGenJetMatch.src=jetSource
            _newPatJetGenJetMatch.matched=_algo.lower()+'GenJets'+postfix
        else :
            setattr(process, 'patJetGenJetMatch'+_labelName+postfix, patJetGenJetMatch.clone(src=jetSource, matched=_algo+'GenJets'))
            knownModules.append('patJetGenJetMatch'+_labelName+postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociation
        if 'patJetPartonAssociation'+_labelName+postfix in knownModules :
            _newPatJetPartonAssociation=getattr(process, 'patJetPartonAssociation'+_labelName+postfix, patJetPartonAssociation.clone(jets=jetSource))
            _newPatJetPartonAssociation.jets=jetSource
        else :
            setattr(process, 'patJetPartonAssociation'+_labelName+postfix, patJetPartonAssociation.clone(jets=jetSource))
            knownModules.append('patJetPartonAssociation'+_labelName+postfix)
        ## add new patJetPartonAssociation to process
        from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
        if 'patJetFlavourAssociation'+_labelName+postfix in knownModules :
            _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix, patJetFlavourAssociation.clone(srcByReference='patJetPartonAssociation'+_labelName+postfix))
            _newPatJetFlavourAssociation.srcByReference='patJetPartonAssociation'+_labelName+postfix
        else:
            setattr(process, 'patJetFlavourAssociation'+_labelName+postfix, patJetFlavourAssociation.clone(srcByReference='patJetPartonAssociation'+_labelName+postfix))
            knownModules.append('patJetFlavourAssociation'+_labelName+postfix)
        ## modify new patJets collection accordingly
        _newPatJets.genJetMatch.setModuleLabel('patJetGenJetMatch'+_labelName+postfix)
        _newPatJets.genPartonMatch.setModuleLabel('patJetPartonMatch'+_labelName+postfix)
        _newPatJets.JetPartonMapSource.setModuleLabel('patJetFlavourAssociation'+_labelName+postfix)

        ## add jetTrackAssociation for btagging (or jetTracksAssociation only) if required by user
        if (jetTrackAssociation or bTagging):
            ## add new jetTracksAssociationAtVertex to process
            from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
            if 'jetTracksAssociationAtVertex'+_labelName+postfix in knownModules :
                _newJetTracksAssociationAtVertex=getattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix)
                _newJetTracksAssociationAtVertex.jets=jetSource
            else:
                setattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix, ak5JetTracksAssociatorAtVertex.clone(jets=jetSource))
                knownModules.append('jetTracksAssociationAtVertex'+_labelName+postfix)
            ## add new patJetCharge to process
            from PhysicsTools.PatAlgos.recoLayer0.jetTracksCharge_cff import patJetCharge
            if 'patJetCharge'+_labelName+postfix in knownModules :
                _newPatJetCharge=getattr(process, 'patJetCharge'+_labelName+postfix)
                _newPatJetCharge.src='jetTracksAssociatorAtVertex'+_labelName+postfix
            else:
                setattr(process, 'patJetCharge'+_labelName+postfix, patJetCharge.clone(src = 'jetTracksAssociatorAtVertex'+_labelName+postfix))
                knownModules.append('patJetCharge'+_labelName+postfix)
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks=True
            _newPatJets.trackAssociationSource=cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)
            _newPatJets.addJetCharge=True
            _newPatJets.jetChargeSource=cms.InputTag('patJetCharge'+_labelName+postfix)
        else:
            ## modify new patJets collection accordingly
            _newPatJets.addAssociatedTracks=False
            _newPatJets.trackAssociationSource=''
            _newPatJets.addJetCharge=False
            _newPatJets.jetChargeSource=''
        ## run btagging if required by user
        if (bTagging):
            ## expand tagInfos to what is explicitely required by user + implicit
            ## requirements that come in from one or the other discriminator
            requiredTagInfos = list(btagInfos)
            for btagDiscr in btagDiscriminators :
                for requiredTagInfo in supportedBtagDiscr[btagDiscr] :
                    tagInfoCovered = False
                    for tagInfo in requiredTagInfos :
                        if requiredTagInfo == tagInfo :
                            tagInfoCovered = True
                            break
                    if not tagInfoCovered :
                        requiredTagInfos.append(requiredTagInfo)
            ## load sequences and setups needed fro btagging
	    ## This loads all available btagger, but the ones we need are added to the process by hand lader. Only needed to get the ESProducer. Needs improvement
            #loadWithPostFix(process,"RecoBTag.Configuration.RecoBTag_cff",postfix)
            process.load("RecoBTag.Configuration.RecoBTag_cff")
	    #addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
            import RecoBTag.Configuration.RecoBTag_cff as btag

            ## prepare setups for simple secondary vertex infos
            setattr(process, "simpleSecondaryVertex2Trk", simpleSecondaryVertex2Trk)
            ## prepare setups for transient tracks
            setattr(process, "TransientTrackBuilderESProducer", TransientTrackBuilderESProducer)
            ## setup all required btagInfos : we give a dedicated treatment for all five different
            ## types of tagINfos here. A common treatment is possible but might require a more
            ## general approach anyway in coordination with the btaggin POG.
            for btagInfo in requiredTagInfos :
                if 'impactParameterTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.impactParameterTagInfos.clone(jetTracks = cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)))
                if 'secondaryVertexTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.secondaryVertexTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
                if 'secondaryVertexNegativeTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.secondaryVertexNegativeTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
                if 'softElectronTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.softElectronTagInfos.clone(jets = cms.InputTag(_newJetCollection)))
                if 'softMuonTagInfos' in btagInfo :
                    setattr(process, btagInfo+_labelName+postfix, btag.softMuonTagInfos.clone(jets = cms.InputTag(_newJetCollection)))
            ## setup all required btagDiscriminators
            for btagDiscr in btagDiscriminators :
                setattr(process, btagDiscr+_labelName+postfix, getattr(btag, btagDiscr).clone(tagInfos = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in supportedBtagDiscr[btagDiscr] ] )))
            ## replace corresponding tags for pat jet production
            _newPatJets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in btagInfos ] )
            _newPatJets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x+_labelName+postfix) for x in btagDiscriminators ] )
        else:
            _newPatJets.addBTagInfo = False
            ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
            for outputModule in outputModules:
                    if hasattr(process,outputModule):
                        getattr(process,outputModule).outputCommands.append("drop *_"+'selected'+_labelName+postfix+"_tagInfos_*")

        ## add jet correction factors if required by user
        if (jetCorrections != None):
            ## check for the correct format
            if type(jetCorrections) != type(('PAYLOAD-LABEL',['CORRECTION-LEVEL-A','CORRECTION-LEVEL-B'], 'MET-LABEL')):
                raise ValueError, "In addJetCollection: 'jetCorrections' must be 'None' (as a python value w/o quotation marks), or of type ('PAYLOAD-LABEL', ['CORRECTION-LEVEL-A', \
                'CORRECTION-LEVEL-B', ...], 'MET-LABEL'). Note that 'MET-LABEL' can be set to 'None' (as a string in quotation marks) in case you do not want to apply MET(Type1) \
                corrections."
            ## determine type of jet constituents from jetSource; supported
            ## jet constituent types are calo, pf, jpt, for pf also particleflow
            ## is aloowed as part of the jetSource label, which might be used
            ## in CommonTools.ParticleFlow
            _type="NONE"
            if jetCorrections[0].count('PF')>0:
                _type='PF'
            elif jetCorrections[0].count('Calo')>0:
                _type='Calo'
            elif jetCorrections[0].count('JPT')>0:
                _type='JPT'
            else:
                raise TypeError, "In addJetCollection: Jet energy corrections are only supported for PF, JPT and Calo jets."
            from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import patJetCorrFactors
            if 'patJetCorrFactors'+_labelName+postfix in knownModules :
                _newPatJetCorrFactors=getattr(process, 'patJetCorrFactors'+_labelName+postfix)
                _newPatJetCorrFactors.src=jetSource
            else :

                setattr(process, 'patJetCorrFactors'+_labelName+postfix, patJetCorrFactors.clone(src=jetSource))
                _newPatJetCorrFactors=getattr(process, "patJetCorrFactors"+_labelName+postfix)
            _newPatJetCorrFactors.payload=jetCorrections[0]
            _newPatJetCorrFactors.levels=jetCorrections[1]
            ## check whether L1Offset or L1FastJet is part of levels
            error=False
            for x in jetCorrections[1]:
                if x == 'L1Offset' :
                    if not error :
                        _newPatJetCorrFactors.useNPV=True
                        _newPatJetCorrFactors.primaryVertices='offlinePrimaryVertices'
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error=True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[1]
                if x == 'L1FastJet' :
                    if not error :
                        if _type == "JPT" :
                            raise TypeError, "In addJetCollection: L1FastJet corrections are only supported for PF and Calo jets."
                        ## configure module
                        _newPatJetCorrFactors.useRho=True
                        _newPatJetCorrFactors.rho=cms.InputTag('kt6'+_type+'Jets', 'rho')
                        ## we set this to True now as a L1 correction type should appear only once
                        ## otherwise levels is miss configured
                        error=True
                    else:
                        raise ValueError, "In addJetCollection: Correction levels for jet energy corrections are miss configured. An L1 correction type should appear not more than \
                        once. Check the list of correction levels you requested to be applied: ", jetCorrections[1]
            _newPatJets.jetCorrFactorsSource=cms.VInputTag(cms.InputTag('patJetCorrFactors'+_labelName+postfix))
            ## configure MET(Type1) corrections
            if jetCorrections[2].lower() != 'none' and jetCorrections[2] != '':
                if not jetCorrections[2].lower() == 'type-1' and not jetCorrections[2].lower() == 'type-2':
                    raise valueError, "In addJetCollection: Wrong choice of MET corrections for new jet collection. Possible choices are None (or empty string), Type-1, Type-2 (i.e.\
                    Type-1 and Type-2 corrections applied). This choice is not case sensitive. Your choice was: ", jetCorrections[2]
                if _type == "JPT":
                    raise ValueError, "In addJecCollection: MET(type1) corrections are not supported for JPTJets. Please set the MET-LABEL to \"None\" (as string in quatiation \
                    marks) and use raw tcMET together with JPTJets."
                ## set up jet correctors for MET corrections
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Fastjet
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Offset
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL2Relative
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL3Absolute
                from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFResidual

                setattr(process, jetCorrections[0]+'L1FastJet', ak5PFL1Fastjet.clone(algorithm=jetCorrections[0], srcRho=cms.InputTag('kt6'+_type+'Jets','rho')))
                setattr(process, jetCorrections[0]+'L1Offset', ak5PFL1Offset.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L2Relative', ak5PFL2Relative.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L3Absolute', ak5PFL3Absolute.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'L2L3Residual', ak5PFResidual.clone(algorithm=jetCorrections[0]))
                setattr(process, jetCorrections[0]+'CombinedCorrector', cms.ESProducer( 'JetCorrectionESChain', correctors = cms.vstring()))
                for x in jetCorrections[1]:
                    if x != 'L1FastJet' and x != 'L1Offset' and x != 'L2Relative' and x != 'L3Absolute' and x != 'L2L3Residual':
                        raise ValueError, 'In addJetCollection: Unsupported JEC for MET(Type1). Currently supported jet correction levels are L1FastJet, L1Offset, L2Relative, \
                        L3Asolute, L2L3Residual. Requested was:', x
                    else:
                        getattr(process, jetCorrections[0]+'CombinedCorrector').correctors.append(jetCorrections[0]+x)

                ## set up MET(Type1) correction modules
                if _type == 'Calo':
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloJetMETcorr
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1CorrectedMet
                    from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloType1p2CorrectedMet
                    setattr(process,jetCorrections[0]+'JetMETcorr'+postfix, caloJetMETcorr.clone(src=jetSource,srcMET = "corMetGlobalMuons",jetCorrections = cms.string(jetCorrections[0]+'CombinedCorrector'+postfix)))
                    setattr(process,jetCorrections[0]+'Type1CorMet'+postfix, caloType1CorrectedMet.clone(src = "corMetGlobalMuons"+postfix,srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1'))))
                    setattr(process,jetCorrections[0]+'Type1p2CorMet'+postfix,caloType1p2CorrectedMet.clone(src = "corMetGlobalMuons"+postfix,srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1')),srcUnclEnergySums = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type2'),cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'offset'),cms.InputTag('muonCaloMETcorr'+postfix))))

                elif _type == 'PF':
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandsNotInJet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandMETcorr
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
                    from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1p2CorrectedMet
                    setattr(process,jetCorrections[0]+'CandsNotInJet'+postfix,pfCandsNotInJet.clone(topCollection = jetSource))
                    setattr(process,jetCorrections[0]+'CandMETcorr'+postfix, pfCandMETcorr.clone(src = cms.InputTag(jetCorrections[0]+'CandsNotInJet'+postfix)))
                    setattr(process,jetCorrections[0]+'JetMETcorr'+postfix, pfJetMETcorr.clone(src = jetSource))
                    setattr(process,jetCorrections[0]+'Type1CorMet'+postfix, pfType1CorrectedMet.clone(srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1'))))
                    setattr(process,jetCorrections[0]+'Type1p2CorMet'+postfix, pfType1p2CorrectedMet.clone(srcType1Corrections = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type1')),srcUnclEnergySums = cms.VInputTag(cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'type2'),cms.InputTag(jetCorrections[0]+'JetMETcorr'+postfix, 'offset'),cms.InputTag(jetCorrections[0]+'CandMETcorr'+postfix))))

                ## common configuration for Calo and PF
                if ('L1FastJet' in jetCorrections[1] or 'L1Fastjet' in jetCorrections[1]):
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string(jetCorrections[0]+'L1FastJet')
                elif ('L1Offset' in jetCorrections[1]):
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string(jetCorrections[0]+'L1Offset')
                else:
                    getattr(process,jetCorrections[0]+'JetMETcorr'+postfix).offsetCorrLabel = cms.string('')

                from PhysicsTools.PatAlgos.producersLayer1.metProducer_cfi import patMETs
                if jetCorrections[2].lower() == 'type-1':
                    setattr(process, 'patMETs'+_labelName+postfix, patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+'Type1CorMet'+postfix), addMuonCorrections = False))
                elif jetCorrections[2].lower() == 'type-1':
                    setattr(process, 'patMETs'+_labelName+postfix, patMETs.clone(metSource = cms.InputTag(jetCorrections[0]+'Type1p2CorMet'+postfix), addMuonCorrections = False))
        else:
            ## switch jetCorrFactors off
            _newPatJets.addJetCorrFactors=False
Пример #6
0
    jetCorrLabel = _jetCorrections,
    doType1MET = False,
    doJetID = True,
    jetIdLabel = "ak5"
)

# apply type I/type I + II PFMEt corrections to pat::MET object 
# and estimate systematic uncertainties on MET
from PhysicsTools.PatUtils.tools.metUncertaintyTools import runMEtUncertainties
runMEtUncertainties(process,doApplyType0corr=False,tauCollection=None)
#runMEtUncertainties(process,doApplyType0corr=False)

process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfType1CorrectedMet
 
process.pfMETType0 = pfType1CorrectedMet.clone()
process.pfMETType0.applyType1Corrections = cms.bool(True)
process.pfMETType0.applyType0Corrections = cms.bool(True)


if IsPythiaShowered:
    filtersequence = cms.Sequence( process.totalKinematicsFilter )
else:
    filtersequence = cms.Sequence()


#for isolation correction in HEEP ID
process.load("RecoJets.JetProducers.kt4PFJets_cfi")
process.kt6PFJetsForIsolation = process.kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)
Пример #7
0
process.pfNoElectronPFCHS.enable = False
process.pfNoMuonPFCHS.enable = False
process.pfNoTauPFCHS.enable = False

# L1 Fast-jet corrections (only PF jets)
process.load("JetMETCorrections.Configuration.DefaultJEC_cff")
process.load("RecoJets.Configuration.RecoPFJets_cff")

process.kt6PFJetsForIso = process.kt4PFJets.clone(rParam=0.6, doRhoFastjet=True)
process.kt6PFJetsForIso.Rho_EtaMax = cms.double(2.5)

# MET corrections
from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr, pfType1CorrectedMet

process.pfJetMETcorr = pfJetMETcorr.clone()
process.pfType1CorrectedMet = pfType1CorrectedMet.clone()
if options.runon == "data":
    process.pfJetMETcorr.jetCorrLabel = process.pfJetMETcorr.jetCorrLabel.value() + "Residual"


from JetMETCorrections.Type1MET.MetType1Corrections_cff import metJESCorAK5CaloJet

process.metMuonJESCorAK5 = metJESCorAK5CaloJet.clone()
process.metMuonJESCorAK5.inputUncorJetsLabel = "ak5CaloJets"
process.metMuonJESCorAK5.inputUncorMetLabel = "corMetGlobalMuons"

process.metCorSequence = cms.Sequence(process.pfJetMETcorr + process.pfType1CorrectedMet + process.metMuonJESCorAK5)


######### Get a list of good primary vertices, in 42x, these are DAF vertices ################
process.goodVertices = cms.EDFilter(
Пример #8
0
# Date: 03.01.09
# Fill validation histograms for MET.
from Validation.RecoMET.METValidation_cfi import *

#Removed the MET collections that we no longer monitor
#in an attempt to reduce the number of histograms produced
# as requested by DQM group to reduce the load on server. 
# -Samantha Hewamanage ([email protected]) - 04-27-2012

from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfJetMETcorr, pfchsMETcorr, pfType1CorrectedMet 

from JetMETCorrections.Configuration.JetCorrectionServices_cff import ak5PFL1FastL2L3,ak5PFL1Fastjet,ak5PFL2Relative,ak5PFL3Absolute
newAk5PFL1FastL2L3 = ak5PFL1FastL2L3.clone()
pfJetMETcorr.jetCorrLabel = cms.string('newAk5PFL1FastL2L3')

pfType0CorrectedMet = pfType1CorrectedMet.clone(applyType0Corrections = cms.bool(True), applyType1Corrections = cms.bool(False))
pfType01CorrectedMet = pfType1CorrectedMet.clone(applyType0Corrections = cms.bool(True), applyType1Corrections = cms.bool(True))

METRelValSequence = cms.Sequence(
    metAnalyzer*
    #metHOAnalyzer*
    #metNoHFAnalyzer*
    #metNoHFHOAnalyzer*
    #metOptAnalyzer*
    #metOptHOAnalyzer*
    #metOptNoHFAnalyzer*
    #metOptNoHFHOAnalyzer
    pfMetAnalyzer*
    tcMetAnalyzer*
    #corMetGlobalMuonsAnalyzer*
    genMetTrueAnalyzer*