Skip to content

Commit

Permalink
Merge pull request #45176 from nurfikri89/backport141XTo140X_base1408…
Browse files Browse the repository at this point in the history
…_puppiUpdateWrapper

[JMENano] Backport of #45167 (Add customize functions to recompute Puppi weights and PuppiMET, add new autoNano option) to 14_0_X
  • Loading branch information
cmsbuild authored Jun 24, 2024
2 parents e551de3 + 51f446b commit 5bd0684
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Configuration/PyReleaseValidation/python/relval_nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,16 @@ def subnext(self):
'-n' : '1000'},
steps['NANO_data13.0']])

steps['jmeNano_data13.0'] = merge([{'-s':'NANO:@JME', '-n' : '1000'},
steps['jmeNANO_data13.0'] = merge([{'-s':'NANO:@JME', '-n' : '1000'},
steps['NANO_data13.0']])

steps['lepTrackInfoNANO_data13.0']=merge([{'-s' : 'NANO:@LepTrackInfo,DQM:@nanoAODDQM',
'-n' : '1000'},
steps['NANO_data13.0']])

steps['jmeNANO_rePuppi_data13.0']= merge([{'-s':'NANO:@JMErePuppi', '-n' : '1000'},
steps['NANO_data13.0']])

###current release cycle workflows : 13.2
steps['TTBarMINIAOD13.2'] = {'INPUT':InputInfo(location='STD',
dataSet='/RelValTTbar_14TeV/CMSSW_13_2_0-PU_131X_mcRun3_2023_realistic_v9-v1/MINIAODSIM')}
Expand All @@ -211,6 +214,10 @@ def subnext(self):
'-n' : '1000'},
steps['NANO_mc13.2']])

steps['jmeNANO_rePuppi_mc13.2']=merge([{'-s' : 'NANO:@JMErePuppi ', '-n' : '1000'},
steps['NANO_mc13.2']])


##13.X INPUT
steps['ScoutingPFRun32022DRAW13.X']={'INPUT':InputInfo(dataSet='/ScoutingPFRun3/Run2022D-v1/RAW',label='2022D',events=100000,location='STD', ls=Run2022D)}

Expand Down Expand Up @@ -263,9 +270,10 @@ def subnext(self):
workflows[_wfn()] = ['muDPGNANOBkg130Xrun3', ['ZeroBias2023DRAW13.0', 'muDPGNANOBkg_data13.0']]
workflows[_wfn()] = ['muPOGNANO130Xrun3', ['MuonEG2023MINIAOD13.0', 'muPOGNANO_data13.0']]
workflows[_wfn()] = ['EGMNANOdata130Xrun3', ['MuonEG2023MINIAOD13.0', 'EGMNano_data13.0']]
workflows[_wfn()] = ['jmeNANOdata130Xrun3', ['MuonEG2023MINIAOD13.0', 'jmeNano_data13.0']]
workflows[_wfn()] = ['jmeNANOdata130Xrun3', ['MuonEG2023MINIAOD13.0', 'jmeNANO_data13.0']]
workflows[_wfn()] = ['lepTrackInfoNANOdata130Xrun3', ['MuonEG2023MINIAOD13.0', 'lepTrackInfoNANO_data13.0']]
workflows[_wfn()] = ['BTVNANO_data130Xrun3', ['MuonEG2023MINIAOD13.0', 'BTVNANO_data13.0']]
workflows[_wfn()] = ['jmeNANOrePuppidata130Xrun3', ['MuonEG2023MINIAOD13.0', 'jmeNANO_rePuppi_data13.0']]

_wfn.next()
################
Expand All @@ -276,6 +284,7 @@ def subnext(self):
workflows[_wfn()] = ['jmeNANOmc132X', ['TTBarMINIAOD13.2', 'jmeNANO_mc13.2']]
workflows[_wfn()] = ['lepTrackInfoNANOmc132X', ['TTBarMINIAOD13.2', 'lepTrackInfoNANO_mc13.2']]
workflows[_wfn()] = ['BTVNANO_mc132X', ['TTBarMINIAOD13.2', 'BTVNANO_mc13.2']]
workflows[_wfn()] = ['jmeNANOrePuppimc132X', ['TTBarMINIAOD13.2', 'jmeNANO_rePuppi_mc13.2']]

_wfn.next()
################
Expand Down
2 changes: 2 additions & 0 deletions PhysicsTools/NanoAOD/python/autoNANO.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def expandNanoMapping(seqList, mapping, key):
# JME custom NANO
'JME' : { 'sequence': '@PHYS',
'customize': '@PHYS+PhysicsTools/NanoAOD/custom_jme_cff.PrepJMECustomNanoAOD'},
'JMErePuppi' : { 'sequence': '@PHYS',
'customize': '@PHYS+@JME+PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET'},
# Muon POG flavours : add tables through customize, supposed to be combined with PHYS
'MUPOG' : { 'sequence': '@PHYS',
'customize' : '@PHYS+PhysicsTools/NanoAOD/custom_muon_cff.PrepMuonCustomNanoAOD'},
Expand Down
34 changes: 34 additions & 0 deletions PhysicsTools/NanoAOD/python/custom_jme_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,40 @@ def RemoveAllJetPtCuts(proc):

return proc

def RecomputePuppiWeights(proc):
"""
Setup packedpuppi and packedpuppiNoLep to recompute puppi weights
"""
if hasattr(proc,"packedpuppi"):
proc.packedpuppi.useExistingWeights = False
if hasattr(proc,"packedpuppiNoLep"):
proc.packedpuppiNoLep.useExistingWeights = False
return proc

def RecomputePuppiMET(proc):
"""
Recompute PuppiMET. This is useful when puppi weights are recomputed.
"""
runOnMC=True
if hasattr(proc,"NANOEDMAODoutput") or hasattr(proc,"NANOAODoutput"):
runOnMC = False

from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
runMetCorAndUncFromMiniAOD(proc, isData=not(runOnMC),
jetCollUnskimmed='updatedJetsPuppi',metType='Puppi',postfix='Puppi',jetFlavor='AK4PFPuppi',
puppiProducerLabel='packedpuppi',puppiProducerForMETLabel='packedpuppiNoLep',
recoMetFromPFCs=True
)
return proc

def RecomputePuppiWeightsAndMET(proc):
"""
Recompute Puppi weights PuppiMET.
"""
proc = RecomputePuppiWeights(proc)
proc = RecomputePuppiMET(proc)
return proc

#===========================================================================
#
# CUSTOMIZATION function
Expand Down

0 comments on commit 5bd0684

Please sign in to comment.