def usePFIso(process, postfix = "PFIso"):
    print "Building particle-based isolation "
    print "***************** "
    process.load("CommonTools.ParticleFlow.Isolation.pfElectronIsolation_cff")
    process.load("CommonTools.ParticleFlow.Isolation.pfMuonIsolation_cff")

    setupPFElectronIso(process, 'gsfElectrons', postfix)
    setupPFMuonIso(process, 'muons', postfix)
    adaptPFIsoMuons( process, applyPostfix(process,"patMuons",""), postfix)
    adaptPFIsoElectrons( process, applyPostfix(process,"patElectrons",""), postfix)
def applyElectronParameters(process, isMC):
    process.electronIsoSequence = setupPFElectronIso(process,'gsfElectrons')

    process.patElectrons.isoDeposits = cms.PSet(
        pfAllParticles   = cms.InputTag("elPFIsoDepositPUPFIso"),             # all PU   CH+MU+E
        pfChargedHadrons = cms.InputTag("elPFIsoDepositChargedPFIso"),        # all noPU CH
        pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutralPFIso"),        # all NH
        pfPhotons        = cms.InputTag("elPFIsoDepositGammaPFIso"),          # all PH
        user = cms.VInputTag( cms.InputTag("elPFIsoDepositChargedAllPFIso") ) # all noPU CH+MU+E
        )

    process.patElectrons.isolationValues = cms.PSet(
        pfAllParticles   = cms.InputTag("elPFIsoValuePU04PFIdPFIso"),
        pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04PFIdPFIso"),
        pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04PFIdPFIso"),
        pfPhotons        = cms.InputTag("elPFIsoValueGamma04PFIdPFIso"),
        user = cms.VInputTag(
            cms.InputTag("elPFIsoValueChargedAll04PFIdPFIso"),
            cms.InputTag("elPFIsoValueChargedAll04NoPFIdPFIso"),
            cms.InputTag("elPFIsoValuePU04NoPFIdPFIso"),
            cms.InputTag("elPFIsoValueCharged04NoPFIdPFIso"),
            cms.InputTag("elPFIsoValueGamma04NoPFIdPFIso"),
            cms.InputTag("elPFIsoValueNeutral04NoPFIdPFIso")
            )
        )

    process.patElectronsWithEmbeddedVariables = cms.EDProducer('ElectronsUserEmbedder',
        electronTag = cms.InputTag("patElectronsTriggerMatch"),
        vertexTag = cms.InputTag("offlinePrimaryVerticesWithBS"),
        isMC = cms.bool(isMC),
        doMVAPOG = cms.bool(True),

        inputFileName0v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat1.weights.xml'),
        inputFileName1v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat2.weights.xml'),
        inputFileName2v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat3.weights.xml'),
        inputFileName3v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat4.weights.xml'),
        inputFileName4v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat5.weights.xml'),
        inputFileName5v2 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat6.weights.xml'),

        inputFileName0v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat1.weights.xml'),
        inputFileName1v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat2.weights.xml'),
        inputFileName2v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat3.weights.xml'),
        inputFileName3v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat4.weights.xml'),
        inputFileName4v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat5.weights.xml'),
        inputFileName5v3 = cms.FileInPath('EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat6.weights.xml')
    )

    process.patElectrons.embedTrack = cms.bool(True)
    process.patElectrons.embedGsfTrack = cms.bool(True)

    process.load('EgammaAnalysis.ElectronTools.electronIdMVAProducer_cfi')
    process.patElectrons.electronIDSources = cms.PSet(mvaNonTrigV0 = cms.InputTag("mvaNonTrigV0"))

    return
def usePFIso(process, postfix = "PFIso"):
    print "Building particle-based isolation "
    print "***************** "
    process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons', postfix)
    process.muIsoSequence = setupPFMuonIso(process, 'muons', postfix)
    adaptPFIsoMuons( process, applyPostfix(process,"patMuons",""), postfix)
    adaptPFIsoElectrons( process, applyPostfix(process,"patElectrons",""), postfix)
    getattr(process,'patDefaultSequence').replace( getattr(process,"patCandidates"),
                                                   process.pfParticleSelectionSequence +
                                                   process.eleIsoSequence +
                                                   process.muIsoSequence +
                                                   getattr(process,"patCandidates") )
def useGsfElectrons(process, postfix, dR = "04"):
    print "using Gsf Electrons in PF2PAT"
    print "WARNING: this will destory the feature of top projection which solves the ambiguity between leptons and jets because"
    print "WARNING: there will be overlap between non-PF electrons and jets even though top projection is ON!"
    print "********************* "
    module = applyPostfix(process,"patElectrons",postfix)
    module.useParticleFlow = False
    print "Building particle-based isolation for GsfElectrons in PF2PAT(PFBRECO)"
    print "********************* "
    adaptPFIsoElectrons( process, module, postfix+"PFIso", dR )
    getattr(process,'patDefaultSequence'+postfix).replace( getattr(process,"patElectrons"+postfix),
                                                   setupPFElectronIso(process, 'gsfElectrons', "PFIso", postfix, runPF2PAT=True) +
                                                   getattr(process,"patElectrons"+postfix) )
def usePFIso(process, postfix="PFIso"):
    print "Building particle-based isolation "
    print "***************** "
    process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons',
                                                postfix)
    process.muIsoSequence = setupPFMuonIso(process, 'muons', postfix)
    adaptPFIsoMuons(process, applyPostfix(process, "patMuons", ""), postfix)
    adaptPFIsoElectrons(process, applyPostfix(process, "patElectrons", ""),
                        postfix)
    getattr(process, 'patDefaultSequence').replace(
        getattr(process, "patCandidates"),
        process.pfParticleSelectionSequence + process.eleIsoSequence +
        process.muIsoSequence + getattr(process, "patCandidates"))
def useGsfElectrons(process, postfix, dR="04"):
    print "using Gsf Electrons in PF2PAT"
    print "WARNING: this will destory the feature of top projection which solves the ambiguity between leptons and jets because"
    print "WARNING: there will be overlap between non-PF electrons and jets even though top projection is ON!"
    print "********************* "
    module = applyPostfix(process, "patElectrons", postfix)
    module.useParticleFlow = False
    print "Building particle-based isolation for GsfElectrons in PF2PAT(PFBRECO)"
    print "********************* "
    adaptPFIsoElectrons(process, module, postfix + "PFIso", dR)
    getattr(process, 'patDefaultSequence' + postfix).replace(
        getattr(process, "patElectrons" + postfix),
        setupPFElectronIso(
            process, 'gsfElectrons', "PFIso", postfix, runPF2PAT=True) +
        getattr(process, "patElectrons" + postfix))
def configureElectronMVAIdIso(process) :
    process.load('EgammaAnalysis.ElectronTools.electronIdMVAProducer_cfi')
    process.mvaID = cms.Sequence(  process.mvaTrigV0 + process.mvaTrigNoIPV0 + process.mvaNonTrigV0 )

    #Electron ID
    process.patElectrons.electronIDSources = cms.PSet(
        #MVA
        mvaTrigV0 = cms.InputTag("mvaTrigV0"),
        mvaNonTrigV0 = cms.InputTag("mvaNonTrigV0"),
        mvaTrigNoIPV0 = cms.InputTag("mvaTrigNoIPV0"),
        )

    from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
    process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons')
    from CommonTools.ParticleFlow.pfParticleSelection_cff import pfParticleSelectionSequence
    process.pfParticleSelectionSequence = pfParticleSelectionSequence
    process.pfIsolationSequence = cms.Sequence(
        process.pfParticleSelectionSequence*
        process.eleIsoSequence
        )

    #Custom cone size for Electron isolation
    process.elPFIsoValueChargedAll04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueCharged04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueGamma04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.08)'
        )
    process.elPFIsoValuePU04PFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueNeutral04PFIdPFIso.deposits[0].vetos = cms.vstring()

    process.elPFIsoValueChargedAll04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueCharged04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueGamma04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.08)'
        )
    process.elPFIsoValuePU04NoPFIdPFIso.deposits[0].vetos = cms.vstring(
        'EcalEndcaps:ConeVeto(0.015)'
        )
    process.elPFIsoValueNeutral04PFIdPFIso.deposits[0].vetos = cms.vstring()

    #Set isolation to the patElectrons
    process.patElectrons.isoDeposits = cms.PSet(
        pfAllParticles   = cms.InputTag("elPFIsoDepositPUPFIso"),      # all PU   CH+MU+E
        pfChargedHadrons = cms.InputTag("elPFIsoDepositChargedPFIso"), # all noPU CH
        pfNeutralHadrons = cms.InputTag("elPFIsoDepositNeutralPFIso"), # all NH
        pfPhotons        = cms.InputTag("elPFIsoDepositGammaPFIso"),   # all PH
        user = cms.VInputTag(
         cms.InputTag("elPFIsoDepositChargedAllPFIso"),                 # all noPU CH+MU+E
         )
        )
    process.patElectrons.isolationValues = cms.PSet(
        pfAllParticles   = cms.InputTag("elPFIsoValuePU04PFIdPFIso"),
        pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04PFIdPFIso"),
        pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04PFIdPFIso"),
        pfPhotons        = cms.InputTag("elPFIsoValueGamma04PFIdPFIso"),
        user = cms.VInputTag(
         cms.InputTag("elPFIsoValueChargedAll04PFIdPFIso"),
         )
        )
    process.patElectrons.isolationValuesNoPFId = cms.PSet(
        pfAllParticles   = cms.InputTag("elPFIsoValuePU04NoPFIdPFIso"),
        pfChargedHadrons = cms.InputTag("elPFIsoValueCharged04NoPFIdPFIso"),
        pfNeutralHadrons = cms.InputTag("elPFIsoValueNeutral04NoPFIdPFIso"),
        pfPhotons        = cms.InputTag("elPFIsoValueGamma04NoPFIdPFIso"),
        user = cms.VInputTag(
         cms.InputTag("elPFIsoValueChargedAll04NoPFIdPFIso")
         )
        )

    ################### vertex sequence ####################

    process.selectedPrimaryVertices = cms.EDFilter(
        "VertexSelector",
        src = cms.InputTag('offlinePrimaryVertices'),
        cut = cms.string("isValid & ndof >= 4 & z > -24 & z < +24 & position.Rho < 2."),
        filter = cms.bool(False)
        )

    #process.primaryVertexCounter = cms.EDFilter(
    #    "VertexCountFilter",
    #    src = cms.InputTag('selectedPrimaryVertices'),
    #    minNumber = cms.uint32(1),
    #    maxNumber = cms.uint32(999),
    #    )
    ########Embed elctrons with variable to cut on############
    process.selectedPatElectronsUserEmbedded = cms.EDProducer( 
        "ElectronsUserEmbedded",
        electronTag = cms.InputTag("selectedPatElectrons"),
        vertexTag   = cms.InputTag("selectedPrimaryVertices"),
        rho = cms.InputTag("kt6PFJets", "rho")
        )
    process.EleEmbedSequence = cms.Sequence(process.selectedPrimaryVertices * process.selectedPatElectronsUserEmbedded)
Exemple #8
0
# parse command line arguments
options.parseArguments()

# MET uncertainty tool
# needs to go before everything else for some reason...
if not ("<DataType>" == "Data") and not ("embedded" in "<DataType>"):
    from SkimProduction.CRAB.metUncertaintyTool_cff import metUncertainty
    metUncertainty(process)

# load full CMSSW reconstruction config, needed for btagging
process.load("Configuration.StandardSequences.Reconstruction_cff")

############ Electrons
# electron isolation
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
process.eleIso = setupPFElectronIso(process, 'gsfElectrons')
process.eleIsoSequence = cms.Sequence(process.pfParticleSelectionSequence
                                      * process.eleIso)
# Electron momentum regression
from SkimProduction.CRAB.eleMomentumRegression_cff import eleMomentumRegression
eleMomentumRegression(process, "<datasetpath>", "<DataType>")

############ Jets
# Jet energy corrections to use:
JetCorrection = "ak5PFL1FastL2L3"
if "<DataType>" == "Data" or "embedded" in "<DataType>":
    JetCorrection += "Residual"
