From 236b6bea3c2c11438c3b863c674783fdfd919360 Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Sat, 8 Jun 2024 11:34:21 +0200 Subject: [PATCH 1/7] Add wrapper functions to setup the recomputation of puppi weights and PuppiMET. The functions can be used through cmsDriver customise commands. --- PhysicsTools/NanoAOD/python/custom_jme_cff.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/custom_jme_cff.py b/PhysicsTools/NanoAOD/python/custom_jme_cff.py index 765b58a848a1a..03c79eac54d81 100644 --- a/PhysicsTools/NanoAOD/python/custom_jme_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_jme_cff.py @@ -1263,6 +1263,33 @@ 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=runOnMC, + jetCollUnskimmed='updatedJetsPuppi',metType='Puppi',postfix='Puppi',jetFlavor='AK4PFPuppi', + puppiProducerLabel='packedpuppi',puppiProducerForMETLabel='packedpuppiNoLep', + recoMetFromPFCs=True + ) + return proc + + #=========================================================================== # # CUSTOMIZATION function From 003040a1332f3f5d91eefd8123a6fc92f4537131 Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Sat, 8 Jun 2024 11:34:55 +0200 Subject: [PATCH 2/7] Add customization function to setup recomputation of Puppi and PuppiMET --- PhysicsTools/NanoAOD/python/custom_jme_cff.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/custom_jme_cff.py b/PhysicsTools/NanoAOD/python/custom_jme_cff.py index 03c79eac54d81..81c51ab3f1535 100644 --- a/PhysicsTools/NanoAOD/python/custom_jme_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_jme_cff.py @@ -1289,6 +1289,13 @@ def RecomputePuppiMET(proc): ) return proc +def RecomputePuppiWeightsAndMET(proc): + """ + Recompute Puppi weights PuppiMET. + """ + proc = RecomputePuppiWeights(proc) + proc = RecomputePuppiMET(proc) + return proc #=========================================================================== # From 9e12af8021f461a0dbc763c77a492c669d2b2dab Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Sat, 8 Jun 2024 11:35:52 +0200 Subject: [PATCH 3/7] Add JMErePuppi autoNano option. Runs JMENano and recompute Puppi weights and Puppi MET. --- PhysicsTools/NanoAOD/python/autoNANO.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PhysicsTools/NanoAOD/python/autoNANO.py b/PhysicsTools/NanoAOD/python/autoNANO.py index 006f58c80f46a..0fa4c0f6a71de 100644 --- a/PhysicsTools/NanoAOD/python/autoNANO.py +++ b/PhysicsTools/NanoAOD/python/autoNANO.py @@ -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'}, From 13feb195e02230ff54686600013ebaafbc693035 Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Sat, 8 Jun 2024 11:36:27 +0200 Subject: [PATCH 4/7] Fix isData argument for runMetCorAndUncFromMiniAOD function --- PhysicsTools/NanoAOD/python/custom_jme_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhysicsTools/NanoAOD/python/custom_jme_cff.py b/PhysicsTools/NanoAOD/python/custom_jme_cff.py index 81c51ab3f1535..971cfec108038 100644 --- a/PhysicsTools/NanoAOD/python/custom_jme_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_jme_cff.py @@ -1282,7 +1282,7 @@ def RecomputePuppiMET(proc): runOnMC = False from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD - runMetCorAndUncFromMiniAOD(proc, isData=runOnMC, + runMetCorAndUncFromMiniAOD(proc, isData=not(runOnMC), jetCollUnskimmed='updatedJetsPuppi',metType='Puppi',postfix='Puppi',jetFlavor='AK4PFPuppi', puppiProducerLabel='packedpuppi',puppiProducerForMETLabel='packedpuppiNoLep', recoMetFromPFCs=True From bc280163d13f09b500a2ade2599b07baa1232ddf Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Sat, 8 Jun 2024 11:38:52 +0200 Subject: [PATCH 5/7] Fix name to be consistent. Add new workflows which produces JMENano with Puppi and PuppiMET recomputed. --- .../PyReleaseValidation/python/relval_nano.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_nano.py b/Configuration/PyReleaseValidation/python/relval_nano.py index 957a6782c54fe..65d93a630001c 100644 --- a/Configuration/PyReleaseValidation/python/relval_nano.py +++ b/Configuration/PyReleaseValidation/python/relval_nano.py @@ -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([steps['jmeNANO_data13.0']]) +steps['jmeNANO_rePuppi_data13.0']['--customise'] += ',"PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET"' + ###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')} @@ -211,6 +214,9 @@ def subnext(self): '-n' : '1000'}, steps['NANO_mc13.2']]) +steps['jmeNANO_rePuppi_mc13.2']=merge([steps['jmeNANO_mc13.2']]) +steps['jmeNANO_rePuppi_mc13.2']['--customise'] += ',"PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET"' + ##13.X INPUT steps['ScoutingPFRun32022DRAW13.X']={'INPUT':InputInfo(dataSet='/ScoutingPFRun3/Run2022D-v1/RAW',label='2022D',events=100000,location='STD', ls=Run2022D)} @@ -263,9 +269,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() ################ @@ -276,6 +283,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() ################ From bd11cb5d921dc22cea3b680344217e644d140816 Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Fri, 14 Jun 2024 10:51:28 +0200 Subject: [PATCH 6/7] Use JMErePuppi --- Configuration/PyReleaseValidation/python/relval_nano.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Configuration/PyReleaseValidation/python/relval_nano.py b/Configuration/PyReleaseValidation/python/relval_nano.py index 65d93a630001c..b44b5227242b1 100644 --- a/Configuration/PyReleaseValidation/python/relval_nano.py +++ b/Configuration/PyReleaseValidation/python/relval_nano.py @@ -186,8 +186,8 @@ def subnext(self): '-n' : '1000'}, steps['NANO_data13.0']]) -steps['jmeNANO_rePuppi_data13.0']=merge([steps['jmeNANO_data13.0']]) -steps['jmeNANO_rePuppi_data13.0']['--customise'] += ',"PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET"' +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', @@ -214,8 +214,9 @@ def subnext(self): '-n' : '1000'}, steps['NANO_mc13.2']]) -steps['jmeNANO_rePuppi_mc13.2']=merge([steps['jmeNANO_mc13.2']]) -steps['jmeNANO_rePuppi_mc13.2']['--customise'] += ',"PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET"' +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)} From 51f446ba88e4486bfddf43c9e8143cb3e58e8e8e Mon Sep 17 00:00:00 2001 From: Nurfikri Norjoharuddeen Date: Mon, 17 Jun 2024 10:14:13 +0200 Subject: [PATCH 7/7] Fix typo --- Configuration/PyReleaseValidation/python/relval_nano.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/PyReleaseValidation/python/relval_nano.py b/Configuration/PyReleaseValidation/python/relval_nano.py index b44b5227242b1..db10045d16474 100644 --- a/Configuration/PyReleaseValidation/python/relval_nano.py +++ b/Configuration/PyReleaseValidation/python/relval_nano.py @@ -214,7 +214,7 @@ def subnext(self): '-n' : '1000'}, steps['NANO_mc13.2']]) -steps['jmeNANO_rePuppi_mc13.2']merge([{'-s' : 'NANO:@JMErePuppi ', '-n' : '1000'}, +steps['jmeNANO_rePuppi_mc13.2']=merge([{'-s' : 'NANO:@JMErePuppi ', '-n' : '1000'}, steps['NANO_mc13.2']])