1 import FWCore.ParameterSet.Config
as cms
4 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi
import simpleCandidateFlatTableProducer
8 from RecoJets.JetProducers.hfJetShowerShape_cfi
import hfJetShowerShape
17 from PhysicsTools.PatAlgos.tools.jetCollectionTools
import GenJetAdder, RecoJetAdder
23 bTagCSVV2 = [
'pfCombinedInclusiveSecondaryVertexV2BJetTags']
24 bTagDeepCSV = [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc',
'pfDeepCSVJetTags:probudsg']
26 'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
27 'pfDeepFlavourJetTags:probc',
'pfDeepFlavourJetTags:probuds',
'pfDeepFlavourJetTags:probg' 30 bTagDiscriminatorsForAK4 = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
35 btagHbb = [
'pfBoostedDoubleSecondaryVertexAK8BJetTags']
37 'pfDeepDoubleBvLJetTags:probHbb',
38 'pfDeepDoubleCvLJetTags:probHcc',
39 'pfDeepDoubleCvBJetTags:probHcc',
40 'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
41 'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
42 'pfMassIndependentDeepDoubleCvBJetTags:probHcc' 45 'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
46 'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
47 'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc' 62 config_genjets = list(
filter(
lambda k: k[
'enabled'], config_genjets))
69 "doc" :
"AK6 Gen jets (made with visible genparticles) with pt > 3 GeV",
83 "inputCollection" :
"slimmedCaloJets",
84 "genJetsCollection":
"AK4GenJetsNoNu",
89 "inputCollection" :
"",
90 "genJetsCollection":
"AK4GenJetsNoNu",
96 "inputCollection" :
"",
97 "genJetsCollection":
"AK8GenJetsNoNu",
101 config_recojets = list(
filter(
lambda k: k[
'enabled'], config_recojets))
105 nanoInfo_recojets = {
108 "doc" :
"AK4 Calo jets (slimmedCaloJets)",
112 "doc" :
"AK4 PF jets",
117 "doc" :
"AK8 PF jets",
122 GENJETVARS = cms.PSet(P4Vars,
123 nConstituents = jetTable.variables.nConstituents,
125 PFJETVARS = cms.PSet(P4Vars,
126 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
127 area = jetTable.variables.area,
128 chHEF = jetTable.variables.chHEF,
129 neHEF = jetTable.variables.neHEF,
130 chEmEF = jetTable.variables.chEmEF,
131 neEmEF = jetTable.variables.neEmEF,
132 muEF = jetTable.variables.muEF,
133 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc =
"hadronic energy fraction in HF",precision = 6),
134 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc =
"electromagnetic energy fraction in HF",precision = 6),
135 nMuons = jetTable.variables.nMuons,
136 nElectrons = jetTable.variables.nElectrons,
137 nConstituents = jetTable.variables.nConstituents,
138 nConstChHads =
Var(
"chargedHadronMultiplicity()",int,doc=
"number of charged hadrons in the jet"),
139 nConstNeuHads =
Var(
"neutralHadronMultiplicity()",int,doc=
"number of neutral hadrons in the jet"),
140 nConstHFHads =
Var(
"HFHadronMultiplicity()", int,doc=
"number of HF hadrons in the jet"),
141 nConstHFEMs =
Var(
"HFEMMultiplicity()",int,doc=
"number of HF EMs in the jet"),
142 nConstMuons =
Var(
"muonMultiplicity()",int,doc=
"number of muons in the jet"),
143 nConstElecs =
Var(
"electronMultiplicity()",int,doc=
"number of electrons in the jet"),
144 nConstPhotons =
Var(
"photonMultiplicity()",int,doc=
"number of photons in the jet"),
147 puId_dR2Mean =
Var(
"?(pt>=10)?userFloat('puId_dR2Mean'):-1",float,doc=
"pT^2-weighted average square distance of jet constituents from the jet axis (PileUp ID BDT input variable)", precision=14),
148 puId_majW =
Var(
"?(pt>=10)?userFloat('puId_majW'):-1",float,doc=
"major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision=14),
149 puId_minW =
Var(
"?(pt>=10)?userFloat('puId_minW'):-1",float,doc=
"minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision=14),
150 puId_frac01 =
Var(
"?(pt>=10)?userFloat('puId_frac01'):-1",float,doc=
"fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)", precision=14),
151 puId_frac02 =
Var(
"?(pt>=10)?userFloat('puId_frac02'):-1",float,doc=
"fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)", precision=14),
152 puId_frac03 =
Var(
"?(pt>=10)?userFloat('puId_frac03'):-1",float,doc=
"fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)", precision=14),
153 puId_frac04 =
Var(
"?(pt>=10)?userFloat('puId_frac04'):-1",float,doc=
"fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)", precision=14),
154 puId_ptD =
Var(
"?(pt>=10)?userFloat('puId_ptD'):-1",float,doc=
"pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision=14),
155 puId_beta =
Var(
"?(pt>=10)?userFloat('puId_beta'):-1",float,doc=
"fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)", precision=14),
156 puId_pull =
Var(
"?(pt>=10)?userFloat('puId_pull'):-1",float,doc=
"magnitude of pull vector (PileUp ID BDT input variable)", precision=14),
157 puId_jetR =
Var(
"?(pt>=10)?userFloat('puId_jetR'):-1",float,doc=
"fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)", precision=14),
158 puId_jetRchg =
Var(
"?(pt>=10)?userFloat('puId_jetRchg'):-1",float,doc=
"fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)", precision=14),
159 puId_nCharged =
Var(
"?(pt>=10)?userInt('puId_nCharged'):-1",int,doc=
"number of charged constituents (PileUp ID BDT input variable)"),
162 qgl_axis2 =
Var(
"?(pt>=10)?userFloat('qgl_axis2'):-1",float,doc=
"ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision=14),
163 qgl_ptD =
Var(
"?(pt>=10)?userFloat('qgl_ptD'):-1",float,doc=
"pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision=14),
164 qgl_mult =
Var(
"?(pt>=10)?userInt('qgl_mult'):-1", int,doc=
"PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
167 btagDeepB =
Var(
"?(pt>=15)&&((bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0)?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc=
"DeepCSV b+bb tag discriminator",precision=10),
168 btagCSVV2 =
Var(
"?(pt>=15)?bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags'):-1",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
169 btagDeepCvL =
Var(
"?(pt>=15)&&(bDiscriminator('pfDeepCSVJetTags:probc')>=0)?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc=
"DeepCSV c vs udsg discriminator",precision=10),
170 btagDeepCvB =
Var(
"?(pt>=15)&&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),
172 DEEPJETVARS = cms.PSet(
173 btagDeepFlavB =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'):-1",float,doc=
"DeepJet b+bb+lepb tag discriminator",precision=10),
174 btagDeepFlavC =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probc'):-1",float,doc=
"DeepFlavour charm tag raw score",precision=10),
175 btagDeepFlavG =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probg'):-1",float,doc=
"DeepFlavour gluon tag raw score",precision=10),
176 btagDeepFlavUDS =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probuds'):-1",float,doc=
"DeepFlavour uds tag raw score",precision=10),
177 btagDeepFlavCvL =
Var(
"?(pt>=15)&&(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),
178 btagDeepFlavCvB =
Var(
"?(pt>=15)&&(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),
179 btagDeepFlavQG =
Var(
"?(pt>=15)&&(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),
181 PARTICLENETAK4VARS = cms.PSet(
182 particleNetAK4_B =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll'):-1",float,doc=
"ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
183 particleNetAK4_CvsL =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL'):-1",float,doc=
"ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
184 particleNetAK4_CvsB =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB'):-1",float,doc=
"ParticleNetAK4 tagger c vs b discriminator",precision=10),
185 particleNetAK4_QvsG =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG'):-1",float,doc=
"ParticleNetAK4 tagger uds vs g discriminator",precision=10),
186 particleNetAK4_G =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4JetTags:probg'):-1",float,doc=
"ParticleNetAK4 tagger g raw score",precision=10),
187 particleNetAK4_puIdDisc =
Var(
"?(pt>=15)?1-bDiscriminator('pfParticleNetAK4JetTags:probpu'):-1",float,doc=
"ParticleNetAK4 tagger pileup jet discriminator",precision=10),
190 CALOJETVARS = cms.PSet(P4Vars,
191 area = jetTable.variables.area,
192 rawFactor = jetTable.variables.rawFactor,
193 emf =
Var(
"emEnergyFraction()", float, doc =
"electromagnetic energy fraction", precision = 10),
204 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
206 Setup modules to calculate PF jet ID 209 isPUPPIJet =
True if "PUPPI" in jetName.upper()
else False 211 looseJetId =
"looseJetId{}".
format(jetName)
212 setattr(proc, looseJetId, proc.looseJetId.clone(
214 filterParams = proc.looseJetId.filterParams.clone(
220 tightJetId =
"tightJetId{}".
format(jetName)
221 setattr(proc, tightJetId, proc.tightJetId.clone(
223 filterParams = proc.tightJetId.filterParams.clone(
224 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
229 tightJetIdLepVeto =
"tightJetIdLepVeto{}".
format(jetName)
230 setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
232 filterParams = proc.tightJetIdLepVeto.filterParams.clone(
233 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
238 run2_jme_2016.toModify(
239 getattr(proc, tightJetId).filterParams, version =
"RUN2UL16{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
241 getattr(proc, tightJetIdLepVeto).filterParams, version =
"RUN2UL16{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
247 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
248 getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
249 getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
254 getattr(proc, jetTableName).variables.jetId =
Var(
"userInt('tightId')*2+4*userInt('tightIdLepVeto')",int,doc=
"Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto")
256 getattr(proc,jetTaskName).
add(getattr(proc, tightJetId))
257 getattr(proc,jetTaskName).
add(getattr(proc, tightJetIdLepVeto))
263 Setup modules to calculate pileup jet ID input variables for PF jet 269 puJetIdVarsCalculator =
"puJetIdCalculator{}".
format(jetName)
270 setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
272 vertexes =
"offlineSlimmedPrimaryVertices",
273 inputIsCorrected =
True,
275 usePuppi =
True if "PUPPI" in jetName.upper()
else False,
276 srcConstituentWeights =
"packedPFCandidatespuppi" if "PUPPI" in jetName.upper()
else "",
280 getattr(proc,jetTaskName).
add(getattr(proc, puJetIdVarsCalculator))
285 puJetIDVar =
"puJetIDVar{}".
format(jetName)
286 setattr(proc, puJetIDVar, cms.EDProducer(
"PileupJetIDVarProducer",
287 srcJet = cms.InputTag(jetSrc),
288 srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
291 getattr(proc,jetTaskName).
add(getattr(proc, puJetIDVar))
296 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
297 getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag(
"{}:dR2Mean".
format(puJetIDVar))
298 getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag(
"{}:majW".
format(puJetIDVar))
299 getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag(
"{}:minW".
format(puJetIDVar))
300 getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag(
"{}:frac01".
format(puJetIDVar))
301 getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag(
"{}:frac02".
format(puJetIDVar))
302 getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag(
"{}:frac03".
format(puJetIDVar))
303 getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag(
"{}:frac04".
format(puJetIDVar))
304 getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag(
"{}:ptD".
format(puJetIDVar))
305 getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag(
"{}:beta".
format(puJetIDVar))
306 getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag(
"{}:pull".
format(puJetIDVar))
307 getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag(
"{}:jetR".
format(puJetIDVar))
308 getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag(
"{}:jetRchg".
format(puJetIDVar))
309 getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag(
"{}:nCharged".
format(puJetIDVar))
314 getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
315 getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
316 getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
317 getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
318 getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
319 getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
320 getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
321 getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
322 getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
323 getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
324 getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
325 getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
326 getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
330 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
332 Schedule the QGTagger module to calculate input variables to the QG likelihood 335 isPUPPIJet =
True if "PUPPI" in jetName.upper()
else False 337 QGLTagger=
"qgtagger{}".
format(jetName)
338 patJetWithUserData=
"{}WithUserData".
format(jetSrc)
341 setattr(proc, QGLTagger, qgtagger.clone(
343 computeLikelihood =
False,
347 getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag(
"packedPFCandidatespuppi")
352 getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+
":axis2")
353 getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+
":ptD")
354 getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+
":mult")
359 getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
360 getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
361 getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
364 getattr(proc,jetTaskName).
add(getattr(proc, QGLTagger))
370 Store b-tagging scores from various algortihm 373 getattr(proc, jetTableName).variables.btagDeepB = BTAGVARS.btagDeepB
374 getattr(proc, jetTableName).variables.btagCSVV2 = BTAGVARS.btagCSVV2
375 getattr(proc, jetTableName).variables.btagDeepCvL = BTAGVARS.btagDeepCvL
376 getattr(proc, jetTableName).variables.btagDeepCvB = BTAGVARS.btagDeepCvB
377 getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
378 getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
379 getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
385 Store DeepJet raw score in jetTable for gluon and light quark 388 getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
389 getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
390 getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
396 Store ParticleNetAK4 scores in jetTable 399 getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
400 getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
401 getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
402 getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
403 getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
404 getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
410 Add patJet into custom nanoAOD 413 jetName = recoJetInfo.jetUpper
414 payload = recoJetInfo.jetCorrPayload
415 doPF = recoJetInfo.doPF
416 doCalo = recoJetInfo.doCalo
417 patJetFinalColl = recoJetInfo.patJetFinalCollection
419 nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
420 jetTablePrefix = nanoInfoForJet[
"name"]
421 jetTableDoc = nanoInfoForJet[
"doc"]
422 ptcut = nanoInfoForJet[
"ptcut"]
if "ptcut" in nanoInfoForJet
else 8
423 doPUIDVar = nanoInfoForJet[
"doPUIDVar"]
if "doPUIDVar" in nanoInfoForJet
else False 424 doQGL = nanoInfoForJet[
"doQGL"]
if "doQGL" in nanoInfoForJet
else False 425 doBTag = nanoInfoForJet[
"doBTag"]
if "doBTag" in nanoInfoForJet
else False 428 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
429 ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
434 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
435 doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
437 Schedule modules for a given patJet collection and save its variables into custom NanoAOD 443 jetCorrFactors =
"jetCorrFactorsNano{}".
format(jetName)
444 setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
445 src = patJetFinalColl,
453 srcJets =
"updatedJets{}".
format(jetName)
454 setattr(proc, srcJets, updatedJets.clone(
455 jetSource = patJetFinalColl,
456 jetCorrFactorsSource = [jetCorrFactors],
463 srcJetsWithUserData =
"updatedJets{}WithUserData".
format(jetName)
464 setattr(proc, srcJetsWithUserData, cms.EDProducer(
"PATJetUserDataEmbedder",
465 src = cms.InputTag(srcJets),
466 userFloats = cms.PSet(),
467 userInts = cms.PSet(),
474 finalJetsCut =
"(pt >= {ptcut:.0f})".
format(ptcut=ptcut)
476 finalJetsCut =
"(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".
format(ptcut=ptcut)
478 finalJetsForTable =
"finalJets{}".
format(jetName)
479 setattr(proc, finalJetsForTable, finalJets.clone(
480 src = srcJetsWithUserData,
488 tableContent = PFJETVARS
490 tableContent = CALOJETVARS
492 jetTableCutDefault =
"" 494 jetTableDocDefault = jetTableDoc +
" with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".
format(ptcut=ptcut)
496 jetTableDocDefault +=
"For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".
format(ptcut=ptcut)
499 jetTableDocDefault = jetTableDoc
501 jetTableName =
"jet{}Table".
format(jetName)
502 setattr(proc,jetTableName, simpleCandidateFlatTableProducer.clone(
503 src = cms.InputTag(finalJetsForTable),
504 cut = cms.string(jetTableCutDefault),
505 name = cms.string(jetTablePrefix),
506 doc = cms.string(jetTableDocDefault),
507 variables = cms.PSet(tableContent)
510 getattr(proc,jetTableName).variables.pt.precision=10
511 getattr(proc,jetTableName).variables.rawFactor.precision=10
516 jetMCTableName =
"jet{}MCTable".
format(jetName)
517 setattr(proc, jetMCTableName, simpleCandidateFlatTableProducer.clone(
518 src = cms.InputTag(finalJetsForTable),
519 cut = getattr(proc,jetTableName).cut,
520 name = cms.string(jetTablePrefix),
521 extension = cms.bool(
True),
522 variables = cms.PSet(
523 partonFlavour =
Var(
"partonFlavour()", int, doc=
"flavour from parton matching"),
524 hadronFlavour =
Var(
"hadronFlavour()", int, doc=
"flavour from hadron ghost clustering"),
525 genJetIdx =
Var(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc=
"index of matched gen jet"),
533 jetTaskName =
"jet{}Task".
format(jetName)
534 setattr(proc, jetTaskName, cms.Task(
535 getattr(proc,jetCorrFactors),
536 getattr(proc,srcJets),
537 getattr(proc,srcJetsWithUserData),
538 getattr(proc,finalJetsForTable)
541 proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
546 jetTableTaskName =
"jet{}TablesTask".
format(jetName)
547 setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
548 proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
550 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
551 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
553 proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
559 proc =
AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
561 proc =
AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
563 proc =
AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=
True)
579 Recluster AK4 Puppi jets and replace slimmedJetsPuppi 580 that is used as default to save AK4 Puppi jets in NanoAODs. 582 print(
"custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
588 "jet" :
"ak4pfpuppi",
589 "inputCollection" :
"",
590 "genJetsCollection":
"AK4GenJetsNoNu",
591 "bTagDiscriminators": bTagDiscriminatorsForAK4,
594 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
596 jetName = recoJetInfo.jetUpper
597 patJetFinalColl = recoJetInfo.patJetFinalCollection
602 run2_jme_2016.toModify(
603 proc.tightJetPuppiId.filterParams, version =
"RUN2UL16PUPPI" 605 proc.tightJetIdLepVeto.filterParams, version =
"RUN2UL16PUPPI" 612 proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
613 proc.updatedJetsPuppi.jetSource=patJetFinalColl
618 finalJetsPuppiCut =
"" 620 finalJetsPuppiCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 622 finalJetsPuppiCut =
"(pt >= 8)" 624 proc.finalJetsPuppi.cut = finalJetsPuppiCut
628 proc.corrT1METJetPuppiTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 634 run2_nanoAOD_ANY.toModify(
635 proc.jetTable, name =
"Jet" 640 src = cms.InputTag(
"finalJetsPuppi")
646 jetPuppiTableDoc =
"AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored." 648 jetPuppiTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 649 proc.jetPuppiTable.doc = jetPuppiTableDoc
651 proc.jetPuppiTable.variables.rawFactor.precision = 10
656 proc.jetPuppiTable.variables.hfHEF = PFJETVARS.hfHEF
657 proc.jetPuppiTable.variables.hfEmEF = PFJETVARS.hfEmEF
658 proc.jetPuppiTable.variables.nConstChHads = PFJETVARS.nConstChHads
659 proc.jetPuppiTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
660 proc.jetPuppiTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
661 proc.jetPuppiTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
662 proc.jetPuppiTable.variables.nConstMuons = PFJETVARS.nConstMuons
663 proc.jetPuppiTable.variables.nConstElecs = PFJETVARS.nConstElecs
664 proc.jetPuppiTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
672 jetSrc =
"updatedJetsPuppi",
673 jetTableName =
"jetPuppiTable",
674 jetTaskName =
"jetPuppiTask" 682 jetSrc =
"updatedJetsPuppi",
683 jetTableName =
"jetPuppiTable",
684 jetTaskName =
"jetPuppiTask",
685 calculateQGLVars=
True 690 proc.jetPuppiTable.variables.btagDeepB = BTAGVARS.btagDeepB
691 proc.jetPuppiTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
692 proc.jetPuppiTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
693 proc.jetPuppiTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
697 proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
698 proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
699 proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
703 proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
704 proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
705 proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
709 proc.jetPuppiTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
710 proc.jetPuppiTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
711 proc.jetPuppiTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
712 proc.jetPuppiTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
713 proc.jetPuppiTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
714 proc.jetPuppiTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
719 run2_nanoAOD_ANY.toReplaceWith(
720 proc.jetPuppiForMETTask,
721 proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
729 jetMCTableName =
"jet{}MCTable".
format(jetName)
730 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
731 src = proc.jetPuppiTable.src,
732 name = proc.jetPuppiTable.name
735 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
736 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
738 run2_nanoAOD_ANY.toReplaceWith(
739 proc.nanoTableTaskFS,
740 proc.nanoTableTaskFS.copyAndAdd( getattr(proc,jetMCTableTaskName))
747 Recluster AK4 CHS jets and replace slimmedJets that is used as default to 748 save AK4 CHS jets in NanoAODs (for Run-2). 750 print(
"custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
757 "inputCollection" :
"",
758 "genJetsCollection":
"AK4GenJetsNoNu",
759 "bTagDiscriminators": bTagDiscriminatorsForAK4,
762 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
764 jetName = recoJetInfo.jetUpper
765 patJetFinalColl = recoJetInfo.patJetFinalCollection
771 proc.jetCorrFactorsNano.src=patJetFinalColl
772 proc.updatedJets.jetSource=patJetFinalColl
779 finalJetsCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 781 finalJetsCut =
"(pt >= 8)" 783 proc.finalJets.cut = finalJetsCut
787 proc.corrT1METJetTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 793 proc.jetTable.src = cms.InputTag(
"finalJets")
794 proc.jetTable.cut = jetTableCut
795 proc.jetMCTable.cut = jetTableCut
796 proc.jetTable.name =
"JetCHS" 801 run2_nanoAOD_ANY.toModify(
803 src = cms.InputTag(
"linkedObjects",
"jets"),
810 jetTableDoc =
"AK4 PF CHS jets with JECs applied. Jets with pt >= 8 GeV are stored." 812 jetTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 813 proc.jetTable.doc = jetTableDoc
815 proc.jetTable.variables.rawFactor.precision = 10
820 proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
821 proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
822 proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
823 proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
824 proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
825 proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
826 proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
827 proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
828 proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
833 proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag(
"jercVars:chargedFromPV1EnergyFraction")
834 proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag(
"jercVars:chargedFromPV2EnergyFraction")
835 proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag(
"jercVars:chargedFromPV3EnergyFraction")
836 proc.jetTable.variables.chFPV1EF =
Var(
"userFloat('chFPV1EF')", float, doc=
"charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
837 proc.jetTable.variables.chFPV2EF =
Var(
"userFloat('chFPV2EF')", float, doc=
"charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
838 proc.jetTable.variables.chFPV3EF =
Var(
"userFloat('chFPV3EF')", float, doc=
"charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
845 jetSrc =
"updatedJets",
846 jetTableName =
"jetTable",
847 jetTaskName =
"jetTask" 853 proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag(
"qgtagger:axis2")
854 proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag(
"qgtagger:ptD")
855 proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag(
"qgtagger:mult")
859 proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
860 proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
861 proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
865 proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
866 proc.jetTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
867 proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
868 proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
872 proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
873 proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
874 proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
878 proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
879 proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
880 proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
884 proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
885 proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
886 proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
887 proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
888 proc.jetTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
889 proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
893 hfJetShowerShapeforCustomNanoAOD =
"hfJetShowerShapeforCustomNanoAOD" 894 setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShape.clone(jets=
"updatedJets", vertices=
"offlineSlimmedPrimaryVertices") )
895 proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
896 proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
897 proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
898 proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
899 proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
900 proc.jetTable.variables.hfsigmaEtaEta =
Var(
"userFloat('hfsigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
901 proc.jetTable.variables.hfsigmaPhiPhi =
Var(
"userFloat('hfsigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
902 proc.jetTable.variables.hfcentralEtaStripSize =
Var(
"userInt('hfcentralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) ")
903 proc.jetTable.variables.hfadjacentEtaStripsSize =
Var(
"userInt('hfadjacentEtaStripsSize')", int, doc=
"eta size of the strips next to the central tower strip in HF (noise discriminating variable) ")
909 (~run2_nanoAOD_ANY).toReplaceWith(
910 proc.jetUserDataTask,
911 proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
914 proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
915 ).toModify(proc.updatedJetsWithUserData.userFloats,
917 leptonPtRelv0 =
None,
918 leptonPtRelInvv0 =
None,
926 proc.updatedJetsWithUserData.userInts,
930 proc.jetTable, externalVariables = cms.PSet()
936 proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
943 jetMCTableName =
"jet{}MCTable".
format(jetName)
944 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
945 src = proc.jetTable.src,
946 name = proc.jetTable.name
949 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
950 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
952 (~run2_nanoAOD_ANY).toReplaceWith(
953 proc.nanoTableTaskFS,
954 proc.nanoTableTaskFS.copyAndAdd(getattr(proc,jetMCTableTaskName))
961 Store a separate AK8 Puppi jet collection for JEC studies. 962 Only minimal info are stored 964 print(
"custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
970 "jet" :
"ak8pfpuppi",
971 "inputCollection" :
"",
972 "genJetsCollection":
"AK8GenJetsNoNu",
975 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
977 jetName = recoJetInfo.jetUpper
978 payload = recoJetInfo.jetCorrPayload
980 patJetFinalColl = recoJetInfo.patJetFinalCollection
981 jetTablePrefix =
"FatJetForJEC" 982 jetTableDoc =
"AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 986 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
987 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
994 Store an AK8 CHS jet collection for JEC studies. 996 print(
"custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1003 "inputCollection" :
"",
1004 "genJetsCollection":
"AK8GenJetsNoNu",
1005 "minPtFastjet" : 0.,
1007 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1009 jetName = recoJetInfo.jetUpper
1010 payload = recoJetInfo.jetCorrPayload
1012 patJetFinalColl = recoJetInfo.patJetFinalCollection
1013 jetTablePrefix =
"FatJetCHS" 1014 jetTableDoc =
"AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 1018 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
1019 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
1026 Add more variables for AK8 PFPUPPI jets 1029 proc.fatJetTable.variables.rawFactor.precision = 10
1035 proc.fatJetTable.variables.chHEF =
Var(
"?isPFJet()?chargedHadronEnergyFraction():-1", float, doc=
"charged Hadron Energy Fraction", precision = 6)
1036 proc.fatJetTable.variables.neHEF =
Var(
"?isPFJet()?neutralHadronEnergyFraction():-1", float, doc=
"neutral Hadron Energy Fraction", precision = 6)
1037 proc.fatJetTable.variables.chEmEF =
Var(
"?isPFJet()?chargedEmEnergyFraction():-1", float, doc=
"charged Electromagnetic Energy Fraction", precision = 6)
1038 proc.fatJetTable.variables.neEmEF =
Var(
"?isPFJet()?neutralEmEnergyFraction():-1", float, doc=
"neutral Electromagnetic Energy Fraction", precision = 6)
1039 proc.fatJetTable.variables.muEF =
Var(
"?isPFJet()?muonEnergyFraction():-1", float, doc=
"muon Energy Fraction", precision = 6)
1040 proc.fatJetTable.variables.hfHEF =
Var(
"?isPFJet()?HFHadronEnergyFraction():-1", float, doc=
"energy fraction in forward hadronic calorimeter", precision = 6)
1041 proc.fatJetTable.variables.hfEmEF =
Var(
"?isPFJet()?HFEMEnergyFraction():-1", float, doc=
"energy fraction in forward EM calorimeter", precision = 6)
1042 proc.fatJetTable.variables.nConstChHads =
Var(
"?isPFJet()?chargedHadronMultiplicity():-1",int, doc=
"number of charged hadrons in the jet")
1043 proc.fatJetTable.variables.nConstNeuHads =
Var(
"?isPFJet()?neutralHadronMultiplicity():-1",int, doc=
"number of neutral hadrons in the jet")
1044 proc.fatJetTable.variables.nConstHFHads =
Var(
"?isPFJet()?HFHadronMultiplicity():-1", int, doc=
"number of HF Hadrons in the jet")
1045 proc.fatJetTable.variables.nConstHFEMs =
Var(
"?isPFJet()?HFEMMultiplicity():-1", int, doc=
"number of HF EMs in the jet")
1046 proc.fatJetTable.variables.nConstMuons =
Var(
"?isPFJet()?muonMultiplicity():-1", int, doc=
"number of muons in the jet")
1047 proc.fatJetTable.variables.nConstElecs =
Var(
"?isPFJet()?electronMultiplicity():-1", int, doc=
"number of electrons in the jet")
1048 proc.fatJetTable.variables.nConstPhotons =
Var(
"?isPFJet()?photonMultiplicity():-1", int, doc=
"number of photons in the jet")
1060 Add genJet into custom nanoAOD 1063 genJetName = genJetInfo.jetUpper
1064 genJetAlgo = genJetInfo.jetAlgo
1065 genJetSize = genJetInfo.jetSize
1066 genJetSizeNr = genJetInfo.jetSizeNr
1067 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1068 genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet][
"name"]
1069 genJetTableDoc = nanoInfo_genjets[genJetInfo.jet][
"doc"]
1071 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1075 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1077 Schedule modules for a given genJet collection and save its variables into custom NanoAOD 1080 genJetTableName =
"jet{}Table".
format(genJetName)
1081 setattr(proc, genJetTableName, genJetTable.clone(
1082 src = genJetFinalColl,
1084 name = genJetTablePrefix,
1085 doc = genJetTableDoc,
1086 variables = GENJETVARS
1090 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1091 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1092 jets = getattr(proc,genJetTableName).src,
1093 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1094 rParam = genJetSizeNr,
1098 genJetFlavourTableName =
"genJet{}FlavourTable".
format(genJetName)
1099 setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1100 name = getattr(proc,genJetTableName).name,
1101 src = getattr(proc,genJetTableName).src,
1102 cut = getattr(proc,genJetTableName).cut,
1103 jetFlavourInfos = genJetFlavourAssociationName,
1107 genJetTaskName =
"genJet{}Task".
format(genJetName)
1108 setattr(proc, genJetTaskName, cms.Task(
1109 getattr(proc,genJetTableName),
1110 getattr(proc,genJetFlavourAssociationName),
1111 getattr(proc,genJetFlavourTableName)
1114 proc.jetMCTask.add(getattr(proc,genJetTaskName))
1120 Recluster AK4 Gen jets and replace 1121 slimmedGenJets that is used as default 1122 to save AK4 Gen jets in NanoAODs. 1124 print(
"custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1132 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1134 genJetName = genJetInfo.jetUpper
1135 genJetAlgo = genJetInfo.jetAlgo
1136 genJetSize = genJetInfo.jetSize
1137 genJetSizeNr = genJetInfo.jetSizeNr
1138 selectedGenJets =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1144 proc.genJetTable.src = selectedGenJets
1145 proc.genJetTable.cut =
"" 1146 proc.genJetTable.doc =
"AK4 Gen jets (made with visible genparticles) with pt > 3 GeV" 1148 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1149 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1150 jets = proc.genJetTable.src,
1151 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1152 rParam = genJetSizeNr,
1155 proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1160 Make a separate AK8 Gen jet collection for JEC studies. 1162 print(
"custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1170 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1172 genJetName = genJetInfo.jetUpper
1173 genJetAlgo = genJetInfo.jetAlgo
1174 genJetSize = genJetInfo.jetSize
1175 genJetSizeNr = genJetInfo.jetSizeNr
1176 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1177 genJetTablePrefix =
"GenJetAK8ForJEC" 1178 genJetTableDoc =
"AK8 Gen jets (made with visible genparticles) with pt > 3 GeV. Reclustered for JEC studies." 1180 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1185 proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1189 proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1199 Remove default pt cuts for all jets set in jets_cff.py 1202 proc.finalJets.cut =
"" 1203 proc.finalJetsPuppi.cut =
"" 1204 proc.finalJetsAK8.cut =
"" 1205 proc.genJetTable.cut =
"" 1206 proc.genJetFlavourTable.cut =
"" 1207 proc.genJetAK8Table.cut =
"" 1208 proc.genJetAK8FlavourTable.cut =
"" 1229 genJA = GenJetAdder()
1247 for jetConfig
in config_genjets:
1248 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1249 genJetInfo = genJA.addGenJetCollection(process, **cfg)
1257 recoJA = RecoJetAdder(runOnMC=runOnMC)
1281 for jetConfig
in config_recojets:
1282 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1283 recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1291 def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1292 if addAK4CHSJetTasks:
1293 proc.nanoTableTaskCommon.add(proc.jetTask)
1294 proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1295 proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1296 if addAK4PuppiJetTasks:
1297 proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1298 proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1299 proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1302 jmeNano_addAK4JetTasks_switch = cms.PSet(
1303 jmeNano_addAK4CHS_switch = cms.untracked.bool(
True),
1304 jmeNano_addAK4Puppi_switch = cms.untracked.bool(
False)
1306 run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1307 jmeNano_addAK4CHS_switch =
False,
1308 jmeNano_addAK4Puppi_switch =
True 1310 process = addAK4JetTasks(process,
1311 addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1312 addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1319 process.puTable.savePtHatMax =
True 1325 process.genWeightsTable.keepAllPSWeights =
True def AddBTaggingScores(proc, jetTableName="")
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def RemoveAllJetPtCuts(proc)
def Var(expr, valtype, doc=None, precision=-1)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def ReclusterAK4GenJets(proc, genJA)
def AddNewAK8CHSJets(proc, recoJA, runOnMC)
def AddNewAK8GenJetsForJEC(proc, genJA)
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
def ReclusterAK4PuppiJets(proc, recoJA, runOnMC)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
def AddNewAK8PuppiJetsForJEC(proc, recoJA, runOnMC)
def AddNewGenJets(proc, genJetInfo)
def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False)
def AddVariablesForAK4GenJets(proc)
def AddVariablesForAK8PuppiJets(proc)
def AddParticleNetAK4Scores(proc, jetTableName="")
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def AddVariablesForAK8GenJets(proc)
def PrepJMECustomNanoAOD_MC(process)
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="")
def PrepJMECustomNanoAOD_Data(process)