process.ak5PFJetsCorr = cms.EDProducer('PFJetCorrectionProducer',
                                       src = cms.InputTag("ak5PFJets"),
                                       correctors = cms.vstring(JetCorrection) # NOTE: use "ak5PFL1FastL2L3" for MC / "ak5PFL1FastL2L3Residual" for Data
                                       )
process.myJetProdLabel = cms.EDProducer('JetProducer',
                                         JetsPtCut  = cms.double(30.), #as suggested by jets contact person
                                         JetsEtaCut = cms.double(3.0)
                                        )

from RecoJets.JetProducers.kt4PFJets_cfi import *
process.kt6PFJetsForIsolation = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)

# particle flow isolation
#

from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso

process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons') 
#print "NewIsolation"
#process.tightElecSequence = setupPFElectronIso(process, 'gsfElectrons')
process.pfiso = cms.Sequence(process.pfParticleSelectionSequence + process.eleIsoSequence )
#process.Newpfiso = cms.Sequence(process.tightElecSequence )

process.myElectronProdLabel = cms.EDProducer('ElectronProducer'  ,
            electronsInputTag = cms.InputTag("gsfElectrons")     ,
            muonsInputTag = cms.InputTag("myLoseMuons")      ,
            conversionsInputTag = cms.InputTag("allConversions") ,
            beamSpotInputTag  = cms.InputTag("offlineBeamSpot")  ,
            rhoIsoInputTag   = cms.InputTag("kt6PFJetsForIsolation","rho"),
            primaryVertexInputTag = cms.InputTag("offlinePrimaryVertices"),

            isoValInputTags =  cms.VInputTag(cms.InputTag('elPFIsoValueCharged03PFIdPFIso'),
                                             cms.InputTag('elPFIsoValueGamma03PFIdPFIso'),
Exemple #10
0
def getBaseConfig(
		globaltag,
		testfile,
		maxevents,
		nickname,
		outputfilename,
		channel='mm',
		is_data=None,
	):

	#  Config parameters  ##############################################
	cmssw_version = os.environ["CMSSW_VERSION"].split('_')
	cmssw_version = tuple([int(i) for i in cmssw_version[1:4]] + cmssw_version[4:])
	autostr = ""
	if globaltag.lower() == 'auto':
		from Configuration.AlCa.autoCond import autoCond
		globaltag = autoCond['startup']
		autostr = " (from autoCond)"
	if is_data is None:
		data = any([name in testfile[0] for name in 'SingleMu', 'DoubleMu', 'DoubleElectron', 'MuEG'])
	else:
		data = is_data
	miniaod = False

	## print information
	print "\n------- CONFIGURATION 1 ---------"
	print "input:          ", testfile[0], "... (%d files)" % len(testfile) if len(testfile) > 1 else ""
	print "file type:      ", "miniAOD" if miniaod else "AOD"
	print "data:           ", data
	print "output:         ", outputfilename
	print "nickname:       ", nickname
	print "global tag:     ", globaltag + autostr
	print "max events:     ", maxevents
	print "cmssw version:  ", '.'.join([str(i) for i in cmssw_version])
	print "channel:        ", channel
	print "---------------------------------"
	print


	############################################################################
	#  Basic Process Setup
	############################################################################
	process = cms.Process("KAPPA")
	## MessageLogger
	process.load("FWCore.MessageLogger.MessageLogger_cfi")
	process.MessageLogger.default = cms.untracked.PSet(
		ERROR = cms.untracked.PSet(limit = cms.untracked.int32(5))
		#suppressError = cms.untracked.vstring("electronIdMVAProducer")
	)
	process.MessageLogger.cerr.FwkReport.reportEvery = 50
	## Options and Output Report
	process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
	## Source
	process.source = cms.Source("PoolSource",
		fileNames = cms.untracked.vstring()
	)
	## Maximal number of Events
	process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(100) )
	## Geometry and Detector Conditions (needed for a few patTuple production steps)
	import Kappa.Skimming.tools as tools
	cmssw_version_number = tools.get_cmssw_version_number()
	process.load("Configuration.Geometry.GeometryIdeal_cff")
	process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
	from Configuration.AlCa.autoCond import autoCond
	process.GlobalTag.globaltag = cms.string(autoCond['startup'])
	# print the global tag until it is clear whether this auto global tag is fine
	print "GT from autoCond:", process.GlobalTag.globaltag
	process.load("Configuration.StandardSequences.MagneticField_cff")


	############################################################################
	#  KAPPA
	############################################################################
	process.load('Kappa.Producers.KTuple_cff')
	process.kappaTuple = cms.EDAnalyzer('KTuple',
		process.kappaTupleDefaultsBlock,
		outputFile = cms.string("kappaTuple.root"),
	)
	process.kappaTuple.active = cms.vstring()
	process.kappaTuple.outputFile = outputfilename			## name of output file
	process.kappaTuple.verbose	= 0				## verbosity level
	process.kappaTuple.profile	= cms.bool(False)
	process.kappaOut = cms.Sequence(process.kappaTuple)

	process.path = cms.Path()


	process.source.fileNames	  = testfile
	process.maxEvents.input		  = maxevents				## number of events to be processed (-1 = all in file)
	if not globaltag.lower() == 'auto' :
		process.GlobalTag.globaltag = globaltag
	data = datasetsHelper.isData(nickname)
	process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )


	############################################################################
	#  Basic Objects
	############################################################################
	process.kappaTuple.active += cms.vstring('VertexSummary')	## save VertexSummary,
	process.kappaTuple.VertexSummary.whitelist = cms.vstring('goodOfflinePrimaryVertices')
	#process.kappaTuple.active += cms.vstring('BeamSpot')		## save Beamspot,
	#process.kappaTuple.active += cms.vstring('TriggerObjects')
	if data:
		process.kappaTuple.active+= cms.vstring('DataInfo')		## produce Metadata for data,
	else:
		process.kappaTuple.active+= cms.vstring('GenInfo')		## produce Metadata for MC,
		process.kappaTuple.active+= cms.vstring('GenParticles')

	#Trigger 
	trigger_dict = {
		'mtrigger': ['^HLT_(Double)?Mu([0-9]+)_(Double)?Mu([0-9]+)(_v[[:digit:]]+)?$'],
		'etrigger': ['HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*'],
		'emtrigger': ["HLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*", "HLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*",]
	}
	channel_dict = {
		'ee': ['etrigger'],
		'mm': ['mtrigger'],
		'eemm': ['etrigger', 'mtrigger'],
		'em': ['emtrigger']
	}	
	process.kappaTuple.Info.hltWhitelist = cms.vstring("")
	for triggers in channel_dict[channel]:
		for trigger in trigger_dict[triggers]:
			process.kappaTuple.Info.hltWhitelist += cms.vstring(trigger)


	############################################################################
	#  PFCandidates
	############################################################################
	process.load('Kappa.Skimming.KPFCandidates_cff')
	process.path *= (
		process.goodOfflinePrimaryVertices
		* process.pfPileUp
		* process.pfNoPileUp
		#* process.makePFBRECO
		#* process.makeKappaPFCandidates
	)

	if 'm' in channel:
		############################################################################
		#  Muons
		############################################################################

		process.kappaTuple.active += cms.vstring('Muons')	## produce/save KappaMuons
		process.kappaTuple.Muons.minPt = cms.double(8.0)

		## Isodeposits for muons
		process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi')
		process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi')
		process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi')

		process.pfmuIsoDepositPFCandidates = cms.EDProducer(
			"CandIsoDepositProducer",
			src = cms.InputTag("muons"),
			MultipleDepositsFlag = cms.bool(False),
			trackType = cms.string('candidate'),
			ExtractorPSet = cms.PSet(
				Diff_z = cms.double(99999.99),
				ComponentName = cms.string('CandViewExtractor'),
				DR_Max = cms.double(1.0),
				Diff_r = cms.double(99999.99),
				inputCandView = cms.InputTag("particleFlow"),
				DR_Veto = cms.double(1e-05),
				DepositLabel = cms.untracked.string('')
			)
		)
		process.path *= (process.pfmuIsoDepositPFCandidates)
		process.goodMuons = cms.EDFilter('CandViewSelector',
			src = cms.InputTag('muons'),
			cut = cms.string("pt > 15.0"),
		)
		process.oneGoodMuon = cms.EDFilter('CandViewCountFilter',
			src = cms.InputTag('goodMuons'),
			minNumber = cms.uint32(1),
		)
		process.twoGoodMuons = cms.EDFilter('CandViewCountFilter',
			src = cms.InputTag('goodMuons'),
			minNumber = cms.uint32(2),
		)
		if 'mm' in channel:
			process.path *= (process.goodMuons * process.twoGoodMuons)

	if 'e' in channel:
		############################################################################
		#  Electrons
		############################################################################

		#TODO Add Electron
		process.load('EgammaAnalysis.ElectronTools.electronIdMVAProducer_cfi')
		process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi')
		process.load('PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi')
		process.patElectrons.electronIDSources = cms.PSet(
			## default cut based Id
			eidRobustLoose      = cms.InputTag("eidRobustLoose"     ),
			eidRobustTight      = cms.InputTag("eidRobustTight"     ),
			eidLoose            = cms.InputTag("eidLoose"           ),
			eidTight            = cms.InputTag("eidTight"           ),
			eidRobustHighEnergy = cms.InputTag("eidRobustHighEnergy"),
			## MVA based Id
			idMvaTrigV0           = cms.InputTag("mvaTrigV0"          ),
			idMvaTrigNoIPV0       = cms.InputTag("mvaTrigNoIPV0"      ),
			idMvaNonTrigV0        = cms.InputTag("mvaNonTrigV0"       ),
		)
		process.patElectrons.genParticleMatch = ""
		process.patElectrons.addGenMatch = False
		process.patElectrons.embedGenMatch = False
		process.patElectrons.embedGsfElectronCore          = True
		process.patElectrons.embedGsfTrack                 = True
		process.patElectrons.embedSuperCluster             = True
		process.patElectrons.embedPflowSuperCluster        = True
		process.patElectrons.embedSeedCluster              = True
		process.patElectrons.embedBasicClusters            = True
		process.patElectrons.embedPreshowerClusters        = True
		process.patElectrons.embedPflowBasicClusters       = True
		process.patElectrons.embedPflowPreshowerClusters   = True
		process.patElectrons.embedPFCandidate              = True
		process.patElectrons.embedTrack                    = True
		process.patElectrons.embedRecHits                  = True

		process.patElectrons.embedHighLevelSelection.pvSrc = "goodOfflinePrimaryVertices"
		process.electronIdMVA = cms.Sequence(
			process.mvaTrigV0+
			process.mvaTrigNoIPV0+
			process.mvaNonTrigV0
		)
		process.makeKappaElectrons = cms.Sequence(
			process.electronIdMVA *
			process.patElectrons
		)
		process.path *= (process.makeKappaElectrons)


		## CALIBRATIONS
		# momentum corrections
		process.load('EgammaAnalysis.ElectronTools.electronRegressionEnergyProducer_cfi')
		process.eleRegressionEnergy.inputElectronsTag = cms.InputTag('patElectrons')
		process.eleRegressionEnergy.inputCollectionType = cms.uint32(1)

		process.load("Configuration.StandardSequences.Services_cff")
		process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService",
				calibratedPatElectrons = cms.PSet(
					initialSeed = cms.untracked.uint32(1),
					engineName = cms.untracked.string('TRandom3')
				),
		)

		# calibrate pat electrons
		process.load("EgammaAnalysis.ElectronTools.calibratedPatElectrons_cfi")
		if data:
			inputDataset =  "22Jan2013ReReco"
		else:
			#inputDataset =  "Summer12_DR53X_HCP2012"
			inputDataset =  "Summer12_LegacyPaper"
		print "Using electron calibration", inputDataset
		process.calibratedPatElectrons.inputDataset = cms.string(inputDataset)
		process.calibratedPatElectrons.isMC = cms.bool(not data)

		## for cutbased ID
		from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
		process.calibeleIsoSequence = setupPFElectronIso(process, 'calibratedPatElectrons', "PFIsoCal")
		process.eleIsoSequence = setupPFElectronIso(process, 'patElectrons')
		process.pfiso = cms.Sequence(process.pfParticleSelectionSequence
			+ process.eleIsoSequence + process.calibeleIsoSequence 
		)

		# rho for e isolation
		from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
		process.kt6PFJetsForIsolation = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
		process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)

		process.path *= (
			process.eleRegressionEnergy *
			process.calibratedPatElectrons * 
			process.pfiso *
			process.kt6PFJetsForIsolation
		)


		#add to Kappa
		process.kappaTuple.active += cms.vstring('Electrons')
		process.kappaTuple.Electrons = cms.PSet(
			process.kappaNoCut, process.kappaNoRegEx,
			ids = cms.vstring(),
			srcIds = cms.string("pat"),
			electrons = cms.PSet(
				src = cms.InputTag("patElectrons"),
				allConversions = cms.InputTag("allConversions"),
				offlineBeamSpot = cms.InputTag("offlineBeamSpot"),
				vertexcollection = cms.InputTag("goodOfflinePrimaryVertices"),
				isoValInputTags = cms.VInputTag(
					cms.InputTag('elPFIsoValueChargedAll04PFIdPFIso'),
					cms.InputTag('elPFIsoValueGamma04PFIdPFIso'),
					cms.InputTag('elPFIsoValueNeutral04PFIdPFIso'),
					cms.InputTag('elPFIsoValuePU04PFIdPFIso')),
				rhoIsoInputTag = cms.InputTag("kt6PFJetsForIsolation", "rho"),
			),
		)
		process.kappaTuple.Electrons.correlectrons = process.kappaTuple.Electrons.electrons.clone(
				src = cms.InputTag("calibratedPatElectrons"),
				isoValInputTags = cms.VInputTag(
					cms.InputTag('elPFIsoValueChargedAll04PFIdPFIsoCal'),
					cms.InputTag('elPFIsoValueGamma04PFIdPFIsoCal'),
					cms.InputTag('elPFIsoValueNeutral04PFIdPFIsoCal'),
					cms.InputTag('elPFIsoValuePU04PFIdPFIsoCal')),
		)

		#process.kappaTuple.Electrons.ids = cms.VInputTag("mvaTrigV0", "mvaTrigNoIPV0", "mvaNonTrigV0")
		process.kappaTuple.Electrons.ids = cms.VInputTag('idMvaNonTrigV0', 'idMvaTrigNoIPV0', 'idMvaTrigV0')
		process.kappaTuple.Electrons.minPt = cms.double(8.0)


		### Filter
		process.goodElectrons = cms.EDFilter('CandViewSelector',
			src = cms.InputTag('calibratedPatElectrons'),
			cut = cms.string("pt > 15.0"),
		)
		process.oneGoodElectron = cms.EDFilter('CandViewCountFilter',
			src = cms.InputTag('goodElectrons'),
			minNumber = cms.uint32(1),
		)
		process.twoGoodElectrons = cms.EDFilter('CandViewCountFilter',
			src = cms.InputTag('goodElectrons'),
			minNumber = cms.uint32(2),
		)
		if 'ee' in channel:
			process.path *= (process.goodElectrons * process.twoGoodElectrons)

	if 'em' in channel:
		process.path *= (process.goodElectrons * process.oneGoodElectron
						* process.goodMuons * process.oneGoodMuon)


	############################################################################
	#  Jets
	############################################################################

	process.load('RecoJets.JetProducers.ak5PFJets_cfi')
	process.ak5PFJets.srcPVs = cms.InputTag('goodOfflinePrimaryVertices')
	process.ak5PFJetsCHS = process.ak5PFJets.clone( src = cms.InputTag('pfNoPileUp') )

	process.kappaTuple.active += cms.vstring('Jets', 'PileupDensity')
	process.kappaTuple.Jets = cms.PSet(
		process.kappaNoCut,
		process.kappaNoRegEx,
		taggers = cms.vstring(),
		ak5PFJets = cms.PSet(
			src = cms.InputTag('ak5PFJets'),
			QGtagger = cms.InputTag('AK5PFJetsQGTagger'),
			Btagger  = cms.InputTag('ak5PF'),
			PUJetID  = cms.InputTag('ak5PFPuJetMva'),
			PUJetID_full = cms.InputTag('full'),
			),
		ak5PFJetsCHS = cms.PSet(
			src = cms.InputTag('ak5PFJetsCHS'),
			QGtagger = cms.InputTag('AK5PFJetsCHSQGTagger'),
			Btagger  = cms.InputTag('ak5PFCHS'),
			PUJetID  = cms.InputTag('ak5PFCHSPuJetMva'),
			PUJetID_full = cms.InputTag('full'),
			),
		)
	process.kappaTuple.Jets.minPt = cms.double(5.0)

	if not data:
		process.load('RecoJets.JetProducers.ak5GenJets_cfi')
		process.path *= (
			process.genParticlesForJetsNoNu *
			process.ak5GenJetsNoNu
		)
		process.kappaTuple.active += cms.vstring('LV')
		process.kappaTuple.LV.rename = cms.vstring('ak => AK')
		process.kappaTuple.LV.whitelist = cms.vstring('ak5GenJetsNoNu')

	# add kt6PFJets, needed for the PileupDensity
	from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
	process.kt6PFJets = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
	process.kt6PFJets.Rho_EtaMax = cms.double(2.5)

	process.path *= (
		process.ak5PFJets
		* process.ak5PFJetsCHS
		* process.kt6PFJets
	)


	############################################################################
	#  MET
	############################################################################
	# MET correction ----------------------------------------------------------
	process.load('JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi')
	process.path *= (
		process.type0PFMEtCorrection
	)
	#TODO check type 0 corrections
	process.kappaTuple.active += cms.vstring('MET')					   ## produce/save KappaPFMET
	process.kappaTuple.MET.whitelist = cms.vstring('pfChMet', '_pfMet_')

	if cmssw_version_number.startswith("5"):
		# MET correction ----------------------------------------------------------
		process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
		process.pfchsMETcorr.src = cms.InputTag('goodOfflinePrimaryVertices')
		# Type-0
		process.pfMETCHS = process.pfType1CorrectedMet.clone(
			applyType1Corrections = cms.bool(False),
			applyType0Corrections = cms.bool(True)
		)
		# MET Path
		process.path *= (
			process.producePFMETCorrections * process.pfMETCHS
		)
		process.kappaTuple.MET.whitelist += cms.vstring("pfMETCHS")


	############################################################################
	#  Almost done ...
	############################################################################
	process.path *= (
		process.kappaOut
	)
	return process
