Skip to content

Commit

Permalink
Merge pull request #3510 from cms-btv-pog/PAT-PythonCircuitryUpdate_f…
Browse files Browse the repository at this point in the history
…rom-CMSSW_7_1_X_2014-04-25-1400

AT -- Updates for PAT python configuration files
  • Loading branch information
ktf committed Apr 28, 2014
2 parents 09e3046 + b971b61 commit d5a1ca6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 36 deletions.
10 changes: 5 additions & 5 deletions PhysicsTools/PatAlgos/python/mcMatchLayer0/jetMatch_cfi.py
Expand Up @@ -3,8 +3,8 @@
#
# Example for a configuration of the MC match
#
patJetPartonMatch = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
src = cms.InputTag("ak5PFJetsCHS"), # RECO objects to match
patJetPartonMatch = cms.EDProducer("MCMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
src = cms.InputTag("ak5PFJetsCHS"), # RECO objects to match
matched = cms.InputTag("genParticles"), # mc-truth particle collection
mcPdgId = cms.vint32(1, 2, 3, 4, 5, 21), # one or more PDG ID (quarks except top; gluons)
mcStatus = cms.vint32(3), # PYTHIA status code (3 = hard scattering)
Expand All @@ -15,14 +15,14 @@
resolveByMatchQuality = cms.bool(False), # False = just match input in order; True = pick lowest deltaR pair first
)

