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
21 bTagCSVV2 = [
'pfCombinedInclusiveSecondaryVertexV2BJetTags']
22 bTagDeepCSV = [
'pfDeepCSVJetTags:probb',
'pfDeepCSVJetTags:probbb',
'pfDeepCSVJetTags:probc',
'pfDeepCSVJetTags:probudsg']
24 'pfDeepFlavourJetTags:probb',
'pfDeepFlavourJetTags:probbb',
'pfDeepFlavourJetTags:problepb',
25 'pfDeepFlavourJetTags:probc',
'pfDeepFlavourJetTags:probuds',
'pfDeepFlavourJetTags:probg' 29 bTagDiscriminatorsForAK4 = cms.PSet(foo = cms.vstring(bTagDeepJet+_pfParticleNetAK4JetTagsAll+_pfParticleTransformerAK4JetTagsAll))
30 run2_nanoAOD_ANY.toModify(
31 bTagDiscriminatorsForAK4,
32 foo = bTagCSVV2+bTagDeepCSV+bTagDeepJet+_pfParticleNetAK4JetTagsAll
34 bTagDiscriminatorsForAK4 = bTagDiscriminatorsForAK4.foo.value()
39 btagHbb = [
'pfBoostedDoubleSecondaryVertexAK8BJetTags']
41 'pfDeepDoubleBvLJetTags:probHbb',
42 'pfDeepDoubleCvLJetTags:probHcc',
43 'pfDeepDoubleCvBJetTags:probHcc',
44 'pfMassIndependentDeepDoubleBvLJetTags:probHbb',
45 'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
46 'pfMassIndependentDeepDoubleCvBJetTags:probHcc' 49 'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
50 'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
51 'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc' 66 config_genjets = list(
filter(
lambda k: k[
'enabled'], config_genjets))
73 "doc" :
"AK6 Gen jets (made with visible genparticles) with pt > 3 GeV",
87 "inputCollection" :
"slimmedCaloJets",
88 "genJetsCollection":
"AK4GenJetsNoNu",
93 "inputCollection" :
"",
94 "genJetsCollection":
"AK4GenJetsNoNu",
100 "inputCollection" :
"",
101 "genJetsCollection":
"AK8GenJetsNoNu",
105 config_recojets = list(
filter(
lambda k: k[
'enabled'], config_recojets))
109 nanoInfo_recojets = {
112 "doc" :
"AK4 Calo jets (slimmedCaloJets)",
116 "doc" :
"AK4 PF jets",
121 "doc" :
"AK8 PF jets",
126 GENJETVARS = cms.PSet(P4Vars,
127 nConstituents = jetTable.variables.nConstituents,
129 PFJETVARS = cms.PSet(P4Vars,
130 rawFactor =
Var(
"1.-jecFactor('Uncorrected')",float,doc=
"1 - Factor to get back to raw pT",precision=6),
131 area = jetTable.variables.area,
132 chHEF = jetTable.variables.chHEF,
133 neHEF = jetTable.variables.neHEF,
134 chEmEF = jetTable.variables.chEmEF,
135 neEmEF = jetTable.variables.neEmEF,
136 muEF = jetTable.variables.muEF,
137 hfHEF =
Var(
"HFHadronEnergyFraction()",float,doc =
"hadronic energy fraction in HF",precision = 6),
138 hfEmEF =
Var(
"HFEMEnergyFraction()",float,doc =
"electromagnetic energy fraction in HF",precision = 6),
139 nMuons = jetTable.variables.nMuons,
140 nElectrons = jetTable.variables.nElectrons,
141 nConstituents = jetTable.variables.nConstituents,
142 nConstChHads =
Var(
"chargedHadronMultiplicity()",int,doc=
"number of charged hadrons in the jet"),
143 nConstNeuHads =
Var(
"neutralHadronMultiplicity()",int,doc=
"number of neutral hadrons in the jet"),
144 nConstHFHads =
Var(
"HFHadronMultiplicity()", int,doc=
"number of HF hadrons in the jet"),
145 nConstHFEMs =
Var(
"HFEMMultiplicity()",int,doc=
"number of HF EMs in the jet"),
146 nConstMuons =
Var(
"muonMultiplicity()",int,doc=
"number of muons in the jet"),
147 nConstElecs =
Var(
"electronMultiplicity()",int,doc=
"number of electrons in the jet"),
148 nConstPhotons =
Var(
"photonMultiplicity()",int,doc=
"number of photons in the jet"),
151 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),
152 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),
153 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),
154 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),
155 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),
156 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),
157 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),
158 puId_ptD =
Var(
"?(pt>=10)?userFloat('puId_ptD'):-1",float,doc=
"pT-weighted average pT of constituents (PileUp ID BDT input variable)", precision=14),
159 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),
160 puId_pull =
Var(
"?(pt>=10)?userFloat('puId_pull'):-1",float,doc=
"magnitude of pull vector (PileUp ID BDT input variable)", precision=14),
161 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),
162 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),
163 puId_nCharged =
Var(
"?(pt>=10)?userInt('puId_nCharged'):-1",int,doc=
"number of charged constituents (PileUp ID BDT input variable)"),
166 qgl_axis2 =
Var(
"?(pt>=10)?userFloat('qgl_axis2'):-1",float,doc=
"ellipse minor jet axis (Quark vs Gluon likelihood input variable)", precision=14),
167 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),
168 qgl_mult =
Var(
"?(pt>=10)?userInt('qgl_mult'):-1", int,doc=
"PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
171 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),
172 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),
173 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),
175 DEEPJETVARS = cms.PSet(
176 btagDeepFlavB =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'):-1",float,doc=
"DeepJet b+bb+lepb tag discriminator",precision=10),
177 btagDeepFlavC =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probc'):-1",float,doc=
"DeepFlavour charm tag raw score",precision=10),
178 btagDeepFlavG =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probg'):-1",float,doc=
"DeepFlavour gluon tag raw score",precision=10),
179 btagDeepFlavUDS =
Var(
"?(pt>=15)?bDiscriminator('pfDeepFlavourJetTags:probuds'):-1",float,doc=
"DeepFlavour uds tag raw score",precision=10),
180 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),
181 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),
182 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),
184 ROBUSTPARTAK4VARS = cms.PSet(
185 btagRobustParTAK4B =
Var(
"?(pt>=15)?bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb'):-1",float,doc=
"RobustParTAK4 b+bb+lepb tag discriminator",precision=10),
186 btagRobustParTAK4C =
Var(
"?(pt>=15)?bDiscriminator('pfParticleTransformerAK4JetTags:probc'):-1",float,doc=
"RobustParTAK4 charm tag raw score",precision=10),
187 btagRobustParTAK4G =
Var(
"?(pt>=15)?bDiscriminator('pfParticleTransformerAK4JetTags:probg'):-1",float,doc=
"RobustParTAK4 gluon tag raw score",precision=10),
188 btagRobustParTAK4UDS =
Var(
"?(pt>=15)?bDiscriminator('pfParticleTransformerAK4JetTags:probuds'):-1",float,doc=
"RobustParTAK4 uds tag raw score",precision=10),
189 btagRobustParTAK4CvL =
Var(
"?(pt>=15)&&(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfParticleTransformerAK4JetTags:probg'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfParticleTransformerAK4JetTags:probg')):-1",float,doc=
"RobustParTAK4 c vs uds+g discriminator",precision=10),
190 btagRobustParTAK4CvB =
Var(
"?(pt>=15)&&(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfParticleTransformerAK4JetTags:probc')+bDiscriminator('pfParticleTransformerAK4JetTags:probb')+bDiscriminator('pfParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfParticleTransformerAK4JetTags:problepb')):-1",float,doc=
"RobustParTAK4 c vs b+bb+lepb discriminator",precision=10),
191 btagRobustParTAK4QG =
Var(
"?(pt>=15)&&(bDiscriminator('pfParticleTransformerAK4JetTags:probg')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds'))>0?bDiscriminator('pfParticleTransformerAK4JetTags:probg')/(bDiscriminator('pfParticleTransformerAK4JetTags:probg')+bDiscriminator('pfParticleTransformerAK4JetTags:probuds')):-1",float,doc=
"RobustParTAK4 g vs uds discriminator",precision=10),
193 PARTICLENETAK4VARS = cms.PSet(
194 particleNetAK4_B =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:BvsAll'):-1",float,doc=
"ParticleNetAK4 tagger b vs all (udsg, c) discriminator",precision=10),
195 particleNetAK4_CvsL =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsL'):-1",float,doc=
"ParticleNetAK4 tagger c vs udsg discriminator",precision=10),
196 particleNetAK4_CvsB =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:CvsB'):-1",float,doc=
"ParticleNetAK4 tagger c vs b discriminator",precision=10),
197 particleNetAK4_QvsG =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4DiscriminatorsJetTags:QvsG'):-1",float,doc=
"ParticleNetAK4 tagger uds vs g discriminator",precision=10),
198 particleNetAK4_G =
Var(
"?(pt>=15)?bDiscriminator('pfParticleNetAK4JetTags:probg'):-1",float,doc=
"ParticleNetAK4 tagger g raw score",precision=10),
199 particleNetAK4_puIdDisc =
Var(
"?(pt>=15)?1-bDiscriminator('pfParticleNetAK4JetTags:probpu'):-1",float,doc=
"ParticleNetAK4 tagger pileup jet discriminator",precision=10),
202 CALOJETVARS = cms.PSet(P4Vars,
203 area = jetTable.variables.area,
204 rawFactor = jetTable.variables.rawFactor,
205 emf =
Var(
"emEnergyFraction()", float, doc =
"electromagnetic energy fraction", precision = 10),
216 def AddJetID(proc, jetName="", jetSrc="", jetTableName="", jetTaskName=""):
218 Setup modules to calculate PF jet ID 221 isPUPPIJet =
True if "PUPPI" in jetName.upper()
else False 223 looseJetId =
"looseJetId{}".
format(jetName)
224 setattr(proc, looseJetId, proc.looseJetId.clone(
226 filterParams = proc.looseJetId.filterParams.clone(
232 tightJetId =
"tightJetId{}".
format(jetName)
233 setattr(proc, tightJetId, proc.tightJetId.clone(
235 filterParams = proc.tightJetId.filterParams.clone(
236 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
241 tightJetIdLepVeto =
"tightJetIdLepVeto{}".
format(jetName)
242 setattr(proc, tightJetIdLepVeto, proc.tightJetIdLepVeto.clone(
244 filterParams = proc.tightJetIdLepVeto.filterParams.clone(
245 version =
"RUN2UL{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
250 run2_jme_2016.toModify(
251 getattr(proc, tightJetId).filterParams, version =
"RUN2UL16{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
253 getattr(proc, tightJetIdLepVeto).filterParams, version =
"RUN2UL16{}".
format(
"PUPPI" if isPUPPIJet
else "CHS")
259 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
260 getattr(proc, patJetWithUserData).userInts.tightId = cms.InputTag(tightJetId)
261 getattr(proc, patJetWithUserData).userInts.tightIdLepVeto = cms.InputTag(tightJetIdLepVeto)
266 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")
268 getattr(proc,jetTaskName).
add(getattr(proc, tightJetId))
269 getattr(proc,jetTaskName).
add(getattr(proc, tightJetIdLepVeto))
275 Setup modules to calculate pileup jet ID input variables for PF jet 281 puJetIdVarsCalculator =
"puJetIdCalculator{}".
format(jetName)
282 setattr(proc, puJetIdVarsCalculator, pileupJetIdCalculator.clone(
284 vertexes =
"offlineSlimmedPrimaryVertices",
285 inputIsCorrected =
True,
287 srcConstituentWeights =
"packedPFCandidatespuppi" if "PUPPI" in jetName.upper()
else "" 290 getattr(proc,jetTaskName).
add(getattr(proc, puJetIdVarsCalculator))
295 puJetIDVar =
"puJetIDVar{}".
format(jetName)
296 setattr(proc, puJetIDVar, cms.EDProducer(
"PileupJetIDVarProducer",
297 srcJet = cms.InputTag(jetSrc),
298 srcPileupJetId = cms.InputTag(puJetIdVarsCalculator)
301 getattr(proc,jetTaskName).
add(getattr(proc, puJetIDVar))
306 patJetWithUserData =
"{}WithUserData".
format(jetSrc)
307 getattr(proc,patJetWithUserData).userFloats.puId_dR2Mean = cms.InputTag(
"{}:dR2Mean".
format(puJetIDVar))
308 getattr(proc,patJetWithUserData).userFloats.puId_majW = cms.InputTag(
"{}:majW".
format(puJetIDVar))
309 getattr(proc,patJetWithUserData).userFloats.puId_minW = cms.InputTag(
"{}:minW".
format(puJetIDVar))
310 getattr(proc,patJetWithUserData).userFloats.puId_frac01 = cms.InputTag(
"{}:frac01".
format(puJetIDVar))
311 getattr(proc,patJetWithUserData).userFloats.puId_frac02 = cms.InputTag(
"{}:frac02".
format(puJetIDVar))
312 getattr(proc,patJetWithUserData).userFloats.puId_frac03 = cms.InputTag(
"{}:frac03".
format(puJetIDVar))
313 getattr(proc,patJetWithUserData).userFloats.puId_frac04 = cms.InputTag(
"{}:frac04".
format(puJetIDVar))
314 getattr(proc,patJetWithUserData).userFloats.puId_ptD = cms.InputTag(
"{}:ptD".
format(puJetIDVar))
315 getattr(proc,patJetWithUserData).userFloats.puId_beta = cms.InputTag(
"{}:beta".
format(puJetIDVar))
316 getattr(proc,patJetWithUserData).userFloats.puId_pull = cms.InputTag(
"{}:pull".
format(puJetIDVar))
317 getattr(proc,patJetWithUserData).userFloats.puId_jetR = cms.InputTag(
"{}:jetR".
format(puJetIDVar))
318 getattr(proc,patJetWithUserData).userFloats.puId_jetRchg = cms.InputTag(
"{}:jetRchg".
format(puJetIDVar))
319 getattr(proc,patJetWithUserData).userInts.puId_nCharged = cms.InputTag(
"{}:nCharged".
format(puJetIDVar))
324 getattr(proc,jetTableName).variables.puId_dR2Mean = PUIDVARS.puId_dR2Mean
325 getattr(proc,jetTableName).variables.puId_majW = PUIDVARS.puId_majW
326 getattr(proc,jetTableName).variables.puId_minW = PUIDVARS.puId_minW
327 getattr(proc,jetTableName).variables.puId_frac01 = PUIDVARS.puId_frac01
328 getattr(proc,jetTableName).variables.puId_frac02 = PUIDVARS.puId_frac02
329 getattr(proc,jetTableName).variables.puId_frac03 = PUIDVARS.puId_frac03
330 getattr(proc,jetTableName).variables.puId_frac04 = PUIDVARS.puId_frac04
331 getattr(proc,jetTableName).variables.puId_ptD = PUIDVARS.puId_ptD
332 getattr(proc,jetTableName).variables.puId_beta = PUIDVARS.puId_beta
333 getattr(proc,jetTableName).variables.puId_pull = PUIDVARS.puId_pull
334 getattr(proc,jetTableName).variables.puId_jetR = PUIDVARS.puId_jetR
335 getattr(proc,jetTableName).variables.puId_jetRchg = PUIDVARS.puId_jetRchg
336 getattr(proc,jetTableName).variables.puId_nCharged = PUIDVARS.puId_nCharged
340 def AddQGLTaggerVars(proc, jetName="", jetSrc="", jetTableName="", jetTaskName="", calculateQGLVars=False):
342 Schedule the QGTagger module to calculate input variables to the QG likelihood 345 isPUPPIJet =
True if "PUPPI" in jetName.upper()
else False 347 QGLTagger=
"qgtagger{}".
format(jetName)
348 patJetWithUserData=
"{}WithUserData".
format(jetSrc)
351 setattr(proc, QGLTagger, qgtagger.clone(
353 computeLikelihood =
False,
357 getattr(proc,QGLTagger).srcConstituentWeights = cms.InputTag(
"packedPFCandidatespuppi")
362 getattr(proc,patJetWithUserData).userFloats.qgl_axis2 = cms.InputTag(QGLTagger+
":axis2")
363 getattr(proc,patJetWithUserData).userFloats.qgl_ptD = cms.InputTag(QGLTagger+
":ptD")
364 getattr(proc,patJetWithUserData).userInts.qgl_mult = cms.InputTag(QGLTagger+
":mult")
369 getattr(proc,jetTableName).variables.qgl_axis2 = QGLVARS.qgl_axis2
370 getattr(proc,jetTableName).variables.qgl_ptD = QGLVARS.qgl_ptD
371 getattr(proc,jetTableName).variables.qgl_mult = QGLVARS.qgl_mult
374 getattr(proc,jetTaskName).
add(getattr(proc, QGLTagger))
380 Store b-tagging scores from various algortihm 383 getattr(proc, jetTableName).variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
384 getattr(proc, jetTableName).variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
385 getattr(proc, jetTableName).variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
387 run2_nanoAOD_ANY.toModify(
388 getattr(proc, jetTableName).variables,
389 btagCSVV2 =
Var(
"bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')",float,doc=
" pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)",precision=10),
390 btagDeepB =
Var(
"?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1",float,doc=
"DeepCSV b+bb tag discriminator",precision=10),
391 btagDeepCvL =
Var(
"?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1", float,doc=
"DeepCSV c vs udsg discriminator",precision=10),
392 btagDeepCvB =
Var(
"?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1",float,doc=
"DeepCSV c vs b+bb discriminator",precision=10)
399 Store DeepJet raw score in jetTable for gluon and light quark 402 getattr(proc, jetTableName).variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
403 getattr(proc, jetTableName).variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
404 getattr(proc, jetTableName).variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
410 Store RobustParTAK4 scores in jetTable 413 getattr(proc, jetTableName).variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
414 getattr(proc, jetTableName).variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
415 getattr(proc, jetTableName).variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
421 Store ParticleNetAK4 scores in jetTable 424 getattr(proc, jetTableName).variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
425 getattr(proc, jetTableName).variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
426 getattr(proc, jetTableName).variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
427 getattr(proc, jetTableName).variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
428 getattr(proc, jetTableName).variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
429 getattr(proc, jetTableName).variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
435 Add patJet into custom nanoAOD 438 jetName = recoJetInfo.jetUpper
439 payload = recoJetInfo.jetCorrPayload
440 doPF = recoJetInfo.doPF
441 doCalo = recoJetInfo.doCalo
442 patJetFinalColl = recoJetInfo.patJetFinalCollection
444 nanoInfoForJet = nanoInfo_recojets[recoJetInfo.jet]
445 jetTablePrefix = nanoInfoForJet[
"name"]
446 jetTableDoc = nanoInfoForJet[
"doc"]
447 ptcut = nanoInfoForJet[
"ptcut"]
if "ptcut" in nanoInfoForJet
else 8
448 doPUIDVar = nanoInfoForJet[
"doPUIDVar"]
if "doPUIDVar" in nanoInfoForJet
else False 449 doQGL = nanoInfoForJet[
"doQGL"]
if "doQGL" in nanoInfoForJet
else False 450 doBTag = nanoInfoForJet[
"doBTag"]
if "doBTag" in nanoInfoForJet
else False 453 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF, doCalo,
454 ptcut=ptcut, doPUIDVar=doPUIDVar, doQGL=doQGL, doBTag=doBTag, runOnMC=runOnMC
459 def SavePatJets(proc, jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc,
460 doPF, doCalo, ptcut, doPUIDVar=False, doQGL=False, doBTag=False, runOnMC=False):
462 Schedule modules for a given patJet collection and save its variables into custom NanoAOD 468 jetCorrFactors =
"jetCorrFactorsNano{}".
format(jetName)
469 setattr(proc, jetCorrFactors, jetCorrFactorsNano.clone(
470 src = patJetFinalColl,
478 srcJets =
"updatedJets{}".
format(jetName)
479 setattr(proc, srcJets, updatedJets.clone(
480 jetSource = patJetFinalColl,
481 jetCorrFactorsSource = [jetCorrFactors],
488 srcJetsWithUserData =
"updatedJets{}WithUserData".
format(jetName)
489 setattr(proc, srcJetsWithUserData, cms.EDProducer(
"PATJetUserDataEmbedder",
490 src = cms.InputTag(srcJets),
491 userFloats = cms.PSet(),
492 userInts = cms.PSet(),
499 finalJetsCut =
"(pt >= {ptcut:.0f})".
format(ptcut=ptcut)
501 finalJetsCut =
"(pt >= {ptcut:.0f}) || ((pt < {ptcut:.0f}) && (genJetFwdRef().backRef().isNonnull()))".
format(ptcut=ptcut)
503 finalJetsForTable =
"finalJets{}".
format(jetName)
504 setattr(proc, finalJetsForTable, finalJets.clone(
505 src = srcJetsWithUserData,
513 tableContent = PFJETVARS
515 tableContent = CALOJETVARS
517 jetTableCutDefault =
"" 519 jetTableDocDefault = jetTableDoc +
" with JECs applied. Jets with pt >= {ptcut:.0f} GeV are stored.".
format(ptcut=ptcut)
521 jetTableDocDefault +=
"For jets with pt < {ptcut:.0f} GeV, only those matched to gen jets are stored.".
format(ptcut=ptcut)
524 jetTableDocDefault = jetTableDoc
526 jetTableName =
"jet{}Table".
format(jetName)
527 setattr(proc,jetTableName, simpleCandidateFlatTableProducer.clone(
528 src = cms.InputTag(finalJetsForTable),
529 cut = cms.string(jetTableCutDefault),
530 name = cms.string(jetTablePrefix),
531 doc = cms.string(jetTableDocDefault),
532 variables = cms.PSet(tableContent)
535 getattr(proc,jetTableName).variables.pt.precision=10
536 getattr(proc,jetTableName).variables.rawFactor.precision=10
541 jetMCTableName =
"jet{}MCTable".
format(jetName)
542 setattr(proc, jetMCTableName, simpleCandidateFlatTableProducer.clone(
543 src = cms.InputTag(finalJetsForTable),
544 cut = getattr(proc,jetTableName).cut,
545 name = cms.string(jetTablePrefix),
546 extension = cms.bool(
True),
547 variables = cms.PSet(
548 partonFlavour =
Var(
"partonFlavour()", int, doc=
"flavour from parton matching"),
549 hadronFlavour =
Var(
"hadronFlavour()", int, doc=
"flavour from hadron ghost clustering"),
550 genJetIdx =
Var(
"?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().key():-1", int, doc=
"index of matched gen jet"),
558 jetTaskName =
"jet{}Task".
format(jetName)
559 setattr(proc, jetTaskName, cms.Task(
560 getattr(proc,jetCorrFactors),
561 getattr(proc,srcJets),
562 getattr(proc,srcJetsWithUserData),
563 getattr(proc,finalJetsForTable)
566 proc.nanoTableTaskCommon.add(getattr(proc,jetTaskName))
571 jetTableTaskName =
"jet{}TablesTask".
format(jetName)
572 setattr(proc, jetTableTaskName, cms.Task(getattr(proc,jetTableName)))
573 proc.nanoTableTaskCommon.add(getattr(proc,jetTableTaskName))
575 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
576 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
578 proc.nanoTableTaskFS.add(getattr(proc,jetMCTableTaskName))
584 proc =
AddJetID(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
586 proc =
AddPileUpJetIDVars(proc, jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName)
588 proc =
AddQGLTaggerVars(proc,jetName=jetName, jetSrc=srcJets, jetTableName=jetTableName, jetTaskName=jetTaskName, calculateQGLVars=
True)
604 Recluster AK4 Puppi jets and replace slimmedJetsPuppi 605 that is used as default to save AK4 Puppi jets in NanoAODs. 607 print(
"custom_jme_cff::ReclusterAK4PuppiJets: Recluster AK4 PF Puppi jets")
613 "jet" :
"ak4pfpuppi",
614 "inputCollection" :
"",
615 "genJetsCollection":
"AK4GenJetsNoNu",
616 "bTagDiscriminators": bTagDiscriminatorsForAK4,
619 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
621 jetName = recoJetInfo.jetUpper
622 patJetFinalColl = recoJetInfo.patJetFinalCollection
627 run2_jme_2016.toModify(
628 proc.tightJetPuppiId.filterParams, version =
"RUN2UL16PUPPI" 630 proc.tightJetIdLepVeto.filterParams, version =
"RUN2UL16PUPPI" 637 proc.jetPuppiCorrFactorsNano.src=patJetFinalColl
638 proc.updatedJetsPuppi.jetSource=patJetFinalColl
643 finalJetsPuppiCut =
"" 645 finalJetsPuppiCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 647 finalJetsPuppiCut =
"(pt >= 8)" 649 proc.finalJetsPuppi.cut = finalJetsPuppiCut
653 proc.corrT1METJetPuppiTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 659 run2_nanoAOD_ANY.toModify(
660 proc.jetTable, name =
"Jet" 665 src = cms.InputTag(
"finalJetsPuppi")
671 jetPuppiTableDoc =
"AK4 PF Puppi jets with JECs applied. Jets with pt >= 8 GeV are stored." 673 jetPuppiTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 674 proc.jetPuppiTable.doc = jetPuppiTableDoc
676 proc.jetPuppiTable.variables.rawFactor.precision = 10
681 proc.jetPuppiTable.variables.hfHEF = PFJETVARS.hfHEF
682 proc.jetPuppiTable.variables.hfEmEF = PFJETVARS.hfEmEF
683 proc.jetPuppiTable.variables.nConstChHads = PFJETVARS.nConstChHads
684 proc.jetPuppiTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
685 proc.jetPuppiTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
686 proc.jetPuppiTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
687 proc.jetPuppiTable.variables.nConstMuons = PFJETVARS.nConstMuons
688 proc.jetPuppiTable.variables.nConstElecs = PFJETVARS.nConstElecs
689 proc.jetPuppiTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
697 jetSrc =
"updatedJetsPuppi",
698 jetTableName =
"jetPuppiTable",
699 jetTaskName =
"jetPuppiTask" 707 jetSrc =
"updatedJetsPuppi",
708 jetTableName =
"jetPuppiTable",
709 jetTaskName =
"jetPuppiTask",
710 calculateQGLVars=
True 715 proc.jetPuppiTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
716 proc.jetPuppiTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
717 proc.jetPuppiTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
721 proc.jetPuppiTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
722 proc.jetPuppiTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
723 proc.jetPuppiTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
727 proc.jetPuppiTable.variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
728 proc.jetPuppiTable.variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
729 proc.jetPuppiTable.variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
733 proc.jetPuppiTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
734 proc.jetPuppiTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
735 proc.jetPuppiTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
736 proc.jetPuppiTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
737 proc.jetPuppiTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
738 proc.jetPuppiTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
743 run2_nanoAOD_ANY.toReplaceWith(
744 proc.jetPuppiForMETTask,
745 proc.jetPuppiForMETTask.copyAndExclude([proc.corrT1METJetPuppiTable])
753 jetMCTableName =
"jet{}MCTable".
format(jetName)
754 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
755 src = proc.jetPuppiTable.src,
756 name = proc.jetPuppiTable.name
759 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
760 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
762 run2_nanoAOD_ANY.toReplaceWith(
763 proc.nanoTableTaskFS,
764 proc.nanoTableTaskFS.copyAndAdd( getattr(proc,jetMCTableTaskName))
771 Recluster AK4 CHS jets and replace slimmedJets that is used as default to 772 save AK4 CHS jets in NanoAODs (for Run-2). 774 print(
"custom_jme_cff::ReclusterAK4CHSJets: Recluster AK4 PF CHS jets")
781 "inputCollection" :
"",
782 "genJetsCollection":
"AK4GenJetsNoNu",
783 "bTagDiscriminators": bTagDiscriminatorsForAK4,
786 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
788 jetName = recoJetInfo.jetUpper
789 patJetFinalColl = recoJetInfo.patJetFinalCollection
795 proc.jetCorrFactorsNano.src=patJetFinalColl
796 proc.updatedJets.jetSource=patJetFinalColl
803 finalJetsCut =
"(pt >= 8) || ((pt < 8) && (genJetFwdRef().backRef().isNonnull()))" 805 finalJetsCut =
"(pt >= 8)" 807 proc.finalJets.cut = finalJetsCut
811 proc.corrT1METJetTable.cut =
"pt>=8 && pt<15 && abs(eta)<9.9" 817 proc.jetTable.src = cms.InputTag(
"finalJets")
818 proc.jetTable.cut = jetTableCut
819 proc.jetMCTable.cut = jetTableCut
820 proc.jetTable.name =
"JetCHS" 825 run2_nanoAOD_ANY.toModify(
827 src = cms.InputTag(
"linkedObjects",
"jets"),
834 jetTableDoc =
"AK4 PF CHS jets with JECs applied. Jets with pt >= 8 GeV are stored." 836 jetTableDoc +=
"For jets with pt < 8 GeV, only those matched to AK4 Gen jets are stored." 837 proc.jetTable.doc = jetTableDoc
839 proc.jetTable.variables.rawFactor.precision = 10
844 proc.jetTable.variables.hfHEF = PFJETVARS.hfHEF
845 proc.jetTable.variables.hfEmEF = PFJETVARS.hfEmEF
846 proc.jetTable.variables.nConstChHads = PFJETVARS.nConstChHads
847 proc.jetTable.variables.nConstNeuHads = PFJETVARS.nConstNeuHads
848 proc.jetTable.variables.nConstHFHads = PFJETVARS.nConstHFHads
849 proc.jetTable.variables.nConstHFEMs = PFJETVARS.nConstHFEMs
850 proc.jetTable.variables.nConstMuons = PFJETVARS.nConstMuons
851 proc.jetTable.variables.nConstElecs = PFJETVARS.nConstElecs
852 proc.jetTable.variables.nConstPhotons = PFJETVARS.nConstPhotons
857 proc.updatedJetsWithUserData.userFloats.chFPV1EF = cms.InputTag(
"jercVars:chargedFromPV1EnergyFraction")
858 proc.updatedJetsWithUserData.userFloats.chFPV2EF = cms.InputTag(
"jercVars:chargedFromPV2EnergyFraction")
859 proc.updatedJetsWithUserData.userFloats.chFPV3EF = cms.InputTag(
"jercVars:chargedFromPV3EnergyFraction")
860 proc.jetTable.variables.chFPV1EF =
Var(
"userFloat('chFPV1EF')", float, doc=
"charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
861 proc.jetTable.variables.chFPV2EF =
Var(
"userFloat('chFPV2EF')", float, doc=
"charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
862 proc.jetTable.variables.chFPV3EF =
Var(
"userFloat('chFPV3EF')", float, doc=
"charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).", precision= 6)
869 jetSrc =
"updatedJets",
870 jetTableName =
"jetTable",
871 jetTaskName =
"jetTask" 877 proc.updatedJetsWithUserData.userFloats.qgl_axis2 = cms.InputTag(
"qgtagger:axis2")
878 proc.updatedJetsWithUserData.userFloats.qgl_ptD = cms.InputTag(
"qgtagger:ptD")
879 proc.updatedJetsWithUserData.userInts.qgl_mult = cms.InputTag(
"qgtagger:mult")
883 proc.jetTable.variables.qgl_axis2 = QGLVARS.qgl_axis2
884 proc.jetTable.variables.qgl_ptD = QGLVARS.qgl_ptD
885 proc.jetTable.variables.qgl_mult = QGLVARS.qgl_mult
889 proc.jetTable.variables.btagDeepB = BTAGVARS.btagDeepB
890 proc.jetTable.variables.btagDeepCvL = BTAGVARS.btagDeepCvL
891 proc.jetTable.variables.btagDeepCvB = BTAGVARS.btagDeepCvB
895 proc.jetTable.variables.btagDeepFlavB = DEEPJETVARS.btagDeepFlavB
896 proc.jetTable.variables.btagDeepFlavCvL = DEEPJETVARS.btagDeepFlavCvL
897 proc.jetTable.variables.btagDeepFlavCvB = DEEPJETVARS.btagDeepFlavCvB
901 proc.jetTable.variables.btagDeepFlavG = DEEPJETVARS.btagDeepFlavG
902 proc.jetTable.variables.btagDeepFlavUDS = DEEPJETVARS.btagDeepFlavUDS
903 proc.jetTable.variables.btagDeepFlavQG = DEEPJETVARS.btagDeepFlavQG
907 proc.jetTable.variables.btagRobustParTAK4B = ROBUSTPARTAK4VARS.btagRobustParTAK4B
908 proc.jetTable.variables.btagRobustParTAK4CvL = ROBUSTPARTAK4VARS.btagRobustParTAK4CvL
909 proc.jetTable.variables.btagRobustParTAK4CvB = ROBUSTPARTAK4VARS.btagRobustParTAK4CvB
913 proc.jetTable.variables.particleNetAK4_B = PARTICLENETAK4VARS.particleNetAK4_B
914 proc.jetTable.variables.particleNetAK4_CvsL = PARTICLENETAK4VARS.particleNetAK4_CvsL
915 proc.jetTable.variables.particleNetAK4_CvsB = PARTICLENETAK4VARS.particleNetAK4_CvsB
916 proc.jetTable.variables.particleNetAK4_QvsG = PARTICLENETAK4VARS.particleNetAK4_QvsG
917 proc.jetTable.variables.particleNetAK4_G = PARTICLENETAK4VARS.particleNetAK4_G
918 proc.jetTable.variables.particleNetAK4_puIdDisc = PARTICLENETAK4VARS.particleNetAK4_puIdDisc
922 hfJetShowerShapeforCustomNanoAOD =
"hfJetShowerShapeforCustomNanoAOD" 923 setattr(proc, hfJetShowerShapeforCustomNanoAOD, hfJetShowerShape.clone(jets=
"updatedJets", vertices=
"offlineSlimmedPrimaryVertices") )
924 proc.jetUserDataTask.add(getattr(proc, hfJetShowerShapeforCustomNanoAOD))
925 proc.updatedJetsWithUserData.userFloats.hfsigmaEtaEta = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaEtaEta')
926 proc.updatedJetsWithUserData.userFloats.hfsigmaPhiPhi = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:sigmaPhiPhi')
927 proc.updatedJetsWithUserData.userInts.hfcentralEtaStripSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:centralEtaStripSize')
928 proc.updatedJetsWithUserData.userInts.hfadjacentEtaStripsSize = cms.InputTag(
'hfJetShowerShapeforCustomNanoAOD:adjacentEtaStripsSize')
929 proc.jetTable.variables.hfsigmaEtaEta =
Var(
"userFloat('hfsigmaEtaEta')",float,doc=
"sigmaEtaEta for HF jets (noise discriminating variable)",precision=10)
930 proc.jetTable.variables.hfsigmaPhiPhi =
Var(
"userFloat('hfsigmaPhiPhi')",float,doc=
"sigmaPhiPhi for HF jets (noise discriminating variable)",precision=10)
931 proc.jetTable.variables.hfcentralEtaStripSize =
Var(
"userInt('hfcentralEtaStripSize')", int, doc=
"eta size of the central tower strip in HF (noise discriminating variable) ")
932 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) ")
938 (~run2_nanoAOD_ANY).toReplaceWith(
939 proc.jetUserDataTask,
940 proc.jetUserDataTask.copyAndExclude([proc.bJetVars])
943 proc.jetTablesTask.copyAndExclude([proc.bjetNN, proc.cjetNN])
944 ).toModify(proc.updatedJetsWithUserData.userFloats,
946 leptonPtRelv0 =
None,
947 leptonPtRelInvv0 =
None,
955 proc.updatedJetsWithUserData.userInts,
959 proc.jetTable, externalVariables = cms.PSet()
965 proc.jetForMETTask.copyAndExclude([proc.corrT1METJetTable])
972 jetMCTableName =
"jet{}MCTable".
format(jetName)
973 setattr(proc, jetMCTableName, proc.jetMCTable.clone(
974 src = proc.jetTable.src,
975 name = proc.jetTable.name
978 jetMCTableTaskName =
"jet{}MCTablesTask".
format(jetName)
979 setattr(proc, jetMCTableTaskName, cms.Task(getattr(proc,jetMCTableName)))
981 (~run2_nanoAOD_ANY).toReplaceWith(
982 proc.nanoTableTaskFS,
983 proc.nanoTableTaskFS.copyAndAdd(getattr(proc,jetMCTableTaskName))
990 Store a separate AK8 Puppi jet collection for JEC studies. 991 Only minimal info are stored 993 print(
"custom_jme_cff::AddNewAK8PuppiJetsForJEC: Make a new AK8 PF Puppi jet collection for JEC studies")
999 "jet" :
"ak8pfpuppi",
1000 "inputCollection" :
"",
1001 "genJetsCollection":
"AK8GenJetsNoNu",
1002 "minPtFastjet" : 0.,
1004 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1006 jetName = recoJetInfo.jetUpper
1007 payload = recoJetInfo.jetCorrPayload
1009 patJetFinalColl = recoJetInfo.patJetFinalCollection
1010 jetTablePrefix =
"FatJetForJEC" 1011 jetTableDoc =
"AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 1015 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
1016 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
1023 Store an AK8 CHS jet collection for JEC studies. 1025 print(
"custom_jme_cff::AddNewAK8CHSJets: Make a new AK8 PF CHS jet collection for JEC studies")
1032 "inputCollection" :
"",
1033 "genJetsCollection":
"AK8GenJetsNoNu",
1034 "minPtFastjet" : 0.,
1036 recoJetInfo = recoJA.addRecoJetCollection(proc, **cfg)
1038 jetName = recoJetInfo.jetUpper
1039 payload = recoJetInfo.jetCorrPayload
1041 patJetFinalColl = recoJetInfo.patJetFinalCollection
1042 jetTablePrefix =
"FatJetCHS" 1043 jetTableDoc =
"AK8 PF CHS jets with JECs applied. Reclustered for JEC studies so only minimal info stored." 1047 jetName, payload, patJetFinalColl, jetTablePrefix, jetTableDoc, doPF=
True,
1048 doCalo=
False, ptcut=ptcut, doPUIDVar=
False, doQGL=
False, doBTag=
False, runOnMC=runOnMC
1055 Add more variables for AK8 PFPUPPI jets 1058 proc.fatJetTable.variables.rawFactor.precision = 10
1064 proc.fatJetTable.variables.chHEF =
Var(
"?isPFJet()?chargedHadronEnergyFraction():-1", float, doc=
"charged Hadron Energy Fraction", precision = 6)
1065 proc.fatJetTable.variables.neHEF =
Var(
"?isPFJet()?neutralHadronEnergyFraction():-1", float, doc=
"neutral Hadron Energy Fraction", precision = 6)
1066 proc.fatJetTable.variables.chEmEF =
Var(
"?isPFJet()?chargedEmEnergyFraction():-1", float, doc=
"charged Electromagnetic Energy Fraction", precision = 6)
1067 proc.fatJetTable.variables.neEmEF =
Var(
"?isPFJet()?neutralEmEnergyFraction():-1", float, doc=
"neutral Electromagnetic Energy Fraction", precision = 6)
1068 proc.fatJetTable.variables.muEF =
Var(
"?isPFJet()?muonEnergyFraction():-1", float, doc=
"muon Energy Fraction", precision = 6)
1069 proc.fatJetTable.variables.hfHEF =
Var(
"?isPFJet()?HFHadronEnergyFraction():-1", float, doc=
"energy fraction in forward hadronic calorimeter", precision = 6)
1070 proc.fatJetTable.variables.hfEmEF =
Var(
"?isPFJet()?HFEMEnergyFraction():-1", float, doc=
"energy fraction in forward EM calorimeter", precision = 6)
1071 proc.fatJetTable.variables.nConstChHads =
Var(
"?isPFJet()?chargedHadronMultiplicity():-1",int, doc=
"number of charged hadrons in the jet")
1072 proc.fatJetTable.variables.nConstNeuHads =
Var(
"?isPFJet()?neutralHadronMultiplicity():-1",int, doc=
"number of neutral hadrons in the jet")
1073 proc.fatJetTable.variables.nConstHFHads =
Var(
"?isPFJet()?HFHadronMultiplicity():-1", int, doc=
"number of HF Hadrons in the jet")
1074 proc.fatJetTable.variables.nConstHFEMs =
Var(
"?isPFJet()?HFEMMultiplicity():-1", int, doc=
"number of HF EMs in the jet")
1075 proc.fatJetTable.variables.nConstMuons =
Var(
"?isPFJet()?muonMultiplicity():-1", int, doc=
"number of muons in the jet")
1076 proc.fatJetTable.variables.nConstElecs =
Var(
"?isPFJet()?electronMultiplicity():-1", int, doc=
"number of electrons in the jet")
1077 proc.fatJetTable.variables.nConstPhotons =
Var(
"?isPFJet()?photonMultiplicity():-1", int, doc=
"number of photons in the jet")
1089 Add genJet into custom nanoAOD 1092 genJetName = genJetInfo.jetUpper
1093 genJetAlgo = genJetInfo.jetAlgo
1094 genJetSize = genJetInfo.jetSize
1095 genJetSizeNr = genJetInfo.jetSizeNr
1096 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1097 genJetTablePrefix = nanoInfo_genjets[genJetInfo.jet][
"name"]
1098 genJetTableDoc = nanoInfo_genjets[genJetInfo.jet][
"doc"]
1100 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1104 def SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=False):
1106 Schedule modules for a given genJet collection and save its variables into custom NanoAOD 1109 genJetTableName =
"jet{}Table".
format(genJetName)
1110 setattr(proc, genJetTableName, genJetTable.clone(
1111 src = genJetFinalColl,
1113 name = genJetTablePrefix,
1114 doc = genJetTableDoc,
1115 variables = GENJETVARS
1119 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1120 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1121 jets = getattr(proc,genJetTableName).src,
1122 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1123 rParam = genJetSizeNr,
1127 genJetFlavourTableName =
"genJet{}FlavourTable".
format(genJetName)
1128 setattr(proc, genJetFlavourTableName, genJetFlavourTable.clone(
1129 name = getattr(proc,genJetTableName).name,
1130 src = getattr(proc,genJetTableName).src,
1131 cut = getattr(proc,genJetTableName).cut,
1132 jetFlavourInfos = genJetFlavourAssociationName,
1136 genJetTaskName =
"genJet{}Task".
format(genJetName)
1137 setattr(proc, genJetTaskName, cms.Task(
1138 getattr(proc,genJetTableName),
1139 getattr(proc,genJetFlavourAssociationName),
1140 getattr(proc,genJetFlavourTableName)
1143 proc.jetMCTask.add(getattr(proc,genJetTaskName))
1149 Recluster AK4 Gen jets and replace 1150 slimmedGenJets that is used as default 1151 to save AK4 Gen jets in NanoAODs. 1153 print(
"custom_jme_cff::ReclusterAK4GenJets: Recluster AK4 Gen jets")
1161 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1163 genJetName = genJetInfo.jetUpper
1164 genJetAlgo = genJetInfo.jetAlgo
1165 genJetSize = genJetInfo.jetSize
1166 genJetSizeNr = genJetInfo.jetSizeNr
1167 selectedGenJets =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1173 proc.genJetTable.src = selectedGenJets
1174 proc.genJetTable.cut =
"" 1175 proc.genJetTable.doc =
"AK4 Gen jets (made with visible genparticles) with pt > 3 GeV" 1177 genJetFlavourAssociationName =
"genJet{}FlavourAssociation".
format(genJetName)
1178 setattr(proc, genJetFlavourAssociationName, genJetFlavourAssociation.clone(
1179 jets = proc.genJetTable.src,
1180 jetAlgorithm = supportedJetAlgos[genJetAlgo],
1181 rParam = genJetSizeNr,
1184 proc.jetMCTask.add(getattr(proc, genJetFlavourAssociationName))
1189 Make a separate AK8 Gen jet collection for JEC studies. 1191 print(
"custom_jme_cff::AddNewAK8GenJetsForJEC: Add new AK8 Gen jets for JEC studies")
1199 genJetInfo = genJA.addGenJetCollection(proc, **cfg)
1201 genJetName = genJetInfo.jetUpper
1202 genJetAlgo = genJetInfo.jetAlgo
1203 genJetSize = genJetInfo.jetSize
1204 genJetSizeNr = genJetInfo.jetSizeNr
1205 genJetFinalColl =
"{}{}{}".
format(genJetAlgo.upper(), genJetSize,
"GenJetsNoNu")
1206 genJetTablePrefix =
"GenJetAK8ForJEC" 1207 genJetTableDoc =
"AK8 Gen jets (made with visible genparticles) with pt > 3 GeV. Reclustered for JEC studies." 1209 SaveGenJets(proc, genJetName, genJetAlgo, genJetSizeNr, genJetFinalColl, genJetTablePrefix, genJetTableDoc, runOnMC=
False)
1214 proc.genJetTable.variables.nConstituents = GENJETVARS.nConstituents
1218 proc.genJetAK8Table.variables.nConstituents = GENJETVARS.nConstituents
1228 Remove default pt cuts for all jets set in jets_cff.py 1231 proc.finalJets.cut =
"" 1232 proc.finalJetsPuppi.cut =
"" 1233 proc.finalJetsAK8.cut =
"" 1234 proc.genJetTable.cut =
"" 1235 proc.genJetFlavourTable.cut =
"" 1236 proc.genJetAK8Table.cut =
"" 1237 proc.genJetAK8FlavourTable.cut =
"" 1258 genJA = GenJetAdder()
1276 for jetConfig
in config_genjets:
1277 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1278 genJetInfo = genJA.addGenJetCollection(process, **cfg)
1286 recoJA = RecoJetAdder(runOnMC=runOnMC)
1310 for jetConfig
in config_recojets:
1311 cfg = { k : v
for k, v
in jetConfig.items()
if k !=
"enabled"}
1312 recoJetInfo = recoJA.addRecoJetCollection(process, **cfg)
1320 def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
1321 if addAK4CHSJetTasks:
1322 proc.nanoTableTaskCommon.add(proc.jetTask)
1323 proc.nanoTableTaskCommon.add(proc.jetTablesTask)
1324 proc.nanoTableTaskCommon.add(proc.jetForMETTask)
1325 if addAK4PuppiJetTasks:
1326 proc.nanoTableTaskCommon.add(proc.jetPuppiTask)
1327 proc.nanoTableTaskCommon.add(proc.jetPuppiTablesTask)
1328 proc.nanoTableTaskCommon.add(proc.jetPuppiForMETTask)
1331 jmeNano_addAK4JetTasks_switch = cms.PSet(
1332 jmeNano_addAK4CHS_switch = cms.untracked.bool(
True),
1333 jmeNano_addAK4Puppi_switch = cms.untracked.bool(
False)
1335 run2_nanoAOD_ANY.toModify(jmeNano_addAK4JetTasks_switch,
1336 jmeNano_addAK4CHS_switch =
False,
1337 jmeNano_addAK4Puppi_switch =
True 1339 process = addAK4JetTasks(process,
1340 addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4CHS_switch,
1341 addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch.jmeNano_addAK4Puppi_switch,
1348 process.puTable.savePtHatMax =
True 1354 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 AddRobustParTAK4Scores(proc, jetTableName="")
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)