process.patTaus.embedIsolationPFGammaCands = cms.bool(True)
process.patTaus.embedSignalPFChargedHadrCands = cms.bool(True)
process.patTaus.embedSignalPFNeutralHadrCands = cms.bool(True)
process.patTaus.embedSignalPFGammaCands = cms.bool(True)
process.patTaus.embedLeadPFChargedHadrCand = cms.bool(True)
process.patTaus.embedLeadPFNeutralCand = cms.bool(True)

#--------------------------------------------------------------------------------

process.load("CommonTools.ParticleFlow.Isolation.pfMuonIsolation_cff")
process.load("CommonTools.ParticleFlow.Isolation.pfElectronIsolation_cff")

from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFMuonIso, setupPFElectronIso

process.stdMuonSequencePFIso = setupPFMuonIso(process,'muons')
process.stdElectronSequencePFIso = setupPFElectronIso(process,'gsfElectrons')

from CommonTools.ParticleFlow.pfParticleSelection_cff import pfParticleSelectionSequence
process.pfParticleSelectionSequence = pfParticleSelectionSequence

process.patMuons.isoDeposits = cms.PSet(
    pfAllParticles = cms.InputTag("muPFIsoDepositPUPFIso"), # all PU CH+MU+E
    pfChargedHadrons = cms.InputTag("muPFIsoDepositChargedPFIso"), # all noPU CH

    pfNeutralHadrons = cms.InputTag("muPFIsoDepositNeutralPFIso"), # all NH
    pfPhotons = cms.InputTag("muPFIsoDepositGammaPFIso"), # all PH

    user = cms.VInputTag(
    cms.InputTag("muPFIsoDepositChargedAllPFIso"), # all noPU CH+MU+E
    )
    )
# rho value for isolation
from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets  # the 4 references the rParam = 0.4
process.kt6PFJetsForIsolation = kt4PFJets.clone(rParam=0.6,
                                                doRhoFastjet=True,
                                                Rho_EtaMax=cms.double(2.5))

# Particle flow isolation
process.load(
    "CommonTools.ParticleFlow.Isolation.pfElectronIsolation_cff"
)  # process.pfElectronIsolationSequence, needed implicityl for process.stdElectronSequencePFIso
process.load("CommonTools.ParticleFlow.pfParticleSelection_cff"
             )  # process.pfParticleSelectionSequence

from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
process.stdElectronSequencePFIso = setupPFElectronIso(process,
                                                      'gedGsfElectrons')

process.pfiso = cms.Sequence(process.pfParticleSelectionSequence +
                             process.stdElectronSequencePFIso)

process.demo = cms.EDAnalyzer('calib')

process.load("RecoEgamma.EgammaHFProducers.hfEMClusteringSequence_cff"
             )  #Kevin: reselect hf electrons out of hf cluster

process.hfRecoEcalCandidate.intercept2DCut = cms.double(-99)  # Kevin
process.hfRecoEcalCandidate.intercept2DSlope = cms.double(99)  # Kevin
process.hfRecoEcalCandidate.e9e25Cut = cms.double(
    -1.0)  # Jeremy - loosen the cut

