diff --git a/Configuration/PyReleaseValidation/python/relval_nano.py b/Configuration/PyReleaseValidation/python/relval_nano.py index 957a6782c54fe..db10045d16474 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([{'-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')} @@ -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)} @@ -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() ################ @@ -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() ################ 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'}, diff --git a/PhysicsTools/NanoAOD/python/custom_jme_cff.py b/PhysicsTools/NanoAOD/python/custom_jme_cff.py index 765b58a848a1a..971cfec108038 100644 --- a/PhysicsTools/NanoAOD/python/custom_jme_cff.py +++ b/PhysicsTools/NanoAOD/python/custom_jme_cff.py @@ -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