Skip to content

Commit

Permalink
Merge pull request #15472 from dntaylor/removeGenPAT
Browse files Browse the repository at this point in the history
Remove generator related PAT collections when running on data
  • Loading branch information
davidlange6 committed Aug 26, 2016
2 parents a610206 + bfe9b63 commit 068e4ef
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions PhysicsTools/PatAlgos/python/tools/coreTools.py
Expand Up @@ -98,6 +98,7 @@ def toolCode(self, process):
outputModules=self._parameters['outputModules'].value

print "************** MC dependence removal ************"
attrsToDelete = []
for obj in range(len(names)):
if( names[obj] == 'Photons' or names[obj] == 'All' ):
print "removing MC dependencies for photons"
Expand All @@ -115,7 +116,10 @@ def toolCode(self, process):
tauProducer = getattr(process,'patTaus'+postfix)
tauProducer.addGenJetMatch = False
tauProducer.embedGenJetMatch = False
attrsToDelete += [tauProducer.genJetMatch.getModuleLabel()]
tauProducer.genJetMatch = ''
attrsToDelete += ['tauGenJets'+postfix]
attrsToDelete += ['tauGenJetsSelectorAllHadrons'+postfix]
#Boosted Taus
if( names[obj] == 'TausBoosted' or names[obj] == 'All' ):
print "removing MC dependencies for taus boosted %s" %postfix
Expand All @@ -125,7 +129,10 @@ def toolCode(self, process):
tauProducer = getattr(process,'patTausBoosted'+postfix)
tauProducer.addGenJetMatch = False
tauProducer.embedGenJetMatch = False
attrsToDelete += [tauProducer.genJetMatch.getModuleLabel()]
tauProducer.genJetMatch = ''
attrsToDelete += ['tauGenJetsBoosted'+postfix]
attrsToDelete += ['tauGenJetsSelectorAllHadronsBoosted'+postfix]
else :
print "...skipped since taus boosted %s" %postfix, "are not part of process."
if( names[obj] == 'Jets' or names[obj] == 'All' ):
Expand All @@ -139,14 +146,19 @@ def toolCode(self, process):
jetProducer = getattr(process, jetCollectionString()+pfix)
jetProducer.addGenPartonMatch = False
jetProducer.embedGenPartonMatch = False
attrsToDelete += [jetProducer.genPartonMatch.getModuleLabel()]
jetProducer.genPartonMatch = ''
jetProducer.addGenJetMatch = False
attrsToDelete += [jetProducer.genJetMatch.getModuleLabel()]
jetProducer.genJetMatch = ''
jetProducer.getJetMCFlavour = False
jetProducer.useLegacyJetMCFlavour = False
jetProducer.addJetFlavourInfo = False
attrsToDelete += [jetProducer.JetPartonMapSource.getModuleLabel()]
jetProducer.JetPartonMapSource = ''
attrsToDelete += [jetProducer.JetFlavourInfoSource.getModuleLabel()]
jetProducer.JetFlavourInfoSource = ''
attrsToDelete += ['slimmedGenJets'+pfix]
## adjust output
for outMod in outputModules:
if hasattr(process,outMod):
Expand All @@ -161,7 +173,15 @@ def toolCode(self, process):
## remove mc extra configs for MET
metProducer = getattr(process, mod)
metProducer.addGenMET = False
attrsToDelete += [metProducer.genMETSource.getModuleLabel()]
metProducer.genMETSource = ''
attrsToDelete += [
'prunedGenParticles',
'prunedGenParticlesWithStatusOne',
'packedGenParticles',
]
for attr in attrsToDelete:
if hasattr(process,attr): delattr(process,attr)

removeMCMatching=RemoveMCMatching()

Expand All @@ -170,4 +190,6 @@ def _removeMCMatchingForPATObject(process, matcherName, producerName, postfix=""
objectProducer = getattr(process, producerName+postfix)
objectProducer.addGenMatch = False
objectProducer.embedGenMatch = False
attr = objectProducer.genParticleMatch.getModuleLabel()
if hasattr(process,attr): delattr(process,attr)
objectProducer.genParticleMatch = ''

0 comments on commit 068e4ef

Please sign in to comment.