process.p = cms.Path(process.kt6PFJetsForIsolation *
## remove certain objects from the default sequence
# removeAllPATObjectsBut(process, ['Muons', 'Electrons', 'Taus', 'METs'])
# removeSpecificPATObjects(process, ['Electrons', 'Muons', 'Taus'])

from PhysicsTools.PatAlgos.tools.tauTools import *

switchToPFTauHPS(process)  # For HPS Taus
# switchToPFTauHPSpTaNC(process) # For HPS TaNC Taus

# --------------------------------------------------------------------------------

from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFMuonIso, setupPFElectronIso

process.muIsoSequence = setupPFMuonIso(process, "muons")
process.electronIsoSequence = setupPFElectronIso(process, "gsfElectrons")

from CommonTools.ParticleFlow.pfParticleSelection_cff import pfParticleSelectionSequence

process.pfParticleSelectionSequence = pfParticleSelectionSequence


process.patMuons.isoDeposits = cms.PSet(
    pfAllParticles=cms.InputTag("muPFIsoDepositPUPFIso"),  # all PU   CH+MU+E
    pfChargedHadrons=cms.InputTag("muPFIsoDepositChargedPFIso"),  # all noPU CH
    pfNeutralHadrons=cms.InputTag("muPFIsoDepositNeutralPFIso"),  # all NH
    pfPhotons=cms.InputTag("muPFIsoDepositGammaPFIso"),  # all PH
    user=cms.VInputTag(cms.InputTag("muPFIsoDepositChargedAllPFIso")),  # all noPU CH+MU+E
)

process.patMuons.isolationValues = cms.PSet(
Exemple #14
0
process.patDefaultSequence.remove(process.selectedPatPhotons)
process.selectedPatCandidateSummary.candidates.remove(cms.InputTag("selectedPatPhotons") )

process.PFTau += process.recoTauFixedConeSequence
process.offlineSequence = cms.Sequence(
    #process.recoTauClassicHPSSequence +
    #process.produceAndDiscriminateFixedConePFTaus +
    process.PFTau +
    process.patDefaultSequence
    )

#Needed??
## pf-isolation
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFMuonIso, setupPFElectronIso
process.muIsoSequence       = cms.Sequence( setupPFMuonIso(process,'muons') )
process.electronIsoSequence = cms.Sequence( setupPFElectronIso(process,'gedGsfElectrons') )
from CommonTools.ParticleFlow.pfParticleSelection_cff import pfParticleSelectionSequence
process.pfParticleSelectionSequence = pfParticleSelectionSequence
process.pfIsolationSequence = cms.Sequence(
    process.pfParticleSelectionSequence*
    process.muIsoSequence* process.electronIsoSequence
    )
process.offlineSequence.replace(
    process.patDefaultSequence,
    process.pfIsolationSequence + process.patDefaultSequence)

#Custom cone size for Electron isolation
process.elPFIsoValueChargedAll04PFIdPFIso.deposits[0].vetos = cms.vstring(
    'EcalBarrel:ConeVeto(0.01)','EcalEndcaps:ConeVeto(0.015)',
    )
process.elPFIsoValueGamma04PFIdPFIso.deposits[0].vetos = cms.vstring(
Exemple #15
0
def getBaseConfig(globaltag= 'START53_V15A::All', testfile=cms.untracked.vstring(""), maxevents=100, nickname = 'SM_VBFHToTauTau_M_90_powheg_pythia_8TeV', kappaTag = 'Kappa_1_0_0'):

	from Kappa.Skimming.KSkimming_template_cfg import process
	process.source.fileNames      = testfile
	process.maxEvents.input	      = maxevents				## number of events to be processed (-1 = all in file)
	process.kappaTuple.outputFile = 'kappaTuple.root'			## name of output file
	process.kappaTuple.verbose    = cms.int32(0)				## verbosity level
	process.kappaTuple.profile    = cms.bool(True)
	if not globaltag.lower() == 'auto' :
		process.GlobalTag.globaltag   = globaltag
		print "GT (overwritten):", process.GlobalTag.globaltag
	data = datasetsHelper.isData(nickname)
	centerOfMassEnergy = datasetsHelper.getCenterOfMassEnergy(nickname)
	isEmbedded = datasetsHelper.getIsEmbedded(nickname)

	process.p = cms.Path()
	## ------------------------------------------------------------------------
	# Configure Metadata describing the file
	process.kappaTuple.active										= cms.vstring('TreeInfo')
	process.kappaTuple.TreeInfo.parameters = cms.PSet(
		dataset						= cms.string(datasetsHelper.getDatasetName(nickname)),
		generator					= cms.string(datasetsHelper.getGenerator(nickname)),
		productionProcess			= cms.string(datasetsHelper.getProcess(nickname)),
		globalTag					= cms.string(globaltag),
		prodCampaignGlobalTag	= cms.string(datasetsHelper.getProductionCampaignGlobalTag(nickname, centerOfMassEnergy)),
		runPeriod					= cms.string(datasetsHelper.getRunPeriod(nickname)),
		kappaTag						= cms.string(kappaTag),
		isEmbedded					= cms.bool(isEmbedded),
		jetMultiplicity			= cms.int32(datasetsHelper.getJetMultiplicity(nickname)),
		centerOfMassEnergy		= cms.int32(centerOfMassEnergy),
		puScenario					= cms.string(datasetsHelper.getPuScenario(nickname, centerOfMassEnergy)),
		isData						= cms.bool(data),
	)


	## ------------------------------------------------------------------------
	# General configuration

	process.kappaTuple.active += cms.vstring('VertexSummary')	## save VertexSummary,
	process.kappaTuple.active += cms.vstring('BeamSpot')		## save Beamspot,
	process.kappaTuple.active += cms.vstring('TriggerObjects')

	if not isEmbedded:
		if data:
			process.kappaTuple.active+= cms.vstring('DataInfo')		## produce Metadata for data,
		else:
			process.kappaTuple.active+= cms.vstring('GenInfo')		## produce Metadata for MC,
			process.kappaTuple.active+= cms.vstring('GenParticles')		## save GenParticles,
			process.kappaTuple.active+= cms.vstring('GenTaus')				## save GenParticles,
	
	# prune GenParticles
	if not data:
		process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
		process.prunedGenParticles = cms.EDProducer("GenParticlePruner",
			src = cms.InputTag("genParticles", "", "SIM"),
			select = cms.vstring(
				"drop  *",
				"keep status == 3",  # all status 3
				"keep++ abs(pdgId) == 23", # Z
				"keep++ abs(pdgId) == 24", # W
				"keep++ abs(pdgId) == 25", # H
				"keep abs(pdgId) == 11 || abs(pdgId) == 13",  # charged leptons
				"keep++ abs(pdgId) == 15"  # keep full tau decay chain
			)
		)
	
	process.kappaTuple.Info.hltWhitelist = cms.vstring(			## HLT selection
		# https://github.com/cms-analysis/HiggsAnalysis-KITHiggsToTauTau/blob/master/data/triggerTables-2011-2012.txt
		# https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsToTauTauWorkingSummer2013
		# can be tested at http://regexpal.com
		# e
		"^HLT_Ele[0-9]+_CaloIdVT(_CaloIsoT)?_TrkIdT(_TrkIsoT)?_v[0-9]+$",
		"^HLT_Ele[0-9]+_WP[0-9]+_v[0-9]+$",
		# m
		"^HLT_(Iso)?Mu[0-9]+(_eta2p1)?_v[0-9]+$",
		# ee
		"^HLT_Ele[0-9]+_CaloId(L|T)(_TrkIdVL)?_CaloIsoVL(_TrkIdVL)?(_TrkIsoVL)?" +
			"_Ele[0-9]+_CaloId(L|T)(_TrkIdVL)?_CaloIsoVL(_TrkIdVL)?(_TrkIsoVL)?_v[0-9]+$",
		"^HLT_Ele[0-9]+_Ele[0-9]+_CaloId(L|T)_CaloIsoVL(_TrkIdVL_TrkIsoVL)?_v[0-9]+$",
		# mm
		"^HLT_(Double)?Mu[0-9]+(_(Mu|Jet)[0-9]+)?_v[0-9]+$",
		# em
		"^HLT_Mu[0-9]+_(Ele|Photon)[0-9]+_CaloId(L|T|VT)(_CaloIsoVL|_IsoT)?(_TrkIdVL_TrkIsoVL)?_v[0-9]+$",
		# et
		"^HLT_Ele[0-9]+_CaloIdVT(_Calo(IsoRho|Iso)T)?_TrkIdT(_TrkIsoT)?_(Loose|Medium|Tight)IsoPFTau[0-9]+_v[0-9]+$",
		"^HLT_Ele[0-9]+_eta2p1_WP[0-9]+(Rho|NoIso)_LooseIsoPFTau[0-9]+_v[0-9]+$",
		# mt
		"^HLT_(Iso)?Mu[0-9]+(_eta2p1)?_(Loose|Medium|Tight)IsoPFTau[0-9]+(_Trk[0-9]_eta2p1)?_v[0-9]+$",
		# tt
		"^HLT_Double(Medium)?IsoPFTau[0-9]+_Trk(1|5)_eta2p1_(Jet[0-9]+|Prong[0-9])?_v[0-9]+$",
		"^HLT_Double(Medium)?IsoPFTau[0-9]+_Trk(1|5)(_eta2p1)?_v[0-9]+$",
		# specials (possible generalization: Mu15, L1ETM20, Photon20, Ele8)
		"^HLT_Ele[0-9]+_CaloId(L|T|VT)_CaloIso(VL|T|VT)(_TrkIdT)?(_TrkIsoVT)?_(SC|Ele)[0-9](_Mass[0-9]+)?_v[0-9]+$",
		"^HLT_Ele8_v[0-9]+$",
		"^HLT_IsoMu15(_eta2p1)?_L1ETM20_v[0-9]+$",
		"^HLT_Photon20_CaloIdVT_IsoT_Ele8_CaloIdL_CaloIsoVL_v[0-9]+$",
		# specials for tag and probe and em fakerate studies could be added if enough bits are ensured
		#"^HLT_Ele[0-9]+_CaloId(L|T|VT)_CaloIso(VL|T|VT)(_TrkIdT_TrkIso(T|VT))?_(SC|Ele)[0-9]+(_Mass[0-9]+)?_v[0-9]+$",
		#"^HLT_Mu[0-9]+_Photon[0-9]+_CaloIdVT_IsoT_v[0-9]+$",
		#"^HLT_Ele[0-9]+_CaloId(L|T)(_TrkIdVL)?_CaloIsoVL(_TrkIdVL_TrkIsoVL)?(_TrkIsoVL)?(_Jet[0-9]+|)?_v[0-9]+$",
		)
	
	process.kappaTuple.Info.hltBlacklist = cms.vstring(
		"HLT_Mu13_Mu8", # v21 gives errors for the trigger objects
		)

	## ------------------------------------------------------------------------
	# Configure PFCandidates and offline PV
	process.load("Kappa.Skimming.KPFCandidates_cff")
	#process.kappaTuple.active += cms.vstring('PFCandidates')		## save PFCandidates for deltaBeta corrected
	process.kappaTuple.PFCandidates.whitelist = cms.vstring(                ## isolation used for electrons and muons.
##		"pfNoPileUpChargedHadrons",    ## switch to pfAllChargedParticles
		"pfAllChargedParticles",       ## same as pfNoPileUpChargedHadrons +pf_electrons + pf_muons
		"pfNoPileUpNeutralHadrons",
		"pfNoPileUpPhotons",
		"pfPileUpChargedHadrons",
		)

	process.p *= ( process.makePFBRECO * process.makePFCandidatesForDeltaBeta )
	
	## ------------------------------------------------------------------------
	# Configure Muons
	process.load("Kappa.Skimming.KMuons_cff")
	process.kappaTuple.active += cms.vstring('Muons')	                ## produce/save KappaMuons
	process.kappaTuple.Muons.minPt = cms.double(8.0)
	process.p *= process.makeKappaMuons

	## ------------------------------------------------------------------------
	# Configure Electrons
	process.load("Kappa.Skimming.KElectrons_cff")
	process.kappaTuple.active += cms.vstring('Electrons')	                ## produce/save KappaElectrons,
	process.kappaTuple.Electrons.ids = cms.vstring("mvaTrigV0",
	                                               "mvaTrigNoIPV0",
	                                               "mvaNonTrigV0")
	process.kappaTuple.Electrons.minPt = cms.double(8.0)
	process.p *= process.makeKappaElectrons
	
	## for electron/muon iso
	# https://github.com/ajgilbert/ICHiggsTauTau/blob/master/test/higgstautau_cfg.py#L418-L448
	from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
	process.eleIsoSequence = setupPFElectronIso(process, 'patElectrons')
	process.muIsoSequence = setupPFMuonIso(process, 'muons')
	
	process.eleIsoSequence.remove(process.elPFIsoValueCharged03NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueChargedAll03NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueGamma03NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueNeutral03NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValuePU03NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueCharged04NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueChargedAll04NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueGamma04NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValueNeutral04NoPFIdPFIso)
	process.eleIsoSequence.remove(process.elPFIsoValuePU04NoPFIdPFIso)
	process.elPFIsoValueGamma04PFIdPFIso.deposits[0].vetos      = cms.vstring('EcalEndcaps:ConeVeto(0.08)','EcalBarrel:ConeVeto(0.08)')
	process.elPFIsoValueNeutral04PFIdPFIso.deposits[0].vetos    = cms.vstring()
	process.elPFIsoValuePU04PFIdPFIso.deposits[0].vetos         = cms.vstring()
	process.elPFIsoValueCharged04PFIdPFIso.deposits[0].vetos    = cms.vstring('EcalEndcaps:ConeVeto(0.015)')
	process.elPFIsoValueChargedAll04PFIdPFIso.deposits[0].vetos = cms.vstring('EcalEndcaps:ConeVeto(0.015)','EcalBarrel:ConeVeto(0.01)')
	process.pfiso = cms.Sequence(process.pfParticleSelectionSequence + process.eleIsoSequence + process.muIsoSequence)

	# rho for electron iso
	from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
	process.kt6PFJetsForIsolation = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
	process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)
	process.p *= (process.pfiso * process.kt6PFJetsForIsolation)

	## ------------------------------------------------------------------------
	# Configure Taus
	process.load("Kappa.Skimming.KTaus_cff")
	process.kappaTuple.active += cms.vstring('Taus')	                ## produce/save KappaTaus
	process.kappaTuple.Taus.minPt = cms.double(8.0)
	process.p *= process.makeKappaTaus

	## ------------------------------------------------------------------------
	## Kappa Jets
	process.load("Kappa.Skimming.KJets_cff")
	process.kappaTuple.active += cms.vstring('Jets', 'PileupDensity')
	process.kappaTuple.Jets = cms.PSet(
		process.kappaNoCut,
		process.kappaNoRegEx,
		taggers = cms.vstring(
			"QGlikelihood",
			"QGmlp",
			"TrackCountingHighEffBJetTags",
			"TrackCountingHighPurBJetTags", 
			"JetProbabilityBJetTags",
			"JetBProbabilityBJetTags", 
			"SoftElectronBJetTags",
			"SoftMuonBJetTags",
			"SoftMuonByIP3dBJetTags",
			"SoftMuonByPtBJetTags",
			"SimpleSecondaryVertexBJetTags", 
			"CombinedSecondaryVertexBJetTags",
			"CombinedSecondaryVertexMVABJetTags",
			"puJetIDFullDiscriminant",
			"puJetIDFullLoose",
			"puJetIDFullMedium",
			"puJetIDFullTight",
			"puJetIDCutbasedDiscriminant",
			"puJetIDCutbasedLoose",
			"puJetIDCutbasedMedium",
			"puJetIDCutbasedTight"
			),
		AK5PFTaggedJets = cms.PSet(
			src = cms.InputTag("ak5PFJets"),
			QGtagger = cms.InputTag("AK5PFJetsQGTagger"),
			Btagger  = cms.InputTag("ak5PF"),
			PUJetID  = cms.InputTag("ak5PFPuJetMva"),
			PUJetID_full = cms.InputTag("full"),
			),
		AK5PFTaggedJetsCHS = cms.PSet(
			src = cms.InputTag("ak5PFJetsCHS"),
			QGtagger = cms.InputTag("AK5PFJetsCHSQGTagger"),
			Btagger  = cms.InputTag("ak5PFCHS"),
			PUJetID  = cms.InputTag("ak5PFCHSPuJetMva"),
			PUJetID_full = cms.InputTag("full"),
			),
		)
	process.kappaTuple.Jets.minPt = cms.double(10.0)

	## ------------------------------------------------------------------------
	# Special settings for embedded samples
	# https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementWithPFlow
	if isEmbedded:
		process.load('RecoBTag/Configuration/RecoBTag_cff')
		process.load('RecoJets/JetAssociationProducers/ak5JTA_cff')
		process.ak5PFJetNewTracksAssociatorAtVertex.tracks = "tmfTracks"
		process.ak5PFCHSNewJetTracksAssociatorAtVertex.tracks = "tmfTracks"
		process.p *= process.btagging
		# disable overrideHLTCheck for embedded samples, since it triggers an Kappa error
		process.kappaTuple.Info.overrideHLTCheck = cms.untracked.bool(True)
		process.kappaTuple.active+= cms.vstring('DataInfo')
		process.kappaTuple.active+= cms.vstring('GenParticles')		## save GenParticles,
		process.kappaTuple.active+= cms.vstring('GenTaus')				## save GenParticles,
		process.kappaTuple.GenParticles.genParticles.src = cms.InputTag("genParticles","","EmbeddedRECO")
		process.kappaTuple.Info.isEmbedded = cms.bool(True)

	# Let Jets run
	process.p *= (
		process.makeKappaTaus *
		process.makePFJets *
		process.makePFJetsCHS *
		process.makeQGTagging *
		process.makeBTagging *
		process.makePUJetID
	)

	## ------------------------------------------------------------------------
	## MET
	process.load("Kappa.Skimming.KMET_cff")
	process.kappaTuple.active += cms.vstring('GenMET')                         ## produce/save KappaMET
	process.kappaTuple.active += cms.vstring('MET')                       ## produce/save KappaPFMET
	process.p *= process.makeKappaMET
	#"""
	
	if not data:
		process.load('PhysicsTools/JetMCAlgos/TauGenJets_cfi')
		process.load('PhysicsTools/JetMCAlgos/TauGenJetsDecayModeSelectorAllHadrons_cfi')
		process.p *= (process.tauGenJets+process.tauGenJetsSelectorAllHadrons)
		process.kappaTuple.GenJets.whitelist = cms.vstring("tauGenJets")
		process.kappaTuple.active += cms.vstring('GenJets')
	
	# add python config to TreeInfo
	process.kappaTuple.TreeInfo.parameters.config = cms.string(process.dumpPython())
	
	# add repository revisions to TreeInfo
	for repo, rev in tools.get_repository_revisions().iteritems():
		setattr(process.kappaTuple.TreeInfo.parameters, repo, cms.string(rev))
	

	## ------------------------------------------------------------------------
	## And let it run
	process.p *= (
		process.kappaOut
	)
	## ------------------------------------------------------------------------
	## declare edm OutputModule (expects a path 'p'), uncommented if wanted

	#process.edmOut = cms.OutputModule(
	#	"PoolOutputModule",
	#	fileName = cms.untracked.string('dump.root'),				## name of output file
	#	SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),	## save only events passing the full path
	#	outputCommands = cms.untracked.vstring('drop *', 'keep *_*_*_KAPPA')	## save each edm object that has been produced by process KAPPA
	#	)
	#process.ep = cms.EndPath(process.edmOut)

	return process
Exemple #16
0
def getBaseConfig(
    globaltag,
    testfile,
    maxevents,
    nickname,
    outputfilename,
    channel='mm',
    is_data=None,
):

    #  Config parameters  ##############################################
    cmssw_version = os.environ["CMSSW_VERSION"].split('_')
    cmssw_version = tuple([int(i)
                           for i in cmssw_version[1:4]] + cmssw_version[4:])
    autostr = ""
    if globaltag.lower() == 'auto':
        from Configuration.AlCa.autoCond import autoCond
        globaltag = autoCond['startup']
        autostr = " (from autoCond)"
    if is_data is None:
        data = any([
            name in testfile[0]
            for name in 'SingleMu', 'DoubleMu', 'DoubleElectron', 'MuEG'
        ])
    else:
        data = is_data
    miniaod = False

    ## print information
    print "\n------- CONFIGURATION 1 ---------"
    print "input:          ", testfile[0], "... (%d files)" % len(
        testfile) if len(testfile) > 1 else ""
    print "file type:      ", "miniAOD" if miniaod else "AOD"
    print "data:           ", data
    print "output:         ", outputfilename
    print "nickname:       ", nickname
    print "global tag:     ", globaltag + autostr
    print "max events:     ", maxevents
    print "cmssw version:  ", '.'.join([str(i) for i in cmssw_version])
    print "channel:        ", channel
    print "---------------------------------"
    print

    ############################################################################
    #  Basic Process Setup
    ############################################################################
    process = cms.Process("KAPPA")
    ## MessageLogger
    process.load("FWCore.MessageLogger.MessageLogger_cfi")
    process.MessageLogger.default = cms.untracked.PSet(
        ERROR=cms.untracked.PSet(limit=cms.untracked.int32(5))
        #suppressError = cms.untracked.vstring("electronIdMVAProducer")
    )
    process.MessageLogger.cerr.FwkReport.reportEvery = 50
    ## Options and Output Report
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True))
    ## Source
    process.source = cms.Source("PoolSource",
                                fileNames=cms.untracked.vstring())
    ## Maximal number of Events
    process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(100))
    ## Geometry and Detector Conditions (needed for a few patTuple production steps)
    import Kappa.Skimming.tools as tools
    cmssw_version_number = tools.get_cmssw_version_number()
    process.load("Configuration.Geometry.GeometryIdeal_cff")
    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    from Configuration.AlCa.autoCond import autoCond
    process.GlobalTag.globaltag = cms.string(autoCond['startup'])
    # print the global tag until it is clear whether this auto global tag is fine
    print "GT from autoCond:", process.GlobalTag.globaltag
    process.load("Configuration.StandardSequences.MagneticField_cff")

    ############################################################################
    #  KAPPA
    ############################################################################
    process.load('Kappa.Producers.KTuple_cff')
    process.kappaTuple = cms.EDAnalyzer(
        'KTuple',
        process.kappaTupleDefaultsBlock,
        outputFile=cms.string("kappaTuple.root"),
    )
    process.kappaTuple.active = cms.vstring()
    process.kappaTuple.outputFile = outputfilename  ## name of output file
    process.kappaTuple.verbose = 0  ## verbosity level
    process.kappaTuple.profile = cms.bool(False)
    process.kappaOut = cms.Sequence(process.kappaTuple)

    process.path = cms.Path()

    process.source.fileNames = testfile
    process.maxEvents.input = maxevents  ## number of events to be processed (-1 = all in file)
    if not globaltag.lower() == 'auto':
        process.GlobalTag.globaltag = globaltag
    data = datasetsHelper.isData(nickname)
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(False))

    ############################################################################
    #  Basic Objects
    ############################################################################
    process.kappaTuple.active += cms.vstring(
        'VertexSummary')  ## save VertexSummary,
    process.kappaTuple.VertexSummary.whitelist = cms.vstring(
        'goodOfflinePrimaryVertices')
    #process.kappaTuple.active += cms.vstring('BeamSpot')		## save Beamspot,
    #process.kappaTuple.active += cms.vstring('TriggerObjects')
    if data:
        process.kappaTuple.active += cms.vstring(
            'DataInfo')  ## produce Metadata for data,
    else:
        process.kappaTuple.active += cms.vstring(
            'GenInfo')  ## produce Metadata for MC,
        process.kappaTuple.active += cms.vstring('GenParticles')

    #Trigger
    trigger_dict = {
        'mtrigger':
        ['^HLT_(Double)?Mu([0-9]+)_(Double)?Mu([0-9]+)(_v[[:digit:]]+)?$'],
        'etrigger': [
            'HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*'
        ],
        'emtrigger': [
            "HLT_Mu17_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*",
            "HLT_Mu8_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL.*",
        ]
    }
    channel_dict = {
        'ee': ['etrigger'],
        'mm': ['mtrigger'],
        'eemm': ['etrigger', 'mtrigger'],
        'em': ['emtrigger']
    }
    process.kappaTuple.Info.hltWhitelist = cms.vstring("")
    for triggers in channel_dict[channel]:
        for trigger in trigger_dict[triggers]:
            process.kappaTuple.Info.hltWhitelist += cms.vstring(trigger)

    ############################################################################
    #  PFCandidates
    ############################################################################
    process.load('Kappa.Skimming.KPFCandidates_cff')
    process.path *= (
        process.goodOfflinePrimaryVertices * process.pfPileUp *
        process.pfNoPileUp
        #* process.makePFBRECO
        #* process.makeKappaPFCandidates
    )

    if 'm' in channel:
        ############################################################################
        #  Muons
        ############################################################################

        process.kappaTuple.active += cms.vstring(
            'Muons')  ## produce/save KappaMuons
        process.kappaTuple.Muons.minPt = cms.double(8.0)

        ## Isodeposits for muons
        process.load(
            'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi'
        )
        process.load(
            'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi'
        )
        process.load(
            'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi'
        )

        process.pfmuIsoDepositPFCandidates = cms.EDProducer(
            "CandIsoDepositProducer",
            src=cms.InputTag("muons"),
            MultipleDepositsFlag=cms.bool(False),
            trackType=cms.string('candidate'),
            ExtractorPSet=cms.PSet(
                Diff_z=cms.double(99999.99),
                ComponentName=cms.string('CandViewExtractor'),
                DR_Max=cms.double(1.0),
                Diff_r=cms.double(99999.99),
                inputCandView=cms.InputTag("particleFlow"),
                DR_Veto=cms.double(1e-05),
                DepositLabel=cms.untracked.string('')))
        process.path *= (process.pfmuIsoDepositPFCandidates)
        process.goodMuons = cms.EDFilter(
            'CandViewSelector',
            src=cms.InputTag('muons'),
            cut=cms.string("pt > 15.0"),
        )
        process.oneGoodMuon = cms.EDFilter(
            'CandViewCountFilter',
            src=cms.InputTag('goodMuons'),
            minNumber=cms.uint32(1),
        )
        process.twoGoodMuons = cms.EDFilter(
            'CandViewCountFilter',
            src=cms.InputTag('goodMuons'),
            minNumber=cms.uint32(2),
        )
        if 'mm' in channel:
            process.path *= (process.goodMuons * process.twoGoodMuons)

    if 'e' in channel:
        ############################################################################
        #  Electrons
        ############################################################################

        #TODO Add Electron
        process.load('EgammaAnalysis.ElectronTools.electronIdMVAProducer_cfi')
        process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi')
        process.load(
            'PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi')
        process.patElectrons.electronIDSources = cms.PSet(
            ## default cut based Id
            eidRobustLoose=cms.InputTag("eidRobustLoose"),
            eidRobustTight=cms.InputTag("eidRobustTight"),
            eidLoose=cms.InputTag("eidLoose"),
            eidTight=cms.InputTag("eidTight"),
            eidRobustHighEnergy=cms.InputTag("eidRobustHighEnergy"),
            ## MVA based Id
            idMvaTrigV0=cms.InputTag("mvaTrigV0"),
            idMvaTrigNoIPV0=cms.InputTag("mvaTrigNoIPV0"),
            idMvaNonTrigV0=cms.InputTag("mvaNonTrigV0"),
        )
        process.patElectrons.genParticleMatch = ""
        process.patElectrons.addGenMatch = False
        process.patElectrons.embedGenMatch = False
        process.patElectrons.embedGsfElectronCore = True
        process.patElectrons.embedGsfTrack = True
        process.patElectrons.embedSuperCluster = True
        process.patElectrons.embedPflowSuperCluster = True
        process.patElectrons.embedSeedCluster = True
        process.patElectrons.embedBasicClusters = True
        process.patElectrons.embedPreshowerClusters = True
        process.patElectrons.embedPflowBasicClusters = True
        process.patElectrons.embedPflowPreshowerClusters = True
        process.patElectrons.embedPFCandidate = True
        process.patElectrons.embedTrack = True
        process.patElectrons.embedRecHits = True

        process.patElectrons.embedHighLevelSelection.pvSrc = "goodOfflinePrimaryVertices"
        process.electronIdMVA = cms.Sequence(process.mvaTrigV0 +
                                             process.mvaTrigNoIPV0 +
                                             process.mvaNonTrigV0)
        process.makeKappaElectrons = cms.Sequence(process.electronIdMVA *
                                                  process.patElectrons)
        process.path *= (process.makeKappaElectrons)

        ## CALIBRATIONS
        # momentum corrections
        process.load(
            'EgammaAnalysis.ElectronTools.electronRegressionEnergyProducer_cfi'
        )
        process.eleRegressionEnergy.inputElectronsTag = cms.InputTag(
            'patElectrons')
        process.eleRegressionEnergy.inputCollectionType = cms.uint32(1)

        process.load("Configuration.StandardSequences.Services_cff")
        process.RandomNumberGeneratorService = cms.Service(
            "RandomNumberGeneratorService",
            calibratedPatElectrons=cms.PSet(
                initialSeed=cms.untracked.uint32(1),
                engineName=cms.untracked.string('TRandom3')),
        )

        # calibrate pat electrons
        process.load("EgammaAnalysis.ElectronTools.calibratedPatElectrons_cfi")
        if data:
            inputDataset = "22Jan2013ReReco"
        else:
            #inputDataset =  "Summer12_DR53X_HCP2012"
            inputDataset = "Summer12_LegacyPaper"
        print "Using electron calibration", inputDataset
        process.calibratedPatElectrons.inputDataset = cms.string(inputDataset)
        process.calibratedPatElectrons.isMC = cms.bool(not data)

        ## for cutbased ID
        from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
        process.calibeleIsoSequence = setupPFElectronIso(
            process, 'calibratedPatElectrons', "PFIsoCal")
        process.eleIsoSequence = setupPFElectronIso(process, 'patElectrons')
        process.pfiso = cms.Sequence(process.pfParticleSelectionSequence +
                                     process.eleIsoSequence +
                                     process.calibeleIsoSequence)

        # rho for e isolation
        from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
        process.kt6PFJetsForIsolation = kt4PFJets.clone(rParam=0.6,
                                                        doRhoFastjet=True)
        process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)

        process.path *= (process.eleRegressionEnergy *
                         process.calibratedPatElectrons * process.pfiso *
                         process.kt6PFJetsForIsolation)

        #add to Kappa
        process.kappaTuple.active += cms.vstring('Electrons')
        process.kappaTuple.Electrons = cms.PSet(
            process.kappaNoCut,
            process.kappaNoRegEx,
            ids=cms.vstring(),
            srcIds=cms.string("pat"),
            electrons=cms.PSet(
                src=cms.InputTag("patElectrons"),
                allConversions=cms.InputTag("allConversions"),
                offlineBeamSpot=cms.InputTag("offlineBeamSpot"),
                vertexcollection=cms.InputTag("goodOfflinePrimaryVertices"),
                isoValInputTags=cms.VInputTag(
                    cms.InputTag('elPFIsoValueChargedAll04PFIdPFIso'),
                    cms.InputTag('elPFIsoValueGamma04PFIdPFIso'),
                    cms.InputTag('elPFIsoValueNeutral04PFIdPFIso'),
                    cms.InputTag('elPFIsoValuePU04PFIdPFIso')),
                rhoIsoInputTag=cms.InputTag("kt6PFJetsForIsolation", "rho"),
            ),
        )
        process.kappaTuple.Electrons.correlectrons = process.kappaTuple.Electrons.electrons.clone(
            src=cms.InputTag("calibratedPatElectrons"),
            isoValInputTags=cms.VInputTag(
                cms.InputTag('elPFIsoValueChargedAll04PFIdPFIsoCal'),
                cms.InputTag('elPFIsoValueGamma04PFIdPFIsoCal'),
                cms.InputTag('elPFIsoValueNeutral04PFIdPFIsoCal'),
                cms.InputTag('elPFIsoValuePU04PFIdPFIsoCal')),
        )

        #process.kappaTuple.Electrons.ids = cms.vstring("mvaTrigV0", "mvaTrigNoIPV0", "mvaNonTrigV0")
        process.kappaTuple.Electrons.ids = cms.vstring('idMvaNonTrigV0',
                                                       'idMvaTrigNoIPV0',
                                                       'idMvaTrigV0')
        process.kappaTuple.Electrons.minPt = cms.double(8.0)

        ### Filter
        process.goodElectrons = cms.EDFilter(
            'CandViewSelector',
            src=cms.InputTag('calibratedPatElectrons'),
            cut=cms.string("pt > 15.0"),
        )
        process.oneGoodElectron = cms.EDFilter(
            'CandViewCountFilter',
            src=cms.InputTag('goodElectrons'),
            minNumber=cms.uint32(1),
        )
        process.twoGoodElectrons = cms.EDFilter(
            'CandViewCountFilter',
            src=cms.InputTag('goodElectrons'),
            minNumber=cms.uint32(2),
        )
        if 'ee' in channel:
            process.path *= (process.goodElectrons * process.twoGoodElectrons)

    if 'em' in channel:
        process.path *= (process.goodElectrons * process.oneGoodElectron *
                         process.goodMuons * process.oneGoodMuon)

    ############################################################################
    #  Jets
    ############################################################################

    process.load('RecoJets.JetProducers.ak5PFJets_cfi')
    process.ak5PFJets.srcPVs = cms.InputTag('goodOfflinePrimaryVertices')
    process.ak5PFJetsCHS = process.ak5PFJets.clone(
        src=cms.InputTag('pfNoPileUp'))

    process.kappaTuple.active += cms.vstring('Jets', 'PileupDensity')
    process.kappaTuple.Jets = cms.PSet(
        process.kappaNoCut,
        process.kappaNoRegEx,
        taggers=cms.vstring(),
        ak5PFJets=cms.PSet(
            src=cms.InputTag('ak5PFJets'),
            QGtagger=cms.InputTag('AK5PFJetsQGTagger'),
            Btagger=cms.InputTag('ak5PF'),
            PUJetID=cms.InputTag('ak5PFPuJetMva'),
            PUJetID_full=cms.InputTag('full'),
        ),
        ak5PFJetsCHS=cms.PSet(
            src=cms.InputTag('ak5PFJetsCHS'),
            QGtagger=cms.InputTag('AK5PFJetsCHSQGTagger'),
            Btagger=cms.InputTag('ak5PFCHS'),
            PUJetID=cms.InputTag('ak5PFCHSPuJetMva'),
            PUJetID_full=cms.InputTag('full'),
        ),
    )
    process.kappaTuple.Jets.minPt = cms.double(5.0)

    if not data:
        process.load('RecoJets.JetProducers.ak5GenJets_cfi')
        process.path *= (process.genParticlesForJetsNoNu *
                         process.ak5GenJetsNoNu)
        process.kappaTuple.active += cms.vstring('LV')
        process.kappaTuple.LV.rename = cms.vstring('ak => AK')
        process.kappaTuple.LV.whitelist = cms.vstring('ak5GenJetsNoNu')

    # add kt6PFJets, needed for the PileupDensity
    from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
    process.kt6PFJets = kt4PFJets.clone(rParam=0.6, doRhoFastjet=True)
    process.kt6PFJets.Rho_EtaMax = cms.double(2.5)

    process.path *= (process.ak5PFJets * process.ak5PFJetsCHS *
                     process.kt6PFJets)

    ############################################################################
    #  MET
    ############################################################################
    # MET correction ----------------------------------------------------------
    process.load('JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi')
    process.path *= (process.type0PFMEtCorrection)
    #TODO check type 0 corrections
    process.kappaTuple.active += cms.vstring('MET')  ## produce/save KappaPFMET
    process.kappaTuple.MET.whitelist = cms.vstring('pfChMet', '_pfMet_')

    if cmssw_version_number.startswith("5"):
        # MET correction ----------------------------------------------------------
        process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
        process.pfchsMETcorr.src = cms.InputTag('goodOfflinePrimaryVertices')
        # Type-0
        process.pfMETCHS = process.pfType1CorrectedMet.clone(
            applyType1Corrections=cms.bool(False),
            applyType0Corrections=cms.bool(True))
        # MET Path
        process.path *= (process.producePFMETCorrections * process.pfMETCHS)
        process.kappaTuple.MET.whitelist += cms.vstring("pfMETCHS")

    ############################################################################
    #  Almost done ...
    ############################################################################
    process.path *= (process.kappaOut)
    return process