patJetGenJetMatch = cms.EDProducer("GenJetMatcher", # cut on deltaR, deltaPt/Pt; pick best by deltaR
src = cms.InputTag("ak5PFJetsCHS"), # RECO jets (any View<Jet> is ok)
patJetGenJetMatch = cms.EDProducer("GenJetMatcher", # cut on deltaR; pick best by deltaR
src = cms.InputTag("ak5PFJetsCHS"), # RECO jets (any View<Jet> is ok)
matched = cms.InputTag("ak5GenJets"), # GEN jets (must be GenJetCollection)
mcPdgId = cms.vint32(), # n/a
mcStatus = cms.vint32(), # n/a
checkCharge = cms.bool(False), # n/a
maxDeltaR = cms.double(0.4), # Minimum deltaR for the match
maxDPtRel = cms.double(3.0), # Minimum deltaPt/Pt for the match
#maxDPtRel = cms.double(3.0), # Minimum deltaPt/Pt for the match (not used in GenJetMatcher)
resolveAmbiguities = cms.bool(True), # Forbid two RECO objects to match to the same GEN object
resolveByMatchQuality = cms.bool(False), # False = just match input in order; True = pick lowest deltaR pair first
)
Expand Down
6 changes: 4 additions & 2 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Expand Up @@ -310,10 +310,10 @@ def toolCode(self, process):
if not tagInfoCovered :
requiredTagInfos.append(requiredTagInfo)
## load sequences and setups needed fro btagging
## This loads all available btagger, but the ones we need are added to the process by hand lader. Only needed to get the ESProducer. Needs improvement
## This loads all available btagger, but the ones we need are added to the process by hand later. Only needed to get the ESProducer. Needs improvement
#loadWithPostFix(process,"RecoBTag.Configuration.RecoBTag_cff",postfix)
process.load("RecoBTag.Configuration.RecoBTag_cff")
#addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
#addESProducers(process,'RecoBTag.Configuration.RecoBTag_cff')
import RecoBTag.Configuration.RecoBTag_cff as btag

## prepare setups for simple secondary vertex infos
Expand Down Expand Up @@ -366,6 +366,8 @@ def toolCode(self, process):
process.load( 'RecoBTag.SecondaryVertex.secondaryVertex_cff' )
if not hasattr( process, 'bToCharmDecayVertexMerged' ):
process.load( 'RecoBTag.SecondaryVertex.bToCharmDecayVertexMerger_cfi' )
## modify new patJets collection accordingly
_newPatJets.addBTagInfo = True
else:
_newPatJets.addBTagInfo = False
## adjust output module; these collections will be empty anyhow, but we do it to stay clean
Expand Down
38 changes: 13 additions & 25 deletions PhysicsTools/PatAlgos/python/tools/pfTools.py
Expand Up @@ -424,32 +424,17 @@ def adaptPVs(process, pvCollection=cms.InputTag('offlinePrimaryVertices'), postf
print "***********************************"

# PV sources to be exchanged:
pvExchange = ['Vertices','vertices','pvSrc','primaryVertices','srcPVs']
pvExchange = ['Vertices','vertices','pvSrc','primaryVertices','srcPVs','primaryVertex']
# PV sources NOT to be exchanged:
#noPvExchange = ['src','PVProducer','primaryVertexSrc','vertexSrc','primaryVertex']

# find out all added jet collections (they don't belong to PF2PAT)
interPostfixes = []
for m in process.producerNames().split(' '):
if m.startswith('patJets') and m.endswith(postfix) and not len(m)==len('patJets')+len(postfix):
interPostfix = m.replace('patJets','')
interPostfix = interPostfix.replace(postfix,'')
interPostfixes.append(interPostfix)
#noPvExchange = ['src','PVProducer','primaryVertexSrc','vertexSrc']

# exchange the primary vertex source of all relevant modules
for m in process.producerNames().split(' '):
modName = m.replace(postfix,'')
for m in (process.producerNames().split(' ') + process.filterNames().split(' ')):
# only if the module has a source with a relevant name
for namePvSrc in pvExchange:
if hasattr(getattr(process,m),namePvSrc):
# only if the module is not coming from an added jet collection
interPostFixFlag = False
for pfix in interPostfixes:
if modName.endswith(pfix):
interPostFixFlag = True
break
if not interPostFixFlag:
setattr(getattr(process,m),namePvSrc,deepcopy(pvCollection))
#print m
setattr(getattr(process,m),namePvSrc,deepcopy(pvCollection))


def usePF2PAT(process,runPF2PAT=True, jetAlgo='AK5', runOnMC=True, postfix="", jetCorrections=('AK5PFchs', ['L1FastJet','L2Relative','L3Absolute'],'None'), pvCollection=cms.InputTag('goodOfflinePrimaryVerticesPFlow',), typeIMetCorrections=False, outputModules=['out'],excludeFromTopProjection=['Tau']):
Expand Down Expand Up @@ -520,14 +505,17 @@ def usePF2PAT(process,runPF2PAT=True, jetAlgo='AK5', runOnMC=True, postfix="", j
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,"pfNoPileUpJME"+postfix).enable = True
getattr(process,"pfNoMuonJME"+postfix).enable = True
getattr(process,"pfNoElectronJME"+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+','
jme = ''
if object in ['Muon','Electron']:
jme = 'JME'
getattr(process,"pfNo"+object+jme+postfix).enable = False
exclusionList=exclusionList+object+','
exclusionList=exclusionList.rstrip(',')
print "Done: PF2PAT interfaced to PAT, postfix=", postfix,", Excluded from Top Projection:",exclusionList
8 changes: 4 additions & 4 deletions PhysicsTools/PatAlgos/test/patTuple_PF2PAT_cfg.py
Expand Up @@ -38,16 +38,16 @@


# top projections in PF2PAT:
getattr(process,"pfNoPileUp"+postfix).enable = True
getattr(process,"pfNoMuon"+postfix).enable = True
getattr(process,"pfNoElectron"+postfix).enable = True
getattr(process,"pfNoPileUpJME"+postfix).enable = True
getattr(process,"pfNoMuonJME"+postfix).enable = True
getattr(process,"pfNoElectronJME"+postfix).enable = True
getattr(process,"pfNoTau"+postfix).enable = False
getattr(process,"pfNoJet"+postfix).enable = True
# to use tau-cleaned jet collection uncomment the following:
#getattr(process,"pfNoTau"+postfix).enable = True

# verbose flags for the PF2PAT modules
getattr(process,"pfNoMuon"+postfix).verbose = False
getattr(process,"pfNoMuonJME"+postfix).verbose = False

# enable delta beta correction for muon selection in PF2PAT?
getattr(process,"pfIsolatedMuons"+postfix).doDeltaBetaCorrection = cms.bool(False)
Expand Down

0 comments on commit d5a1ca6

Please sign in to comment.