Skip to content

Commit

Permalink
fix met tool
Browse files Browse the repository at this point in the history
  • Loading branch information
gouskos committed Feb 26, 2018
1 parent c73014f commit 0498bd6
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -310,6 +310,7 @@ def toolCode(self, process):
self.extractMET(process, "raw", patMetModuleSequence, postfix)

#jet AK4 reclustering if needed for JECs

if reclusterJets:
jetCollectionUnskimmed = self.ak4JetReclustering(process, pfCandCollection,
patMetModuleSequence, postfix)
Expand All @@ -318,7 +319,7 @@ def toolCode(self, process):
if onMiniAOD:
if not reclusterJets and reapplyJEC:
jetCollectionUnskimmed = self.updateJECs(process, jetCollectionUnskimmed, patMetModuleSequence, postfix)


#getting the jet collection that will be used for corrections
#and uncertainty computation
Expand All @@ -328,13 +329,13 @@ def toolCode(self, process):
autoJetCleaning,
patMetModuleSequence,
postfix)

#pre-preparation to run over miniAOD
if onMiniAOD:
self.miniAODConfigurationPre(process, patMetModuleSequence, pfCandCollection, postfix)

#default MET production
self.produceMET(process, metType,patMetModuleSequence, postfix)
self.produceMET(process, metType,patMetModuleSequence, jetCollectionUnskimmed, postfix)



Expand Down Expand Up @@ -439,7 +440,7 @@ def toolCode(self, process):
process.patDefaultSequence += getattr(process, "fullPatMetSequence"+postfix)

#====================================================================================================
def produceMET(self, process, metType, metModuleSequence, postfix):
def produceMET(self, process, metType, metModuleSequence, jetCollectionUnskimmed, postfix):

task = getPatAlgosToolsTask(process)

Expand All @@ -452,6 +453,10 @@ def produceMET(self, process, metType, metModuleSequence, postfix):
if postfix != "" and metType == "PF" and not hasattr(process, 'pat'+metType+'Met'+postfix):
noClonesTmp = [ "particleFlowDisplacedVertex", "pfCandidateToVertexAssociation" ]
configtools.cloneProcessingSnippet(process, getattr(process,"producePatPFMETCorrections"), postfix, noClones = noClonesTmp, addToTask = True)
#MM FIXME, this could be done in a mch better way, this is not
#handled by the above cloning sequence
getattr(process,"selectedPatJetsForMetT1T2Corr").src=jetCollectionUnskimmed #cms.InputTag("patJets"+postfix)
getattr(process,"selectedPatJetsForMetT2Corr").src=jetCollectionUnskimmed #cms.InputTag("patJets"+postfix)
addToProcessAndTask('pat'+metType+'Met'+postfix, getattr(process,'patPFMet' ).clone(), process, task)
getattr(process, "patPFMet"+postfix).metSource = cms.InputTag("pfMet"+postfix)
getattr(process, "patPFMet"+postfix).srcPFCands = self._parameters["pfCandCollection"].value
Expand Down Expand Up @@ -1443,8 +1448,9 @@ def ak4JetReclustering(self,process, pfCandCollection, patMetModuleSequence, pos
pfCHS=None
if self._parameters["onMiniAOD"].value:
pfCHS = cms.EDFilter("CandPtrSelector", src = pfCandCollection, cut = cms.string("fromPV"))
setattr(process,"pfNoPileUpJME"+postfix,pfCHS)
pfCandColl = cms.InputTag("pfNoPileUpJME"+postfix)
addToProcessAndTask("pfNoPileUpJME"+postfix, pfCHS, process, task)
patMetModuleSequence += getattr(process, "pfNoPileUpJME"+postfix)
else:
addToProcessAndTask("tmpPFCandCollPtr"+postfix,
cms.EDProducer("PFCandidateFwdPtrProducer",
Expand All @@ -1459,6 +1465,8 @@ def ak4JetReclustering(self,process, pfCandCollection, patMetModuleSequence, pos
bottomCollection = cms.InputTag("tmpPFCandCollPtr"+postfix) ),
process, task )
pfCandColl = cms.InputTag("pfNoPileUpJME"+postfix)
patMetModuleSequence += getattr(process, "tmpPFCandCollPtr"+postfix)
patMetModuleSequence += getattr(process, "pfNoPileUpJME"+postfix)

jetColName+=postfix
if not hasattr(process, jetColName):
Expand Down Expand Up @@ -1513,10 +1521,11 @@ def miniAODConfigurationPre(self, process, patMetModuleSequence, pfCandCollectio

#extractor for caloMET === temporary for the beginning of the data taking
self.extractMET(process,"rawCalo",patMetModuleSequence,postfix)
caloMetName="metrawCalo" if hasattr(process,"metrawCalo") else "metrawCalo"+postfix
from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
addMETCollection(process,
labelName = "patCaloMet",
metSource = "metrawCalo"
metSource = caloMetName
)
getattr(process,"patCaloMet").addGenMET = False

Expand Down

0 comments on commit 0498bd6

Please sign in to comment.