Exemple #17
0
def applyElectronParameters(process, isMC):
    process.electronIsoSequence = setupPFElectronIso(process, 'gsfElectrons')

    process.patElectrons.isoDeposits = cms.PSet(
        pfAllParticles=cms.InputTag(
            "elPFIsoDepositPUPFIso"),  # all PU   CH+MU+E
        pfChargedHadrons=cms.InputTag(
            "elPFIsoDepositChargedPFIso"),  # all noPU CH
        pfNeutralHadrons=cms.InputTag("elPFIsoDepositNeutralPFIso"),  # all NH
        pfPhotons=cms.InputTag("elPFIsoDepositGammaPFIso"),  # all PH
        user=cms.VInputTag(
            cms.InputTag("elPFIsoDepositChargedAllPFIso"))  # all noPU CH+MU+E
    )

    process.patElectrons.isolationValues = cms.PSet(
        pfAllParticles=cms.InputTag("elPFIsoValuePU04PFIdPFIso"),
        pfChargedHadrons=cms.InputTag("elPFIsoValueCharged04PFIdPFIso"),
        pfNeutralHadrons=cms.InputTag("elPFIsoValueNeutral04PFIdPFIso"),
        pfPhotons=cms.InputTag("elPFIsoValueGamma04PFIdPFIso"),
        user=cms.VInputTag(cms.InputTag("elPFIsoValueChargedAll04PFIdPFIso"),
                           cms.InputTag("elPFIsoValueChargedAll04NoPFIdPFIso"),
                           cms.InputTag("elPFIsoValuePU04NoPFIdPFIso"),
                           cms.InputTag("elPFIsoValueCharged04NoPFIdPFIso"),
                           cms.InputTag("elPFIsoValueGamma04NoPFIdPFIso"),
                           cms.InputTag("elPFIsoValueNeutral04NoPFIdPFIso")))

    process.patElectronsWithEmbeddedVariables = cms.EDProducer(
        'ElectronsUserEmbedder',
        electronTag=cms.InputTag("patElectronsTriggerMatch"),
        vertexTag=cms.InputTag("offlinePrimaryVerticesWithBS"),
        isMC=cms.bool(isMC),
        doMVAPOG=cms.bool(True),
        inputFileName0v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat1.weights.xml'
        ),
        inputFileName1v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat2.weights.xml'
        ),
        inputFileName2v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat3.weights.xml'
        ),
        inputFileName3v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat4.weights.xml'
        ),
        inputFileName4v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat5.weights.xml'
        ),
        inputFileName5v2=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_TrigV0_Cat6.weights.xml'
        ),
        inputFileName0v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat1.weights.xml'
        ),
        inputFileName1v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat2.weights.xml'
        ),
        inputFileName2v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat3.weights.xml'
        ),
        inputFileName3v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat4.weights.xml'
        ),
        inputFileName4v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat5.weights.xml'
        ),
        inputFileName5v3=cms.FileInPath(
            'EgammaAnalysis/ElectronTools/data/Electrons_BDTG_NonTrigV0_Cat6.weights.xml'
        ))

    process.patElectrons.embedTrack = cms.bool(True)
    process.patElectrons.embedGsfTrack = cms.bool(True)

    process.load('EgammaAnalysis.ElectronTools.electronIdMVAProducer_cfi')
    process.patElectrons.electronIDSources = cms.PSet(
        mvaNonTrigV0=cms.InputTag("mvaNonTrigV0"))

    return
