# take into account different electron vetos in mu and e channel
        options['cutsElec'    ] = 'et > 20. & abs(eta) < 2.5'
	if(PF2PATwithoutLeptonIsoCut):
	    ## change the source of the PAT leptons to nonIso leptons to be able to do isolation studies
	    process.load("PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi")
            process.patElectrons.pfElectronSource = cms.InputTag("pfSelectedElectrons")
	else:
	    options['skipIfNoPFElec']=True
    elif(leptonTypeId==13):
	if(PF2PATwithoutLeptonIsoCut):
	    ## change the source of the PAT leptons to nonIso leptons to be able to do isolation studies
	    process.load("PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi")
            process.patMuons.pfMuonSource = cms.InputTag("pfSelectedMuons")
	else:
	    options['skipIfNoPFMuon']=True 
    prependPF2PATSequence(process, allpaths, options)
    ## change the source of the PAT leptons to nonIso leptons to be able to do isolation studies
    if(PF2PATwithoutLeptonIsoCut):
        for path in allpaths:
	    if(leptonTypeId==11):
		getattr(process,path).remove(process.electronMatch)
		getattr(process,path).remove(process.patElectrons)
		if(dataSelector == 1):
		    getattr(process,path).replace(process.pfIsolatedElectrons, process.electronMatch*process.patElectrons*process.pfIsolatedElectrons)
		else:
		    getattr(process,path).replace(process.pfIsolatedElectrons, process.patElectrons*process.pfIsolatedElectrons)
		      
	    elif(leptonTypeId==13):
		getattr(process,path).remove(process.muonMatch)
		getattr(process,path).remove(process.patMuons)
		if(dataSelector == 1):
        'switchOffEmbedding': False,
        'addResolutions': True,
	'resolutionsVersion': 'fall11',
        'runOnOLDcfg': True,
        'cutsMuon': 'pt > 10. & abs(eta) < 2.5',
        'cutsElec': 'et > 15. & abs(eta) < 2.5',
        'cutsJets': 'pt > 10 & abs(eta) < 5.0', 
        'electronIDs': ['CiC','classical','MVA'],
        'pfIsoConeMuon': 0.4,
        'pfIsoConeElec': 0.3,
        'pfIsoValMuon': 0.2,
        'pfIsoValElec': 0.15,
        'skipIfNoPFMuon': True,
        'skipIfNoPFElec': False,
        'doDeltaBetaCorrMuon' : True,
        'doDeltaBetaCorrElec' : True,
        'addNoCutPFMuon': False,
        'addNoCutPFElec': False,
        'noMuonTopProjection': False,
        'noElecTopProjection': False,
        'analyzersBeforeMuonIso':cms.Sequence(),
	'analyzersBeforeElecIso':cms.Sequence(),
        'excludeElectronsFromWsFromGenJets': True,
	'METCorrectionLevel': 1
        }   
    prependPF2PATSequence(process, recoPaths, PFoptions)
    #for path in recoPaths:
        # replace object consistently with names from PF2PAT
        #massSearchReplaceAnyInputTag(getattr(process,path), 'patMETsPF', 'patMETs')
        #massSearchReplaceAnyInputTag(getattr(process,path), 'selectedPatJetsAK5PF', 'selectedPatJets')
process = cms.Process("ResolutionTreeWriter")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.threshold = "INFO"
process.MessageLogger.cerr.FwkReport.reportEvery = 1000

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
process.load("Configuration.StandardSequences.Geometry_cff")
process.GlobalTag.globaltag = cms.string("START42_V17::All")

process.source = cms.Source(
    "PoolSource",
    fileNames=cms.untracked.vstring(
        "/store/mc/Fall11/TTJets_TuneZ2_7TeV-madgraph-tauola/AODSIM/PU_S6_START42_V14B-v2/0000/0040932D-A80F-E111-BBF7-00304867BFAA.root"
    ),
)
process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(100))

process.TFileService = cms.Service("TFileService", fileName=cms.string("ResolutionTree.root"))

from TopAnalysis.TopUtils.ResolutionTreeWriter_cfi import writeResolutionTree

process.resolutionTreeWriter = writeResolutionTree

process.p = cms.Path(process.resolutionTreeWriter)

from TopAnalysis.TopUtils.usePatTupleWithParticleFlow_cff import prependPF2PATSequence

PFoptions = {"runOnAOD": True}
prependPF2PATSequence(process, "p", PFoptions)