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
[NanoAOD] Setup AK4 Puppi jets as default AK4 collection for Run 3 #37744
Merged
cmsbuild
merged 4 commits into
cms-sw:master
from
nurfikri89:from1240pre3_nano_jetsrun3_forPR
Jun 3, 2022
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c9e6314
Rename file jets_cf as prep for Run3 updates
nurfikri89 9927904
Setup AK4 Puppi for Nano Run3. Split reco jet configurations into 3 c…
nurfikri89 e230b0e
Add muonSubtrFactor variable for AK4 Puppi table
nurfikri89 f3d6e21
Move run2_nanoAOD_ANY grouped modifier to nano_eras_cff.py
nurfikri89 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from PhysicsTools.NanoAOD.nano_eras_cff import * | ||
from PhysicsTools.NanoAOD.common_cff import * | ||
|
||
##################### User floats producers, selectors ########################## | ||
|
||
from PhysicsTools.PatAlgos.recoLayer0.jetCorrFactors_cfi import * | ||
# Note: Safe to always add 'L2L3Residual' as MC contains dummy L2L3Residual corrections (always set to 1) | ||
# (cf. https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CMSSW_7_6_4_and_above ) | ||
jetPuppiCorrFactorsNano = patJetCorrFactors.clone(src='slimmedJetsPuppi', | ||
levels = cms.vstring('L1FastJet', | ||
'L2Relative', | ||
'L3Absolute', | ||
'L2L3Residual'), | ||
payload = cms.string('AK4PFPuppi'), | ||
primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"), | ||
) | ||
|
||
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cfi import * | ||
|
||
updatedJetsPuppi = updatedPatJets.clone( | ||
addBTagInfo=False, | ||
jetSource='slimmedJetsPuppi', | ||
jetCorrFactorsSource=cms.VInputTag(cms.InputTag("jetPuppiCorrFactorsNano") ), | ||
) | ||
|
||
tightJetPuppiId = cms.EDProducer("PatJetIDValueMapProducer", | ||
filterParams=cms.PSet( | ||
version = cms.string('RUN2ULPUPPI'), | ||
quality = cms.string('TIGHT'), | ||
), | ||
src = cms.InputTag("updatedJetsPuppi") | ||
) | ||
tightJetPuppiIdLepVeto = cms.EDProducer("PatJetIDValueMapProducer", | ||
filterParams=cms.PSet( | ||
version = cms.string('RUN2ULPUPPI'), | ||
quality = cms.string('TIGHTLEPVETO'), | ||
), | ||
src = cms.InputTag("updatedJetsPuppi") | ||
) | ||
|
||
#HF shower shape recomputation | ||
from RecoJets.JetProducers.hfJetShowerShape_cfi import hfJetShowerShape | ||
hfJetPuppiShowerShapeforNanoAOD = hfJetShowerShape.clone(jets="updatedJetsPuppi",vertices="offlineSlimmedPrimaryVertices") | ||
|
||
updatedJetsPuppiWithUserData = cms.EDProducer("PATJetUserDataEmbedder", | ||
src = cms.InputTag("updatedJetsPuppi"), | ||
userFloats = cms.PSet( | ||
hfsigmaEtaEta = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaEtaEta'), | ||
hfsigmaPhiPhi = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:sigmaPhiPhi'), | ||
), | ||
userInts = cms.PSet( | ||
tightId = cms.InputTag("tightJetPuppiId"), | ||
tightIdLepVeto = cms.InputTag("tightJetPuppiIdLepVeto"), | ||
hfcentralEtaStripSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:centralEtaStripSize'), | ||
hfadjacentEtaStripsSize = cms.InputTag('hfJetPuppiShowerShapeforNanoAOD:adjacentEtaStripsSize'), | ||
), | ||
) | ||
|
||
finalJetsPuppi = cms.EDFilter("PATJetRefSelector", | ||
src = cms.InputTag("updatedJetsPuppiWithUserData"), | ||
cut = cms.string("pt > 15") | ||
) | ||
|
||
##################### Tables for final output and docs ########################## | ||
jetPuppiTable = cms.EDProducer("SimpleCandidateFlatTableProducer", | ||
src = cms.InputTag("linkedObjects","jets"), | ||
cut = cms.string(""), #we should not filter on cross linked collections | ||
name = cms.string("Jet"), | ||
doc = cms.string("slimmedJetsPuppi, i.e. ak4 PFJets Puppi with JECs applied, after basic selection (" + finalJetsPuppi.cut.value()+")"), | ||
singleton = cms.bool(False), # the number of entries is variable | ||
extension = cms.bool(False), # this is the main table for the jets | ||
externalVariables = cms.PSet(), | ||
variables = cms.PSet(P4Vars, | ||
area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10), | ||
nMuons = Var("?hasOverlaps('muons')?overlaps('muons').size():0", int, doc="number of muons in the jet"), | ||
muonIdx1 = Var("?overlaps('muons').size()>0?overlaps('muons')[0].key():-1", int, doc="index of first matching muon"), | ||
muonIdx2 = Var("?overlaps('muons').size()>1?overlaps('muons')[1].key():-1", int, doc="index of second matching muon"), | ||
electronIdx1 = Var("?overlaps('electrons').size()>0?overlaps('electrons')[0].key():-1", int, doc="index of first matching electron"), | ||
electronIdx2 = Var("?overlaps('electrons').size()>1?overlaps('electrons')[1].key():-1", int, doc="index of second matching electron"), | ||
nElectrons = Var("?hasOverlaps('electrons')?overlaps('electrons').size():0", int, doc="number of electrons in the jet"), | ||
btagDeepB = Var("?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc="DeepCSV b+bb tag discriminator",precision=10), | ||
btagDeepFlavB = Var("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')",float,doc="DeepJet b+bb+lepb tag discriminator",precision=10), | ||
btagCSVV2 = Var("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10), | ||
btagDeepCvL = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc="DeepCSV c vs udsg discriminator",precision=10), | ||
btagDeepCvB = Var("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc="DeepCSV c vs b+bb discriminator",precision=10), | ||
btagDeepFlavCvL = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1",float,doc="DeepJet c vs uds+g discriminator",precision=10), | ||
btagDeepFlavCvB = Var("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1",float,doc="DeepJet c vs b+bb+lepb discriminator",precision=10), | ||
btagDeepFlavQG = Var("?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1",float,doc="DeepJet g vs uds discriminator",precision=10), | ||
jetId = Var("userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc="Jet ID flag: bit2 is tight, bit3 is tightLepVeto"), | ||
hfsigmaEtaEta = Var("userFloat('hfsigmaEtaEta')",float,doc="sigmaEtaEta for HF jets (noise discriminating variable)",precision=10), | ||
hfsigmaPhiPhi = Var("userFloat('hfsigmaPhiPhi')",float,doc="sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10), | ||
hfcentralEtaStripSize = Var("userInt('hfcentralEtaStripSize')", int, doc="eta size of the central tower strip in HF (noise discriminating variable)"), | ||
hfadjacentEtaStripsSize = Var("userInt('hfadjacentEtaStripsSize')", int, doc="eta size of the strips next to the central tower strip in HF (noise discriminating variable)"), | ||
nConstituents = Var("numberOfDaughters()","uint8",doc="Number of particles in the jet"), | ||
rawFactor = Var("1.-jecFactor('Uncorrected')",float,doc="1 - Factor to get back to raw pT",precision=6), | ||
chHEF = Var("chargedHadronEnergyFraction()", float, doc="charged Hadron Energy Fraction", precision= 6), | ||
neHEF = Var("neutralHadronEnergyFraction()", float, doc="neutral Hadron Energy Fraction", precision= 6), | ||
chEmEF = Var("chargedEmEnergyFraction()", float, doc="charged Electromagnetic Energy Fraction", precision= 6), | ||
neEmEF = Var("neutralEmEnergyFraction()", float, doc="neutral Electromagnetic Energy Fraction", precision= 6), | ||
muEF = Var("muonEnergyFraction()", float, doc="muon Energy Fraction", precision= 6), | ||
) | ||
) | ||
|
||
#jets are not as precise as muons | ||
jetPuppiTable.variables.pt.precision=10 | ||
|
||
################################################################################ | ||
# JETS FOR MET type1 | ||
################################################################################ | ||
basicJetsPuppiForMetForT1METNano = cms.EDProducer("PATJetCleanerForType1MET", | ||
src = updatedJetsPuppiWithUserData.src, | ||
jetCorrEtaMax = cms.double(9.9), | ||
jetCorrLabel = cms.InputTag("L3Absolute"), | ||
jetCorrLabelRes = cms.InputTag("L2L3Residual"), | ||
offsetCorrLabel = cms.InputTag("L1FastJet"), | ||
skipEM = cms.bool(False), | ||
skipEMfractionThreshold = cms.double(0.9), | ||
skipMuonSelection = cms.string('isGlobalMuon | isStandAloneMuon'), | ||
skipMuons = cms.bool(True), | ||
type1JetPtThreshold = cms.double(0.0), | ||
calcMuonSubtrRawPtAsValueMap = cms.bool(True) | ||
) | ||
|
||
updatedJetsPuppiWithUserData.userFloats.muonSubtrRawPt = cms.InputTag("basicJetsPuppiForMetForT1METNano:MuonSubtrRawPt") | ||
|
||
corrT1METJetPuppiTable = cms.EDProducer("SimpleCandidateFlatTableProducer", | ||
src = finalJetsPuppi.src, | ||
cut = cms.string("pt<15 && abs(eta)<9.9"), | ||
name = cms.string("CorrT1METJet"), | ||
doc = cms.string("Additional low-pt ak4 Puppi jets for Type-1 MET re-correction"), | ||
singleton = cms.bool(False), # the number of entries is variable | ||
extension = cms.bool(False), # this is the main table for the jets | ||
variables = cms.PSet( | ||
rawPt = Var("pt()*jecFactor('Uncorrected')",float,precision=10), | ||
eta = Var("eta", float,precision=12), | ||
phi = Var("phi", float, precision=12), | ||
area = Var("jetArea()", float, doc="jet catchment area, for JECs",precision=10), | ||
) | ||
) | ||
|
||
corrT1METJetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6) | ||
jetPuppiTable.variables.muonSubtrFactor = Var("1-userFloat('muonSubtrRawPt')/(pt()*jecFactor('Uncorrected'))",float,doc="1-(muon-subtracted raw pt)/(raw pt)",precision=6) | ||
|
||
nurfikri89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
jetPuppiForMETTask = cms.Task(basicJetsPuppiForMetForT1METNano,corrT1METJetPuppiTable) | ||
|
||
#before cross linking | ||
jetPuppiUserDataTask = cms.Task(tightJetPuppiId, tightJetPuppiIdLepVeto, hfJetPuppiShowerShapeforNanoAOD) | ||
|
||
#before cross linking | ||
jetPuppiTask = cms.Task(jetPuppiCorrFactorsNano,updatedJetsPuppi,jetPuppiUserDataTask,updatedJetsPuppiWithUserData,finalJetsPuppi) | ||
|
||
#after cross linkining | ||
jetPuppiTablesTask = cms.Task(jetPuppiTable) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should define this in the PhysicsTools.NanoAOD.nano_eras_cff so that get imported w/o being redefined multiple times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move
run2_nanoAOD_ANY
in the next commit shortly.