def add_hZg_iso_needs(process):
    print "Adding rhos and collections needs for hZg"

    process.load("RecoJets.JetProducers.kt4PFJets_cfi")

    # for photon H/E
    process.CaloTowerConstituentsMapBuilder = cms.ESProducer(
        "CaloTowerConstituentsMapBuilder",
        MapFile = cms.untracked.string('Geometry/CaloTopology/data/CaloTowerEEGeometric.map.gz')
            )            

    process.pfAllNeutralHadronsAndPhotonsHZG = cms.EDProducer(
        "CandViewMerger",
        src = cms.VInputTag(cms.InputTag("pfAllNeutralHadrons"),
                            cms.InputTag("pfAllPhotons"))
        )

    process.kt6PFJetsHZGPho = process.kt4PFJets.clone(
        rParam = cms.double(0.6),
        doRhoFastjet = cms.bool(True),
        doAreaFastjet = cms.bool(True),
        voronoiRfact = cms.double(0.9)
        )

    process.kt6PFJetsCentralHZGEle = process.kt4PFJets.clone(
        rParam = cms.double(0.6),
        Rho_EtaMax = cms.double(2.5),        
        doRhoFastjet  = cms.bool(True),
        voronoiRfact = cms.double(0.9)
        )
    
    process.kt6PFJetsCentralNeutralHZGMu = process.kt4PFJets.clone(
        rParam        = cms.double(0.6),
        src           = cms.InputTag("pfAllNeutralHadronsAndPhotonsHZG"),
        Ghost_EtaMax  = cms.double(3.1),
        Rho_EtaMax    = cms.double(2.5),
        inputEtMin    = cms.double(0.5),
        doAreaFastjet = cms.bool(True),
        doRhoFastjet  = cms.bool(True),
        voronoiRfact = cms.double(0.9)
        )

    process.kt6PFJetsCentralHZGMu = process.kt4PFJets.clone(
        rParam = cms.double(0.6),
        Ghost_EtaMax = cms.double(2.5),
        Rho_EtaMax = cms.double(2.5),
        doAreaFastjet = cms.bool(True),
        doRhoFastjet  = cms.bool(True),
        voronoiRfact = cms.double(0.9)
        )

    process.hzg_isolations = cms.Sequence(
        process.kt6PFJetsHZGPho + 
        process.pfAllNeutralHadronsAndPhotonsHZG +        
        process.kt6PFJetsCentralHZGEle +
        process.kt6PFJetsCentralNeutralHZGMu +
        process.kt6PFJetsCentralHZGMu )

    #add in isolations with the wrong vetos in case some people are using them
    
    # Charged particle isolation
    process.muPFIsoValueCharged04PFIsoHZGWrongVeto = \
            process.muPFIsoValueChargedAll04PFIso.clone()
    process.muPFIsoValueNeutral04PFIsoHZGWrongVeto = \
            process.muPFIsoValueNeutral04PFIso.clone()
    process.muPFIsoValueGamma04PFIsoHZGWrongVeto = \
            process.muPFIsoValueGamma04PFIso.clone()

    process.muPFIsoValueCharged04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring()
    process.muPFIsoValueNeutral04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring('Threshold(0.5)')
    process.muPFIsoValueGamma04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring('Threshold(0.5)')

    process.hzg_isolations += process.muPFIsoValueCharged04PFIsoHZGWrongVeto
    process.hzg_isolations += process.muPFIsoValueNeutral04PFIsoHZGWrongVeto
    process.hzg_isolations += process.muPFIsoValueGamma04PFIsoHZGWrongVeto
        
    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueCharged04PFIsoHZGWrongVeto"))
    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueNeutral04PFIsoHZGWrongVeto"))
    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueGamma04PFIsoHZGWrongVeto"))

    process.hzg_isolations += process.muPFIsoValueGamma03PFIso    

    #take Egamma POG recipe 
    process.eleIsoSequenceHZG = setupPFElectronIso(process,
                                                   'gsfElectrons',
                                                   'PFIsoEGTwiki')
    process.eleIsoSequenceHZG += process.patElectrons

    #stick iso sequence infront of patElectron producer
    process.patDefaultSequence.replace(process.patElectrons,
                                       process.eleIsoSequenceHZG)

    process.patElectrons.isoDeposits.pfChargedHadrons = \
        cms.InputTag('elPFIsoDepositChargedPFIsoEGTwiki')
    process.patElectrons.isoDeposits.pfNeutralHadrons = \
        cms.InputTag('elPFIsoDepositNeutralPFIsoEGTwiki')
    process.patElectrons.isoDeposits.pfPhotons = \
        cms.InputTag('elPFIsoDepositGammaPFIsoEGTwiki')

    process.patElectrons.isolationValues.pfChargedHadrons = \
        cms.InputTag('elPFIsoValueCharged04PFIdPFIsoEGTwiki')
    process.patElectrons.isolationValues.pfNeutralHadrons = \
        cms.InputTag('elPFIsoValueNeutral04PFIdPFIsoEGTwiki')
    process.patElectrons.isolationValues.pfPhotons = \
        cms.InputTag('elPFIsoValueGamma04PFIdPFIsoEGTwiki')

    process.patElectrons.isolationValuesNoPFId.pfChargedHadrons = \
        cms.InputTag('elPFIsoValueCharged04NoPFIdPFIsoEGTwiki')
    process.patElectrons.isolationValuesNoPFId.pfNeutralHadrons = \
        cms.InputTag('elPFIsoValueNeutral04NoPFIdPFIsoEGTwiki')
    process.patElectrons.isolationValuesNoPFId.pfPhotons = \
        cms.InputTag('elPFIsoValueGamma04NoPFIdPFIsoEGTwiki')
    
    
    replace_result = process.patDefaultSequence.replace(
        process.muPFIsoValueGamma03PFIso,        
        process.hzg_isolations
        )
