1 import FWCore.ParameterSet.Config
as cms
3 from Configuration.Eras.Modifier_run2_jme_2016_cff
import run2_jme_2016
4 from Configuration.Eras.Modifier_run2_jme_2017_cff
import run2_jme_2017
15 from PhysicsTools.PatAlgos.tools.jetCollectionTools
import GenJetAdder, RecoJetAdder
21 bTagCSVV2 = [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc']
22 bTagDeepCSV = [
'pfCombinedInclusiveSecondaryVertexV2BJetTags']
24 'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
25 'pfDeepFlavourJetTags:probc',
'pfDeepFlavourJetTags:probuds',
'pfDeepFlavourJetTags:probg' 29 bTagDiscriminatorsForAK4 = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
43 config_genjets =
list(
filter(
lambda k: k[
'enabled'], config_genjets))
50 "doc" :
"AK8 Gen jets",
64 "inputCollection" :
"slimmedCaloJets",
65 "genJetsCollection":
"AK4GenJetsNoNu",
70 "inputCollection" :
"",
71 "genJetsCollection":
"AK4GenJetsNoNu",
76 "inputCollection" :
"",
77 "genJetsCollection":
"AK4GenJetsNoNu",
78 "bTagDiscriminators": bTagDiscriminatorsForAK4
83 "inputCollection" :
"",
84 "genJetsCollection":
"slimmedGenJetsAK8",
89 "inputCollection" :
"",
90 "genJetsCollection":
"slimmedGenJetsAK8",
93 config_recojets =
list(
filter(
lambda k: k[
'enabled'], config_recojets))
100 "doc" :
"AK4 PF Puppi jets with JECs applied, after basic selection (pt > 2)",
108 "doc" :
"AK4 PF jets with JECs applied, after basic selection (pt > 2)",
113 "doc" :
"AK4 Calo jets with JECs applied",
116 "name" :
"FatJetCHS",
117 "doc" :
"AK8 PF CHS jets with JECs applied, after basic selection (pt > 100)",
122 "doc" :
"AK8 PF jets with JECs applied, after basic selection (pt > 100)",
123 "ptcut" :
"pt > 100",
129 GENJETVARS = cms.PSet(P4Vars,
130 nConstituents = jetTable.variables.nConstituents,
132 PFJETVARS = cms.PSet(P4Vars,
133 rawFactor = jetTable.variables.rawFactor,
134 area = jetTable.variables.area,
135 chHEF = jetTable.variables.chHEF,
136 neHEF = jetTable.variables.neHEF,
137 chEmEF = jetTable.variables.chEmEF,
138 neEmEF = jetTable.variables.neEmEF,
139 muEF = jetTable.variables.muEF,
140 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc =
"hadronic energy fraction in HF",precision = 6),
141 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc =
"electromagnetic energy fraction in HF",precision = 6),
142 nMuons = jetTable.variables.nMuons,
143 nElectrons = jetTable.variables.nElectrons,
144 nConstituents = jetTable.variables.nConstituents,
145 nConstChHads =
Var(
"chargedHadronMultiplicity()",int,doc=
"number of charged hadrons in the jet"),
146 nConstNeuHads =
Var(
"neutralHadronMultiplicity()",int,doc=
"number of neutral hadrons in the jet"),
147 nConstHFHads =
Var(
"HFHadronMultiplicity()", int,doc=
"number of HF hadrons in the jet"),
148 nConstHFEMs =
Var(
"HFEMMultiplicity()",int,doc=
"number of HF EMs in the jet"),
149 nConstMuons =
Var(
"muonMultiplicity()",int,doc=
"number of muons in the jet"),
150 nConstElecs =
Var(
"electronMultiplicity()",int,doc=
"number of electrons in the jet"),
151 nConstPhotons =
Var(
"photonMultiplicity()",int,doc=
"number of photons in the jet"),
154 puId_dR2Mean =
Var(
"userFloat('puId_dR2Mean')",float,doc=
"pT^2-weighted average square distance of jet constituents from the jet axis (PileUp ID BDT input variable)", precision= 6),
155 puId_majW =
Var(
"userFloat('puId_majW')",float,doc=
"major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision= 6) ,
156 puId_minW =
Var(
"userFloat('puId_minW')",float,doc=
"minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)", precision= 6) ,
157 puId_frac01 =
Var(
"userFloat('puId_frac01')",float,doc=
"fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)", precision= 6) ,
158 puId_frac02 =
Var(
"userFloat('puId_frac02')",float,doc=
"fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)", precision= 6) ,
159 puId_frac03 =
Var(
"userFloat('puId_frac03')",float,doc=
"fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)", precision= 6) ,
160 puId_frac04 =
Var(
"userFloat('puId_frac04')",float,doc=
"fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)", precision= 6) ,
161 puId_ptD =
Var(
"userFloat('puId_ptD')",float,doc=
"pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision= 6) ,
162 puId_beta =
Var(
"userFloat('puId_beta')",float,doc=
"fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)", precision= 6) ,
163 puId_pull =
Var(
"userFloat('puId_pull')",float,doc=
"magnitude of pull vector (PileUp ID BDT input variable)", precision= 6) ,
164 puId_jetR =
Var(
"userFloat('puId_jetR')",float,doc=
"fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)", precision= 6) ,
165 puId_jetRchg =
Var(
"userFloat('puId_jetRchg')",float,doc=
"fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)", precision= 6) ,
166 puId_nCharged =
Var(
"userInt('puId_nCharged')",int,doc=
"number of charged constituents (PileUp ID BDT input variable)"),
169 qgl_axis2 =
Var(
"userFloat('qgl_axis2')",float,doc=
"ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision= 6),
170 qgl_ptD =
Var(
"userFloat('qgl_ptD')",float,doc=
"pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)", precision= 6),
171 qgl_mult =
Var(
"userInt('qgl_mult')", int,doc=
"PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
174 btagDeepB = jetTable.variables.btagDeepB,
175 btagCSVV2 = jetTable.variables.btagCSVV2,
176 btagDeepCvL = jetTable.variables.btagDeepCvL,
178 DEEPJETVARS = cms.PSet(
179 btagDeepFlavB = jetTable.variables.btagDeepFlavB,
180 btagDeepFlavC =
Var(
"bDiscriminator('pfDeepFlavourJetTags:probc')",float,doc=
"DeepFlavour charm tag raw score",precision=10),
181 btagDeepFlavG =
Var(
"bDiscriminator('pfDeepFlavourJetTags:probg')",float,doc=
"DeepFlavour gluon tag raw score",precision=10),
182 btagDeepFlavUDS =
Var(
"bDiscriminator('pfDeepFlavourJetTags:probuds')",float,doc=
"DeepFlavour uds tag raw score",precision=10)
184 PARTICLENETAK4VARS = cms.PSet(
185 particleNetAK4_B =
Var(
"bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll')",float,doc=
"ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
186 particleNetAK4_CvsL =
Var(
"bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL')",float,doc=
"ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
187 particleNetAK4_CvsB =
Var(
"bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB')",float,doc=
"ParticleNetAK4 tagger c vs b discriminator",precision=10),
188 particleNetAK4_QvsG =
Var(
"bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG')",float,doc=
"ParticleNetAK4 tagger uds vs g discriminator",precision=10),
189 particleNetAK4_puIdDisc =
Var(
"1-bDiscriminator('pfParticleNetAK4JetTags:probpu')",float,doc=
"ParticleNetAK4 tagger pileup jet discriminator",precision=10),
192 CALOJETVARS = cms.PSet(P4Vars,
193 area = jetTable.variables.area,
194 rawFactor = jetTable.variables.rawFactor,
195 emf =
Var(
"emEnergyFraction()", float, doc =
"electromagnetic energy fraction", precision = 10),
206 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName=""):
208 Setup modules to calculate PF jet ID 211 isPUPPIJet =
True if "Puppi" in jetName
else False 213 looseJetId =
"looseJetId{}".
format(jetName)
214 setattr(proc, looseJetId, proc.looseJetId.clone(
216 filterParams=proc.looseJetId.filterParams.clone(
222 tightJetId =
"tightJetId{}".
format(jetName)
223 setattr(proc, tightJetId, proc.tightJetId.clone(
225 filterParams=proc.tightJetId.filterParams.clone(
226 version =
"SUMMER18{}".
format(
"PUPPI" if isPUPPIJet
else "")
231 tightJetIdLepVeto =
"tightJetIdLepVeto{}".
format(jetName)
232 setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
234 filterParams=proc.tightJetIdLepVeto.filterParams.clone(
235 version =
"SUMMER18{}".
format(
"PUPPI" if isPUPPIJet
else "")
239 run2_jme_2016.toModify(getattr(proc, tightJetId) .filterParams, version =
"WINTER16" )
240 run2_jme_2016.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version =
"WINTER16" )
241 run2_jme_2017.toModify(getattr(proc, tightJetId) .filterParams, version =
"WINTER17{}".
format(
"PUPPI" if isPUPPIJet
else ""))
242 run2_jme_2017.toModify(getattr(proc, tightJetIdLepVeto) .filterParams, version =
"WINTER17{}".
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 run2_jme_2016.toModify(getattr(proc, patJetWithUserData).userInts, looseId = cms.InputTag(looseJetId))
255 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 run2_jme_2016.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"))
258 getattr(proc,jetSequenceName).
insert(getattr(proc,jetSequenceName).
index(getattr(proc, jetSrc))+1, getattr(proc, tightJetId))
259 getattr(proc,jetSequenceName).
insert(getattr(proc,jetSequenceName).
index(getattr(proc, tightJetId))+1, getattr(proc, tightJetIdLepVeto))
261 setattr(proc,
"_"+jetSequenceName+
"_2016", getattr(proc,jetSequenceName).
copy())
262 getattr(proc,
"_"+jetSequenceName+
"_2016").
insert(getattr(proc,
"_"+jetSequenceName+
"_2016").
index(getattr(proc, tightJetId)), getattr(proc, looseJetId))
263 run2_jme_2016.toReplaceWith(getattr(proc,jetSequenceName), getattr(proc,
"_"+jetSequenceName+
"_2016"))
269 Setup modules to calculate pileup jet ID input variables for PF jet 275 puJetIdVarsCalculator =
"puJetIdCalculator{}".
format(jetName)
276 setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
278 vertexes =
"offlineSlimmedPrimaryVertices",
279 inputIsCorrected =
True,
281 usePuppi =
True if "Puppi" in jetName
else False 284 getattr(proc,jetSequenceName).
insert(getattr(proc,jetSequenceName).
index(getattr(proc, jetSrc))+1, getattr(proc, puJetIdVarsCalculator))
289 puJetIDVar =
"puJetIDVar{}".
format(jetName)
290 setattr(proc, puJetIDVar, cms.EDProducer(
"PileupJetIDVarProducer",
291 srcJet = cms.InputTag(jetSrc),
292 srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
295 getattr(proc,jetSequenceName).
insert(getattr(proc,jetSequenceName).
index(getattr(proc, puJetIdVarsCalculator))+1, getattr(proc, puJetIDVar))
300 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
301 getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag(
"{}:dR2Mean".
format(puJetIDVar))
302 getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag(
"{}:majW".
format(puJetIDVar))
303 getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag(
"{}:minW".
format(puJetIDVar))
304 getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag(
"{}:frac01".
format(puJetIDVar))
305 getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag(
"{}:frac02".
format(puJetIDVar))
306 getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag(
"{}:frac03".
format(puJetIDVar))
307 getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag(
"{}:frac04".
format(puJetIDVar))
308 getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag(
"{}:ptD".
format(puJetIDVar))
309 getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag(
"{}:beta".
format(puJetIDVar))
310 getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag(
"{}:pull".
format(puJetIDVar))
311 getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag(
"{}:jetR".
format(puJetIDVar))
312 getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag(
"{}:jetRchg".
format(puJetIDVar))
313 getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag(
"{}:nCharged".
format(puJetIDVar))
318 getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
319 getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
320 getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
321 getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
322 getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
323 getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
324 getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
325 getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
326 getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
327 getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
328 getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
329 getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
330 getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
334 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False):
336 Schedule the QGTagger module to calculate input variables to the QG likelihood 339 QGLTagger=
"qgtagger{}".
format(jetName)
340 patJetWithUserData=
"{}WithUserData".
format(jetSrc)
343 setattr(proc, QGLTagger, qgtagger.clone(
351 getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+
":axis2")
352 getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+
":ptD")
353 getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+
":mult")
358 getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
359 getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
360 getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
363 getattr(proc,jetSequenceName).
insert(getattr(proc,jetSequenceName).
index(getattr(proc, jetSrc))+1, getattr(proc, QGLTagger))
369 Store b-tagging scores from various algortihm 372 getattr(proc, jetTableName).variables.btagDeepB = jetTable.variables.btagDeepB
373 getattr(proc, jetTableName).variables.btagCSVV2 = jetTable.variables.btagCSVV2
374 getattr(proc, jetTableName).variables.btagDeepCvL = jetTable.variables.btagDeepCvL
375 getattr(proc, jetTableName).variables.btagDeepFlavB = jetTable.variables.btagDeepFlavB
376 getattr(proc, jetTableName).variables.btagDeepFlavCvL = jetTable.variables.btagDeepFlavCvL
382 Store DeepJet raw score in jetTable for gluon and light quark 385 getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
386 getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
392 Store ParticleNetAK4 scores in jetTable 395 getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
396 getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
397 getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
398 getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
399 getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
405 Add patJet into custom nanoAOD 408 jetName = recoJetInfo.jetUpper
409 payload = recoJetInfo.jetCorrPayload
410 doPF = recoJetInfo.doPF
411 doCalo = recoJetInfo.doCalo
413 if recoJetInfo.inputCollection !=
"":
414 patJetFinalColl = recoJetInfo.inputCollection
416 patJetFinalColl =
"selectedUpdatedPatJets{}Final".
format(jetName)
419 patJetFinalColl =
"selectedPatJets{}".
format(jetName)
421 nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
422 jetTablePrefix = nanoInfoForJet[
"name"]
423 jetTableDoc = nanoInfoForJet[
"doc"]
424 ptcut = nanoInfoForJet[
"ptcut"]
if "ptcut" in nanoInfoForJet
else "" 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 finalJetsForTable =
"finalJets{}".
format(jetName)
477 setattr(proc, finalJetsForTable, finalJets.clone(
478 src = srcJetsWithUserData,
486 tableContent = PFJETVARS
488 tableContent = CALOJETVARS
490 jetTable =
"jet{}Table".
format(jetName)
491 setattr(proc,jetTable, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
492 src = cms.InputTag(finalJetsForTable),
493 cut = cms.string(
""),
494 name = cms.string(jetTablePrefix),
495 doc = cms.string(jetTableDoc),
496 singleton = cms.bool(
False),
497 extension = cms.bool(
False),
498 variables = cms.PSet(tableContent)
501 getattr(proc,jetTable).variables.pt.precision=10
506 jetMCTable =
"jet{}MCTable".
format(jetName)
507 setattr(proc, jetMCTable, cms.EDProducer(
"SimpleCandidateFlatTableProducer",
508 src = cms.InputTag(finalJetsForTable),
509 cut = getattr(proc,jetTable).cut,
510 name = cms.string(jetTablePrefix),
511 singleton = cms.bool(
False),
512 extension = cms.bool(
True),
513 variables = cms.PSet(
514 partonFlavour =
Var(
"partonFlavour()", int, doc=
"flavour from parton matching"),
515 hadronFlavour =
Var(
"hadronFlavour()", int, doc=
"flavour from hadron ghost clustering"),
516 genJetIdx =
Var(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc=
"index of matched gen jet"),
524 jetSequenceName =
"jet{}Sequence".
format(jetName)
525 setattr(proc, jetSequenceName, cms.Sequence(
526 getattr(proc,jetCorrFactors)+
527 getattr(proc,srcJets)+
528 getattr(proc,srcJetsWithUserData)+
529 getattr(proc,finalJetsForTable)
536 jetTableSequenceName =
"jet{}TablesSequence".
format(jetName)
537 setattr(proc, jetTableSequenceName, cms.Sequence(getattr(proc,jetTable)))
539 jetTableSequenceMCName =
"jet{}MCTablesSequence".
format(jetName)
540 setattr(proc, jetTableSequenceMCName, cms.Sequence(getattr(proc,jetMCTable)))
543 proc.nanoSequenceMC += getattr(proc,jetSequenceName)
544 proc.nanoSequenceMC += getattr(proc,jetTableSequenceName)
545 proc.nanoSequenceMC += getattr(proc,jetTableSequenceMCName)
547 proc.nanoSequence += getattr(proc,jetSequenceName)
548 proc.nanoSequence += getattr(proc,jetTableSequenceName)
554 proc =
AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
556 proc =
AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName)
558 proc =
AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTable, jetSequenceName=jetSequenceName, calculateQGLVars=
True)
573 Recluster AK4 CHS jets and replace slimmedJets 574 that is used as default to save AK4 CHS jets 577 print(
"custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
584 "inputCollection" :
"",
585 "genJetsCollection":
"AK4GenJetsNoNu",
586 "bTagDiscriminators": bTagDiscriminatorsForAK4
588 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
590 jetName = recoJetInfo.jetUpper
591 patJetFinalColl =
"selectedUpdatedPatJets{}Final".
format(jetName)
597 proc.jetCorrFactorsNano.src=patJetFinalColl
598 proc.updatedJets.jetSource=patJetFinalColl
603 proc.finalJets.cut =
"pt > 2" 604 proc.simpleCleanerTable.jetSel =
"pt > 10" 609 proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
610 proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
611 proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
612 proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
613 proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
614 proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
615 proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
616 proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
617 proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
619 proc.jetTable.doc = cms.string(
"AK4 PF CHS Jets with JECs applied, after basic selection (pt > 2)")
624 pileupJetId80X =
"pileupJetId80X" 625 setattr(proc, pileupJetId80X, pileupJetId.clone(
627 algos=cms.VPSet(_chsalgos_81x),
628 inputIsCorrected=
True,
630 vertexes=
"offlineSlimmedPrimaryVertices" 633 proc.jetSequence.insert(proc.jetSequence.index(proc.pileupJetId94X), getattr(proc, pileupJetId80X))
635 proc.updatedJetsWithUserData.userInts.puId80XfullId = cms.InputTag(
'pileupJetId80X:fullId')
636 run2_jme_2016.toModify(proc.updatedJetsWithUserData.userFloats, puId80XDisc = cms.InputTag(
"pileupJetId80X:fullDiscriminant"))
638 proc.jetTable.variables.puId =
Var(
"userInt('puId80XfullId')", int, doc=
"Pilup ID flags with 80X (2016) training")
639 run2_jme_2016.toModify(proc.jetTable.variables, puIdDisc =
Var(
"userFloat('puId80XDisc')",float,doc=
"Pilup ID discriminant with 80X (2016) training",precision=10))
646 jetSrc=
"updatedJets",
647 jetTableName=
"jetTable",
648 jetSequenceName=
"jetSequence" 654 proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag(
"qgtagger:axis2")
655 proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag(
"qgtagger:ptD")
656 proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag(
"qgtagger:mult")
660 proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
661 proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
662 proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
666 proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
667 proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
671 proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
672 proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
673 proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
674 proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
675 proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
679 hfJetShowerShapeforCustomNanoAOD =
"hfJetShowerShapeforCustomNanoAOD" 680 setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShapeforNanoAOD.clone(jets=
"updatedJets",vertices=
"offlineSlimmedPrimaryVertices") )
681 proc.jetSequence.insert(proc.jetSequence.index(proc.updatedJetsWithUserData), getattr(proc, hfJetShowerShapeforCustomNanoAOD))
682 proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
683 proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
684 proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
685 proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
686 proc.jetTable.variables.hfsigmaEtaEta =
Var(
"userFloat('hfsigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
687 proc.jetTable.variables.hfsigmaPhiPhi =
Var(
"userFloat('hfsigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
688 proc.jetTable.variables.hfcentralEtaStripSize =
Var(
"userInt('hfcentralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) ")
689 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) ")
695 Add more variables for AK8 PFPUPPI jets 702 proc.fatJetTable.variables.chHEF =
Var(
"?isPFJet()?chargedHadronEnergyFraction():-1", float, doc=
"charged Hadron Energy Fraction", precision = 6)
703 proc.fatJetTable.variables.neHEF =
Var(
"?isPFJet()?neutralHadronEnergyFraction():-1", float, doc=
"neutral Hadron Energy Fraction", precision = 6)
704 proc.fatJetTable.variables.chEmEF =
Var(
"?isPFJet()?chargedEmEnergyFraction():-1", float, doc=
"charged Electromagnetic Energy Fraction", precision = 6)
705 proc.fatJetTable.variables.neEmEF =
Var(
"?isPFJet()?neutralEmEnergyFraction():-1", float, doc=
"neutral Electromagnetic Energy Fraction", precision = 6)
706 proc.fatJetTable.variables.muEF =
Var(
"?isPFJet()?muonEnergyFraction():-1", float, doc=
"muon Energy Fraction", precision = 6)
707 proc.fatJetTable.variables.hfHEF =
Var(
"?isPFJet()?HFHadronEnergyFraction():-1", float, doc=
"energy fraction in forward hadronic calorimeter", precision = 6)
708 proc.fatJetTable.variables.hfEmEF =
Var(
"?isPFJet()?HFEMEnergyFraction():-1", float, doc=
"energy fraction in forward EM calorimeter", precision = 6)
709 proc.fatJetTable.variables.nConstChHads =
Var(
"?isPFJet()?chargedHadronMultiplicity():-1",int, doc=
"number of charged hadrons in the jet")
710 proc.fatJetTable.variables.nConstNeuHads =
Var(
"?isPFJet()?neutralHadronMultiplicity():-1",int, doc=
"number of neutral hadrons in the jet")
711 proc.fatJetTable.variables.nConstHFHads =
Var(
"?isPFJet()?HFHadronMultiplicity():-1", int, doc=
"number of HF Hadrons in the jet")
712 proc.fatJetTable.variables.nConstHFEMs =
Var(
"?isPFJet()?HFEMMultiplicity():-1", int, doc=
"number of HF EMs in the jet")
713 proc.fatJetTable.variables.nConstMuons =
Var(
"?isPFJet()?muonMultiplicity():-1", int, doc=
"number of muons in the jet")
714 proc.fatJetTable.variables.nConstElecs =
Var(
"?isPFJet()?electronMultiplicity():-1", int, doc=
"number of electrons in the jet")
715 proc.fatJetTable.variables.nConstPhotons =
Var(
"?isPFJet()?photonMultiplicity():-1", int, doc=
"number of photons in the jet")
727 Add genJet into custom nanoAOD 730 genJetName = genJetInfo.jetUpper
731 genJetAlgo = genJetInfo.jetAlgo
732 genJetSize = genJetInfo.jetSize
733 genJetSizeNr = genJetInfo.jetSizeNr
734 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
735 genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet][
"name"]
736 genJetTableDoc = nanoInfo_genjets[genJetInfo.jet][
"doc"]
738 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
742 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
744 Schedule modules for a given genJet collection and save its variables into custom NanoAOD 747 genJetTableThisJet =
"jet{}Table".
format(genJetName)
748 setattr(proc, genJetTableThisJet, genJetTable.clone(
749 src = genJetFinalColl,
751 name = genJetTablePrefix,
752 doc = genJetTableDoc,
753 variables = GENJETVARS
757 genJetFlavourAssociationThisJet =
"genJet{}FlavourAssociation".
format(genJetName)
758 setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
759 jets = getattr(proc,genJetTableThisJet).src,
760 jetAlgorithm = supportedJetAlgos[genJetAlgo],
761 rParam = genJetSizeNr,
765 genJetFlavourTableThisJet =
"genJet{}FlavourTable".
format(genJetName)
766 setattr(proc, genJetFlavourTableThisJet, genJetFlavourTable.clone(
767 name = getattr(proc,genJetTableThisJet).name,
768 src = getattr(proc,genJetTableThisJet).src,
769 cut = getattr(proc,genJetTableThisJet).cut,
770 jetFlavourInfos = genJetFlavourAssociationThisJet,
774 genJetSequenceName =
"genJet{}Sequence".
format(genJetName)
775 setattr(proc, genJetSequenceName, cms.Sequence(
776 getattr(proc,genJetTableThisJet)+
777 getattr(proc,genJetFlavourAssociationThisJet)+
778 getattr(proc,genJetFlavourTableThisJet)
781 proc.nanoSequenceMC.insert(proc.nanoSequenceMC.index(proc.jetMC)+1, getattr(proc,genJetSequenceName))
787 Recluster AK4 Gen jets and replace 788 slimmedGenJets that is used as default 789 to save AK4 Gen jets in NanoAODs. 791 print(
"custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
799 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
801 genJetName = genJetInfo.jetUpper
802 genJetAlgo = genJetInfo.jetAlgo
803 genJetSize = genJetInfo.jetSize
804 genJetSizeNr = genJetInfo.jetSizeNr
805 selectedPatGenJets =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
811 proc.genJetTable.src = selectedPatGenJets
812 proc.genJetTable.cut =
"pt > 1" 813 proc.genJetTable.doc =
"AK4 Gen jets (made with visible genparticles)" 815 genJetFlavourAssociationThisJet =
"genJet{}FlavourAssociation".
format(genJetName)
816 setattr(proc, genJetFlavourAssociationThisJet, genJetFlavourAssociation.clone(
817 jets = proc.genJetTable.src,
818 jetAlgorithm = supportedJetAlgos[genJetAlgo],
819 rParam = genJetSizeNr,
822 proc.jetMC.insert(proc.jetMC.index(proc.genJetFlavourTable), getattr(proc, genJetFlavourAssociationThisJet))
826 proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
830 proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
840 Remove default pt cuts for all jets set in jets_cff.py 843 proc.finalJets.cut =
"" 844 proc.finalJetsAK8.cut =
"" 845 proc.genJetTable.cut =
"" 846 proc.genJetFlavourTable.cut =
"" 847 proc.genJetAK8Table.cut =
"" 848 proc.genJetAK8FlavourTable.cut =
"" 869 genJA = GenJetAdder()
883 for jetConfig
in config_genjets:
884 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
885 genJetInfo = genJA.addGenJetCollection(process, **cfg)
893 recoJA = RecoJetAdder(runOnMC=runOnMC)
905 for jetConfig
in config_recojets:
906 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
907 recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
914 process.puTable.savePtHatMax =
True
def AddBTaggingScores(proc, jetTableName="")
def ReclusterAK4CHSJets(proc, recoJA, runOnMC)
def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="", calculateQGLVars=False)
def RemoveAllJetPtCuts(proc)
def PrepJMECustomNanoAOD(process, runOnMC)
def AddNewPatJets(proc, recoJetInfo, runOnMC)
S & print(S &os, JobReport::InputFile const &f)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
def ReclusterAK4GenJets(proc, genJA)
def AddDeepJetGluonLQuarkScores(proc, jetTableName="")
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo, ptcut="", doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False)
def AddPileUpJetIDVars(proc, jetName="", jetSrc="", jetTableName="", jetSequenceName="")
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="")
def AddVariablesForAK8GenJets(proc)
def PrepJMECustomNanoAOD_MC(process)
def PrepJMECustomNanoAOD_Data(process)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run