process.vetoMuons = selectedPatMuons.clone(
    src='muonUserData',
    cut='userInt("isLoose")',
)

process.goodNonIsoR1Muons = process.goodMuons.clone(
    cut='userInt("isGoodNonIsoR1")',
)

process.goodNonIsoR2Muons = process.goodMuons.clone(
    cut='userInt("isGoodNonIsoR2")',
)

process.goodElectrons = selectedPatElectrons.clone(
    src='electronUserData',
    cut=cms.string('userInt("isGood")'),
    lazyParser=cms.untracked.bool(True),
)

process.vetoElectrons = process.goodElectrons.clone(
    cut=cms.string('userInt("isVeto")'),
)

process.goodConversionElectrons = process.goodElectrons.clone(
    cut='userInt("isGoodConversion")',
)
process.goodNonIsoElectrons = process.goodElectrons.clone(
    cut='userInt("isGoodNonIso")',
)

process.goodJets = cleanPatJets.clone(
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons

userPreselectedElectrons = selectedPatElectrons.clone(
    src='slimmedElectrons',
    cut=
    '(pt > 10.) && (abs(superCluster.eta) < 2.5) && !((1.4442 < abs(superCluster.eta)) && (abs(superCluster.eta) < 1.5660))',
)

_elecID_dxydzCuts = '((abs(superCluster.eta) < 1.4442) && (abs(userFloat("dxyPV")) < 0.05) && (abs(userFloat("dzPV")) < 0.10))'
_elecID_dxydzCuts += ' || ((abs(superCluster.eta) > 1.5660) && (abs(userFloat("dxyPV")) < 0.10) && (abs(userFloat("dzPV")) < 0.20))'

userElectronsWithUserData = cms.EDProducer(
    'ElectronPATUserData',
    src=cms.InputTag('userPreselectedElectrons'),
    primaryVertices=cms.InputTag('offlineSlimmedPrimaryVertices'),
    effAreas_file=cms.FileInPath(
        'RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt'
    ),
    rho=cms.InputTag('fixedGridRhoFastjetAll'),
    userFloat_copycat=cms.PSet(
        mva_Iso=cms.string('ElectronMVAEstimatorRun2Fall17' + 'IsoV1Values'),
        mva_NoIso=cms.string('ElectronMVAEstimatorRun2Fall17' +
                             'NoIsoV1Values'),
    ),
    userInt_stringSelectors=cms.PSet(
        IDCutBasedVeto=cms.string(
            '(' + _elecID_dxydzCuts +
            ') && (electronID("cutBasedElectronID-Fall17-94X-V1-veto") > 0.5)'
        ),
Exemple #3
0
)

# Step 3

electronsWithRegression = eleRegressionEnergy.clone(
  inputElectronsTag = cms.InputTag( 'patElectrons' )
, rhoCollection     = cms.InputTag( 'fixedGridRhoFastjetAll' )
, vertexCollection  = cms.InputTag( 'offlinePrimaryVertices' )
)
calibratedElectrons = calibratedPatElectrons.clone(
  inputPatElectronsTag = cms.InputTag( 'electronsWithRegression' )
, inputDataset         = 'Summer12'
)

selectedElectrons = selectedPatElectrons.clone(
  src = cms.InputTag( 'patElectrons' )
, cut = '' # electronCut
)

standAloneElectronVetoFilter = cms.EDFilter(
  "PATCandViewCountFilter"
, src       = cms.InputTag( 'selectedElectrons' )
, minNumber = cms.uint32( 0 )
, maxNumber = cms.uint32( 0 )
)

# Step 4

selectedJets = selectedPatJets.clone(
  src = cms.InputTag( 'patJets' )
, cut = '' # jetCut
)
import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons
isolatedPatElectrons = selectedPatElectrons.clone(src="selectedPatElectrons", cut="pt>10 & abs(eta)<2.5 & (trackIso+caloIso)/pt<0.05")

from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import selectedPatMuons
isolatedPatMuons = selectedPatMuons.clone(src="selectedPatMuons", cut="pt>10 & abs(eta)<2.5 & (trackIso+caloIso)/pt<0.05")

customSelection = cms.Sequence(
    isolatedPatElectrons *isolatedPatMuons
    )
Exemple #5
0
process.load('JMETriggerAnalysis.NTuplizers.userElectrons_cff')
process.offlineEventSelectionSeq *= process.userElectronsSequence

## Event Selection
from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import selectedPatMuons

process.eventSelMuons = selectedPatMuons.clone(
    src='userIsolatedMuons',
    cut='pt>27 && userInt("IDMedium") && userFloat("pfIsoR04") < 0.25',
)

from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons

process.eventSelElectrons = selectedPatElectrons.clone(
    src='userIsolatedElectrons',
    cut='pt>35 && userInt("IDCutBasedMedium")',
)

process.eventSelLeptons = cms.EDProducer(
    'CandViewMerger',
    src=cms.VInputTag('eventSelMuons', 'eventSelElectrons'),
)

process.eventSelOneLepton = cms.EDFilter(
    'CandViewCountFilter',
    src=cms.InputTag('eventSelLeptons'),
    minNumber=cms.uint32(1),
)

process.offlineEventSelectionSeq *= cms.Sequence(
    process.eventSelMuons * process.eventSelElectrons *
Exemple #6
0
def userElectrons(process, era):
    ###
    ### setupEgammaPostRecoSeq: EGamma-POG routine to apply IDs + Energy-Scale/Smearing Corrections
    ###
    ###  - https://twiki.cern.ch/twiki/bin/view/CMS/EgammaMiniAODV2
    ###  - https://twiki.cern.ch/twiki/bin/view/CMS/EgammaPostRecoRecipes
    ###  - https://hypernews.cern.ch/HyperNews/CMS/get/egamma/2204/1/1.html (because of PUPPI MET, added 'phoIDModules=[]')
    ###
    if era == '2016':
        setupEgammaPostRecoSeq(process,
                               runVID=True,
                               phoIDModules=[],
                               runEnergyCorrections=True,
                               applyEnergyCorrections=False,
                               era='2016-Legacy')
    elif era == '2017':
        setupEgammaPostRecoSeq(process,
                               runVID=True,
                               phoIDModules=[],
                               runEnergyCorrections=True,
                               applyEnergyCorrections=False,
                               era='2017-Nov17ReReco')
    elif era == '2018':
        setupEgammaPostRecoSeq(process,
                               runVID=True,
                               phoIDModules=[],
                               runEnergyCorrections=True,
                               applyEnergyCorrections=False,
                               era='2018-Prompt')
    else:
        raise RuntimeError('userElectrons(process, era="' + str(era) +
                           '") -- invalid value for argument "era"')

    process.userPreselectedElectrons = selectedPatElectrons.clone(
        src='slimmedElectrons',
        cut=
        '(pt > 10.) && (abs(superCluster.eta) < 2.5) && !((1.4442 < abs(superCluster.eta)) && (abs(superCluster.eta) < 1.5660))',
    )

    _elecID_dxydzCuts = '((abs(superCluster.eta) < 1.4442) && (abs(userFloat("dxyPV")) < 0.05) && (abs(userFloat("dzPV")) < 0.10))'
    _elecID_dxydzCuts += ' || ((abs(superCluster.eta) > 1.5660) && (abs(userFloat("dxyPV")) < 0.10) && (abs(userFloat("dzPV")) < 0.20))'

    process.userElectronsWithUserData = cms.EDProducer(
        'ElectronPATUserData',
        src=cms.InputTag('userPreselectedElectrons'),
        primaryVertices=cms.InputTag('offlineSlimmedPrimaryVertices'),
        effAreas_file=cms.FileInPath(
            'RecoEgamma/ElectronIdentification/data/Fall17/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_94X.txt'
        ),
        rho=cms.InputTag('fixedGridRhoFastjetAll'),
        userFloat_copycat=cms.PSet(
            mva_Iso=cms.string('ElectronMVAEstimatorRun2Fall17' +
                               'IsoV2Values'),
            mva_NoIso=cms.string('ElectronMVAEstimatorRun2Fall17' +
                                 'NoIsoV2Values'),
        ),
        userInt_stringSelectors=cms.PSet(
            IDCutBasedVeto=cms.string(
                '(' + _elecID_dxydzCuts +
                ') && (electronID("cutBasedElectronID-Fall17-94X-V2-veto") > 0.5)'
            ),
            IDCutBasedLoose=cms.string(
                '(' + _elecID_dxydzCuts +
                ') && (electronID("cutBasedElectronID-Fall17-94X-V2-loose") > 0.5)'
            ),
            IDCutBasedMedium=cms.string(
                '(' + _elecID_dxydzCuts +
                ') && (electronID("cutBasedElectronID-Fall17-94X-V2-medium") > 0.5)'
            ),
            IDCutBasedTight=cms.string(
                '(' + _elecID_dxydzCuts +
                ') && (electronID("cutBasedElectronID-Fall17-94X-V2-tight") > 0.5)'
            ),
            IDMVAIsoWP80=cms.string(
                '(electronID("mvaEleID-Fall17-iso-V2-wp80") > 0.5)'),
            IDMVAIsoWP90=cms.string(
                '(electronID("mvaEleID-Fall17-iso-V2-wp90") > 0.5)'),
        ),
    )

    if era == '2016':
        process.userElectronsWithUserData.effAreas_file = 'RecoEgamma/ElectronIdentification/data/Summer16/effAreaElectrons_cone03_pfNeuHadronsAndPhotons_80X.txt'

    process.userIsolatedElectrons = selectedPatElectrons.clone(
        src='userElectronsWithUserData',
        cut='userInt("IDCutBasedLoose") > 0',
    )

    process.userElectronsTask = cms.Task(
        process.userPreselectedElectrons,
        process.userElectronsWithUserData,
        process.userIsolatedElectrons,
    )

    process.userElectronsSeq = cms.Sequence(process.egammaPostRecoSeq,
                                            process.userElectronsTask)

    return process, 'userIsolatedElectrons'
####################
# Customization
####################
isMC = True
####################

import FWCore.ParameterSet.Config as cms

##select electrons according to these criteria

from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons
selectedElectrons = selectedPatElectrons.clone()
selectedElectrons.src = cms.InputTag("patElectrons")
selectedElectrons.cut = cms.string("pt > 10. & abs(eta) < 3. ")

if isMC == True:
	# Electron MC Matcher
	from PhysicsTools.PatAlgos.mcMatchLayer0.electronMatch_cfi import *
	electronMatch.src = cms.InputTag("gsfElectrons") # RECO objects to match
	electronMatch.matched = cms.InputTag("genParticles")   # mc-truth particle collection
	electronMatch.mcStatus = cms.vint32(1)

	selectedElectrons.addGenMatch = cms.bool(True)
	selectedElectrons.embedGenMatch = cms.bool(True)
	selectedElectrons.genParticleMatch = cms.InputTag("electronMatch")

# new class of selected Electrons
selectedElectrons1 = cms.EDFilter("LargestPtCandViewSelector",
  src = cms.InputTag("selectedElectrons"),
  maxNumber = cms.uint32(2)
)
Exemple #8
0
)

process.vetoMuons = selectedPatMuons.clone(
    src='muonUserData',
    cut='userInt("isLoose")',
)

process.goodNonIsoR1Muons = process.goodMuons.clone(
    cut='userInt("isGoodNonIsoR1")', )

process.goodNonIsoR2Muons = process.goodMuons.clone(
    cut='userInt("isGoodNonIsoR2")', )

process.goodElectrons = selectedPatElectrons.clone(
    src='electronUserData',
    cut=cms.string('userInt("isGood")'),
    lazyParser=cms.untracked.bool(True),
)

process.vetoElectrons = process.goodElectrons.clone(
    cut=cms.string('userInt("isVeto")'), )

process.goodConversionElectrons = process.goodElectrons.clone(
    cut='userInt("isGoodConversion")', )
process.goodNonIsoElectrons = process.goodElectrons.clone(
    cut='userInt("isGoodNonIso")', )

process.goodJets = cleanPatJets.clone(
    src=cms.InputTag("jetUserData"),
    preselection='userInt("passesPt") && userInt("isGood")',
    checkOverlaps=cms.PSet(
Exemple #9
0
import FWCore.ParameterSet.Config as cms

#______________________ Event-Selection _____________________________

from HLTrigger.HLTfilters.hltHighLevel_cfi import hltHighLevel
hltFilter = hltHighLevel.clone(
    andOr = True, ## choose logical OR between Triggerbits
    HLTPaths = ['HLT_ZeroBias'],
    throw = False # tolerate triggers stated above, but not available
    )

#______________________ Object-Selection ____________________________

from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons
from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import selectedPatMuons
from PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi import selectedPatTaus

patJetSelector = selectedPatJets.clone( filter = cms.bool(False), src = "", cut = "")
patElectronSelector = selectedPatElectrons.clone( filter = cms.bool(False), src = "", cut = "")
patMuonSelector = selectedPatMuons.clone( filter = cms.bool(False), src = "", cut = "")
patTauSelector = selectedPatTaus.clone( filter = cms.bool(False), src = "", cut = "")

candStringSelector = cms.EDFilter("CandViewSelector",
    filter = cms.bool(False),
    src = cms.InputTag(""),
    cut = cms.string("")
)


import FWCore.ParameterSet.Config as cms

from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons
isolatedPatElectrons = selectedPatElectrons.clone(
    src="selectedPatElectrons",
    cut="pt>10 & abs(eta)<2.5 & (trackIso+caloIso)/pt<0.05")

from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import selectedPatMuons
isolatedPatMuons = selectedPatMuons.clone(
    src="selectedPatMuons",
    cut="pt>10 & abs(eta)<2.5 & (trackIso+caloIso)/pt<0.05")

customSelection = cms.Sequence(isolatedPatElectrons * isolatedPatMuons)
Exemple #11
0
#______________________ Event-Selection _____________________________

from HLTrigger.HLTfilters.hltHighLevel_cfi import hltHighLevel
hltFilter = hltHighLevel.clone(
    andOr=True,  ## choose logical OR between Triggerbits
    HLTPaths=['HLT_ZeroBias'],
    throw=False  # tolerate triggers stated above, but not available
)

#______________________ Object-Selection ____________________________

from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
from PhysicsTools.PatAlgos.selectionLayer1.electronSelector_cfi import selectedPatElectrons
from PhysicsTools.PatAlgos.selectionLayer1.muonSelector_cfi import selectedPatMuons
from PhysicsTools.PatAlgos.selectionLayer1.tauSelector_cfi import selectedPatTaus

patJetSelector = selectedPatJets.clone(filter=cms.bool(False), src="", cut="")
patElectronSelector = selectedPatElectrons.clone(filter=cms.bool(False),
                                                 src="",
                                                 cut="")
patMuonSelector = selectedPatMuons.clone(filter=cms.bool(False),
                                         src="",
                                         cut="")
patTauSelector = selectedPatTaus.clone(filter=cms.bool(False), src="", cut="")

candStringSelector = cms.EDFilter("CandViewSelector",
                                  filter=cms.bool(False),
                                  src=cms.InputTag(""),
                                  cut=cms.string(""))