# parse command line arguments
options.parseArguments()

# MET uncertainty tool
# needs to go before everything else for some reason...
if not ("<DataType>" == "Data") and not ("embedded" in "<DataType>"):
    from SkimProduction.CRAB.metUncertaintyTool_cff import metUncertainty
    metUncertainty(process)

# load full CMSSW reconstruction config, needed for btagging
process.load("Configuration.StandardSequences.Reconstruction_cff")

############ Electrons
# electron isolation
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
process.eleIso = setupPFElectronIso(process, 'gsfElectrons')
process.eleIsoSequence = cms.Sequence(process.pfParticleSelectionSequence
                                      * process.eleIso)
# Electron momentum regression
from SkimProduction.CRAB.eleMomentumRegression_cff import eleMomentumRegression
eleMomentumRegression(process, "<datasetpath>", "<DataType>")

############ Jets
# Jet energy corrections to use:
JetCorrection = "ak5PFL1FastL2L3"
if "<DataType>" == "Data" or "embedded" in "<DataType>":
    JetCorrection += "Residual"
process.ak5PFJetsCorr = cms.EDProducer('PFJetCorrectionProducer',
                                       src = cms.InputTag("ak5PFJets"),
                                       correctors = cms.vstring(JetCorrection) # NOTE: use "ak5PFL1FastL2L3" for MC / "ak5PFL1FastL2L3Residual" for Data
                                       )

# parton flavour
process.load("PhysicsTools.JetMCAlgos.CaloJetsMCFlavour_cfi")

import FWCore.ParameterSet.Config as cms

process.AK5PFbyRef = process.AK5byRef.clone(jets="ak5PFJets")

process.AK5PFbyValAlgo = process.AK5byValAlgo.clone(srcByReference="AK5PFbyRef")

##########################################################################
### PF isolation settings ################################################
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFPhotonIso

process.eleIsoSequence = setupPFElectronIso(process, "gsfElectrons", newpostfix="Standard")
process.analyze.tag_elepfisosEvent = [
    "elPFIsoValueCharged03PFIdStandard",
    "elPFIsoValueCharged04PFIdStandard",
    "elPFIsoValueNeutral03PFIdStandard",
    "elPFIsoValueNeutral04PFIdStandard",
    "elPFIsoValueGamma03PFIdStandard",
    "elPFIsoValueGamma04PFIdStandard",
]

process.phoIsoSequence = setupPFPhotonIso(process, "photons")

