Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JMENano] Backport of #45167 (Add customize functions to recompute Puppi weights and PuppiMET, add new autoNano option) to 14_0_X #45176

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