1 import FWCore.ParameterSet.Config
as cms
15 from PhysicsTools.PatAlgos.tools.jetCollectionTools
import GenJetAdder, RecoJetAdder
21 bTagCSVV2 = [
'pfCombinedInclusiveSecondaryVertexV2BJetTags']
22 bTagDeepCSV = [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
24 'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
25 'pfDeepFlavourJetTags:probc',
'pfDeepFlavourJetTags:probuds',
'pfDeepFlavourJetTags:probg' 28 bTagDiscriminatorsForAK4 = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
33 btagHbb = [
'pfBoostedDoubleSecondaryVertexAK8BJetTags']
35 'pfDeepDoubleBvLJetTags:probHbb',
36 'pfDeepDoubleCvLJetTags:probHcc',
37 'pfDeepDoubleCvBJetTags:probHcc',
38 'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
39 'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
40 'pfMassIndependentDeepDoubleCvBJetTags:probHcc' 43 'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
44 'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
45 'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc' 60 config_genjets = list(
filter(
lambda k: k[
'enabled'], config_genjets))
67 "doc" :
"AK6 Gen jets (made with visible genparticles) with pt > 3 GeV",
81 "inputCollection" :
"slimmedCaloJets",
82 "genJetsCollection":
"AK4GenJetsNoNu",
87 "inputCollection" :
"",
88 "genJetsCollection":
"AK4GenJetsNoNu",
94 "inputCollection" :
"",
95 "genJetsCollection":
"AK8GenJetsNoNu",
99 config_recojets = list(
filter(
lambda k: k[
'enabled'], config_recojets))
103 nanoInfo_recojets = {
106 "doc" :
"AK4 Calo jets with JECs applied",
110 "doc" :
"AK4 PF jets",
115 "doc" :
"AK8 PF jets",
120 GENJETVARS = cms.PSet(P4Vars,
121 nConstituents = jetTable.variables.nConstituents,
123 PFJETVARS = cms.PSet(P4Vars,
124 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
125 area = jetTable.variables.area,
126 chHEF = jetTable.variables.chHEF,
127 neHEF = jetTable.variables.neHEF,
128 chEmEF = jetTable.variables.chEmEF,
129 neEmEF = jetTable.variables.neEmEF,
130 muEF = jetTable.variables.muEF,
131 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc =
"hadronic energy fraction in HF",precision = 6),
132 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc =
"electromagnetic energy fraction in HF",precision = 6),
133 nMuons = jetTable.variables.nMuons,
134 nElectrons = jetTable.variables.nElectrons,
135 nConstituents = jetTable.variables.nConstituents,
136 nConstChHads =
Var(
"chargedHadronMultiplicity()",int,doc=
"number of charged hadrons in the jet"),
137 nConstNeuHads =
Var(
"neutralHadronMultiplicity()",int,doc=
"number of neutral hadrons in the jet"),
138 nConstHFHads =
Var(
"HFHadronMultiplicity()", int,doc=
"number of HF hadrons in the jet"),
139 nConstHFEMs =
Var(
"HFEMMultiplicity()",int,doc=
"number of HF EMs in the jet"),
140 nConstMuons =
Var(
"muonMultiplicity()",int,doc=
"number of muons in the jet"),
141 nConstElecs =
Var(
"electronMultiplicity()",int,doc=
"number of electrons in the jet"),
142 nConstPhotons =
Var(
"photonMultiplicity()",int,doc=
"number of photons in the jet"),
145 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=6),
146 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=6),
147 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=6),
148 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=6),
149 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=6),
150 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=6),
151 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=6),
152 puId_ptD =
Var(
"?(pt>=10)?userFloat('puId_ptD'):-1",float,doc=
"pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision=6),
153 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=6),
154 puId_pull =
Var(
"?(pt>=10)?userFloat('puId_pull'):-1",float,doc=
"magnitude of pull vector (PileUp ID BDT input variable)", precision=6),
155 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=6),
156 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=6),
157 puId_nCharged =
Var(
"?(pt>=10)?userInt('puId_nCharged'):-1",int,doc=
"number of charged constituents (PileUp ID BDT input variable)"),
160 qgl_axis2 =
Var(
"?(pt>=10)?userFloat('qgl_axis2'):-1",float,doc=
"ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision=10),
161 qgl_ptD =
Var(
"?(pt>=10)?userFloat('qgl_ptD'):-1",float,doc=
"pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision=10),
162 qgl_mult =
Var(
"?(pt>=10)?userInt('qgl_mult'):-1", int,doc=
"PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
165 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),
166 btagCSVV2 =
Var(
"?(pt>=15)?bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags'):-1",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
167 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),
168 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),
170 DEEPJETVARS = cms.PSet(
171 btagDeepFlavB =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'):-1",float,doc=
"DeepJet b+bb+lepb tag discriminator",precision=10),
172 btagDeepFlavC =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probc'):-1",float,doc=
"DeepFlavour charm tag raw score",precision=10),
173 btagDeepFlavG =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probg'):-1",float,doc=
"DeepFlavour gluon tag raw score",precision=10),
174 btagDeepFlavUDS =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probuds'):-1",float,doc=
"DeepFlavour uds tag raw score",precision=10),
175 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),
176 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),
177 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),
179 PARTICLENETAK4VARS = cms.PSet(
180 particleNetAK4_B =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll'):-1",float,doc=
"ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
181 particleNetAK4_CvsL =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL'):-1",float,doc=
"ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
182 particleNetAK4_CvsB =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB'):-1",float,doc=
"ParticleNetAK4 tagger c vs b discriminator",precision=10),
183 particleNetAK4_QvsG =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG'):-1",float,doc=
"ParticleNetAK4 tagger uds vs g discriminator",precision=10),
184 particleNetAK4_puIdDisc =
Var(
"?(pt>=15)?1-bDiscriminator('pfParticleNetAK4JetTags:probpu'):-1",float,doc=
"ParticleNetAK4 tagger pileup jet discriminator",precision=10),
187 CALOJETVARS = cms.PSet(P4Vars,
188 area = jetTable.variables.area,
189 rawFactor = jetTable.variables.rawFactor,
190 emf =
Var(
"emEnergyFraction()", float, doc =
"electromagnetic energy fraction", precision = 10),
201 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
203 Setup modules to calculate PF jet ID 206 isPUPPIJet =
True if "Puppi" in jetName
else False 208 looseJetId =
"looseJetId{}".
format(jetName)
209 setattr(proc, looseJetId, proc.looseJetId.clone(
211 filterParams = proc.looseJetId.filterParams.clone(
217 tightJetId =
"tightJetId{}".
format(jetName)
218 setattr(proc, tightJetId, proc.tightJetId.clone(
220 filterParams = proc.tightJetId.filterParams.clone(
221 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
226 tightJetIdLepVeto =
"tightJetIdLepVeto{}".
format(jetName)
227 setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
229 filterParams = proc.tightJetIdLepVeto.filterParams.clone(
230 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
235 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
236 modifier.toModify(getattr(proc, tightJetId).filterParams, version =
"WINTER16" )
237 modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version =
"WINTER16" )
238 for modifier
in run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2:
239 modifier.toModify(getattr(proc, tightJetId).filterParams, version =
"WINTER17{}".
format(
"PUPPI" if isPUPPIJet
else ""))
240 modifier.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version =
"WINTER17{}".
format(
"PUPPI" if isPUPPIJet
else ""))
241 run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetId).filterParams, version =
"SUMMER18{}".
format(
"PUPPI" if isPUPPIJet
else "") )
242 run2_nanoAOD_102Xv1.toModify(getattr(proc, tightJetIdLepVeto).filterParams, version =
"SUMMER18{}".
format(
"PUPPI" if isPUPPIJet
else "") )
247 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
248 getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
249 getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
250 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
251 modifier.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))
256 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")
257 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
258 modifier.toModify(getattr(proc, jetTableName).variables, jetId =
Var(
"userInt('tightIdLepVeto')*4+userInt('tightId')*2+userInt('looseId')",int, doc=
"Jet ID flags bit1 is loose, bit2 is tight, bit3 is tightLepVeto"))
261 getattr(proc,jetTaskName).
add(getattr(proc, tightJetId))
262 getattr(proc,jetTaskName).
add(getattr(proc, tightJetIdLepVeto))
264 setattr(proc,
"_"+jetTaskName+
"_2016", getattr(proc,jetTaskName).
copy())
265 getattr(proc,
"_"+jetTaskName+
"_2016").
add(getattr(proc, looseJetId))
266 for modifier
in run2_miniAOD_80XLegacy, run2_nanoAOD_94X2016:
267 modifier.toReplaceWith(getattr(proc,jetTaskName), getattr(proc,
"_"+jetTaskName+
"_2016"))
273 Setup modules to calculate pileup jet ID input variables for PF jet 279 puJetIdVarsCalculator =
"puJetIdCalculator{}".
format(jetName)
280 setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
282 vertexes =
"offlineSlimmedPrimaryVertices",
283 inputIsCorrected =
True,
285 usePuppi =
True if "Puppi" in jetName
else False 288 getattr(proc,jetTaskName).
add(getattr(proc, puJetIdVarsCalculator))
293 puJetIDVar =
"puJetIDVar{}".
format(jetName)
294 setattr(proc, puJetIDVar, cms.EDProducer(
"PileupJetIDVarProducer",
295 srcJet = cms.InputTag(jetSrc),
296 srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
299 getattr(proc,jetTaskName).
add(getattr(proc, puJetIDVar))
304 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
305 getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag(
"{}:dR2Mean".
format(puJetIDVar))
306 getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag(
"{}:majW".
format(puJetIDVar))
307 getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag(
"{}:minW".
format(puJetIDVar))
308 getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag(
"{}:frac01".
format(puJetIDVar))
309 getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag(
"{}:frac02".
format(puJetIDVar))
310 getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag(
"{}:frac03".
format(puJetIDVar))
311 getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag(
"{}:frac04".
format(puJetIDVar))
312 getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag(
"{}:ptD".
format(puJetIDVar))
313 getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag(
"{}:beta".
format(puJetIDVar))
314 getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag(
"{}:pull".
format(puJetIDVar))
315 getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag(
"{}:jetR".
format(puJetIDVar))
316 getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag(
"{}:jetRchg".
format(puJetIDVar))
317 getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag(
"{}:nCharged".
format(puJetIDVar))
322 getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
323 getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
324 getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
325 getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
326 getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
327 getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
328 getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
329 getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
330 getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
331 getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
332 getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
333 getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
334 getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
338 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
340 Schedule the QGTagger module to calculate input variables to the QG likelihood 343 QGLTagger=
"qgtagger{}".
format(jetName)
344 patJetWithUserData=
"{}WithUserData".
format(jetSrc)
347 setattr(proc, QGLTagger, qgtagger.clone(
355 getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+
":axis2")
356 getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+
":ptD")
357 getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+
":mult")
362 getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
363 getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
364 getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
367 getattr(proc,jetTaskName).
add(getattr(proc, QGLTagger))
373 Store b-tagging scores from various algortihm 376 getattr(proc, jetTableName).variables.btagDeepB = BTAGVARS.btagDeepB
377 getattr(proc, jetTableName).variables.btagCSVV2 = BTAGVARS.btagCSVV2
378 getattr(proc, jetTableName).variables.btagDeepCvL = BTAGVARS.btagDeepCvL
379 getattr(proc, jetTableName).variables.btagDeepCvB = BTAGVARS.btagDeepCvB
380 getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
381 getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
382 getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
388 Store DeepJet raw score in jetTable for gluon and light quark 391 getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
392 getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
393 getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
399 Store ParticleNetAK4 scores in jetTable 402 getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
403 getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
404 getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
405 getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
406 getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
412 Add patJet into custom nanoAOD 415 jetName = recoJetInfo.jetUpper
416 payload = recoJetInfo.jetCorrPayload
417 doPF = recoJetInfo.doPF
418 doCalo = recoJetInfo.doCalo
419 patJetFinalColl = recoJetInfo.patJetFinalCollection
421 nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
422 jetTablePrefix = nanoInfoForJet[
"name"]
423 jetTableDoc = nanoInfoForJet[
"doc"]
424 ptcut = nanoInfoForJet[
"ptcut"]
if "ptcut" in nanoInfoForJet
else 8
425 doPUIDVar = nanoInfoForJet[
"doPUIDVar"]
if "doPUIDVar" in nanoInfoForJet
else False 426 doQGL = nanoInfoForJet[
"doQGL"]
if "doQGL" in nanoInfoForJet
else False 427 doBTag = nanoInfoForJet[
"doBTag"]
if "doBTag" in nanoInfoForJet
else False 430 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
431 ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
436 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
437 doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
439 Schedule modules for a given patJet collection and save its variables into custom NanoAOD 445 jetCorrFactors =
"jetCorrFactorsNano{}".
format(jetName)
446 setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
447 src = patJetFinalColl,
455 srcJets =
"updatedJets{}".
format(jetName)
456 setattr(proc, srcJets, updatedJets.clone(
457 jetSource = patJetFinalColl,
458 jetCorrFactorsSource = [jetCorrFactors],
465 srcJetsWithUserData =
"updatedJets{}WithUserData".
format(jetName)
466 setattr(proc, srcJetsWithUserData, cms.EDProducer(
"PATJetUserDataEmbedder",
467 src = cms.InputTag(srcJets),
468 userFloats = cms.PSet(),
469 userInts = cms.PSet(),
476 finalJetsCut =
"(pt >= {ptcut:.0f})".
format(ptcut=ptcut)
478 finalJetsCut =
"(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".
format(ptcut=ptcut)
480 finalJetsForTable =
"finalJets{}".
format(jetName)
481 setattr(proc, finalJetsForTable, finalJets.clone(
482 src = srcJetsWithUserData,
490 tableContent = PFJETVARS
492 tableContent = CALOJETVARS
494 jetTableCutDefault =
"" 496 jetTableDocDefault = jetTableDoc +
" with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".
format(ptcut=ptcut)
498 jetTableDocDefault +=
"For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".
format(ptcut=ptcut)
500 jetTableName =
"jet{}Table".
format(jetName)
501 setattr(proc,jetTableName, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
502 src = cms.InputTag(finalJetsForTable),
503 cut = cms.string(jetTableCutDefault),
504 name = cms.string(jetTablePrefix),
505 doc = cms.string(jetTableDocDefault),
506 singleton = cms.bool(
False),
507 extension = cms.bool(
False),
508 variables = cms.PSet(tableContent)
511 getattr(proc,jetTableName).variables.pt.precision=10
512 getattr(proc,jetTableName).variables.rawFactor.precision=10
517 jetMCTableName =
"jet{}MCTable".
format(jetName)
518 setattr(proc, jetMCTableName, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
519 src = cms.InputTag(finalJetsForTable),
520 cut = getattr(proc,jetTableName).cut,
521 name = cms.string(jetTablePrefix),
522 singleton = cms.bool(
False),
523 extension = cms.bool(
True),
524 variables = cms.PSet(
525 partonFlavour =
Var(
"partonFlavour()", int, doc=
"flavour from parton matching"),
526 hadronFlavour =
Var(
"hadronFlavour()", int, doc=
"flavour from hadron ghost clustering"),
527 genJetIdx =
Var(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc=
"index of matched gen jet"),
535 jetTaskName =
"jet{}Task".
format(jetName)
536 setattr(proc, jetTaskName, cms.Task(
537 getattr(proc,jetCorrFactors),
538 getattr(proc,srcJets),
539 getattr(proc,srcJetsWithUserData),
540 getattr(proc,finalJetsForTable)
543 proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
548 jetTableTaskName =
"jet{}TablesTask".
format(jetName)
549 setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
550 proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
552 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
553 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
555 proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
561 proc =
AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
563 proc =
AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
565 proc =
AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=
True)
581 Recluster AK4 Puppi jets and replace slimmedJetsPuppi 582 that is used as default to save AK4 Puppi jets in NanoAODs. 584 print(
"custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
590 "jet" :
"ak4pfpuppi",
591 "inputCollection" :
"",
592 "genJetsCollection":
"AK4GenJetsNoNu",
593 "bTagDiscriminators": bTagDiscriminatorsForAK4,
596 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
598 jetName = recoJetInfo.jetUpper
599 patJetFinalColl = recoJetInfo.patJetFinalCollection
605 proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
606 proc.updatedJetsPuppi.jetSource=patJetFinalColl
611 finalJetsPuppiCut =
"" 613 finalJetsPuppiCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 615 finalJetsPuppiCut =
"(pt >= 8)" 617 proc.finalJetsPuppi.cut = finalJetsPuppiCut
621 proc.corrT1METJetPuppiTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 627 run2_nanoAOD_ANY.toModify(proc.jetTable, name =
"Jet")
629 run2_nanoAOD_ANY.toModify(proc.jetPuppiTable,
631 src = cms.InputTag(
"finalJetsPuppi")
637 jetPuppiTableDoc =
"AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored." 639 jetPuppiTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 640 proc.jetPuppiTable.doc = jetPuppiTableDoc
642 proc.jetPuppiTable.variables.rawFactor.precision = 10
647 proc.jetPuppiTable.variables.hfHEF = PFJETVARS.hfHEF
648 proc.jetPuppiTable.variables.hfEmEF = PFJETVARS.hfEmEF
649 proc.jetPuppiTable.variables.nConstChHads = PFJETVARS.nConstChHads
650 proc.jetPuppiTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
651 proc.jetPuppiTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
652 proc.jetPuppiTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
653 proc.jetPuppiTable.variables.nConstMuons = PFJETVARS.nConstMuons
654 proc.jetPuppiTable.variables.nConstElecs = PFJETVARS.nConstElecs
655 proc.jetPuppiTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
663 jetSrc =
"updatedJetsPuppi",
664 jetTableName =
"jetPuppiTable",
665 jetTaskName =
"jetPuppiTask" 673 jetSrc =
"updatedJetsPuppi",
674 jetTableName =
"jetPuppiTable",
675 jetTaskName =
"jetPuppiTask",
676 calculateQGLVars=
True 681 proc.jetPuppiTable.variables.btagDeepB = BTAGVARS.btagDeepB
682 proc.jetPuppiTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
683 proc.jetPuppiTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
684 proc.jetPuppiTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
688 proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
689 proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
690 proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
694 proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
695 proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
696 proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
700 proc.jetPuppiTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
701 proc.jetPuppiTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
702 proc.jetPuppiTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
703 proc.jetPuppiTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
704 proc.jetPuppiTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
709 _jetPuppiForMETTask = proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
710 run2_nanoAOD_ANY.toReplaceWith(proc.jetPuppiForMETTask, _jetPuppiForMETTask)
717 jetMCTableName =
"jet{}MCTable".
format(jetName)
718 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
719 src = proc.jetPuppiTable.src,
720 name = proc.jetPuppiTable.name
723 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
724 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
726 _nanoTableTaskFS = proc.nanoTableTaskFS.copy()
727 _nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
728 run2_nanoAOD_ANY.toReplaceWith(proc.nanoTableTaskFS, _nanoTableTaskFS)
734 Recluster AK4 CHS jets and replace slimmedJets that is used as default to 735 save AK4 CHS jets in NanoAODs (for Run-2). 737 print(
"custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
744 "inputCollection" :
"",
745 "genJetsCollection":
"AK4GenJetsNoNu",
746 "bTagDiscriminators": bTagDiscriminatorsForAK4,
749 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
751 jetName = recoJetInfo.jetUpper
752 patJetFinalColl = recoJetInfo.patJetFinalCollection
758 proc.jetCorrFactorsNano.src=patJetFinalColl
759 proc.updatedJets.jetSource=patJetFinalColl
766 finalJetsCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 768 finalJetsCut =
"(pt >= 8)" 770 proc.finalJets.cut = finalJetsCut
774 proc.corrT1METJetTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 780 proc.jetTable.src = cms.InputTag(
"finalJets")
781 proc.jetTable.cut = jetTableCut
782 proc.jetMCTable.cut = jetTableCut
783 proc.jetTable.name =
"JetCHS" 788 run2_nanoAOD_ANY.toModify(proc.jetTable,
789 src = cms.InputTag(
"linkedObjects",
"jets"),
796 jetTableDoc =
"AK4 PF CHS jets with JECs applied. Jets with pt >= 8 GeV are stored." 798 jetTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 799 proc.jetTable.doc = jetTableDoc
801 proc.jetTable.variables.rawFactor.precision = 10
806 proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
807 proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
808 proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
809 proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
810 proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
811 proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
812 proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
813 proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
814 proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
819 pileupJetId80X =
"pileupJetId80X" 820 setattr(proc, pileupJetId80X, pileupJetId.clone(
821 jets =
"updatedJets",
822 algos = cms.VPSet(_chsalgos_81x),
823 inputIsCorrected =
True,
825 vertexes =
"offlineSlimmedPrimaryVertices" 828 _jetUserDataTask = proc.jetUserDataTask.copy()
829 _jetUserDataTask.add(getattr(proc,pileupJetId80X))
830 for modifier
in run2_nanoAOD_94X2016, run2_nanoAOD_94XMiniAODv1, run2_nanoAOD_94XMiniAODv2, run2_nanoAOD_102Xv1:
831 modifier.toReplaceWith(proc.jetUserDataTask, _jetUserDataTask)
832 modifier.toModify(proc.updatedJetsWithUserData.userInts, puId80XfullId = cms.InputTag(
'pileupJetId80X:fullId'))
833 modifier.toModify(proc.jetTable.variables, puId =
Var(
"userInt('puId80XfullId')", int, doc=
"Pileup ID flags with 80X (2016) training"))
834 run2_nanoAOD_94X2016.toModify(proc.updatedJetsWithUserData.userFloats, puId80XDisc = cms.InputTag(
"pileupJetId80X:fullDiscriminant"))
835 run2_nanoAOD_94X2016.toModify(proc.jetTable.variables, puIdDisc =
Var(
"userFloat('puId80XDisc')",float,doc=
"Pilup ID discriminant with 80X (2016) training",precision=10))
840 proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag(
"jercVars:chargedFromPV1EnergyFraction")
841 proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag(
"jercVars:chargedFromPV2EnergyFraction")
842 proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag(
"jercVars:chargedFromPV3EnergyFraction")
843 proc.jetTable.variables.chFPV1EF =
Var(
"userFloat('chFPV1EF')", float, doc=
"charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
844 proc.jetTable.variables.chFPV2EF =
Var(
"userFloat('chFPV2EF')", float, doc=
"charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
845 proc.jetTable.variables.chFPV3EF =
Var(
"userFloat('chFPV3EF')", float, doc=
"charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
852 jetSrc =
"updatedJets",
853 jetTableName =
"jetTable",
854 jetTaskName =
"jetTask" 860 proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag(
"qgtagger:axis2")
861 proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag(
"qgtagger:ptD")
862 proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag(
"qgtagger:mult")
866 proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
867 proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
868 proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
872 proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
873 proc.jetTable.variables.btagCSVV2 = BTAGVARS.btagCSVV2
874 proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
875 proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
879 proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
880 proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
881 proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
885 proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
886 proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
887 proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
891 proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
892 proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
893 proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
894 proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
895 proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
899 hfJetShowerShapeforCustomNanoAOD =
"hfJetShowerShapeforCustomNanoAOD" 900 setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShapeforNanoAOD.clone(jets=
"updatedJets",vertices=
"offlineSlimmedPrimaryVertices") )
901 proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
902 proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
903 proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
904 proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
905 proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
906 proc.jetTable.variables.hfsigmaEtaEta =
Var(
"userFloat('hfsigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
907 proc.jetTable.variables.hfsigmaPhiPhi =
Var(
"userFloat('hfsigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
908 proc.jetTable.variables.hfcentralEtaStripSize =
Var(
"userInt('hfcentralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) ")
909 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) ")
915 _jetUserDataTask = proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
916 (~run2_nanoAOD_ANY).toReplaceWith(proc.jetUserDataTask, _jetUserDataTask)
918 _jetTablesTask = proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
919 (~run2_nanoAOD_ANY).toReplaceWith(proc.jetTablesTask, _jetTablesTask)
921 (~run2_nanoAOD_ANY).toModify(proc.updatedJetsWithUserData.userFloats,
924 leptonPtRatio =
None,
925 leptonPtRelInv =
None,
926 leptonPtRelv0 =
None,
927 leptonPtRatiov0 =
None,
928 leptonPtRelInvv0 =
None,
939 (~run2_nanoAOD_ANY).toModify(proc.updatedJetsWithUserData.userInts,
944 (~run2_nanoAOD_ANY).toModify(proc.jetTable, externalVariables = cms.PSet())
949 _jetForMETTask = proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
950 (~run2_nanoAOD_ANY).toReplaceWith(proc.jetForMETTask, _jetForMETTask)
956 jetMCTableName =
"jet{}MCTable".
format(jetName)
957 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
958 src = proc.jetTable.src,
959 name = proc.jetTable.name
962 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
963 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
965 _nanoTableTaskFS = proc.nanoTableTaskFS.copy()
966 _nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
967 (~run2_nanoAOD_ANY).toReplaceWith(proc.nanoTableTaskFS, _nanoTableTaskFS)
973 Store a separate AK8 Puppi jet collection for JEC studies. 974 Only minimal info are stored 976 print(
"custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
982 "jet" :
"ak8pfpuppi",
983 "inputCollection" :
"",
984 "genJetsCollection":
"AK8GenJetsNoNu",
987 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
989 jetName = recoJetInfo.jetUpper
990 payload = recoJetInfo.jetCorrPayload
992 patJetFinalColl = recoJetInfo.patJetFinalCollection
993 jetTablePrefix =
"FatJetForJEC" 994 jetTableDoc =
"AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 998 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
999 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
1006 Store an AK8 CHS jet collection for JEC studies. 1008 print(
"custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1015 "inputCollection" :
"",
1016 "genJetsCollection":
"AK8GenJetsNoNu",
1017 "minPtFastjet" : 0.,
1019 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1021 jetName = recoJetInfo.jetUpper
1022 payload = recoJetInfo.jetCorrPayload
1024 patJetFinalColl = recoJetInfo.patJetFinalCollection
1025 jetTablePrefix =
"FatJetCHS" 1026 jetTableDoc =
"AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 1030 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
1031 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
1038 Add more variables for AK8 PFPUPPI jets 1041 proc.fatJetTable.variables.rawFactor.precision = 10
1047 proc.fatJetTable.variables.chHEF =
Var(
"?isPFJet()?chargedHadronEnergyFraction():-1", float, doc=
"charged Hadron Energy Fraction", precision = 6)
1048 proc.fatJetTable.variables.neHEF =
Var(
"?isPFJet()?neutralHadronEnergyFraction():-1", float, doc=
"neutral Hadron Energy Fraction", precision = 6)
1049 proc.fatJetTable.variables.chEmEF =
Var(
"?isPFJet()?chargedEmEnergyFraction():-1", float, doc=
"charged Electromagnetic Energy Fraction", precision = 6)
1050 proc.fatJetTable.variables.neEmEF =
Var(
"?isPFJet()?neutralEmEnergyFraction():-1", float, doc=
"neutral Electromagnetic Energy Fraction", precision = 6)
1051 proc.fatJetTable.variables.muEF =
Var(
"?isPFJet()?muonEnergyFraction():-1", float, doc=
"muon Energy Fraction", precision = 6)
1052 proc.fatJetTable.variables.hfHEF =
Var(
"?isPFJet()?HFHadronEnergyFraction():-1", float, doc=
"energy fraction in forward hadronic calorimeter", precision = 6)
1053 proc.fatJetTable.variables.hfEmEF =
Var(
"?isPFJet()?HFEMEnergyFraction():-1", float, doc=
"energy fraction in forward EM calorimeter", precision = 6)
1054 proc.fatJetTable.variables.nConstChHads =
Var(
"?isPFJet()?chargedHadronMultiplicity():-1",int, doc=
"number of charged hadrons in the jet")
1055 proc.fatJetTable.variables.nConstNeuHads =
Var(
"?isPFJet()?neutralHadronMultiplicity():-1",int, doc=
"number of neutral hadrons in the jet")
1056 proc.fatJetTable.variables.nConstHFHads =
Var(
"?isPFJet()?HFHadronMultiplicity():-1", int, doc=
"number of HF Hadrons in the jet")
1057 proc.fatJetTable.variables.nConstHFEMs =
Var(
"?isPFJet()?HFEMMultiplicity():-1", int, doc=
"number of HF EMs in the jet")
1058 proc.fatJetTable.variables.nConstMuons =
Var(
"?isPFJet()?muonMultiplicity():-1", int, doc=
"number of muons in the jet")
1059 proc.fatJetTable.variables.nConstElecs =
Var(
"?isPFJet()?electronMultiplicity():-1", int, doc=
"number of electrons in the jet")
1060 proc.fatJetTable.variables.nConstPhotons =
Var(
"?isPFJet()?photonMultiplicity():-1", int, doc=
"number of photons in the jet")
1072 Add genJet into custom nanoAOD 1075 genJetName = genJetInfo.jetUpper
1076 genJetAlgo = genJetInfo.jetAlgo
1077 genJetSize = genJetInfo.jetSize
1078 genJetSizeNr = genJetInfo.jetSizeNr
1079 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1080 genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet][
"name"]
1081 genJetTableDoc = nanoInfo_genjets[genJetInfo.jet][
"doc"]
1083 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1087 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1089 Schedule modules for a given genJet collection and save its variables into custom NanoAOD 1092 genJetTableName =
"jet{}Table".
format(genJetName)
1093 setattr(proc, genJetTableName, genJetTable.clone(
1094 src = genJetFinalColl,
1096 name = genJetTablePrefix,
1097 doc = genJetTableDoc,
1098 variables = GENJETVARS
1102 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1103 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1104 jets = getattr(proc,genJetTableName).src,
1105 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1106 rParam = genJetSizeNr,
1110 genJetFlavourTableName =
"genJet{}FlavourTable".
format(genJetName)
1111 setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1112 name = getattr(proc,genJetTableName).name,
1113 src = getattr(proc,genJetTableName).src,
1114 cut = getattr(proc,genJetTableName).cut,
1115 jetFlavourInfos = genJetFlavourAssociationName,
1119 genJetTaskName =
"genJet{}Task".
format(genJetName)
1120 setattr(proc, genJetTaskName, cms.Task(
1121 getattr(proc,genJetTableName),
1122 getattr(proc,genJetFlavourAssociationName),
1123 getattr(proc,genJetFlavourTableName)
1126 proc.jetMCTask.add(getattr(proc,genJetTaskName))
1132 Recluster AK4 Gen jets and replace 1133 slimmedGenJets that is used as default 1134 to save AK4 Gen jets in NanoAODs. 1136 print(
"custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1144 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1146 genJetName = genJetInfo.jetUpper
1147 genJetAlgo = genJetInfo.jetAlgo
1148 genJetSize = genJetInfo.jetSize
1149 genJetSizeNr = genJetInfo.jetSizeNr
1150 selectedGenJets =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1156 proc.genJetTable.src = selectedGenJets
1157 proc.genJetTable.cut =
"" 1158 proc.genJetTable.doc =
"AK4 Gen jets (made with visible genparticles) with pt > 3 GeV" 1160 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1161 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1162 jets = proc.genJetTable.src,
1163 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1164 rParam = genJetSizeNr,
1167 proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1172 Make a separate AK8 Gen jet collection for JEC studies. 1174 print(
"custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1182 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1184 genJetName = genJetInfo.jetUpper
1185 genJetAlgo = genJetInfo.jetAlgo
1186 genJetSize = genJetInfo.jetSize
1187 genJetSizeNr = genJetInfo.jetSizeNr
1188 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1189 genJetTablePrefix =
"GenJetAK8ForJEC" 1190 genJetTableDoc =
"AK8 Gen jets (made with visible genparticles) with pt > 3 GeV. Reclustered for JEC studies." 1192 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1197 proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1201 proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1211 Remove default pt cuts for all jets set in jets_cff.py 1214 proc.finalJets.cut =
"" 1215 proc.finalJetsPuppi.cut =
"" 1216 proc.finalJetsAK8.cut =
"" 1217 proc.genJetTable.cut =
"" 1218 proc.genJetFlavourTable.cut =
"" 1219 proc.genJetAK8Table.cut =
"" 1220 proc.genJetAK8FlavourTable.cut =
"" 1241 genJA = GenJetAdder()
1259 for jetConfig
in config_genjets:
1260 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1261 genJetInfo = genJA.addGenJetCollection(process, **cfg)
1269 recoJA = RecoJetAdder(runOnMC=runOnMC)
1293 for jetConfig
in config_recojets:
1294 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1295 recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1303 def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1304 if addAK4CHSJetTasks:
1305 proc.nanoTableTaskCommon.add(proc.jetTask)
1306 proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1307 proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1308 if addAK4PuppiJetTasks:
1309 proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1310 proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1311 proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1314 jmeNano_addAK4JetTasks_switch = cms.PSet(
1315 jmeNano_addAK4CHS_switch = cms.untracked.bool(
True),
1316 jmeNano_addAK4Puppi_switch = cms.untracked.bool(
False)
1318 run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1319 jmeNano_addAK4CHS_switch =
False,
1320 jmeNano_addAK4Puppi_switch =
True 1322 process = addAK4JetTasks(process,
1323 addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1324 addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1331 process.puTable.savePtHatMax =
True 1337 process.genWeightsTable.keepAllPSWeights =
True 1341 from PhysicsTools.NanoAOD.V10.nano_cff
import nanoAOD_customizeV10
def AddBTaggingScores(proc, jetTableName="")
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
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 nanoAOD_customizeV10(process)
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)