## import skeleton process from PhysicsTools.PatAlgos.patTemplate_cfg import * runOnMC = False #if runOnMC: #from PhysicsTools.PatAlgos.patInputFiles_cff import filesRelValProdTTbarAODSIM #process.source.fileNames = filesRelValProdTTbarAODSIM #else: #from PhysicsTools.PatAlgos.patInputFiles_cff import filesSingleMuRECO #process.source.fileNames = filesSingleMuRECO #process.GlobalTag.globaltag = cms.string("FT_P_V42::All" ) from PhysicsTools.PatAlgos.tools.helpers import loadWithPostFix loadWithPostFix(process, 'PhysicsTools.PatAlgos.patSequences_cff', '') #print process.patDefaultSequence # Configure PAT to use PF2PAT instead of AOD sources # this function will modify the PAT sequences. from PhysicsTools.PatAlgos.tools.pfTools import * # An empty postfix means that only PF2PAT is run, # otherwise both standard PAT and PF2PAT are run. In the latter case PF2PAT # collections have standard names + postfix (e.g. patElectronPFlow) postfix = "PFlow" postfix2 = 'PFlow2' jetAlgo = "AK5" jetAlgo2 = "AK7" #Define Objects to be excluded from Top Projection. Default is Tau, so objects are not cleaned for taus excludeFromTopProjection = ['Tau'] usePF2PAT(process,
## import skeleton process from PhysicsTools.PatAlgos.patTemplate_cfg import * runOnMC = False #if runOnMC: #from PhysicsTools.PatAlgos.patInputFiles_cff import filesRelValProdTTbarAODSIM #process.source.fileNames = filesRelValProdTTbarAODSIM #else: #from PhysicsTools.PatAlgos.patInputFiles_cff import filesSingleMuRECO #process.source.fileNames = filesSingleMuRECO #process.GlobalTag.globaltag = cms.string("FT_P_V42::All" ) from PhysicsTools.PatAlgos.tools.helpers import loadWithPostFix loadWithPostFix(process,'PhysicsTools.PatAlgos.patSequences_cff','') #print process.patDefaultSequence # Configure PAT to use PF2PAT instead of AOD sources # this function will modify the PAT sequences. from PhysicsTools.PatAlgos.tools.pfTools import * # An empty postfix means that only PF2PAT is run, # otherwise both standard PAT and PF2PAT are run. In the latter case PF2PAT # collections have standard names + postfix (e.g. patElectronPFlow) postfix = "PFlow" postfix2 = 'PFlow2' jetAlgo = "AK5" jetAlgo2 = "AK7"
def usePF2PAT(process,runPF2PAT=True, jetAlgo='ak5', runOnMC=True, postfix="", jetCorrections=('AK5PFchs', ['L1FastJet','L2Relative','L3Absolute'],'None'), pvCollection=cms.InputTag('offlinePrimaryVertices',), typeIMetCorrections=False, outputModules=['out'],excludeFromTopProjection=['Tau']): # PLEASE DO NOT CLOBBER THIS FUNCTION WITH CODE SPECIFIC TO A GIVEN PHYSICS OBJECT. # CREATE ADDITIONAL FUNCTIONS IF NEEDED. #if jetCorrections[2] == 'Type-1': #typeIMetCorrections=True if typeIMetCorrections: jetCorrections = (jetCorrections[0],jetCorrections[1],'Type-1') """Switch PAT to use PF2PAT instead of AOD sources. if 'runPF2PAT' is true, we'll also add PF2PAT in front of the PAT sequence""" # -------- CORE --------------- from PhysicsTools.PatAlgos.tools.helpers import loadWithPostFix if runPF2PAT: loadWithPostFix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix) loadWithPostFix(process,"CommonTools.ParticleFlow.PF2PAT_cff",postfix) else: loadWithPostFix(process,'PhysicsTools.PatAlgos.patSequences_cff',postfix) # -------- OBJECTS ------------ # Muons adaptPFMuons(process, applyPostfix(process,"patMuons",postfix), postfix) # Electrons adaptPFElectrons(process, applyPostfix(process,"patElectrons",postfix), postfix) # Photons #print "Temporarily switching off photons completely" #removeSpecificPATObjects(process,names=['Photons'],outputModules=outputModules,postfix=postfix) #removeIfInSequence(process,"patPhotonIsolation","patPF2PATSequence",postfix) # Jets if runOnMC : switchToPFJets( process, cms.InputTag('pfNoTauClones'+postfix), jetAlgo, postfix=postfix, jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules ) ### No longer needed in unscheduled mode### #applyPostfix(process,"patPF2PATSequence",postfix).replace( #applyPostfix(process,"patJetGenJetMatch",postfix), #getattr(process,"patPF2PATSequence") * #applyPostfix(process,"patJetGenJetMatch",postfix) #) else : if not 'L2L3Residual' in jetCorrections[1]: ### think of a more accurate warning print '#################################################' print 'WARNING! Not using L2L3Residual but this is data.' print 'If this is okay with you, disregard this message.' print '#################################################' switchToPFJets( process, cms.InputTag('pfNoTauClones'+postfix), jetAlgo, postfix=postfix, jetCorrections=jetCorrections, type1=typeIMetCorrections, outputModules=outputModules ) # Taus #adaptPFTaus( process, tauType='shrinkingConePFTau', postfix=postfix ) #adaptPFTaus( process, tauType='fixedConePFTau', postfix=postfix ) adaptPFTaus( process, tauType='hpsPFTau', postfix=postfix ) # MET switchToPFMET(process, cms.InputTag('pfMET'+postfix), type1=typeIMetCorrections, postfix=postfix) # Unmasked PFCandidates addPFCandidates(process,cms.InputTag('pfNoJetClones'+postfix),patLabel='PFParticles'+postfix,cut="",postfix=postfix) # adapt primary vertex collection adaptPVs(process, pvCollection=pvCollection, postfix=postfix) if runOnMC: loadWithPostFix(process,"CommonTools.ParticleFlow.genForPF2PAT_cff",postfix) ### no longer needed in unscheduled mode ### #getattr(process, "patPF2PATSequence"+postfix).replace( #applyPostfix(process,"patCandidates",postfix), #process.genForPF2PATSequence+applyPostfix(process,"patCandidates",postfix) #) else: runOnData(process,postfix=postfix,outputModules=outputModules) # Configure Top Projections getattr(process,"pfNoPileUp"+postfix).enable = True getattr(process,"pfNoMuon"+postfix).enable = True getattr(process,"pfNoElectron"+postfix).enable = True getattr(process,"pfNoTau"+postfix).enable = False getattr(process,"pfNoJet"+postfix).enable = True exclusionList = '' for object in excludeFromTopProjection: getattr(process,"pfNo"+object+postfix).enable = False exclusionList=exclusionList+object+',' exclusionList=exclusionList.rstrip(',') print "Done: PF2PAT interfaced to PAT, postfix=", postfix,", Exluded from Top Projection:",exclusionList