process.load("DiLeptonAnalysis.NTupleProducer.leptonPFIsolation_cff")
process.pfPileUp.Vertices = "goodVertices"
process.analyze.tag_muonpfisosCustom = [
    "muonPFIsoChHad03",
Exemple #21
0
from ZFinder.Event.electron_regression_cfi import CalibratedElectrons_MC, RandomNumberGeneratorService, ElectronEnergyRegressions_MC

process.RandomNumberGeneratorService = RandomNumberGeneratorService
process.CalibratedElectrons = CalibratedElectrons_MC
process.eleRegressionEnergy = ElectronEnergyRegressions_MC

# Import rho value for isolation correction
from ZFinder.Event.kt6_pfjets_cfi import kt6PFJetsForIsolation

process.kt6PFJetsForIsolation = kt6PFJetsForIsolation.clone()

# Particle flow isolation
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso

process.eleIsoSequence = setupPFElectronIso(
    process, 'CalibratedElectrons:calibratedGsfElectrons')
process.pfiso = cms.Sequence(process.pfParticleSelectionSequence +
                             process.eleIsoSequence)

# Compute PDF weights for uncertainty calculation
process.pdfWeights = cms.EDProducer(
    "PdfWeightProducer",
    #Fix POWHEG if buggy (this PDF set will also appear on output,
    #so only two more PDF sets can be added in PdfSetNames if not "")
    #FixPOWHEG = cms.untracked.string("cteq66.LHgrid"),
    GenTag=cms.untracked.InputTag("genParticles"),
    PdfInfoTag=cms.untracked.InputTag("generator"),
    # Produce PDF weights (maximum is 3)
    PdfSetNames=cms.untracked.vstring(
        #            "NNPDF23_nlo_as_0118.LHgrid",
        #            "MSTW2008nlo68cl.LHgrid",
def add_hZg_iso_needs(process):
    print "Adding rhos and collections needs for hZg"

    process.load("RecoJets.JetProducers.kt4PFJets_cfi")

    # for photon H/E
    process.CaloTowerConstituentsMapBuilder = cms.ESProducer(
        "CaloTowerConstituentsMapBuilder",
        MapFile=cms.untracked.string(
            'Geometry/CaloTopology/data/CaloTowerEEGeometric.map.gz'))

    process.pfAllNeutralHadronsAndPhotonsHZG = cms.EDProducer(
        "CandViewMerger",
        src=cms.VInputTag(cms.InputTag("pfAllNeutralHadrons"),
                          cms.InputTag("pfAllPhotons")))

    process.kt6PFJetsHZGPho = process.kt4PFJets.clone(
        rParam=cms.double(0.6),
        doRhoFastjet=cms.bool(True),
        doAreaFastjet=cms.bool(True),
        voronoiRfact=cms.double(0.9))

    process.kt6PFJetsCentralHZGEle = process.kt4PFJets.clone(
        rParam=cms.double(0.6),
        Rho_EtaMax=cms.double(2.5),
        doRhoFastjet=cms.bool(True),
        voronoiRfact=cms.double(0.9))

    process.kt6PFJetsCentralNeutralHZGMu = process.kt4PFJets.clone(
        rParam=cms.double(0.6),
        src=cms.InputTag("pfAllNeutralHadronsAndPhotonsHZG"),
        Ghost_EtaMax=cms.double(3.1),
        Rho_EtaMax=cms.double(2.5),
        inputEtMin=cms.double(0.5),
        doAreaFastjet=cms.bool(True),
        doRhoFastjet=cms.bool(True),
        voronoiRfact=cms.double(0.9))

    process.kt6PFJetsCentralHZGMu = process.kt4PFJets.clone(
        rParam=cms.double(0.6),
        Ghost_EtaMax=cms.double(2.5),
        Rho_EtaMax=cms.double(2.5),
        doAreaFastjet=cms.bool(True),
        doRhoFastjet=cms.bool(True),
        voronoiRfact=cms.double(0.9))

    process.hzg_isolations = cms.Sequence(
        process.kt6PFJetsHZGPho + process.pfAllNeutralHadronsAndPhotonsHZG +
        process.kt6PFJetsCentralHZGEle + process.kt6PFJetsCentralNeutralHZGMu +
        process.kt6PFJetsCentralHZGMu)

    #add in isolations with the wrong vetos in case some people are using them

    # Charged particle isolation
    process.muPFIsoValueCharged04PFIsoHZGWrongVeto = \
            process.muPFIsoValueChargedAll04PFIso.clone()
    process.muPFIsoValueNeutral04PFIsoHZGWrongVeto = \
            process.muPFIsoValueNeutral04PFIso.clone()
    process.muPFIsoValueGamma04PFIsoHZGWrongVeto = \
            process.muPFIsoValueGamma04PFIso.clone()

    process.muPFIsoValueCharged04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring()
    process.muPFIsoValueNeutral04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring('Threshold(0.5)')
    process.muPFIsoValueGamma04PFIsoHZGWrongVeto.deposits[0].vetos = \
            cms.vstring('Threshold(0.5)')

    process.hzg_isolations += process.muPFIsoValueCharged04PFIsoHZGWrongVeto
    process.hzg_isolations += process.muPFIsoValueNeutral04PFIsoHZGWrongVeto
    process.hzg_isolations += process.muPFIsoValueGamma04PFIsoHZGWrongVeto

    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueCharged04PFIsoHZGWrongVeto"))
    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueNeutral04PFIsoHZGWrongVeto"))
    process.patMuons.isolationValues.user.append(
        cms.InputTag("muPFIsoValueGamma04PFIsoHZGWrongVeto"))

    process.hzg_isolations += process.muPFIsoValueGamma03PFIso

    #take Egamma POG recipe
    process.eleIsoSequenceHZG = setupPFElectronIso(process, 'gsfElectrons',
                                                   'PFIsoEGTwiki')
    process.eleIsoSequenceHZG += process.patElectrons

    #stick iso sequence infront of patElectron producer
    process.patDefaultSequence.replace(process.patElectrons,
                                       process.eleIsoSequenceHZG)

    process.patElectrons.isoDeposits.pfChargedHadrons = \
        cms.InputTag('elPFIsoDepositChargedPFIsoEGTwiki')
    process.patElectrons.isoDeposits.pfNeutralHadrons = \
        cms.InputTag('elPFIsoDepositNeutralPFIsoEGTwiki')
    process.patElectrons.isoDeposits.pfPhotons = \
        cms.InputTag('elPFIsoDepositGammaPFIsoEGTwiki')

    process.patElectrons.isolationValues.pfChargedHadrons = \
        cms.InputTag('elPFIsoValueCharged04PFIdPFIsoEGTwiki')
    process.patElectrons.isolationValues.pfNeutralHadrons = \
        cms.InputTag('elPFIsoValueNeutral04PFIdPFIsoEGTwiki')
    process.patElectrons.isolationValues.pfPhotons = \
        cms.InputTag('elPFIsoValueGamma04PFIdPFIsoEGTwiki')

    process.patElectrons.isolationValuesNoPFId.pfChargedHadrons = \
        cms.InputTag('elPFIsoValueCharged04NoPFIdPFIsoEGTwiki')
    process.patElectrons.isolationValuesNoPFId.pfNeutralHadrons = \
        cms.InputTag('elPFIsoValueNeutral04NoPFIdPFIsoEGTwiki')
    process.patElectrons.isolationValuesNoPFId.pfPhotons = \
        cms.InputTag('elPFIsoValueGamma04NoPFIdPFIsoEGTwiki')

    replace_result = process.patDefaultSequence.replace(
        process.muPFIsoValueGamma03PFIso, process.hzg_isolations)
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('/store/data/Run2012A/DoubleElectron/AOD/22Jan2013-v1/20000/003EC246-5E67-E211-B103-00259059642E.root')
)

from ZFinder.Event.electron_regression_cfi import CalibratedElectrons, ElectronEnergyRegressions
# Energy Regression
process.eleRegressionEnergy = ElectronEnergyRegressions
# Energy Scale calibration
process.CalibratedElectrons = CalibratedElectrons



# Particle flow isolation
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
process.eleIsoSequence = setupPFElectronIso(process, 'CalibratedElectrons:calibratedGsfElectrons')
process.pfiso = cms.Sequence(process.pfParticleSelectionSequence + process.eleIsoSequence)

# My analyzer
process.trigeff = cms.EDAnalyzer('TrigEff',
        ecalElectronsInputTag = cms.InputTag("CalibratedElectrons", "calibratedGsfElectrons"),
        )

process.p = cms.Path(
        process.kt6PFJetsForIsolation
        * process.eleRegressionEnergy
        * process.CalibratedElectrons
        * process.pfiso
        * process.trigeff
        )
                                    triggerEvent=cms.InputTag("patTriggerEvent"),
                                    tauMatch_Loose=cms.string('tauTriggerMatchHLTTausLoose'),
                                    tauMatch_Medium=cms.string('tauTriggerMatchHLTTausMedium'),
                                    electronMatch_Loose=cms.string('electronTriggerMatchHLTElectronsLoose'),
                                    muonMatch_Loose=cms.string('muonTriggerMatchHLTMuonsLoose'),


                                    puJetIdFlag=cms.InputTag("puJetMva","fullId"),
                                    #rho
                                    rhoProducer = cms.InputTag('kt6PFJetsForRhoComputationVoronoi','rho')
                                    )
#################################################   PFIsolation  ################################
from CommonTools.ParticleFlow.pfParticleSelection_cff import *

from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso
process.eleIsoSequence = setupPFElectronIso(process, 'selectedPatElectrons')

#from RecoParticleFlow.PFProducer.electronPFIsolationValues_cff import *
# cone vetos as used in Htautau
process.elPFIsoValueChargedAll04NoPFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.01)','EcalEndcaps:ConeVeto(0.015)')
process.elPFIsoValueChargedAll04PFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.01)','EcalEndcaps:ConeVeto(0.015)')
process.elPFIsoValueChargedAll03NoPFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.01)','EcalEndcaps:ConeVeto(0.015)')
process.elPFIsoValueChargedAll03PFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.01)','EcalEndcaps:ConeVeto(0.015)')

process.elPFIsoValueGamma04NoPFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.08)','EcalEndcaps:ConeVeto(0.08)')
process.elPFIsoValueGamma04PFIdPFIso.deposits[0].vetos = cms.vstring('EcalBarrel:ConeVeto(0.08)','EcalEndcaps:ConeVeto(0.08)')

#process.elPFIsoValuePU04NoPFIdPFIso.deposits[0].vetos = cms.vstring('')
#process.elPFIsoValuePU04PFIdPFIso.deposits[0].vetos = cms.vstring('')

Exemple #25
0
          jets = cms.InputTag("ak5PFJets"),
          vertexes = cms.InputTag("offlinePrimaryVertices"),
          algos = cms.VPSet(stdalgos),
          rho     = cms.InputTag("kt6PFJets","rho"),
          jec     = cms.string("AK5PF"),
          applyJec = cms.bool(True),
          inputIsCorrected = cms.bool(False),                                     
          residualsFromTxt = cms.bool(False),
          residualsTxt     = cms.FileInPath("RecoJets/JetProducers/data/dummy.txt"),
          )

################################################################
### Lepton Isolation
################################################################
from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons')
process.muIsoSequence = setupPFMuonIso(process, 'pfAllMuons')
# massSearchReplaceAnyInputTag(process.pfParticleSelectionSequence,
#                              "offlinePrimaryVertices",
#                              "goodOfflinePrimaryVertices",
#                              verbose=True)
# massSearchReplaceAnyInputTag(process.eleIsoSequence,
#                              "offlinePrimaryVertices",
#                              "goodOfflinePrimaryVertices",
#                              verbose=True)
# massSearchReplaceAnyInputTag(process.muIsoSequence,
#                              "offlinePrimaryVertices",
#                              "goodOfflinePrimaryVertices",
#                              verbose=True)

process.eleIsoSequence.remove(process.elPFIsoValueCharged03NoPFIdPFIso)
Exemple #26
0
            print "[INFO] Using GT POSTLS162_V5::All"
            process.GlobalTag.globaltag = 'POSTLS162_V5::All'
        else:
            process.GlobalTag.globaltag = 'GR_R_62_V3'
    else:
        print "[ERROR]::Global Tag not set for CMSSW_VERSION: ", CMSSW_VERSION
    

#Define the sequences
#
# particle flow isolation
#
process.pfIsoEgamma = cms.Sequence()
if((options.type=='ALCARECO' or options.type=='ALCARECOSIM') and not re.match("CMSSW_7_.*_.*",CMSSW_VERSION)):
    from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
    process.eleIsoSequence = setupPFElectronIso(process, 'gedGsfElectrons', 'PFIso')
    process.pfIsoEgamma *= (process.pfParticleSelectionSequence + process.eleIsoSequence)
elif((options.type=='ALCARECO' or options.type=='ALCARECOSIM') and re.match("CMSSW_7_.*_.*",CMSSW_VERSION)):
    # getting the ptrs
    from RecoParticleFlow.PFProducer.pfLinker_cff import particleFlowPtrs
    process.pfIsoEgamma*=particleFlowPtrs
    process.load('CommonTools.ParticleFlow.pfNoPileUpIso_cff')
    process.pfPileUp.PFCandidates = 'particleFlowPtrs'
    process.pfNoPileUp.bottomCollection = 'particleFlowPtrs'
    process.pfPileUpIso.PFCandidates = 'particleFlowPtrs'
    process.pfNoPileUpIso.bottomCollection='particleFlowPtrs'
    process.pfPileUpJME.PFCandidates = 'particleFlowPtrs'
    process.pfNoPileUpJME.bottomCollection='particleFlowPtrs'

    #    process.load('RecoParticleFlow/Configuration/python/RecoParticleFlow_cff') #CommonTools.ParticleFlow.PFBRECO_cff')
    process.pfIsoEgamma*= process.pfNoPileUpSequence * process.pfNoPileUpIsoSequence