Skip to content

Commit

Permalink
Merge pull request #28844 from ahinzmann/customizationPuppiV13_111X
Browse files Browse the repository at this point in the history
Add customizer for PUPPI tune v13
  • Loading branch information
cmsbuild authored Feb 24, 2020
2 parents 7ab5197 + 6975b12 commit 02b300b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
40 changes: 40 additions & 0 deletions CommonTools/PileupAlgos/python/customizePuppiTune_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import FWCore.ParameterSet.Config as cms

def UpdatePuppiTuneV13(process):
#
# Adapt for re-running PUPPI
#
print("customizePuppiTune_cff::UpdatePuppiTuneV13: Recomputing PUPPI with Tune v13, slimmedJetsPuppi and slimmedMETsPuppi")
from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask
task = getPatAlgosToolsTask(process)
from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD
makePuppiesFromMiniAOD(process,True)
process.puppi.useExistingWeights = False
process.puppiNoLep.useExistingWeights = False
from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
runMetCorAndUncFromMiniAOD(process,isData=False,metType="Puppi",postfix="Puppi",jetFlavor="AK4PFPuppi",recoMetFromPFCs=True,pfCandColl=cms.InputTag("puppiForMET"))
from PhysicsTools.PatAlgos.patPuppiJetSpecificProducer_cfi import patPuppiJetSpecificProducer
addToProcessAndTask('patPuppiJetSpecificProducer', patPuppiJetSpecificProducer.clone(src=cms.InputTag("patJetsPuppi")), process, task)
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
updateJetCollection(
process,
labelName = 'PuppiJetSpecific',
jetSource = cms.InputTag('patJetsPuppi'),
)
process.updatedPatJetsPuppiJetSpecific.userData.userFloats.src = ['patPuppiJetSpecificProducer:puppiMultiplicity', 'patPuppiJetSpecificProducer:neutralPuppiMultiplicity', 'patPuppiJetSpecificProducer:neutralHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:photonPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFHadronPuppiMultiplicity', 'patPuppiJetSpecificProducer:HFEMPuppiMultiplicity' ]
addToProcessAndTask('slimmedJetsPuppi', process.updatedPatJetsPuppiJetSpecific.clone(), process, task)
del process.updatedPatJetsPuppiJetSpecific
process.puppiSequence = cms.Sequence(process.puppiMETSequence+process.fullPatMetSequencePuppi+process.patPuppiJetSpecificProducer+process.slimmedJetsPuppi)
#
# Adapt for PUPPI tune V13
#
process.puppi.UseFromPVLooseTight = False
process.puppi.UseDeltaZCut = False
process.puppi.PtMaxCharged = 20.
process.puppi.EtaMaxCharged = 2.5
process.puppi.PtMaxNeutralsStartSlope = 20.
process.puppiNoLep.UseFromPVLooseTight = False
process.puppiNoLep.UseDeltaZCut = False
process.puppiNoLep.PtMaxCharged = 20.
process.puppiNoLep.EtaMaxCharged = 2.5
process.puppiNoLep.PtMaxNeutralsStartSlope = 20.
8 changes: 6 additions & 2 deletions PhysicsTools/NanoAOD/python/custom_jme_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ def addTable(self, proc, recoJetInfo):
area = jetTable.variables.area,
rawFactor = jetTable.variables.rawFactor,
)
elif "puppi" in recoJetInfo.jet:
tableContents = JETVARS.clone(
puppiMultiplicity = Var("userFloat('patPuppiJetSpecificProducer:puppiMultiplicity')",float,doc="Sum of PUPPI weights of particles in the jet", precision= 6),
neutralPuppiMultiplicity = Var("userFloat('patPuppiJetSpecificProducer:neutralPuppiMultiplicity')",float,doc="Sum of PUPPI weights of neutral particles in the jet", precision= 6)
)
else:
tableContents = JETVARS.clone()

Expand Down Expand Up @@ -392,7 +397,7 @@ def AddPileUpJetIDVars(proc):
proc.jetTable.variables.pull = Var("userFloat('pull')", float, doc="magnitude of pull vector", precision= 6)
proc.jetTable.variables.jetR = Var("userFloat('jetR')", float, doc="fraction of jet pT carried by the leading constituent", precision= 6)
proc.jetTable.variables.jetRchg = Var("userFloat('jetRchg')", float, doc="fraction of jet pT carried by the leading charged constituent", precision= 6)
proc.jetTable.variables.nCharged = Var("userInt('nCharged')", float, doc="number of charged constituents", precision= 6)
proc.jetTable.variables.nCharged = Var("userInt('nCharged')", int, doc="number of charged constituents")

def PrepJMECustomNanoAOD(process):
#
Expand Down Expand Up @@ -481,4 +486,3 @@ def PrepJMECustomNanoAOD(process):

process.nanoSequenceMC += recoJA.getSequence(process)
process.nanoSequenceMC += tableRecoJA.getSequence(process)

0 comments on commit 02b300b

Please sign in to comment.